Bluetooth signal strength between iphone devices

前端 未结 1 1723
借酒劲吻你
借酒劲吻你 2021-01-01 04:08

I have two iphone deveices connected by bluetooth. Is it possible to get signal strength between those deveices? if possible,How? Thanks, K.D

1条回答
  •  春和景丽
    2021-01-01 04:54

    Take a look on Apple Sample Project for Transferring Data from One device to another via Bluetooth. BTLE Apple Sample Code

    You can find out the signal strength with the value of RSSI (Received signal strength indication)

    In sample code you will get RSSI value when data is received. Check the following method in BTLECentralViewController.m in Project:

    - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
    {
        // Reject any where the value is above reasonable range
        if (RSSI.integerValue > -15) {
            return;
        }
    
        // Reject if the signal strength is too low to be close enough (Close is around -22dB)
        if (RSSI.integerValue < -35) {
            return;
        }
    
        NSLog(@"Discovered %@ at %@", peripheral.name, RSSI);
    
        // Ok, it's in range - have we already seen it?
        if (self.discoveredPeripheral != peripheral) {
    
            // Save a local copy of the peripheral, so CoreBluetooth doesn't get rid of it
            self.discoveredPeripheral = peripheral;
    
            // And connect
            NSLog(@"Connecting to peripheral %@", peripheral);
            [self.centralManager connectPeripheral:peripheral options:nil];
        }
    }
    

    Each time when u received data from advertising by another device. You will receive a RSSI value from this u can find strength and Range of device.

    Also take a look on RSSI Details on Wiki

    I hope this will helps u.

    0 讨论(0)
提交回复
热议问题