BLE Peripheral设备的名字显示错误
来源:互联网 发布:ubuntu 14无法解析域名 编辑:程序博客网 时间:2024/04/27 22:22
在IOS BLE开发中碰到一个搜索到的设备名称(pheripheral.name)和设备实际名称不相符的问题。
最后发现这个问题的原因是,在iPhone中,被连接过的BLE设备名称都会被缓存。如果你在连接过一次某设备后,更改了该设备的名字。那么在你的iphone BLE cache数据清除之前,你无论多少次搜索这个设备,都会是旧的名字。比如你有个设备的初始名字是F5000,你用iphone连接过一次后,如果把设备名字再改成FA01Y,那么当你再次用iphone搜索设备时,你永远搜到的都是F5000而不是该设备的新名称FA01Y。
目前有两个解决办法:
1. 清除你iphone的BLE cache。
2. 另一个更简单的办法是,通过任何一款BLE测试软件连接该设备。或者通过设备的旧名称来连接一次设备。当设备被你再次连接过后,本地cache中该设备的BLE名字会更新。之后你搜到该设备就会显示它的新名字了。
以下是我碰到的问题实例。
先看代码:
@property (strong, nonatomic) CBCentralManager *manager;
@property NSString *deviceName;
self.manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
self.deviceName = @"FA01Y";
[self.manager scanForPeripheralsWithServices:nil options:nil];
-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *,id> *)advertisementData RSSI:(NSNumber *)RSSI{
NSLog(@"Found Device: %@", peripheral.name);
if ([peripheral.name isEqualToString:self.deviceName]) {
[self.manager stopScan];
self.selectedDevice = peripheral;
self.selectedDevice.delegate = self;
[self.manager connectPeripheral:peripheral options:nil];
}
}
-(void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral{
NSLog(@"Connected device: %@", peripheral.name);
[self.selectedDevice discoverServices:nil];
}
我有一个BLE设备作为Peripheral,它的初始名字是:F5000。之后我把名字设置为了:FA01Y。我想要通过以上代码,来通过这个FA01Y新名字来连接设备,但是失败了。
原因是:程序没有搜索到FA01Y设备,而是只搜索到一个名字叫做“F5000”的设备:
2015-12-30 14:28:18.345 PainKARE1.0[10017:1824607] Found Device: F5000
2015-12-30 14:28:18.425 PainKARE1.0[10017:1824607] Found device: F5000
- BLE Peripheral设备的名字显示错误
- 【BLE】peripheral设备如何获取central设备的PublicAddr
- [BLE] CC2541 BLE Peripheral工程的建立
- CC2541 BLE Peripheral工程的建立
- 【TL8266】显示BLE设备列表
- Android BLE开发: BLE Peripheral开发流程
- 获得设备的名字
- BLE的设备各种状态
- android5.0(Lollipop) BLE Peripheral牛刀小试
- BLE in Linux : Set a Simple Peripheral
- BLE工作模式: Central+Peripheral(Advertising+Connected)
- CC2540 BLE peripheral 主动断开连接
- 蓝牙4.0 BLE peripheral 广播设置
- NPC名字的显示
- BLE常见的一些错误
- S3连接ble设备的一个问题
- 医疗设备BLE蓝牙开发的总结。
- android蓝牙-isMultipleAdvertisementSupported(API21)判断支持不支持BLE Peripheral
- 通过httpclient和urlconnection下载网络文件
- ALUA,AA,多路径
- SpringMVC配置
- tableview footer and header 取消粘稠效果
- jQuery插件的写法以及使用
- BLE Peripheral设备的名字显示错误
- 代码规范性思考
- 我的信息系统项目管理师之路
- 图书管理系统_jdbc连接下基于servlet的最原始的javaWeb项目
- ALV动态列内表实现Demo
- Android 开发最佳实践
- Myeclipse8.5 反编译插件 jad 安装
- Linux下动态共享库加载时的搜索路径详解
- mxnet实战之艺术画