|
|
|
@ -37,6 +37,9 @@ NSString *FLT_BLE_RCSP_R = @"AE02"; //命令“读”通道 |
|
|
|
|
|
|
|
@property (strong, nonatomic) GET_DEVICE_CALLBACK getCallback; |
|
|
|
|
|
|
|
@property (strong, nonatomic) NSString *lastAddress; |
|
|
|
@property (strong, nonatomic) NSString *lastFilePath; |
|
|
|
|
|
|
|
|
|
|
|
@end |
|
|
|
|
|
|
|
@ -83,8 +86,10 @@ NSString *FLT_BLE_RCSP_R = @"AE02"; //命令“读”通道 |
|
|
|
#pragma mark - 扫描设备相关 |
|
|
|
|
|
|
|
#pragma mark 开始扫描 |
|
|
|
- (void)startScanBLE { |
|
|
|
- (void)startScanBLE:(NSString * _Nullable)address filePath:(NSString * _Nullable)filePath { |
|
|
|
kJLLog(JLLOG_DEBUG, @"BLE ---> startScanBLE."); |
|
|
|
self.lastAddress = address; |
|
|
|
self.lastFilePath = filePath; |
|
|
|
_blePeripheralArr = [NSMutableArray new]; |
|
|
|
if (_bleManager) { |
|
|
|
if (_bleManager.state == CBManagerStatePoweredOn) { |
|
|
|
@ -135,7 +140,7 @@ NSString *FLT_BLE_RCSP_R = @"AE02"; //命令“读”通道 |
|
|
|
|
|
|
|
- (void)connectPeripheralWithUUID:(NSString*)uuid { |
|
|
|
_connectByUUID = uuid; |
|
|
|
[self startScanBLE]; |
|
|
|
[self startScanBLE:self.lastAddress filePath:self.lastFilePath]; |
|
|
|
} |
|
|
|
|
|
|
|
-(void)findHid:(NSString *)uuid{ |
|
|
|
@ -198,12 +203,11 @@ NSString *FLT_BLE_RCSP_R = @"AE02"; //命令“读”通道 |
|
|
|
|
|
|
|
NSString *ble_name = advertisementData[@"kCBAdvDataLocalName"]; |
|
|
|
NSData *ble_AD = advertisementData[@"kCBAdvDataManufacturerData"]; |
|
|
|
NSDictionary *info = [JLAdvParse bluetoothAdvParse:self.pairKey AdvData:advertisementData]; |
|
|
|
if (ble_name.length == 0) return; |
|
|
|
|
|
|
|
kJLLog(JLLOG_DEBUG, @"发现 ----> NAME:%@ RSSI:%@ AD:%@", ble_name,RSSI,ble_AD); |
|
|
|
|
|
|
|
[self addPeripheral:peripheral RSSI:RSSI Name:ble_name Info:info]; |
|
|
|
[self addPeripheral:peripheral RSSI:RSSI Name:ble_name Info:ble_AD]; |
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:kFLT_BLE_FOUND object:_blePeripheralArr userInfo:nil]; |
|
|
|
|
|
|
|
@ -213,11 +217,11 @@ NSString *FLT_BLE_RCSP_R = @"AE02"; //命令“读”通道 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
- (void)addPeripheral:(CBPeripheral*)peripheral RSSI:(NSNumber *)rssi Name:(NSString*)name Info:(NSDictionary*)info{ |
|
|
|
if ([name isEqualToString:@"DeapSound"]) { |
|
|
|
[self stopScanBLE]; |
|
|
|
[self connectBLE:peripheral]; |
|
|
|
} |
|
|
|
- (void)addPeripheral:(CBPeripheral*)peripheral RSSI:(NSNumber *)rssi Name:(NSString*)name Info:(NSData*)blead{ |
|
|
|
// if ([name isEqualToString:@"DeapSound"]) { |
|
|
|
// [self stopScanBLE]; |
|
|
|
// [self connectBLE:peripheral]; |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
#pragma mark 设备连接回调 |
|
|
|
|