iOS AILinkBleSDK - 蓝牙SDK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HeightBodyFatScaleVC.m 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. //
  2. // HeightBodyFatScaleVC.m
  3. // AILinkBleSDK_Example
  4. //
  5. // Created by LarryZhang on 2023/2/4.
  6. // Copyright © 2023 zhengzida. All rights reserved.
  7. //
  8. #import "HeightBodyFatScaleVC.h"
  9. #import <AILinkBleSDK/ELHeightBodyFatScaleBleManager.h>
  10. #import <AILinkBleSDK/ELAILinkBleManager.h>
  11. #import "ELDemoButton.h"
  12. @interface HeightBodyFatScaleVC () <ELHeightBodyFatScaleBleDelegate>
  13. @property (weak, nonatomic) IBOutlet UILabel *bleStatusLabel;
  14. //work mode
  15. @property (weak, nonatomic) IBOutlet ELDemoButton *weightModeButton;
  16. @property (weak, nonatomic) IBOutlet ELDemoButton *weightHeightModeButton;
  17. @property (weak, nonatomic) IBOutlet ELDemoButton *weightHeightFatModeButton;
  18. @property (weak, nonatomic) IBOutlet ELDemoButton *withBabyModeButton;
  19. //Weight
  20. @property (weak, nonatomic) IBOutlet UILabel *weightValueLabel;
  21. //Height
  22. @property (weak, nonatomic) IBOutlet UILabel *heightValueLabel;
  23. //Setting
  24. @property (weak, nonatomic) IBOutlet ELDemoButton *voiceSettingButton;
  25. @property (weak, nonatomic) IBOutlet ELDemoButton *uintSettingButton;
  26. //workMode
  27. @property (nonatomic, assign) HeightBodyFatScale_WorkModeType workMode;
  28. //voice on/of
  29. @property (nonatomic, assign) BOOL voiceOn;
  30. //unit
  31. @property (nonatomic, assign) ELDeviceWeightUnit weightUnit;
  32. @property (nonatomic, assign) ELDeviceHeightUnit heightUnit;
  33. //report
  34. @property (weak, nonatomic) IBOutlet UILabel *reportValueLabel;
  35. //baby mode value
  36. @property (weak, nonatomic) IBOutlet UILabel *babyWeightValueLabel;
  37. @property (weak, nonatomic) IBOutlet UILabel *adultWeightValueLabel;
  38. @property (weak, nonatomic) IBOutlet UILabel *babyAdultWeightValueLabel;
  39. /** 抱婴模式下的测量状态下标 */
  40. @property (nonatomic, assign) NSInteger babyModeIndex;
  41. @end
  42. @implementation HeightBodyFatScaleVC
  43. - (void)viewDidLoad {
  44. [super viewDidLoad];
  45. // Do any additional setup after loading the view from its nib.
  46. self.weightUnit = ELDeviceWeightUnit_KG;
  47. self.heightUnit = ELDeviceHeightUnit_CM;
  48. [self uiSetUnit];
  49. self.babyModeIndex = 0;
  50. [self bleScan];
  51. }
  52. - (void)dealloc {
  53. [ELHeightBodyFatScaleBleManager shareManager].heightBodyFatScaleDelegate = nil;
  54. [[ELHeightBodyFatScaleBleManager shareManager] disconnectPeripheral];
  55. }
  56. - (void)bleScan {
  57. //创建蓝牙
  58. [ELHeightBodyFatScaleBleManager shareManager].heightBodyFatScaleDelegate = self;
  59. [[ELHeightBodyFatScaleBleManager shareManager] startScan];
  60. }
  61. //发送用户信息
  62. - (void)sendUserData {
  63. //// 0 female、1 male & 178(cm)
  64. [[ELHeightBodyFatScaleBleManager shareManager] sendUserDataWithGender:1 age:20 heightInCm:178];
  65. }
  66. #pragma mark -UI
  67. - (void)uiSetWorkMode:(HeightBodyFatScale_WorkModeType)mode {
  68. self.weightModeButton.lighted = NO;
  69. self.weightHeightModeButton.lighted = NO;
  70. self.weightHeightFatModeButton.lighted = NO;
  71. self.withBabyModeButton.lighted = NO;
  72. if (mode == HeightBodyFatScale_WorkModeType_WeightMode) {
  73. self.weightModeButton.lighted = YES;
  74. } else if (mode == HeightBodyFatScale_WorkModeType_WeightHeightMode) {
  75. self.weightHeightModeButton.lighted = YES;
  76. } else if (mode == HeightBodyFatScale_WorkModeType_HeightBodyFatMode) {
  77. self.weightHeightFatModeButton.lighted = YES;
  78. } else if (mode == HeightBodyFatScale_WorkModeType_BabyMode) {
  79. self.withBabyModeButton.lighted = YES;
  80. }
  81. }
  82. - (void)uiSetVoiceOn:(BOOL)voiceOn {
  83. self.voiceSettingButton.lighted = voiceOn;
  84. if (voiceOn) {
  85. [self.voiceSettingButton setTitle:@"Voice: On" forState:UIControlStateNormal];
  86. } else {
  87. [self.voiceSettingButton setTitle:@"Voice: Off" forState:UIControlStateNormal];
  88. }
  89. }
  90. - (void)uiSetUnit {
  91. if (self.weightUnit == ELDeviceWeightUnit_KG) {
  92. [self.uintSettingButton setTitle:[NSString stringWithFormat:@"Unit: kg & cm"] forState:UIControlStateNormal];
  93. } else {
  94. [self.uintSettingButton setTitle:[NSString stringWithFormat:@"Unit: lb & ft"] forState:UIControlStateNormal];
  95. }
  96. }
  97. #pragma mark -Setter Getter
  98. - (void)setWorkMode:(HeightBodyFatScale_WorkModeType)workMode {
  99. _workMode = workMode;
  100. [self uiSetWorkMode:workMode];
  101. }
  102. - (void)setVoiceOn:(BOOL)voiceOn {
  103. _voiceOn = voiceOn;
  104. [self uiSetVoiceOn:voiceOn];
  105. }
  106. #pragma mark -Actions
  107. - (IBAction)weightButtonAction:(id)sender {
  108. [[ELHeightBodyFatScaleBleManager shareManager] sendDeviceWorkMode:HeightBodyFatScale_WorkModeType_WeightMode];
  109. self.workMode = HeightBodyFatScale_WorkModeType_WeightMode;
  110. }
  111. - (IBAction)weightHeightButtonAction:(id)sender {
  112. [[ELHeightBodyFatScaleBleManager shareManager] sendDeviceWorkMode:HeightBodyFatScale_WorkModeType_WeightHeightMode];
  113. self.workMode = HeightBodyFatScale_WorkModeType_WeightHeightMode;
  114. }
  115. - (IBAction)weightHeightFatButtonAction:(id)sender {
  116. [[ELHeightBodyFatScaleBleManager shareManager] sendDeviceWorkMode:HeightBodyFatScale_WorkModeType_HeightBodyFatMode];
  117. self.workMode = HeightBodyFatScale_WorkModeType_HeightBodyFatMode;
  118. }
  119. - (IBAction)withBabyButtonAction:(id)sender {
  120. [[ELHeightBodyFatScaleBleManager shareManager] sendDeviceWorkMode:HeightBodyFatScale_WorkModeType_BabyMode];
  121. self.workMode = HeightBodyFatScale_WorkModeType_BabyMode;
  122. }
  123. - (IBAction)voiceSettingButtonAction:(id)sender {
  124. BOOL voiceOn = !self.voiceOn;
  125. [[ELHeightBodyFatScaleBleManager shareManager] sendVoiceSetting:voiceOn];
  126. self.voiceOn = voiceOn;
  127. }
  128. - (IBAction)unitSettingButtonAction:(id)sender {
  129. if (self.weightUnit == ELDeviceWeightUnit_KG) {
  130. self.weightUnit = ELDeviceWeightUnit_LB;
  131. self.heightUnit = ELDeviceHeightUnit_FT_IN;
  132. [[ELHeightBodyFatScaleBleManager shareManager] sendUnitWithHeightUnit:ELDeviceHeightUnit_FT_IN weightUnit:ELDeviceWeightUnit_LB];
  133. } else {
  134. self.weightUnit = ELDeviceWeightUnit_KG;
  135. self.heightUnit = ELDeviceHeightUnit_CM;
  136. [[ELHeightBodyFatScaleBleManager shareManager] sendUnitWithHeightUnit:ELDeviceHeightUnit_CM weightUnit:ELDeviceWeightUnit_KG];
  137. }
  138. [self uiSetUnit];
  139. }
  140. #pragma mark - util
  141. + (NSString *)getWeightStringWithWeight:(NSInteger)weight unit:(ELDeviceWeightUnit)unit point:(NSInteger)point {
  142. NSString *formatStr = [NSString stringWithFormat:@"%%.%luf",(unsigned long)point];
  143. switch (unit) {
  144. case ELDeviceWeightUnit_KG: {
  145. double kgNumber = (double)weight/pow(10, point);
  146. NSString *weightString = [NSString stringWithFormat:formatStr,kgNumber];
  147. return weightString;
  148. }
  149. case ELDeviceWeightUnit_JIN: {
  150. double jinNumber = (double)weight/pow(10, point);
  151. NSString *jinString = [NSString stringWithFormat:formatStr,jinNumber];
  152. return jinString;
  153. }
  154. case ELDeviceWeightUnit_LB_OZ: {
  155. //返回小单位oz
  156. double ozNumber = (double)weight/pow(10, point);
  157. NSInteger lbNumber = ozNumber / 16;
  158. NSString *ozString = [NSString stringWithFormat:formatStr,(ozNumber-lbNumber*16)];
  159. return [NSString stringWithFormat:@"%zd:%@",lbNumber,ozString];
  160. }
  161. case ELDeviceWeightUnit_OZ: {
  162. double ozNumber = (double)weight/pow(10, point);
  163. NSString *ozString = [NSString stringWithFormat:formatStr,ozNumber];
  164. return ozString;
  165. }
  166. case ELDeviceWeightUnit_ST_LB: {
  167. //返回小单位lb
  168. double lbNumber = (double)weight/pow(10, point);
  169. NSInteger stNumber = lbNumber/14;
  170. NSString *lbString = [NSString stringWithFormat:formatStr,(lbNumber-stNumber*14)];
  171. return [NSString stringWithFormat:@"%zd:%@",stNumber,lbString];
  172. }
  173. case ELDeviceWeightUnit_G: {
  174. double gNunber = (double)weight/pow(10, point);
  175. NSString *gString = [NSString stringWithFormat:formatStr,gNunber];
  176. return gString;
  177. }
  178. case ELDeviceWeightUnit_LB: {
  179. double lbNumber = (double)weight/pow(10, point);
  180. NSString *lbString = [NSString stringWithFormat:formatStr,lbNumber];
  181. return lbString;
  182. }
  183. default: {
  184. //不支持的单位
  185. return @"";
  186. }
  187. }
  188. return @"";
  189. }
  190. + (NSString *)getHeightStringWithHeight:(NSInteger)height unit:(ELDeviceHeightUnit)unit point:(NSInteger)point {
  191. NSString *formatStr = [NSString stringWithFormat:@"%%.%luf", (unsigned long)point];
  192. switch (unit) {
  193. case ELDeviceHeightUnit_CM: {
  194. double cmNumber = (double)height/pow(10, point);
  195. NSString *cmString = [NSString stringWithFormat:formatStr,cmNumber];
  196. return cmString;
  197. }
  198. case ELDeviceHeightUnit_Inch: {
  199. double inchNumber = (double)height/pow(10, point);
  200. NSString *inchString = [NSString stringWithFormat:formatStr,inchNumber];
  201. return inchString;
  202. }
  203. case ELDeviceHeightUnit_FT_IN: {
  204. //返回小单位inch
  205. double inchNumber = (double)height/pow(10, point);
  206. NSInteger ftNumber = inchNumber/12;
  207. NSString *inchString = [NSString stringWithFormat:formatStr, (inchNumber-ftNumber*12)];
  208. return [NSString stringWithFormat:@"%zd′%@″", ftNumber, inchString];
  209. }
  210. case ELDeviceHeightUnit_M: {
  211. double mNumber = (double)height/pow(10, point);
  212. NSString *mString = [NSString stringWithFormat:formatStr, mNumber];
  213. return mString;
  214. }
  215. default: {
  216. //不支持的单位
  217. return @"";
  218. }
  219. }
  220. return @"";
  221. }
  222. @end
  223. @implementation HeightBodyFatScaleVC (ble)
  224. #pragma mark - ble Delegate
  225. ///返回设备连接状态
  226. - (void)heightBodyFatScaleManagerUpdateState:(ELBluetoothState)state {
  227. NSLog(@"heightBodyFatScaleManagerUpdateState() state:%@", @(state));
  228. if (state == ELBluetoothStateDidValidationPass) {
  229. //获取设备状态
  230. [[ELHeightBodyFatScaleBleManager shareManager] getWorkState];
  231. //设置用户信息
  232. [self sendUserData];
  233. }
  234. if (state == ELBluetoothStateScaning) {
  235. self.bleStatusLabel.text = @"BLE connecting";
  236. } else if (state == ELBluetoothStateConnectFail) {
  237. self.bleStatusLabel.text = @"BLE failed";
  238. } else if (state == ELBluetoothStateDidValidationPass) {
  239. self.bleStatusLabel.text = @"BLE connected";
  240. } else if (state == ELBluetoothStateDidDisconnect) {
  241. self.bleStatusLabel.text = @"BLE did disconnect";
  242. }
  243. }
  244. ///回调扫描到的身高体脂秤
  245. - (void)heightBodyFatScaleManagerScanDevices:(NSArray<ELPeripheralModel *> *)scanDevices {
  246. for (ELPeripheralModel *model in scanDevices) {
  247. if ([model.macAddress isEqualToString:self.per.macAddressString]) {
  248. [[ELHeightBodyFatScaleBleManager shareManager] stopScan];
  249. [[ELHeightBodyFatScaleBleManager shareManager] connectPeripheral:model];
  250. }
  251. }
  252. }
  253. ///回调用户信息设置结果
  254. - (void)heightBodyFatScaleManagerSetUserDataResult:(HeightBodyFatScale_SetupResult)result {
  255. if (result == HeightBodyFatScale_SetupResult_Failure) {
  256. //重新设置
  257. [self sendUserData];
  258. }
  259. }
  260. ///MCU主动请求用户信息
  261. - (void)heightBodyFatScaleManagerRequestUserData {
  262. //设置用户信息
  263. [self sendUserData];
  264. }
  265. ///MCU设置单位
  266. - (void)heightBodyFatScaleManagerMCUSetHeightUnit:(ELDeviceHeightUnit)heightUnit weightUnit:(ELDeviceWeightUnit)weightUnit {
  267. NSLog(@"weightUnit: %@", @(weightUnit));
  268. NSLog(@"heightUnit: %@", @(heightUnit));
  269. self.weightUnit = weightUnit;
  270. self.heightUnit = heightUnit;
  271. [self uiSetUnit];
  272. }
  273. ///MCU回复单位设置结果
  274. - (void)heightBodyFatScaleManagerReportUnitResult:(HeightBodyFatScale_SetupResult)result {
  275. }
  276. ///MCU回复工作模式设置结果
  277. - (void)heightBodyFatScaleManagerWorkModeResult:(HeightBodyFatScale_SetupResult)result {
  278. }
  279. #pragma mark MCU回复设备状态
  280. - (void)heightBodyFatScaleManagerReportDevStateWithWorkMode:(HeightBodyFatScale_WorkModeType)mode power:(NSInteger)power charging:(BOOL)charging weightUnit:(ELDeviceWeightUnit)weightUnit height:(ELDeviceHeightUnit)heightUnit voiceState:(BOOL)voice {
  281. self.workMode = mode;
  282. self.voiceOn = voice;
  283. self.weightUnit = weightUnit;
  284. self.heightUnit = heightUnit;
  285. [self uiSetUnit];
  286. //防止连接设备后设备已经在测量而导致测量失败的问题,新协议设置模式之后会让设备重新进行测量数据
  287. [[ELHeightBodyFatScaleBleManager shareManager] sendDeviceWorkMode:mode];
  288. NSLog(@"heightBodyFatScaleManagerReportDevStateWithWorkMode() workMode: %@", @(mode));
  289. NSLog(@"heightBodyFatScaleManagerReportDevStateWithWorkMode() power: %@", @(power));
  290. NSLog(@"heightBodyFatScaleManagerReportDevStateWithWorkMode() charging: %@", @(charging));
  291. NSLog(@"heightBodyFatScaleManagerReportDevStateWithWorkMode() weightUnit: %@", @(weightUnit));
  292. NSLog(@"heightBodyFatScaleManagerReportDevStateWithWorkMode() heightUnit: %@", @(heightUnit));
  293. NSLog(@"heightBodyFatScaleManagerReportDevStateWithWorkMode() voiceState: %@", @(voice));
  294. }
  295. #pragma mark 身高体脂模式
  296. ///MCU上报称重状态
  297. - (void)heightBodyFatScaleManagerReportWeighingState:(HeightBodyFatScale_WeightStableType)stable weightNumber:(NSInteger)weight weightPoint:(NSInteger)point unit:(ELDeviceWeightUnit)unit {
  298. NSString *unitString = AiLinkBleWeightUnitDic[@(unit)];
  299. NSString *dataString = [self.class getWeightStringWithWeight:weight unit:unit point:point];
  300. self.weightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  301. NSLog(@"heightBodyFatScaleManagerReportWeighingState() stable: %@", @(stable));
  302. NSLog(@"heightBodyFatScaleManagerReportWeighingState() weight: %@", @(weight));
  303. NSLog(@"heightBodyFatScaleManagerReportWeighingState() point: %@", @(point));
  304. NSLog(@"heightBodyFatScaleManagerReportWeighingState() point: %@", @(unit));
  305. }
  306. ///MCU上报阻抗数据
  307. - (void)heightBodyFatScaleManagerReportAdcDataWithImpedanceState:(HeightBodyFatScale_AdcStateType)state aisle:(HeightBodyFatScale_AdcAisleType)aisle adc:(NSInteger)adc algorithmId:(NSInteger)algorithmId {
  308. if (state == HeightBodyFatScale_AdcStateType_Over) {
  309. NSLog(@"adc: %@", @(adc));
  310. NSLog(@"algorithmId: %@", @(algorithmId));
  311. }
  312. }
  313. ///MCU上报心率数据
  314. - (void)heightBodyFatScaleManagerReportHeartRateDataWithState:(HeightBodyFatScale_HeartRateStateType)state bpm:(NSInteger)bpm {
  315. if (state == HeightBodyFatScale_HeartRateStateType_Success) {
  316. NSLog(@"HeartRate bpm: %@", @(bpm));
  317. }
  318. }
  319. ///MCU上报温度数据
  320. - (void)heightBodyFatScaleManagerReportTemDataWithNegative:(BOOL)negative tem:(NSInteger)tem point:(NSInteger)point unit:(ELDeviceTemperatureUnit)unit {
  321. NSLog(@"negative: %@", @(negative));
  322. NSLog(@"tem: %@", @(tem));
  323. NSLog(@"point: %@", @(point));
  324. NSLog(@"unit: %@", @(unit));
  325. }
  326. ///MCU上报身高数据
  327. - (void)heightBodyFatScaleManagerReportHeightDataWithHeight:(NSInteger)height unit:(ELDeviceHeightUnit)unit point:(NSInteger)point {
  328. NSString *unitString = AiLinkBleHeightUnitDic[@(unit)];
  329. NSString *dataString = [self.class getHeightStringWithHeight:height unit:unit point:point];
  330. self.heightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  331. NSLog(@"height: %@", @(height));
  332. NSLog(@"unit: %@", @(unit));
  333. NSLog(@"point: %@", @(point));
  334. }
  335. /// MCU上报体脂数据
  336. - (void)heightBodyFatScaleManagerReportBodyFatDataWithDataModel:(ELHeightBodyFatScaleBleWeightBodyModel *)model {
  337. NSLog(@"model: %@", model);
  338. self.reportValueLabel.text = [NSString stringWithFormat:@"%@", model];
  339. }
  340. #pragma mark 抱婴模式
  341. - (void)heightBodyFatScaleManagerReportBabyModetWithWeighingState:(HeightBodyFatScale_WeightStableType)stable adultWeight:(NSInteger)adultWeight allWeight:(NSInteger)allWeight babyWeight:(NSInteger)babyWeight point:(NSInteger)point unit:(ELDeviceWeightUnit)unit {
  342. NSLog(@"workMode: HeightBodyFatScale_WorkModeType_BabyMode");
  343. // self.workMode = HeightBodyFatScale_WorkModeType_BabyMode;
  344. // [self uiSetWorkMode:self.workMode];
  345. NSLog(@"stable: %@", @(stable));
  346. NSLog(@"unit: %@", @(unit));
  347. NSLog(@"point: %@", @(point));
  348. NSString *unitString = AiLinkBleWeightUnitDic[@(unit)];
  349. if (babyWeight > 0) {
  350. NSLog(@"babyWeight: %@", @(babyWeight));
  351. NSString *dataString = [self.class getWeightStringWithWeight:babyWeight unit:unit point:point];
  352. self.babyWeightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  353. } else if (allWeight > 0) {
  354. NSLog(@"allWeight: %@", @(allWeight));
  355. NSString *dataString = [self.class getWeightStringWithWeight:allWeight unit:unit point:point];
  356. self.babyAdultWeightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  357. } else {
  358. NSLog(@"adultWeight: %@", @(adultWeight));
  359. NSString *dataString = [self.class getWeightStringWithWeight:adultWeight unit:unit point:point];
  360. self.adultWeightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  361. }
  362. if (self.babyModeIndex == 0) {
  363. NSLog(@"course_adult, 正在测量成人体重…");
  364. } else if (self.babyModeIndex == 1) {
  365. NSLog(@"course_withbaby, 请抱着宝宝重新上秤…");
  366. }
  367. if (stable == HeightBodyFatScale_WeightStableType_Stable) {
  368. if (self.babyModeIndex == 0) {
  369. self.babyModeIndex = 1;
  370. NSLog(@"course_withbaby, 请抱着宝宝重新上秤…");
  371. }
  372. }
  373. if (stable == HeightBodyFatScale_WeightStableType_Stable && babyWeight > 0) {
  374. // TODO: save data (babyWeight unit:unit point:point)
  375. }
  376. }
  377. #pragma mark 体重模式
  378. - (void)heightBodyFatScaleManagerReportWeightModeWithWeighingState:(HeightBodyFatScale_WeightStableType)stable weightNumber:(NSInteger)weight point:(NSInteger)point unit:(ELDeviceWeightUnit)unit {
  379. NSString *unitString = AiLinkBleWeightUnitDic[@(unit)];
  380. NSString *dataString = [self.class getWeightStringWithWeight:weight unit:unit point:point];
  381. self.weightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  382. NSLog(@"workMode: HeightBodyFatScale_WorkModeType_WeightMode");
  383. // self.workMode = HeightBodyFatScale_WorkModeType_WeightMode;
  384. // [self uiSetWorkMode:self.workMode];
  385. NSLog(@"stable: %@", @(stable));
  386. NSLog(@"weight: %@", @(weight));
  387. NSLog(@"unit: %@", @(unit));
  388. NSLog(@"point: %@", @(point));
  389. if (stable == HeightBodyFatScale_WeightStableType_Stable) {
  390. // TODO: save data (weight unit:unit point:point)
  391. }
  392. }
  393. #pragma mark 体重身高模式
  394. //MCU上报体重数据
  395. - (void)heightBodyFatScaleManagerReportWeightHeightModeWithWeighingState:(HeightBodyFatScale_WeightStableType)stable weightNumber:(NSInteger)weight point:(NSInteger)point unit:(ELDeviceWeightUnit)unit {
  396. NSString *unitString = AiLinkBleWeightUnitDic[@(unit)];
  397. NSString *dataString = [self.class getWeightStringWithWeight:weight unit:unit point:point];
  398. self.weightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  399. NSLog(@"workMode: HeightBodyFatScale_WorkModeType_WeightHeightMode");
  400. // self.workMode = HeightBodyFatScale_WorkModeType_WeightHeightMode;
  401. // [self uiSetWorkMode:self.workMode];
  402. NSLog(@"stable: %@", @(stable));
  403. NSLog(@"weight: %@", @(weight));
  404. NSLog(@"unit: %@", @(unit));
  405. NSLog(@"point: %@", @(point));
  406. if (stable == HeightBodyFatScale_WeightStableType_Stable) {
  407. // TODO: save data (weight unit:unit point:point)
  408. }
  409. }
  410. //MCU上报身高数据
  411. - (void)heightBodyFatScaleManagerReportWeightHeightMOdeWithHeightNumber:(NSInteger)height point:(NSInteger)point unit:(ELDeviceHeightUnit)unit {
  412. NSString *unitString = AiLinkBleHeightUnitDic[@(unit)];
  413. NSString *dataString = [self.class getHeightStringWithHeight:height unit:unit point:point];
  414. self.heightValueLabel.text = [NSString stringWithFormat:@"%@ %@", dataString, unitString];
  415. NSLog(@"workMode: HeightBodyFatScale_WorkModeType_WeightHeightMode");
  416. // self.workMode = HeightBodyFatScale_WorkModeType_WeightHeightMode;
  417. // [self uiSetWorkMode:self.workMode];
  418. NSLog(@"height: %@", @(height));
  419. NSLog(@"unit: %@", @(unit));
  420. NSLog(@"point: %@", @(point));
  421. }
  422. #pragma mark 测量完成
  423. - (void)heightBodyFatScaleManagerSendCompletedWithWorkMode:(HeightBodyFatScale_WorkModeType)type {
  424. NSLog(@"heightBodyFatScaleManagerSendCompletedWithWorkMode() WorkMode type: %@", @(type));
  425. }
  426. @end