Skip to content

add RSSI to discoverUnpairedDevices() #473

@hawajrambo

Description

@hawajrambo

This patch adds the RSSI values to the discovered devices in Android.
//!TODO make the same in IOS.

cordova-plugin-bluetooth-classic-serial-port+1.1.0.patch

in brief:

if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE); // Extract the RSSI value from the intent
JSONObject o = deviceToJSON(device, (int) rssi);
.....
Integer RSSI_NOT_AVAILABLE = null;
private JSONObject deviceToJSON(BluetoothDevice device, Integer rssi) throws JSONException {
if (rssi != RSSI_NOT_AVAILABLE) json.put("rssi", rssi);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions