RSSI に基づいて最も近い周辺機器のみに接続する方法を探しています。私の目標は、他の周辺機器をリストしたままにして、最も近い周辺機器のみを接続することです。
RSSI はデバイスが接続されている間のみ利用できるため、すべてのデバイスが接続されるまで待ってから、RSSI に基づいて最も近い周辺機器を決定し、残りを切断することは理にかなっていますか?
接続
- (void) connectToPeripheral:(CBPeripheral *)peripheral
{
NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE],CBConnectPeripheralOptionNotifyOnDisconnectionKey,nil];
[myCBCentralManager connectPeripheral:peripheral options:options];
}
使用されたデリゲート
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error;
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral;
CBペリフェラル
/*!
* @property RSSI
*
* @discussion While connected, the RSSI of the link in decibels.
*/
@property(retain, readonly) NSNumber *RSSI;