Bluetooth RSSI / Request Checker on Mac - Detecting Proximity to iPhone Without Connectivity?

I often have to get away from the computer, and I want to run some commands to start when my iPhone is close enough / far enough away from my iMac (next to it or 2-3 meters from the other side of the wall). A delay of a couple of minutes is wonderful.


Partial Solution: Proximity

I downloaded reduxcomputing-proximity , and it works, but it only works when the device goes into / out of the Bluetooth range, but my desired range is much smaller.

(Proxy polls [IOBluetoothDevice -remoteNameRequest]to find out if the device is in the Bluetooth range or not.)

Enhancement: rawRSSI

I used [IOBluetoothDevice -rawRSSI]to get RSSI when I'm connected to the iPhone (when disconnected, it just returns +127), but to save the battery life of my iPhone , I would rather avoid having to establish a full Bluetooth connection .

Do I believe that maintaining a connection will consume more battery life than just polling every couple of minutes?

I redefined the method isInRange proximityhere to give me a working solution, which is probably relatively intense compared to the previous method remoteNameRequest::

- (BOOL)isInRange {
    BluetoothHCIRSSIValue RSSI = 127; /* Valid Range: -127 to +20 */
    if (device) {
        if (![device isConnected]) {
            [device openConnection];
        }
        if ([device isConnected]) {
            RSSI = [device rawRSSI];
            [device closeConnection];
        }
    }
    return (RSSI >= -60 && RSSI <= 20);
}

(Proximity uses synchronous calls - if and when I approach my needs, I will edit it as asynchronous, but at the moment this is not important.)


On Linux: l2ping - scan request?

SO RSSI " " , , , Linux Bluez, Mac - , , ! ( USB- Bluetooth... !)

, IOBluetoothDeviceInquiry, , . Bluetooth !


, Apple Scripts, ,

:

tell application "Skype"
    send command "SET USERSTATUS ONLINE" script name "X"
    do shell script "afplay '/System/Library/Sounds/Blow.aiff'"
end tell

:

tell application "Skype"
    send command "SET USERSTATUS AWAY" script name "X"
    do shell script "afplay '/System/Library/Sounds/Basso.aiff'"
end tell

, , !

+5
2

, / RSSI . ( 2,56 ) , . RSSI ( , - rssi , )

+1

, . , API- Mac OS, RSSI . BT Mac OS PacketLogger. . Bluetooth - mac osx

, RSSI. WireShark, , RSSI.

- , , , RSSI, .

+1

All Articles