1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
//
// BG5S.h
// iHealthSDKStatic
//
// Created by Lei Bao on 2017/6/30.
// Copyright © 2017年 daiqingquan. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BGMacroFile.h"
// --------------- DELEGATE ---------------
@class BG5S;
/**
BG5SDelegate
*/
@protocol BG5SDelegate <NSObject>
@required
/**
Device sends an error
@param device active device
@param error error number
@param errorDescription error message
*/
- (void)device:(BG5S *)device occurError:(BG5SError)error errorDescription:(NSString *)errorDescription;
/**
Device sends strip state message
@note Only after startMeasure: method is called, does the device send strip state message.
If you insert strip before calling startMeasure: method, the device doesn't send strip state(Insert or Pull off) until startMeasure: method is called.
@param device active device
@param state BG5SStripState enum
*/
- (void)device:(BG5S *)device stripStateDidUpdate:(BG5SStripState)state;
/**
Device sends drop blood or ctl message
@note After reciving this message, you should not call any method until you recive result. If called, the method may be timeout.
@param device active device
*/
- (void)deviceDropBlood:(BG5S *)device;
/**
Device sends result
@param device active device
@param dataID data identifier (Only for SDK users)
@param result blood glucose value with mg/dL unit
*/
- (void)device:(BG5S *)device dataID:(NSString *)dataID measureReult:(NSInteger)result;
/**
Device sends charging state
@note Only state changes, is the message sent.
@param device active device
@param state BG5SChargeState object
*/
- (void)device:(BG5S *)device chargeStateDidUpdate:(BG5SChargeState)state;
@end
/**
state information of BG5S when call "queryStateInfoWithSuccess:"
*/
@interface BG5SStateInfo : NSObject
/**
0-100 means battery percent, 255 means charging
*/
@property (assign, nonatomic, readonly) NSInteger batteryValue;
/**
device date (UTC)
*/
@property (copy, nonatomic, readonly) NSDate *deviceDate;
/**
device timezon -12.00 to 14.00. Without setting, default timezone is 0.00
*/
@property (assign, nonatomic, readonly) float deviceTimeZone;
/**
quantity of strip used in measurement.range:[0,65535]. If value is 65535, there may be something wrong with BG5S. Because 65535 is very large number for true user.
*/
@property (assign, nonatomic, readonly) NSInteger stripUsedValue;
/**
quantity of record measuring without connecting to APP.range:[0,500]. If value is 65535, there may be something wrong with BG5S.
*/
@property (assign, nonatomic, readonly) NSInteger offlineDataQuantity;
/**
blood code version (0-255)
*/
@property (assign, nonatomic, readonly) NSInteger bloodCodeVersion;
/**
ctl code version (0-255)
*/
@property (assign, nonatomic, readonly) NSInteger ctlCodeVersion;
/**
measure unit (BGUnit_Unknown means that BG5S has never been set unit from App,BGUnit_mmolPL stands for mmol/L,BGUnit_mgPmL stands for mg/dL)
*/
@property (assign, nonatomic, readonly) BGUnit unit;
@end
/**
Offline data model of BG5S
*/
@interface BG5SRecordModel : NSObject
/**
Data ID (Only for SDK users)
*/
@property (copy, nonatomic, readonly) NSString *dataID;
/**
Measure Date (UTC)
*/
@property (copy, nonatomic, readonly) NSDate *measureDate;
/**
Time zone
*/
@property (assign, nonatomic, readonly) float timeZone;
/**
BG Value with mg/dL unit
*/
@property (assign, nonatomic, readonly) NSInteger value;
/**
Correct Flag, YES:can be corrected, NO:cannot be corrected
*/
@property (assign, nonatomic, readonly) BOOL canCorrect;
@end
/**
Modified offline data model of BG5S
*/
@interface BG5SRecordModifiedModel : NSObject
/**
Data ID (Only for SDK users)
*/
@property (copy, nonatomic) NSString *dataID;
/**
Measure Date (UTC)
*/
@property (copy, nonatomic) NSDate *measureDate;
/**
Time zone
*/
@property (assign, nonatomic,) float timeZone;
/**
BG Value with mg/dL unit
*/
@property (assign, nonatomic) NSInteger value;
@end
/**
BG5S
*/
@interface BG5S : BGDevice
@property (weak, nonatomic) id<BG5SDelegate> delegate;
/**
Query BG5S state information including battery value,device date, device timezone, strip used, quantity of offline data, blood code version, CTL code version, unit.
@param stateInfoBlock BG5SStateInfo object
@param errorBlock the block means fail. You can get error from this block
@note If analysis occurs error, BG5SStateInfo object maybe nil or some of its property are nil.
*/
- (void)queryStateInfoWithSuccess:(BG5SStateInfoBlock)stateInfoBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
/**
Set time
@param date the date you want to set should be an UTC time. valid range:Jan. 1,2000 - Dec. 31,2099. If date is nil, use [NSdate date] and system time zone
@param timezone the timezone you want to set should be from -12.00 to 14.00; step length = 0.25
@param successBlock the block means success
@param errorBlock the block means fail. You can get error from this block
@note If date is out of reange, BG5SError_InputParametersError will be returned by block.
If date and timezone are invalid , use input parameters; otherwise use [NSdate date] and system time zone;
*/
- (void)setTimeWithDate:(NSDate *)date
timezone:(float)timezone
successBlock:(BG5SSuccessBlock)successBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
/**
Set unit
@param unit the unit you want to set (BGUnit_mmolPL stands for mmol/L,BGUnit_mgPmL stands for mg/dL)
@param successBlock the block means success
@param errorBlock the block means fail. You can get error from this block
*/
- (void)setUnit:(BGUnit)unit
successBlock:(BG5SSuccessBlock)successBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
/**
Delete strip used info (the quantity of strip used is set to 0)
@param successBlock the block means success
@param errorBlock the block means fail. You can get error from this block
*/
- (void)deleteStripUsedInfoWithSuccessBlock:(BG5SSuccessBlock)successBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
/**
Query record data stored in BG5S
@param successBlock the block means success; if has record, return non-empty array (BG5SRecordModel object); if no record, return empty array
@param errorBlock the block means fail. You can get error from this block
*/
- (void)queryRecordWithSuccessBlock:(BG5SRecordBlock)successBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
/**
Delete record data stored in BG5S
@param successBlock the block means success
@param errorBlock the block means fail. You can get error from this block
*/
- (void)deleteRecordWithSuccessBlock:(BG5SSuccessBlock)successBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
/**
Start online measurement with specific measure mode.
@note If you don't call this method, BG5S use blood mode by default.
If CTL mode is sent, BG5S use CTL mode and BG5S can't be set to use blood mode until next connection.
@param measureMode Blood or CTL
@param successBlock the block means success
@param errorBlock the block means fail. You can get error from this block
*/
- (void)startMeasure:(BGMeasureMode)measureMode
withSuccessBlock:(BG5SSuccessBlock)successBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
/**
Disconnect device
*/
- (void)disconnectDevice;
/**
Correct Measure Date if canCorrect is YES in BG5SRecordModel
@param array BG5SRecordModel objects
@param deviceDate This date should be read before set time method called.
@return BG5SRecordModifiedModel objects; return empty array means input parameters is wrong.
*/
- (NSArray *)processData:(NSArray<BG5SRecordModel*> *)array deviceDate:(NSDate *)deviceDate;
/**
Is offline measurement allowed
@param isOffline Is offline measurement allowed 0:allowed 1:Offline measurement is not allowed
@param successBlock the block means success
@param errorBlock the block means fail. You can get error from this block
*/
- (void)setIsOfflineMeasurementAllowed:(BOOL)isOffline
successBlock:(BG5SSuccessBlock)successBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
- (void)setCodeWithMeasureMode:(BGMeasureMode)mode
resultBlock:(BG5SSetCodeResultBlock)resultBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
- (void)readDeviceInfoWithSuccessBlock:(BG5SDeviceInfoBlock)deviceInfoBlock
errorBlock:(BG5SSDKErrorBlock)errorBlock;
- (void)commandCloseDeviceBLEWithSuccessBlock:(BG5SSuccessBlock)successBlock errorBlock:(BG5SSDKErrorBlock)errorBlock;
- (void)commandSetDeviceDisplay:(BOOL)isDisplay successBlock:(BG5SSuccessBlock)successBlock errorBlock:(BG5SSDKErrorBlock)errorBlock;
@end
|