1. Query done by Rpi
2. Query done by Android App
I have not yet checked on how I can get the first step done programmatic-ally, for the purpose of integrating it into our Server program. This example showed how it is done via terminal : forum link.
However, I have a written a simple app for the 2nd method. This App catches the RSSI values of every bluetooth devices it found during 'discovery' by requesting an extra field in ACTION_FOUND intents of the discovery : EXTRA_RSSI. This value (of data type Short) contains the RSSI value of the remote devices found.
Here is the snippet on how it is done:
// Create a BroadcastReceiver for ACTION_FOUND
BroadcastReceiver receiver;
receiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
// Add the name and address to an array adapter to show in a ListView
mArrayAdapter.add(device.getName() + "\n" + device.getAddress() + "\n" + rssi + " db" + "\n" );
//add notify discovery is done
Toast.makeText(getApplicationContext(),"Bluetooth devices discovery done...", Toast.LENGTH_SHORT).show();
}
}
};
In short, we can get the signal strength of any discovered bluetooth devices, without even having to connect to those devices. Hence, 'signal strength' or more correctly, 'distance between the user and the door' verification can be done first before 'key' verification. Refer HERE to see the methods we proposed earlier.
Here is the updated version of the App (remove the RSSI values display through toast, put them into the list view instead).
Downloads:
ApkMainActivity (main code)
Project files (all)
No comments:
Post a Comment
Write a reply