RSSI测试器
更新时间:2017-08-08 阅读:2345
设备扫描
扫描开启指定服务的设备,以便于连接到自己的设备.
[centralManager scanForPeripheralsWithServices: @[[CBUUID UUIDWithString:BATTERY_SERVICE_UUID],[CBUUID UUIDWithString:IMALERT_SERVICE_UUID] ,[CBUUID UUIDWithString:INTERACTION_SERVICE_UUID],[CBUUID UUIDWithString:OTA_SERVICE_UUID]] options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }];
也可以扫描所有的设备:
[centralManager scanForPeripheralsWithServices:nil options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }];
连接设备
[centralManager connectPeripheral:peripheral options:nil];
获取RSSI值
[_blePeripheral.discoveredPeripheral readRSSI];
调用函数readRSSI后,读到的值会直接赋值到参数RSSI中.