/* Begin PBXBuildFile section */ | /* Begin PBXBuildFile section */ | ||||
952D19A1276DE80000ED3A0C /* AILinkBleSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 952D19A0276DE80000ED3A0C /* AILinkBleSDK.framework */; }; | 952D19A1276DE80000ED3A0C /* AILinkBleSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 952D19A0276DE80000ED3A0C /* AILinkBleSDK.framework */; }; | ||||
95565B792786EA3B000265EA /* SkipConnectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 95565B752786EA3B000265EA /* SkipConnectionViewController.m */; }; | |||||
95565B7A2786EA3B000265EA /* SkipScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 95565B782786EA3B000265EA /* SkipScanViewController.m */; }; | |||||
95572623276C38CD003BFBAC /* BloodConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 955725BC276C38CC003BFBAC /* BloodConnectViewController.m */; }; | 95572623276C38CD003BFBAC /* BloodConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 955725BC276C38CC003BFBAC /* BloodConnectViewController.m */; }; | ||||
95572624276C38CD003BFBAC /* BloodScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 955725BD276C38CC003BFBAC /* BloodScanViewController.m */; }; | 95572624276C38CD003BFBAC /* BloodScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 955725BD276C38CC003BFBAC /* BloodScanViewController.m */; }; | ||||
95572625276C38CD003BFBAC /* AiFreshNutritionScaleScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 955725C0276C38CC003BFBAC /* AiFreshNutritionScaleScanViewController.m */; }; | 95572625276C38CD003BFBAC /* AiFreshNutritionScaleScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 955725C0276C38CC003BFBAC /* AiFreshNutritionScaleScanViewController.m */; }; | ||||
/* Begin PBXFileReference section */ | /* Begin PBXFileReference section */ | ||||
952D19A0276DE80000ED3A0C /* AILinkBleSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AILinkBleSDK.framework; sourceTree = "<group>"; }; | 952D19A0276DE80000ED3A0C /* AILinkBleSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AILinkBleSDK.framework; sourceTree = "<group>"; }; | ||||
95565B752786EA3B000265EA /* SkipConnectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SkipConnectionViewController.m; sourceTree = "<group>"; }; | |||||
95565B762786EA3B000265EA /* SkipScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkipScanViewController.h; sourceTree = "<group>"; }; | |||||
95565B772786EA3B000265EA /* SkipConnectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkipConnectionViewController.h; sourceTree = "<group>"; }; | |||||
95565B782786EA3B000265EA /* SkipScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SkipScanViewController.m; sourceTree = "<group>"; }; | |||||
955725BB276C38CC003BFBAC /* BloodScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BloodScanViewController.h; sourceTree = "<group>"; }; | 955725BB276C38CC003BFBAC /* BloodScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BloodScanViewController.h; sourceTree = "<group>"; }; | ||||
955725BC276C38CC003BFBAC /* BloodConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BloodConnectViewController.m; sourceTree = "<group>"; }; | 955725BC276C38CC003BFBAC /* BloodConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BloodConnectViewController.m; sourceTree = "<group>"; }; | ||||
955725BD276C38CC003BFBAC /* BloodScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BloodScanViewController.m; sourceTree = "<group>"; }; | 955725BD276C38CC003BFBAC /* BloodScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BloodScanViewController.m; sourceTree = "<group>"; }; | ||||
name = SDK; | name = SDK; | ||||
sourceTree = "<group>"; | sourceTree = "<group>"; | ||||
}; | }; | ||||
95565B742786EA3B000265EA /* 24_Skip */ = { | |||||
isa = PBXGroup; | |||||
children = ( | |||||
95565B752786EA3B000265EA /* SkipConnectionViewController.m */, | |||||
95565B762786EA3B000265EA /* SkipScanViewController.h */, | |||||
95565B772786EA3B000265EA /* SkipConnectionViewController.h */, | |||||
95565B782786EA3B000265EA /* SkipScanViewController.m */, | |||||
); | |||||
path = 24_Skip; | |||||
sourceTree = "<group>"; | |||||
}; | |||||
955725BA276C38CC003BFBAC /* 05_BloodPressure */ = { | 955725BA276C38CC003BFBAC /* 05_BloodPressure */ = { | ||||
isa = PBXGroup; | isa = PBXGroup; | ||||
children = ( | children = ( | ||||
955725EF276C38CC003BFBAC /* 21_NutritionScale */, | 955725EF276C38CC003BFBAC /* 21_NutritionScale */, | ||||
955725BF276C38CC003BFBAC /* 22_AiFreshNutritionScale */, | 955725BF276C38CC003BFBAC /* 22_AiFreshNutritionScale */, | ||||
955725F4276C38CD003BFBAC /* 23_FaceMask */, | 955725F4276C38CD003BFBAC /* 23_FaceMask */, | ||||
95565B742786EA3B000265EA /* 24_Skip */, | |||||
958B4E74263C08E700476BAE /* Others */, | 958B4E74263C08E700476BAE /* Others */, | ||||
958B4E67263C08E700476BAE /* Tools */, | 958B4E67263C08E700476BAE /* Tools */, | ||||
E622E26A243F1CA6003C319D /* Assets.xcassets */, | E622E26A243F1CA6003C319D /* Assets.xcassets */, | ||||
buildActionMask = 2147483647; | buildActionMask = 2147483647; | ||||
files = ( | files = ( | ||||
9557264A276C38CD003BFBAC /* ToothbrushConnectionViewController.m in Sources */, | 9557264A276C38CD003BFBAC /* ToothbrushConnectionViewController.m in Sources */, | ||||
95565B7A2786EA3B000265EA /* SkipScanViewController.m in Sources */, | |||||
9557263B276C38CD003BFBAC /* FaceMaskScanViewController.m in Sources */, | 9557263B276C38CD003BFBAC /* FaceMaskScanViewController.m in Sources */, | ||||
9557263F276C38CD003BFBAC /* EightScaleConnectionViewController.m in Sources */, | 9557263F276C38CD003BFBAC /* EightScaleConnectionViewController.m in Sources */, | ||||
9557262B276C38CD003BFBAC /* WheelMonitorScanViewController.m in Sources */, | 9557262B276C38CD003BFBAC /* WheelMonitorScanViewController.m in Sources */, | ||||
95572633276C38CD003BFBAC /* BabyScaleConnectViewController.m in Sources */, | 95572633276C38CD003BFBAC /* BabyScaleConnectViewController.m in Sources */, | ||||
95572644276C38CD003BFBAC /* BodyFatScaleConnectViewController.m in Sources */, | 95572644276C38CD003BFBAC /* BodyFatScaleConnectViewController.m in Sources */, | ||||
958B4EBD263C08E800476BAE /* AppDelegate.m in Sources */, | 958B4EBD263C08E800476BAE /* AppDelegate.m in Sources */, | ||||
95565B792786EA3B000265EA /* SkipConnectionViewController.m in Sources */, | |||||
958B4EAE263C08E800476BAE /* ViewController+MASAdditions.m in Sources */, | 958B4EAE263C08E800476BAE /* ViewController+MASAdditions.m in Sources */, | ||||
958B4EA8263C08E800476BAE /* CABasicAnimation+ELAnimation.m in Sources */, | 958B4EA8263C08E800476BAE /* CABasicAnimation+ELAnimation.m in Sources */, | ||||
9557263D276C38CD003BFBAC /* ThermometerConnectViewController.m in Sources */, | 9557263D276C38CD003BFBAC /* ThermometerConnectViewController.m in Sources */, |
// | |||||
// FaceMaskConnectionViewController.h | |||||
// AILinkBleSDKSourceCode | |||||
// | |||||
// Created by LarryZhang on 2021/12/13. | |||||
// Copyright © 2021 IOT. All rights reserved. | |||||
// | |||||
#import <UIKit/UIKit.h> | |||||
@class ELPeripheralModel; | |||||
NS_ASSUME_NONNULL_BEGIN | |||||
@interface SkipConnectionViewController : UIViewController | |||||
@property (nonatomic, strong) ELPeripheralModel *p; | |||||
@end | |||||
NS_ASSUME_NONNULL_END |
// | |||||
// FaceMaskConnectionViewController.m | |||||
// AILinkBleSDKSourceCode | |||||
// | |||||
// Created by LarryZhang on 2021/12/13. | |||||
// Copyright © 2021 IOT. All rights reserved. | |||||
// | |||||
#import "SkipConnectionViewController.h" | |||||
#import "Masonry.h" | |||||
#import <AILinkBleSDK/ELSkipBleDataModel.h> | |||||
#import <AILinkBleSDK/ELSkipBleManager.h> | |||||
@interface SkipConnectionViewController () <ELSkipBleDelegate, ELBluetoothManagerDelegate> | |||||
@property(nonatomic, strong) UITextView *textView; | |||||
@property(nonatomic, copy) NSArray<NSNumber *> *units; | |||||
@property(nonatomic, strong) UIButton *connectButton; | |||||
@end | |||||
@implementation SkipConnectionViewController | |||||
- (void)viewDidLoad { | |||||
[super viewDidLoad]; | |||||
// Do any additional setup after loading the view. | |||||
self.view.backgroundColor = [UIColor whiteColor]; | |||||
[ELSkipBleManager shareManager].skipDelegate = self; | |||||
[ELSkipBleManager shareManager].delegate = self; | |||||
[[ELSkipBleManager shareManager] connectPeripheral:self.p]; | |||||
[self setupUIView]; | |||||
} | |||||
- (void)viewWillDisappear:(BOOL)animated { | |||||
[[ELSkipBleManager shareManager] disconnectPeripheral]; | |||||
} | |||||
- (void)addLog:(NSString *)log { | |||||
self.textView.text = [NSString stringWithFormat:@"%@\n\n%@", log, self.textView.text]; | |||||
} | |||||
//- (void)connectDevice { | |||||
// [[ELSkipBleManager shareManager] startScan]; | |||||
//} | |||||
- (void)setupUIView { | |||||
// self.connectButton = [[UIButton alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 100) / 2, 88, 100, 40)]; | |||||
// [self.connectButton setTitle:@"点击重连" forState:UIControlStateNormal]; | |||||
// [self.connectButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | |||||
// [self.view addSubview:self.connectButton]; | |||||
// [self.connectButton addTarget:self action:@selector(connectDevice) forControlEvents:UIControlEventTouchUpInside]; | |||||
// self.connectButton.hidden = YES; | |||||
self.textView = [[UITextView alloc] init]; | |||||
self.textView.backgroundColor = [UIColor blackColor]; | |||||
self.textView.text = @"Log"; | |||||
self.textView.textColor = [UIColor redColor]; | |||||
[self.view addSubview:self.textView]; | |||||
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
make.left.mas_equalTo(10); | |||||
make.right.mas_equalTo(-10); | |||||
make.bottom.offset(-44); | |||||
// make.height.mas_equalTo(350); | |||||
make.top.offset(80); | |||||
}]; | |||||
} | |||||
#pragma mark - ble Delegate | |||||
//- (void)skipManagerScanDevices:(nonnull NSArray<ELPeripheralModel *> *)scanDevices { | |||||
// //reconnect | |||||
//} | |||||
/// 蓝牙连接状态 | |||||
/// @param state 连接状态 | |||||
- (void)skipManagerUpdateState:(ELBluetoothState)state { | |||||
switch (state) { | |||||
case ELBluetoothStateUnavailable: { | |||||
self.title = @"Please open the bluetooth"; | |||||
} | |||||
break; | |||||
case ELBluetoothStateAvailable: { | |||||
self.title = @"Bluetooth is open"; | |||||
} | |||||
break; | |||||
case ELBluetoothStateScaning: { | |||||
self.title = @"Scanning"; | |||||
} | |||||
break; | |||||
case ELBluetoothStateConnectFail: { | |||||
self.title = @"Connect fail"; | |||||
} | |||||
break; | |||||
case ELBluetoothStateDidDisconnect: { | |||||
self.title = @"Disconnected"; | |||||
self.connectButton.hidden = NO; | |||||
} | |||||
break; | |||||
case ELBluetoothStateDidValidationPass: { | |||||
self.connectButton.hidden = YES; | |||||
self.title = @"Connected"; | |||||
//获取版本号 | |||||
[[ELSkipBleManager shareManager] getBluetoothInfoWithELInetGetCmdType:ELInetGetCmdTypeGetBMVersion]; | |||||
//发送绑定命令(如果设备不支持绑定确认,也可以不发) | |||||
[[ELSkipBleManager shareManager] bindDeviceWithType:Skip_BindDeviceType_KeyBinding]; | |||||
//弹出提示框 | |||||
//[self showPopupView]; | |||||
} | |||||
break; | |||||
case ELBluetoothStateFailedValidation: { | |||||
self.title = @"Illegal equipment"; | |||||
} | |||||
break; | |||||
case ELBluetoothStateWillConnect: | |||||
self.title = @"Connecting"; | |||||
break; | |||||
case ELBluetoothStateUnauthorized: | |||||
self.title = @"BLE Unauthorized"; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
//返回绑定结果 | |||||
- (void)skipManagerResult:(enum Skip_ResultType)result bleHeaderType:(enum Skip_BleHeadType)type { | |||||
if (type == Skip_BleHeadType_BindDevice) { | |||||
if (result == Skip_ResultType_Success) { | |||||
[self addLog:@"绑定成功"]; | |||||
//通过验证,同步设备时间 | |||||
[[ELSkipBleManager shareManager] syncDevTimeStamp:[[NSDate date] timeIntervalSince1970]]; | |||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | |||||
//获取离线历史记录 | |||||
[[ELSkipBleManager shareManager] getOfflineHistory]; | |||||
}); | |||||
} else { | |||||
[self addLog:@"绑定失败"]; | |||||
} | |||||
} | |||||
} | |||||
//返回版本号 | |||||
- (void)bluetoothManagerReceiveBMVersion:(NSString *)bmVersion { | |||||
[self addLog:[NSString stringWithFormat:@"ble version:%@", bmVersion]]; | |||||
} | |||||
- (void)skipManagerRealtimeDataWithState:(enum Skip_ReadyStateType)readyState skipModel:(nonnull ELSkipBleDataModel *)model power:(NSUInteger)power { | |||||
[self addLog:[NSString stringWithFormat:@"skip state:%zd num:%zd",readyState, model.sportNum]]; | |||||
} | |||||
- (void)skipManagerReportOfflineHistoryWithHistoryModelList:(nonnull NSArray<ELSkipHistoryDataModel *> *)modelList { | |||||
[self addLog:[NSString stringWithFormat:@"skip history num:%zd",modelList.count]]; | |||||
} | |||||
- (void)skipManagerSportEndReportDataWithHistoryModel:(nonnull ELSkipHistoryDataModel *)model { | |||||
[self addLog:[NSString stringWithFormat:@"skip end, result:%zd",model.dataModel.sportNum]]; | |||||
} | |||||
@end |
// | |||||
// FaceMaskScanViewController.h | |||||
// AILinkBleSDKSourceCode | |||||
// | |||||
// Created by LarryZhang on 2021/12/13. | |||||
// Copyright © 2021 IOT. All rights reserved. | |||||
// | |||||
#import <UIKit/UIKit.h> | |||||
NS_ASSUME_NONNULL_BEGIN | |||||
@interface SkipScanViewController : UIViewController | |||||
@end | |||||
NS_ASSUME_NONNULL_END |
// | |||||
// FaceMaskScanViewController.m | |||||
// AILinkBleSDKSourceCode | |||||
// | |||||
// Created by LarryZhang on 2021/12/13. | |||||
// Copyright © 2021 IOT. All rights reserved. | |||||
// | |||||
#import "SkipScanViewController.h" | |||||
#import <AILinkBleSDK/ELSkipBleManager.h> | |||||
#import "Masonry.h" | |||||
#import "SkipConnectionViewController.h" | |||||
@interface SkipScanViewController () <UITableViewDelegate, UITableViewDataSource, ELSkipBleDelegate> | |||||
@property(nonatomic, strong) UITableView *tableView; | |||||
@property(nonatomic, strong) NSArray<ELPeripheralModel *> *devices; | |||||
@end | |||||
@implementation SkipScanViewController | |||||
- (void)viewDidLoad { | |||||
[super viewDidLoad]; | |||||
// Do any additional setup after loading the view. | |||||
[self.view addSubview:self.tableView]; | |||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { | |||||
make.top.left.right.bottom.mas_equalTo(0); | |||||
}]; | |||||
} | |||||
- (void)viewWillAppear:(BOOL)animated { | |||||
[[ELSkipBleManager shareManager] startScan]; | |||||
[ELSkipBleManager shareManager].skipDelegate = self; | |||||
} | |||||
- (void)viewWillDisappear:(BOOL)animated { | |||||
[[ELSkipBleManager shareManager] stopScan]; | |||||
} | |||||
#pragma mark - BloodSugarBleDelegate | |||||
- (void)skipManagerUpdateState:(ELBluetoothState)state { | |||||
NSLog(@"---ble state:%ld",state); | |||||
} | |||||
- (void)skipManagerScanDevices:(NSArray<ELPeripheralModel *> *)scanDevices { | |||||
self.devices = scanDevices; | |||||
[self.tableView reloadData]; | |||||
} | |||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | |||||
return self.devices.count; | |||||
} | |||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { | |||||
return 60; | |||||
} | |||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |||||
static NSString *cellId = @"cellid"; | |||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; | |||||
if (!cell) { | |||||
cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; | |||||
} | |||||
ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
cell.textLabel.text = [NSString stringWithFormat:@"Name:%@---Mac:%@\nCID:%ld---VID:%ld---PID:%ld", p.deviceName, p.macAddress, p.deviceType, p.vendorID, p.productID]; | |||||
cell.textLabel.numberOfLines = 2; | |||||
cell.textLabel.textColor = [UIColor blackColor]; | |||||
return cell; | |||||
} | |||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | |||||
ELPeripheralModel *p = self.devices[indexPath.row]; | |||||
SkipConnectionViewController *vc = [[SkipConnectionViewController alloc] init]; | |||||
vc.p = p; | |||||
[self.navigationController pushViewController:vc animated:YES]; | |||||
} | |||||
- (UITableView *)tableView { | |||||
if (_tableView == nil) { | |||||
_tableView = [[UITableView alloc] init]; | |||||
_tableView.delegate = self; | |||||
_tableView.dataSource = self; | |||||
} | |||||
return _tableView; | |||||
} | |||||
@end |
#import "NutritionScaleScanViewController.h" | #import "NutritionScaleScanViewController.h" | ||||
#import "AiFreshNutritionScaleScanViewController.h" | #import "AiFreshNutritionScaleScanViewController.h" | ||||
#import "FaceMaskScanViewController.h" | #import "FaceMaskScanViewController.h" | ||||
#import "SkipScanViewController.h" | |||||
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource> | @interface ViewController ()<UITableViewDelegate,UITableViewDataSource> | ||||
@"21_NutritionScale(连接营养秤)", | @"21_NutritionScale(连接营养秤)", | ||||
@"22_AiFreshNutritionScale(好营养营养秤)", | @"22_AiFreshNutritionScale(好营养营养秤)", | ||||
@"23_FaceMask(智能口罩)", | @"23_FaceMask(智能口罩)", | ||||
@"24_Skip(跳绳)", | |||||
]; | ]; | ||||
self.vcsArray = @[ | self.vcsArray = @[ | ||||
[[NutritionScaleScanViewController alloc] init], | [[NutritionScaleScanViewController alloc] init], | ||||
[[AiFreshNutritionScaleScanViewController alloc] init], | [[AiFreshNutritionScaleScanViewController alloc] init], | ||||
[[FaceMaskScanViewController alloc] init], | [[FaceMaskScanViewController alloc] init], | ||||
[[SkipScanViewController alloc] init] | |||||
]; | ]; | ||||
[self.view addSubview:self.tableView]; | [self.view addSubview:self.tableView]; |