|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UITextView *textView; |
|
|
@property (nonatomic, strong) UITextView *textView; |
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UIButton *changeIpBtn; |
|
|
|
|
|
|
|
|
@end |
|
|
@end |
|
|
|
|
|
|
|
|
@implementation ELBfsWifiConnectVC |
|
|
@implementation ELBfsWifiConnectVC |
|
|
|
|
|
|
|
|
[self addLog:@"Disconnected"]; |
|
|
[self addLog:@"Disconnected"]; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (sender.tag) { |
|
|
|
|
|
case 1: { |
|
|
|
|
|
//获取BM Version |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeGetBMVersion]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: { |
|
|
|
|
|
//Get CVP ID |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"Cid:%zd, Vid:%zd, Pid:%zd",self.p.deviceType,self.p.vendorID,self.p.productID]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 3: { |
|
|
|
|
|
//Get Name |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"DeviceName:%@",self.p.deviceName]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 4: { |
|
|
|
|
|
//Set name |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] setBluetoothName:@"Ailink_Dev"]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 5: { |
|
|
|
|
|
//Change unit |
|
|
|
|
|
if (sender.selected) { |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] changeBodyFatScaleUnit:ELDeviceWeightUnit_LB]; |
|
|
|
|
|
[self addLog:@"set lb unit"]; |
|
|
|
|
|
} else { |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] changeBodyFatScaleUnit:ELDeviceWeightUnit_KG]; |
|
|
|
|
|
[self addLog:@"set kg unit"]; |
|
|
|
|
|
} |
|
|
|
|
|
sender.selected = !sender.selected; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[self addLog:sender.titleLabel.text]; |
|
|
[self addLog:sender.titleLabel.text]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// [self.view addSubview:button1]; |
|
|
// [self.view addSubview:button1]; |
|
|
// [button1 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
// [button1 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
// make.left.mas_equalTo(10); |
|
|
// make.left.mas_equalTo(10); |
|
|
// make.top.mas_equalTo(80); |
|
|
|
|
|
|
|
|
// make.top.mas_equalTo(85); |
|
|
// make.width.mas_equalTo(100); |
|
|
// make.width.mas_equalTo(100); |
|
|
// make.height.mas_equalTo(40); |
|
|
// make.height.mas_equalTo(40); |
|
|
// }]; |
|
|
// }]; |
|
|
|
|
|
|
|
|
// [self.view addSubview:button2]; |
|
|
// [self.view addSubview:button2]; |
|
|
// [button2 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
// [button2 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
// make.left.equalTo(button1.mas_right).mas_offset(10); |
|
|
// make.left.equalTo(button1.mas_right).mas_offset(10); |
|
|
// make.top.mas_equalTo(80); |
|
|
|
|
|
|
|
|
// make.top.mas_equalTo(85); |
|
|
// make.width.mas_equalTo(100); |
|
|
// make.width.mas_equalTo(100); |
|
|
// make.height.mas_equalTo(40); |
|
|
// make.height.mas_equalTo(40); |
|
|
// }]; |
|
|
// }]; |
|
|
|
|
|
|
|
|
// [self.view addSubview:button3]; |
|
|
// [self.view addSubview:button3]; |
|
|
// [button3 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
// [button3 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
// make.left.equalTo(button2.mas_right).mas_offset(10); |
|
|
// make.left.equalTo(button2.mas_right).mas_offset(10); |
|
|
// make.top.mas_equalTo(80); |
|
|
|
|
|
|
|
|
// make.top.mas_equalTo(85); |
|
|
// make.width.mas_equalTo(100); |
|
|
// make.width.mas_equalTo(100); |
|
|
// make.height.mas_equalTo(40); |
|
|
// make.height.mas_equalTo(40); |
|
|
// }]; |
|
|
// }]; |
|
|
|
|
|
|
|
|
// make.width.mas_equalTo(100); |
|
|
// make.width.mas_equalTo(100); |
|
|
// make.height.mas_equalTo(40); |
|
|
// make.height.mas_equalTo(40); |
|
|
// }]; |
|
|
// }]; |
|
|
// |
|
|
|
|
|
// UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; |
|
|
|
|
|
// [button5 setTitle:@"Change unit" forState:(UIControlStateNormal)]; |
|
|
|
|
|
// button5.tag = 5; |
|
|
|
|
|
// button5.titleLabel.adjustsFontSizeToFitWidth = YES; |
|
|
|
|
|
// button5.titleLabel.numberOfLines = 2; |
|
|
|
|
|
// button5.backgroundColor = [UIColor blackColor]; |
|
|
|
|
|
// [button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; |
|
|
|
|
|
// [self.view addSubview:button5]; |
|
|
|
|
|
// [button5 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIButton *button5 = [UIButton buttonWithType:(UIButtonTypeCustom)]; |
|
|
|
|
|
[button5 setTitle:@"Change unit" forState:(UIControlStateNormal)]; |
|
|
|
|
|
button5.tag = 5; |
|
|
|
|
|
button5.titleLabel.adjustsFontSizeToFitWidth = YES; |
|
|
|
|
|
button5.titleLabel.numberOfLines = 2; |
|
|
|
|
|
button5.backgroundColor = [UIColor blackColor]; |
|
|
|
|
|
[button5 addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)]; |
|
|
|
|
|
[self.view addSubview:button5]; |
|
|
|
|
|
[button5 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
// make.left.equalTo(button4.mas_right).mas_offset(10); |
|
|
// make.left.equalTo(button4.mas_right).mas_offset(10); |
|
|
// make.top.equalTo(button1.mas_bottom).mas_offset(10); |
|
|
// make.top.equalTo(button1.mas_bottom).mas_offset(10); |
|
|
// make.width.mas_equalTo(100); |
|
|
|
|
|
// make.height.mas_equalTo(40); |
|
|
|
|
|
// }]; |
|
|
|
|
|
|
|
|
make.left.offset(10); |
|
|
|
|
|
make.top.offset(90); |
|
|
|
|
|
make.width.mas_equalTo(100); |
|
|
|
|
|
make.height.mas_equalTo(40); |
|
|
|
|
|
}]; |
|
|
// |
|
|
// |
|
|
self.textView = [[UITextView alloc] init]; |
|
|
self.textView = [[UITextView alloc] init]; |
|
|
self.textView.backgroundColor = [UIColor blackColor]; |
|
|
self.textView.backgroundColor = [UIColor blackColor]; |
|
|
|
|
|
|
|
|
make.height.mas_equalTo(300); |
|
|
make.height.mas_equalTo(300); |
|
|
}]; |
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
self.changeIpBtn = [[UIButton alloc] init]; |
|
|
|
|
|
[self.changeIpBtn setTitle:@"Switch to the test environment" forState:UIControlStateNormal]; |
|
|
|
|
|
[self.changeIpBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; |
|
|
|
|
|
[self.changeIpBtn setTitle:@"Switch to the formal environment" forState:UIControlStateSelected]; |
|
|
|
|
|
[self.changeIpBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected]; |
|
|
|
|
|
self.changeIpBtn.adjustsImageWhenHighlighted = YES; |
|
|
|
|
|
self.changeIpBtn.backgroundColor = [UIColor blackColor]; |
|
|
|
|
|
self.changeIpBtn.titleLabel.font = [UIFont systemFontOfSize:13]; |
|
|
|
|
|
self.changeIpBtn.titleLabel.numberOfLines = 2; |
|
|
|
|
|
[self.changeIpBtn addTarget:self action:@selector(changeDevIpAddress:) forControlEvents:UIControlEventTouchUpInside]; |
|
|
|
|
|
[self.view addSubview:self.changeIpBtn]; |
|
|
|
|
|
[self.changeIpBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
|
make.left.equalTo(button5.mas_right).mas_offset(10); |
|
|
|
|
|
make.centerY.equalTo(button5.mas_centerY); |
|
|
|
|
|
make.width.mas_equalTo(120); |
|
|
|
|
|
make.height.mas_equalTo(40); |
|
|
|
|
|
|
|
|
|
|
|
// make.left.offset(20); |
|
|
|
|
|
// make.top.offset(100); |
|
|
|
|
|
// make.size.mas_equalTo(CGSizeMake(120, 30)); |
|
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; |
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; |
|
|
self.tableView.delegate = self; |
|
|
self.tableView.delegate = self; |
|
|
self.tableView.dataSource = self; |
|
|
self.tableView.dataSource = self; |
|
|
[self.view addSubview:self.tableView]; |
|
|
[self.view addSubview:self.tableView]; |
|
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
make.left.right.offset(0); |
|
|
make.left.right.offset(0); |
|
|
make.top.offset(100); |
|
|
|
|
|
|
|
|
make.top.equalTo(self.changeIpBtn.mas_bottom).offset(15); |
|
|
make.bottom.equalTo(self.textView.mas_top).offset(-20); |
|
|
make.bottom.equalTo(self.textView.mas_top).offset(-20); |
|
|
}]; |
|
|
}]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//MARK:回调Wifi列表 |
|
|
//MARK:回调Wifi列表 |
|
|
-(void)bleWifiReceiveWifiDetailModel:(ELBleWifiDetailModel *)model{ |
|
|
-(void)bleWifiReceiveWifiDetailModel:(ELBleWifiDetailModel *)model{ |
|
|
//用一个tableview显示喽 |
|
|
//用一个tableview显示喽 |
|
|
[self addLog:[NSString stringWithFormat:@"wifi类型---%lu 名称---%@ 连接状态--%zd",(unsigned long)model.wifiState,model.wifiName,model.wifiState]]; |
|
|
|
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"wifi type---%lu name---%@ link state--%zd",(unsigned long)model.wifiState,model.wifiName,model.wifiState]]; |
|
|
// MARK:3.WiFi配置得到Wifi列表 |
|
|
// MARK:3.WiFi配置得到Wifi列表 |
|
|
if (model.wifiName.length > 0) { |
|
|
if (model.wifiName.length > 0) { |
|
|
[self.dataSource addObject:model]; |
|
|
[self.dataSource addObject:model]; |
|
|
|
|
|
|
|
|
return self.dataSource.count; |
|
|
return self.dataSource.count; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { |
|
|
|
|
|
return 0.f; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { |
|
|
|
|
|
return nil; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
|
static NSString *cellId = @"ELBfsWifiConnectTableViewCell"; |
|
|
static NSString *cellId = @"ELBfsWifiConnectTableViewCell"; |
|
|
ELBfsWifiConnectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; |
|
|
ELBfsWifiConnectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; |
|
|
|
|
|
|
|
|
[self presentViewController:alert animated:YES completion:nil]; |
|
|
[self presentViewController:alert animated:YES completion:nil]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - 切换秤环境 |
|
|
|
|
|
|
|
|
|
|
|
static NSString *formalAddress = @"http://ailink.iot.aicare.net.cn"; |
|
|
|
|
|
static NSString *testAddress = @"http://test.ailink.revice.aicare.net.cn"; |
|
|
|
|
|
static NSString *pathURL = @"/devivce/serverRedirect/"; |
|
|
|
|
|
|
|
|
|
|
|
- (void)changeDevIpAddress:(UIButton *)sender { |
|
|
|
|
|
// if ([self.title isEqualToString:@"Connected"]) { |
|
|
|
|
|
if (sender.selected) { |
|
|
|
|
|
//切换到生产环境 |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] setDevAccessIpAddress:formalAddress path:pathURL]; |
|
|
|
|
|
[self addLog:@"Start to configure as a production environment(开始配置为生产环境"]; |
|
|
|
|
|
} else { |
|
|
|
|
|
//切到测试环境 |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] setDevAccessIpAddress:testAddress path:pathURL]; |
|
|
|
|
|
// [[ELBodyFatScaleBleManager shareManager] setDevAccessIpAddress:@"ABCD1234567890" path:pathURL]; |
|
|
|
|
|
[self addLog:@"Start to configure as a test environment(开始配置为测试环境"]; |
|
|
|
|
|
} |
|
|
|
|
|
// sender.selected = !sender.selected; |
|
|
|
|
|
// } else { |
|
|
|
|
|
// [self addLog:@"当前设备未连接"]; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 返回ip地址配置结果 */ |
|
|
|
|
|
- (void)bodyFatScaleManagerCallBackSetIPAddressResult:(NSInteger)result { |
|
|
|
|
|
NSString *resultStr = @""; |
|
|
|
|
|
if (result == 0) { |
|
|
|
|
|
//失败 |
|
|
|
|
|
resultStr = @"Environment configuration failed(环境配置失败"; |
|
|
|
|
|
} else if (result == 1) { |
|
|
|
|
|
//成功 |
|
|
|
|
|
resultStr = @"Environment configuration is successful(环境配置成功"; |
|
|
|
|
|
self.changeIpBtn.selected = !self.changeIpBtn.selected; |
|
|
|
|
|
} else { |
|
|
|
|
|
//不支持 |
|
|
|
|
|
resultStr = @"The current device does not support environment configuration(当前设备不支持环境配置"; |
|
|
|
|
|
} |
|
|
|
|
|
[self addLog:resultStr]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - |
|
|
#pragma mark - |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] disconnectPeripheral]; |
|
|
[[ELBodyFatScaleBleManager shareManager] disconnectPeripheral]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark ============ 如下是蓝牙交互部分,wifi不用管 ============== |
|
|
#pragma mark ============ 如下是蓝牙交互部分,wifi不用管 ============== |
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
///** |
|
|
|
|
|
// MCU requests user information( MCU 请求用户信息) |
|
|
|
|
|
// |
|
|
|
|
|
// @param status 请求状态 |
|
|
|
|
|
// */ |
|
|
|
|
|
//- (void)bodyFatScaleManagerMCURequestAppUserInfoType:(BodyFatScaleMCURequestUserInfoStatus)status{ |
|
|
|
|
|
// if (status == BodyFatScaleMCURequestUserInfoStatus_Get) { |
|
|
|
|
|
// //下发当前用户给秤 |
|
|
|
|
|
// [[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]]; |
|
|
|
|
|
// }else if (status == BodyFatScaleMCURequestUserInfoStatus_Success){ |
|
|
|
|
|
// [self addLog:@"MCU requests user information success"]; |
|
|
|
|
|
// }else if (BodyFatScaleMCURequestUserInfoStatus_Fail){ |
|
|
|
|
|
// [self addLog:@"MCU requests user information failure"]; |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
// |
|
|
|
|
|
///** |
|
|
|
|
|
// Return weight and body fat model(返回重量及体脂model) |
|
|
|
|
|
// */ |
|
|
|
|
|
//-(void)bodyFatScaleManagerCallBackWeight:(ELBodyFatScaleBleWeightModel *)weightModel state:(BodyFatScaleMeasureStatus)status{ |
|
|
|
|
|
// switch (status) { |
|
|
|
|
|
// case BodyFatScaleMeasureStatus_Unstable: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"Unstable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleMeasureStatus_Stable: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"Stable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleMeasureStatus_Failed: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:@"Test failure"]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleMeasureStatus_Complete: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"Tested weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; |
|
|
|
|
|
// |
|
|
|
|
|
// //更新用户信息给秤 |
|
|
|
|
|
// [[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]]; |
|
|
|
|
|
// //下发用户列表 |
|
|
|
|
|
// [[ELBodyFatScaleBleManager shareManager] sendOfflineUserListToBle:[self get8Users]]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// default: |
|
|
|
|
|
// break; |
|
|
|
|
|
// } |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
// |
|
|
|
|
|
///** |
|
|
|
|
|
// Return temperature (unit: ° C)(返回温度(单位:°C)) |
|
|
|
|
|
// |
|
|
|
|
|
// @param temp 温度(单位:°C) |
|
|
|
|
|
// */ |
|
|
|
|
|
//-(void)bodyFatScaleManagerCallBackTemp:(NSString *)temp{ |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"temperature is %@",temp]]; |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
///** |
|
|
|
|
|
// Back to impedance measurement(返回阻抗测量) |
|
|
|
|
|
// |
|
|
|
|
|
// @param status 阻抗测量状态 |
|
|
|
|
|
// @param adc 阻抗 |
|
|
|
|
|
// */ |
|
|
|
|
|
//-(void)bodyFatScaleManagerCallBackAdcMeasureStatus:(BodyFatScaleAdcMeasureStatus)status adcValue:(NSInteger)adc{ |
|
|
|
|
|
// switch (status) { |
|
|
|
|
|
// case BodyFatScaleAdcMeasureStatus_Testing: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:@"adc testing"]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleAdcMeasureStatus_Success: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"adc is %ld",adc]]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleAdcMeasureStatus_Fail: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:@"adc test failure"]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleAdcMeasureStatus_SuccessCustom: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"adc is %ld and user app algum",adc]]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// default: |
|
|
|
|
|
// break; |
|
|
|
|
|
// } |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
///** |
|
|
|
|
|
// Callback heart rate measurement(回调心率测量) |
|
|
|
|
|
// |
|
|
|
|
|
// @param status 心率测量状态 |
|
|
|
|
|
// @param heartRate 心率 |
|
|
|
|
|
// */ |
|
|
|
|
|
//-(void)bodyFatScaleManagerCallBackHeartRateMeasureStatus:(BodyFatScaleHeartRateMeasureStatus)status heartRateValue:(NSInteger)heartRate{ |
|
|
|
|
|
// switch (status) { |
|
|
|
|
|
// case BodyFatScaleHeartRateMeasureStatus_Testing: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:@"Heart Rate Testing"]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleHeartRateMeasureStatus_Success: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"Heart Rate is %ld",heartRate]]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// case BodyFatScaleHeartRateMeasureStatus_Fail: |
|
|
|
|
|
// { |
|
|
|
|
|
// [self addLog:@"Heart Rate Test failure"]; |
|
|
|
|
|
// } |
|
|
|
|
|
// break; |
|
|
|
|
|
// default: |
|
|
|
|
|
// break; |
|
|
|
|
|
// } |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
///** |
|
|
|
|
|
// Return error code(返回错误码) |
|
|
|
|
|
// |
|
|
|
|
|
// @param code 错误码 |
|
|
|
|
|
// 1:超重 |
|
|
|
|
|
// */ |
|
|
|
|
|
//-(void)bodyFatScaleManagerCallBackErrorCode:(NSInteger)code{ |
|
|
|
|
|
// [self addLog:[NSString stringWithFormat:@"error code = %ld",code]]; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion { |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"BMVersion :%@",bmVersion]]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
MCU requests user information( MCU 请求用户信息) |
|
|
|
|
|
|
|
|
|
|
|
@param status 请求状态 |
|
|
|
|
|
*/ |
|
|
|
|
|
- (void)bodyFatScaleManagerMCURequestAppUserInfoType:(BodyFatScaleMCURequestUserInfoStatus)status{ |
|
|
|
|
|
if (status == BodyFatScaleMCURequestUserInfoStatus_Get) { |
|
|
|
|
|
//下发当前用户给秤 |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]]; |
|
|
|
|
|
}else if (status == BodyFatScaleMCURequestUserInfoStatus_Success){ |
|
|
|
|
|
[self addLog:@"MCU requests user information success"]; |
|
|
|
|
|
}else if (BodyFatScaleMCURequestUserInfoStatus_Fail){ |
|
|
|
|
|
[self addLog:@"MCU requests user information failure"]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
Return weight and body fat model(返回重量及体脂model) |
|
|
|
|
|
*/ |
|
|
|
|
|
-(void)bodyFatScaleManagerCallBackWeight:(ELBodyFatScaleBleWeightModel *)weightModel state:(BodyFatScaleMeasureStatus)status{ |
|
|
|
|
|
switch (status) { |
|
|
|
|
|
case BodyFatScaleMeasureStatus_Unstable: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"Unstable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleMeasureStatus_Stable: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"Stable data weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleMeasureStatus_Failed: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:@"Test failure"]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleMeasureStatus_Complete: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"Tested weight = %ld unit = %@ point = %ld adc = %ld",weightModel.weight,AiLinkBleWeightUnitDic[@(weightModel.weightUnit)],weightModel.weightPoint,weightModel.adc]]; |
|
|
|
|
|
|
|
|
|
|
|
//更新用户信息给秤 |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] sendCurrentUserToBle:[self getOneUser]]; |
|
|
|
|
|
//下发用户列表 |
|
|
|
|
|
[[ELBodyFatScaleBleManager shareManager] sendOfflineUserListToBle:[self get8Users]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
Return temperature (unit: ° C)(返回温度(单位:°C)) |
|
|
|
|
|
|
|
|
|
|
|
@param temp 温度(单位:°C) |
|
|
|
|
|
*/ |
|
|
|
|
|
-(void)bodyFatScaleManagerCallBackTemp:(NSString *)temp{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"temperature is %@",temp]]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
Back to impedance measurement(返回阻抗测量) |
|
|
|
|
|
|
|
|
|
|
|
@param status 阻抗测量状态 |
|
|
|
|
|
@param adc 阻抗 |
|
|
|
|
|
*/ |
|
|
|
|
|
-(void)bodyFatScaleManagerCallBackAdcMeasureStatus:(BodyFatScaleAdcMeasureStatus)status adcValue:(NSInteger)adc{ |
|
|
|
|
|
switch (status) { |
|
|
|
|
|
case BodyFatScaleAdcMeasureStatus_Testing: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:@"adc testing"]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleAdcMeasureStatus_Success: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"adc is %ld",adc]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleAdcMeasureStatus_Fail: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:@"adc test failure"]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleAdcMeasureStatus_SuccessCustom: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"adc is %ld and user app algum",adc]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
Callback heart rate measurement(回调心率测量) |
|
|
|
|
|
|
|
|
|
|
|
@param status 心率测量状态 |
|
|
|
|
|
@param heartRate 心率 |
|
|
|
|
|
*/ |
|
|
|
|
|
-(void)bodyFatScaleManagerCallBackHeartRateMeasureStatus:(BodyFatScaleHeartRateMeasureStatus)status heartRateValue:(NSInteger)heartRate{ |
|
|
|
|
|
switch (status) { |
|
|
|
|
|
case BodyFatScaleHeartRateMeasureStatus_Testing: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:@"Heart Rate Testing"]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleHeartRateMeasureStatus_Success: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"Heart Rate is %ld",heartRate]]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case BodyFatScaleHeartRateMeasureStatus_Fail: |
|
|
|
|
|
{ |
|
|
|
|
|
[self addLog:@"Heart Rate Test failure"]; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
Return error code(返回错误码) |
|
|
|
|
|
|
|
|
|
|
|
@param code 错误码 |
|
|
|
|
|
1:超重 |
|
|
|
|
|
*/ |
|
|
|
|
|
-(void)bodyFatScaleManagerCallBackErrorCode:(NSInteger)code{ |
|
|
|
|
|
[self addLog:[NSString stringWithFormat:@"error code = %ld",code]]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////MARK:回调A6指令数据 |
|
|
////MARK:回调A6指令数据 |
|
|
// |
|
|
// |
|
|
///** |
|
|
///** |
|
|
|
|
|
|
|
|
// //这里的身体指标数据由秤计算得到 |
|
|
// //这里的身体指标数据由秤计算得到 |
|
|
// [self addLog:[NSString stringWithFormat:@"MCU algorithm-offline history data:userId = %ld weight = %ld unit =%@ point = %ld",user.usrID,bodyModel.weight,AiLinkBleWeightUnitDic[@(bodyModel.weightUnit)],bodyModel.weightPoint]]; |
|
|
// [self addLog:[NSString stringWithFormat:@"MCU algorithm-offline history data:userId = %ld weight = %ld unit =%@ point = %ld",user.usrID,bodyModel.weight,AiLinkBleWeightUnitDic[@(bodyModel.weightUnit)],bodyModel.weightPoint]]; |
|
|
//} |
|
|
//} |
|
|
// |
|
|
|
|
|
// |
|
|
|
|
|
//-(NSArray<ELBodyFatScaleBleUserModel *> *)get8Users{ |
|
|
|
|
|
// NSMutableArray *users = [[NSMutableArray alloc] init]; |
|
|
|
|
|
// for (int i=0; i<8; i++) { |
|
|
|
|
|
// ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init]; |
|
|
|
|
|
// user.createTime = [[NSDate date] timeIntervalSince1970]; |
|
|
|
|
|
// user.usrID = i; |
|
|
|
|
|
// user.role = i%4; |
|
|
|
|
|
// user.sex = i%2; |
|
|
|
|
|
// user.age = 26+i; |
|
|
|
|
|
// user.height = 170+i; |
|
|
|
|
|
// user.weight = 600+i; |
|
|
|
|
|
// user.adc = 560+i; |
|
|
|
|
|
// [users addObject:user]; |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// return users.copy; |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
//-(ELBodyFatScaleBleUserModel *)getOneUser{ |
|
|
|
|
|
// ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init]; |
|
|
|
|
|
// user.createTime = [[NSDate date] timeIntervalSince1970]; |
|
|
|
|
|
// user.usrID = 0; |
|
|
|
|
|
// user.role = BodyFatScaleRole_Ordinary; |
|
|
|
|
|
// user.sex = ELBluetoothUserSex_Woman; |
|
|
|
|
|
// user.age = 26; |
|
|
|
|
|
// user.height = 170; |
|
|
|
|
|
// user.weight = 600; |
|
|
|
|
|
// user.adc = 560; |
|
|
|
|
|
// return user; |
|
|
|
|
|
//} |
|
|
|
|
|
//-(void)dealloc{ |
|
|
|
|
|
// |
|
|
|
|
|
// |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(NSArray<ELBodyFatScaleBleUserModel *> *)get8Users{ |
|
|
|
|
|
NSMutableArray *users = [[NSMutableArray alloc] init]; |
|
|
|
|
|
for (int i=0; i<8; i++) { |
|
|
|
|
|
ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init]; |
|
|
|
|
|
user.createTime = [[NSDate date] timeIntervalSince1970]; |
|
|
|
|
|
user.usrID = i; |
|
|
|
|
|
user.role = i%4; |
|
|
|
|
|
user.sex = i%2; |
|
|
|
|
|
user.age = 26+i; |
|
|
|
|
|
user.height = 170+i; |
|
|
|
|
|
user.weight = 600+i; |
|
|
|
|
|
user.adc = 560+i; |
|
|
|
|
|
[users addObject:user]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return users.copy; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
-(ELBodyFatScaleBleUserModel *)getOneUser{ |
|
|
|
|
|
ELBodyFatScaleBleUserModel *user = [[ELBodyFatScaleBleUserModel alloc] init]; |
|
|
|
|
|
user.createTime = [[NSDate date] timeIntervalSince1970]; |
|
|
|
|
|
user.usrID = 0; |
|
|
|
|
|
user.role = BodyFatScaleRole_Ordinary; |
|
|
|
|
|
user.sex = ELBluetoothUserSex_Woman; |
|
|
|
|
|
user.age = 26; |
|
|
|
|
|
user.height = 170; |
|
|
|
|
|
user.weight = 600; |
|
|
|
|
|
user.adc = 560; |
|
|
|
|
|
return user; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@end |
|
|
@end |