ios中蓝牙自动连接出现硬件提示框的问题

ios中蓝牙自动连接出现硬件提示框的问题

出现如图所示情况,这时候有两种方法可以处理,一种是让硬件部修改硬件配对,另一种是程序里面测试该提示框的对应特征值,不要调用该特征值就不会出现

//2.扫描到Characteristics,特征回调

-(void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error{

for (CBCharacteristic *characteristic in service.characteristics)

{

_writePeripheral = peripheral;

//截取设备uuid6

NSString *UID2 =[UUIDSERVICE2 substringWithRange:NSMakeRange(4, 4)];

//转化为大写

NSString*UUIDString2 =[UID2 uppercaseString];

//获取当前密码状态

if ( [characteristic.UUID.UUIDString isEqualToString:UUIDString2]) {

_readCharacteristic =characteristic;

[peripheral setNotifyValue:YES forCharacteristic:characteristic];

}

//截取设备uuid6

NSString *UID6 =[UUIDSERVICE6 substringWithRange:NSMakeRange(4, 4)];

//转化为大写

NSString*UUIDString6 =[UID6 uppercaseString];

//截取设备uuid4

NSString *UID4 =[UUIDSERVICE4 substringWithRange:NSMakeRange(4, 4)];

//转化为大写

NSString*UUIDString4 =[UID4 uppercaseString];

//写入数据

if ( [characteristic.UUID.UUIDString isEqualToString:UUIDString6]) {

// 拿到特征,和外围设备进行交互   保存写的特征

_writeDataCharacteristic = characteristic;

[peripheral setNotifyValue:YES forCharacteristic:characteristic];

}

//获取当前状态

if ( [characteristic.UUID.UUIDString isEqualToString:UUIDString4]) {

_readCharacteristic =characteristic;

[peripheral setNotifyValue:YES forCharacteristic:characteristic];

}

}

}

在这里不要调用多余的特征值和提示框显示的特征值,

[peripheral readValueForCharacteristic:characteristic];这行代码要注意在特定的特征值里再调用,特征值外面别调用,不然问题就来了

上一篇:Java集合框架中底层文档的List与Set


下一篇:centos 7中监控mysql 数据库脚本(监控端口)