summaryrefslogtreecommitdiff
path: root/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/BPProfileModule.m
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ihealth-sdk/ios/ReactNativeIOSLibrary/BPProfileModule.m')
-rwxr-xr-xlibs/ihealth-sdk/ios/ReactNativeIOSLibrary/BPProfileModule.m182
1 files changed, 182 insertions, 0 deletions
diff --git a/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/BPProfileModule.m b/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/BPProfileModule.m
new file mode 100755
index 0000000..6417dc5
--- /dev/null
+++ b/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/BPProfileModule.m
@@ -0,0 +1,182 @@
1//
2// BPProfileModule.m
3// ReactNativeIOSLibrary
4//
5// Created by daiqingquan on 2016/11/23.
6// Copyright © 2016年 daiqingquan. All rights reserved.
7//
8
9#import "BPProfileModule.h"
10#import "BPMacroFile.h"
11@implementation BPProfileModule
12
13
14
15
16RCT_EXPORT_MODULE()
17
18#pragma mark
19#pragma mark - constantsToExport
20
21
22- (NSDictionary *)constantsToExport
23{
24 return @{
25 @"ACTION_ERROR_BP":kACTION_ERROR_BP,
26 @"ACTION_BATTERY_BP":kACTION_BATTERY_BP,
27 @"ACTION_ZOREING_BP":kACTION_ZOREING_BP,
28 @"ACTION_ZOREOVER_BP":kACTION_ZOREOVER_BP,
29 @"ACTION_ONLINE_PRESSURE_BP":kACTION_ONLINE_PRESSURE_BP,
30 @"ACTION_ONLINE_PULSEWAVE_BP":kACTION_ONLINE_PULSEWAVE_BP,
31 @"ACTION_ONLINE_RESULT_BP":kACTION_ONLINE_RESULT_BP,
32 @"ACTION_HISTORICAL_NUM_BP":kACTION_HISTORICAL_NUM_BP,
33 @"ACTION_HISTORICAL_DATA_BP":kACTION_HISTORICAL_DATA_BP,
34 @"ACTION_HISTORICAL_OVER_BP":kACTION_HISTORICAL_OVER_BP,
35 @"ACTION_FUNCTION_INFORMATION_BP":kACTION_FUNCTION_INFORMATION_BP,
36 @"ACTION_SET_UNIT_SUCCESS_BP":kACTION_SET_UNIT_SUCCESS_BP,
37 @"ACTION_SET_ANGLE_SUCCESS_BP":kACTION_SET_ANGLE_SUCCESS_BP,
38 @"ACTION_INTERRUPTED_BP":kACTION_INTERRUPTED_BP,
39
40 @"ACTION_ENABLE_OFFLINE_BP":kACTION_ENABLE_OFFLINE_BP,
41 @"ACTION_DISENABLE_OFFLINE_BP":kACTION_DISENABLE_OFFLINE_BP,
42 @"ACTION_IS_ENABLE_OFFLINE":kACTION_IS_ENABLE_OFFLINE,
43
44 @"ERROR_NUM_BP":kERROR_NUM_BP,
45 @"BATTERY_BP":kBATTERY_BP,
46 @"BLOOD_PRESSURE_BP":kBLOOD_PRESSURE_BP,
47 @"FLAG_HEARTBEAT_BP":kFLAG_HEARTBEAT_BP,
48 @"PULSEWAVE_BP":kPULSEWAVE_BP,
49 @"HIGH_BLOOD_PRESSURE_BP":kHIGH_BLOOD_PRESSURE_BP,
50 @"LOW_BLOOD_PRESSURE_BP":kLOW_BLOOD_PRESSURE_BP,
51 @"PULSE_BP":kPULSE_BP,
52 @"MEASUREMENT_DATE_BP":kMEASUREMENT_DATE_BP,
53 @"MEASUREMENT_AHR_BP":kMEASUREMENT_AHR_BP,
54 @"MEASUREMENT_HSD_BP":kMEASUREMENT_HSD_BP,
55 @"MEASUREMENT_STRAT_ANGLE_BP":kMEASUREMENT_STRAT_ANGLE_BP,
56 @"MEASUREMENT_ANGLE_CHANGE_BP":kMEASUREMENT_ANGLE_CHANGE_BP,
57 @"MEASUREMENT_HAND_BP":kMEASUREMENT_HAND_BP,
58 @"DATAID":kDATAID,
59 @"IS_ENABLE_OFFLINE":kIS_ENABLE_OFFLINE,
60
61 @"HISTORICAL_NUM_BP":kHISTORICAL_NUM_BP,
62 @"HISTORICAL_DATA_BP":kHISTORICAL_DATA_BP,
63
64 @"FUNCTION_IS_UPAIR_MEASURE":kFUNCTION_IS_UPAIR_MEASURE,
65 @"FUNCTION_IS_ARM_MEASURE":kFUNCTION_IS_ARM_MEASURE,
66 @"FUNCTION_HAVE_ANGLE_SENSOR":kFUNCTION_HAVE_ANGLE_SENSOR,
67 @"FUNCTION_HAVE_OFFLINE":kFUNCTION_HAVE_OFFLINE,
68 @"FUNCTION_HAVE_ANGLE_SETTING":kFUNCTION_HAVE_ANGLE_SETTING,
69 @"FUNCTION_IS_MULTI_UPLOAD":kFUNCTION_IS_MULTI_UPLOAD,
70 @"FUNCTION_HAVE_SELF_UPDATE":kFUNCTION_HAVE_SELF_UPDATE,
71 @"FUNCTION_HAVE_HSD":kFUNCTION_HAVE_HSD,
72 @"ERROR_DESCRIPTION_BP":kERROR_DESCRIPTION_BP,
73
74 @"ACTION_ANGLE_BP":kACTION_ANGLE_BP,
75
76 @"ANGLE_BP":kANGLE_BP,
77
78 @"WHICH_ARM":kWHICH_ARM,
79
80 @"ACTION_GET_ALL_CONNECTED_DEVICES":@"ACTION_GET_ALL_CONNECTED_DEVICES",
81 };
82}
83+ (BOOL)requiresMainQueueSetup
84{
85 return YES;
86}
87+ (NSString*)descriptionForErrorCode:(NSInteger)errorCode{
88 switch (errorCode) {
89 case BPError0:
90 return @"not find a suitable zero in 20s.";
91 case BPError1:
92 return @"not find high pressure.";
93 case BPError2:
94 return @"not find low pressure or the high pressure value is lower than the low pressure value.";
95 case BPError3:
96 return @"pressurization fast.";
97 case BPError4:
98 return @"pressurization slow.";
99 case BPError5:
100 return @"pressure exceeds 300mmHg.";
101 case BPError6:
102 return @"time of pressure greater than 15 mmHg exceeds 160s.";
103 case BPError7:
104 return @"EE read and write error.";
105 case BPError8:
106 return @"EE three backup data error.";
107 case BPError9:
108 return @"retention.";
109 case BPError10:
110 return @"SPAN value error.";
111 case BPError11:
112 return @"CRC errors.";
113 case BPError12:
114 return @"connect error.";
115 case BPError13:
116 return @"low power tips.";
117 case BPError14:
118 return @"device bluetooth set failed";
119 case BPError15:
120 return @"high or low pressure value of measurement exceeds the set upper limit.";
121 case BPError16:
122 return @"high or low pressure value of measurement exceeds the set lower limit.";
123 case BPError17:
124 return @"arm movement during the measurement over the machine set point.";
125 case BPNormalError:
126 return @"device error, error message displayed automatically";
127 case BPOverTimeError:
128 return @"abnormal communication";
129 case BPNoRespondError:
130 return @"abnormal communication";
131 case BPBeyondRangeError:
132 return @"device is out of communication range.";
133 case BPDidDisconnect:
134 return @"device is disconnected.";
135 case BPAskToStopMeasure:
136 return @"measurement has been stopped.";
137 case BPDeviceBusy:
138 return @"device is busy doing other things";
139 case BPInputParameterError:
140 return @"the argument of method is illegal.";
141 case 401:
142 return @"the operation is illegal";
143 case 900:
144 return @"iOS doesn't support disconnect normal BT devices";
145 }
146 return @"unknown error";
147}
148
149
150+ (void)sendErrorToEmitter:(RCTEventEmitter *)emitter eventNotify:(NSString*)eventNotify WithCode:(NSInteger)errorCode{
151 NSDictionary* errorDict;
152
153
154 if(errorCode==BPDidDisconnect){
155
156
157 errorDict = @{
158 kACTION:kACTION_ERROR_BP,
159 kERROR_DESCRIPTION_BP:[self descriptionForErrorCode:errorCode]
160 };
161
162 }else{
163
164
165 errorDict = @{
166 kACTION:kACTION_ERROR_BP,
167 kERROR_NUM_BP:@(errorCode),
168 kERROR_DESCRIPTION_BP:[self descriptionForErrorCode:errorCode]
169 };
170
171
172 }
173
174 [self sendEventToEmitter:emitter eventNotify:eventNotify WithDict:errorDict];
175}
176
177+ (void)sendEventToEmitter:(RCTEventEmitter *)emitter eventNotify:(NSString*)eventNotify WithDict:(NSDictionary*)dict{
178 [emitter sendEventWithName:eventNotify body:dict];
179}
180
181
182@end