How does scanCallback work for BluetoothDevices? - android

I am following this tutorial. https://medium.com/#avigezerit/bluetooth-low-energy-on-android-22bc7310387a
Trying to understand LeScancallBacks
I am also following the documentation and the sample for Bluetooth devices from google
BluetoothAdapter.LeScanCallback scanCallback =
new BluetoothAdapter.LeScanCallback() {};
bluetoothAdapter.startLeScan(scanCallback);
#Override
public void onLeScan(final BluetoothDevice device, int rssi,
byte[] scanRecord) {
if(device.address == HR_SENSOR_ADDRESS){
myDevice = device;
}
}
My Code gives me the following error:
"Class 'Anonymous class derived from LeScanCallback' must either be
declared abstract or implement abstract method
'onLeScan(BluetoothDevice, int, byte[])' in 'LeScanCallback'"
When I compare it with the code from google.
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
#Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
broadcastUpdate(intentAction);
Log.i(TAG, "Connected to GATT server.");
// Attempts to discover services after successful connection.
Log.i(TAG, "Attempting to start service discovery:" +
mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
intentAction = ACTION_GATT_DISCONNECTED;
mConnectionState = STATE_DISCONNECTED;
Log.i(TAG, "Disconnected from GATT server.");
broadcastUpdate(intentAction);
}
}
This is the only other Callback I can find, is it possible that someone can help? I tried to program this project, alone for some time.

When you define that scanCallback object, you need to add in the required method like so:
BluetoothAdapter.LeScanCallback scanCallback = new BluetoothAdapter.LeScanCallback() {
#Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
//do stuff here
}
};
You can then handle the response in that onLeScan method.
In Java, an abstract class requires that any instantiation of it must implement the required methods, which is the error you were getting.

Related

Can't read Heart Rate in Xiaomi Band 2

I was trying to read Heart Rate values from my Xiaomi Band 2. For this I tried using and adapting BluetoothLeGatt project from https://github.com/android/connectivity-samples/tree/master/BluetoothLeGatt .
So far I was able to survey the BLE devices nearby. After that I selected Xiaomi Band 2 and I could successfully list out all the services this device had, including Heart Rate Service. Inside Heart Rate Service I found the characteristic Heart Rate Measurement that I was looking for.
I tried to print data from this characteristic without success. I was unable to see any data in my log, even though I made some slight changes.
This is my LEScanCallback (with the slight changes done)
// Implements callback methods for GATT events that the app cares about. For example,
// connection change and services discovered.
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
#Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
broadcastUpdate(intentAction);
Log.i(TAG, "Connected to GATT server.");
// Attempts to discover services after successful connection.
Log.i(TAG, "Attempting to start service discovery:" +
mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
intentAction = ACTION_GATT_DISCONNECTED;
mConnectionState = STATE_DISCONNECTED;
Log.i(TAG, "Disconnected from GATT server.");
broadcastUpdate(intentAction);
}
}
#Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
} else {
Log.w(TAG, "onServicesDiscovered received: " + status);
}
BluetoothGattCharacteristic characteristic =
gatt.getService(HEART_RATE_SERVICE_UUID)
.getCharacteristic(HEART_RATE_MEASUREMENT_CHAR_UUID);
System.out.println("HEART_RATE_MEASUREMENT_CHAR_UUID: "+HEART_RATE_MEASUREMENT_CHAR_UUID);
/*gatt.setCharacteristicNotification(characteristic, true);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_UUID);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
gatt.writeDescriptor(descriptor); */
setCharacteristicNotification(characteristic,true);
}
#Override
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,
int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
System.out.println("onCharacteristicRead: " + Arrays.toString(characteristic.getValue()));
}
#Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status){
super.onDescriptorWrite(gatt, descriptor, status);
System.out.println("onDescriptorWrite");
BluetoothGattCharacteristic characteristic = gatt.getService(HEART_RATE_SERVICE_UUID)
.getCharacteristic(HEART_RATE_MEASUREMENT_CHAR_UUID);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
characteristic.setValue(new byte[]{1, 1});
//gatt.writeCharacteristic(characteristic);
boolean success = gatt.readCharacteristic(characteristic);
System.out.println("success? "+success);
System.out.println("status: "+status);
}
#Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
System.out.println("onCharacteristicChanged: " + Arrays.toString(characteristic.getValue()));
}
};
I don't get to the point onCharacteristicRead() or onCharacteristicChanged() is called. I believe it's because gatt.readCharacteristic(characteristic) is FALSE and status is 3 (GATT_WRITE_NOT_PERMITTED) in onDescriptorWrite() function.
Can somebody help me figuring out the problem? I'm starting to lose all hope...

Garmin HRM Dual, not transmitting data over BLE

For some reason device does not transmit data (heart rate) over BLE. It connects fine, phone app is also able to discover services and connect to service.
I started up with iOS and Health app and actually saw some data coming through, so, it worked initially. Later, created the base for the BLE connectivity on Android app, it connected just fine, discovered the correct services and connected to these. And no data. Re-checked with iOS, also silence. Assuming that it is device'd problem (faulty sensors etc), took it to the shop I purchased it from. Tested it, worked like a charm with ANT+. So, it has to be BLE issue. The code itself is pretty much sample code from Android dev guides.
{
//0x180D - heart rate service
//0x2A37 - heart rate characteristic
private static HrmHandler instance;
private static UUID UUID_HRM_SERVICE = UUID.fromString("0000180d-0000-1000-8000-00805f9b34fb");
private static UUID UUID_HRM_CHARACTERISTIC = UUID.fromString("00002a37-0000-1000-8000-00805f9b34fb");
private static String LOG_TAG = HrmHandler.class.getSimpleName();
private BluetoothAdapter mBtAdapter;
private BluetoothDevice mBtDevice;
private String mBtDeviceAddress;
private Context mContext;
public static HrmHandler getInstance() {
if (instance == null)
instance = new HrmHandler();
return instance;
}
public void connect(Context ctx) {
mContext = ctx;
BluetoothManager bt_manager = (BluetoothManager) ctx.getSystemService(Context.BLUETOOTH_SERVICE);
mBtAdapter = bt_manager.getAdapter();
if (mBtAdapter == null || !mBtAdapter.isEnabled()) return;
mBtAdapter.startLeScan(new UUID[] {UUID_HRM_SERVICE}, this);
}
public void disconnect() {
}
#Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
Log.v(LOG_TAG, "Found HRM device " + device.getName());
mBtDevice = device;
mBtAdapter.stopLeScan(this);
mBtDeviceAddress = mBtDevice.getAddress();
mBtDevice.connectGatt(mContext, false,this);
}
#Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
super.onConnectionStateChange(gatt, status, newState);
Log.v(LOG_TAG, String.format("Connection state change, new state %d", newState));
if (mBtDeviceAddress == null || !mBtDeviceAddress.equals(gatt.getDevice().getAddress()))
return; //we are not interested about that connection state
if (newState == BluetoothProfile.STATE_CONNECTED) {
Log.v(LOG_TAG, "Device connected");
gatt.discoverServices();
return;
}
if (newState == BluetoothProfile.STATE_DISCONNECTED) {
Log.v(LOG_TAG, "Device disconnected");
return;
}
}
#Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (gatt != null) {
BluetoothGattCharacteristic characteristic = null;
List<BluetoothGattService> services = gatt.getServices();
for (BluetoothGattService s : services) {
Log.v(LOG_TAG, String.format("Discovered %s, uuid %s", s.toString(), s.getUuid().toString()));
}
BluetoothGattService service = gatt.getService(UUID_HRM_SERVICE);
if (service != null)
characteristic = service.getCharacteristic(UUID_HRM_CHARACTERISTIC);
gatt.readCharacteristic(characteristic);
gatt.setCharacteristicNotification(characteristic, true);
}
}
#Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
super.onCharacteristicRead(gatt, characteristic, status);
if (!UUID_HRM_CHARACTERISTIC.equals(characteristic.getUuid())) {
Log.v(LOG_TAG, "READ: Not interesting characteristic " + characteristic.getUuid().toString());
return;
}
int flags = characteristic.getProperties();
int format = (flags & 0x01) != 0 ? BluetoothGattCharacteristic.FORMAT_UINT16 : BluetoothGattCharacteristic.FORMAT_UINT8;
int heart_rate = characteristic.getIntValue(format, 1);
Log.v(LOG_TAG, String.format("Heart rate %d bpm", heart_rate) );
}
#Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
super.onCharacteristicChanged(gatt, characteristic);
if (!UUID_HRM_CHARACTERISTIC.equals(characteristic.getUuid())) {
Log.v(LOG_TAG, "CHANGED: Not interesting characteristic " + characteristic.getUuid().toString());
return;
}
gatt.readCharacteristic(characteristic);
}
Can anyone help me forward, especially someone at Garmin, or is it common and known issue and I just should forget about it and try to go forward with ANT+?

How to notify user if connection fails to BLE device in Android?

How do I notify users if the device they are trying to connect to does not connect, besides waiting and testing for a connection. There does not seem to be any callback for a failed connection after trying connectGatt().
Thanks!
The method: connGATT() has 3 parameters. The third one is a callback:
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
if you want to know the connection is success or not, you should add override the method:
#Override
public void onConnectionStateChange(BluetoothGatt gatt, int status,
int newState)
Here is the link.https://developer.android.com/guide/topics/connectivity/bluetooth-le.html
The whole callback looks like this:
private final BluetoothGattCallback mGattCallback =
new BluetoothGattCallback() {
#Override
public void onConnectionStateChange(BluetoothGatt gatt, int status,
int newState) {
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
broadcastUpdate(intentAction);
Log.i(TAG, "Connected to GATT server.");
Log.i(TAG, "Attempting to start service discovery:" +
mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
intentAction = ACTION_GATT_DISCONNECTED;
mConnectionState = STATE_DISCONNECTED;
Log.i(TAG, "Disconnected from GATT server.");
broadcastUpdate(intentAction);
}
}
#Override
// New services discovered
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
} else {
Log.w(TAG, "onServicesDiscovered received: " + status);
}
}
#Override
// Result of a characteristic read operation
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,
int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
}
...
};
...
}

Writing data to Bluetooth LE characteristic in Android

Although similar questions have been asked but it's slightly different. I know how to pass data to a connected BLE device but I think I'm doing something wrong for which I need help.
The code below contains all the methods from my class that is extending BroadcastReceiver.
I scan and connect to a device specified by `PEN_ADDRESS`.
In `onServicesDiscovered` method I look for a service whose `UUID` contains `abcd`.
Then I loop through the characteristics of this services and look for three characteristics with specific strings in their `UUID`.
The third characteristic is a writable characteristic in which I'm trying to write data by calling the method `writeCharac(mGatt,writeChar1,123);`
The data `123` passed above is just a dummy data.
I debugged my code while trying writing to this characteristic but on putting breakpoints inside the writeCharac method, I found that the status value is false, indicating that the write was not successful.
Am I missing something here? Please do help!
public class BackgroundReceiverFire extends BroadcastReceiver {
Context context;
private BluetoothAdapter mBluetoothAdapter;
private BluetoothGatt mGatt;
private BluetoothLeService mBluetoothLeService;
private boolean mScanning;
private final String TAG = "READING: ";
private BluetoothDevice mDevice;
private Handler mHandler;
private static final int REQUEST_ENABLE_BT = 1;
private final String PEN_ADDRESS = "FB:23:AF:42:5C:56";
// Stops scanning after 10 seconds.
private static final long SCAN_PERIOD = 10000;
public void onReceive(Context context, Intent intent) {
this.context = context;
Toast.makeText(context, "Started Scanning", LENGTH_SHORT).show();
initializeBluetooth();
startScan();
}
private void initializeBluetooth() {
mHandler = new Handler();
// Use this check to determine whether BLE is supported on the device. Then you can
// selectively disable BLE-related features.
// Initializes a Bluetooth adapter. For API level 18 and above, get a reference to
// BluetoothAdapter through BluetoothManager.
final BluetoothManager bluetoothManager =
(BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();
// Checks if Bluetooth is supported on the device.
if (mBluetoothAdapter == null) {
Toast.makeText(this.context, "No Bluetooth", LENGTH_SHORT).show();
return;
}
}
private void startScan() {
scanLeDevice(true);
}
private void stopScan() {
scanLeDevice(false);
}
private void scanLeDevice(final boolean enable) {
if (enable) {
// Stops scanning after a pre-defined scan period.
mHandler.postDelayed(new Runnable() {
#Override
public void run() {
mScanning = false;
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}, SCAN_PERIOD);
mScanning = true;
//Scanning for the device
mBluetoothAdapter.startLeScan(mLeScanCallback);
} else {
mScanning = false;
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}
private BluetoothAdapter.LeScanCallback mLeScanCallback =
new BluetoothAdapter.LeScanCallback() {
#Override
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
if (device.getAddress().matches(PEN_ADDRESS)) {
connectBluetooth(device);
Toast.makeText(context, "Device Found: " + device.getAddress(), Toast.LENGTH_LONG).show();
}
}
};
private void connectBluetooth(BluetoothDevice insulinPen) {
if (mGatt == null) {
Log.d("connectToDevice", "connecting to device: " + insulinPen.toString());
mDevice = insulinPen;
mGatt = insulinPen.connectGatt(context, true, gattCallback);
scanLeDevice(false);// will stop after first device detection
}
}
private void enableBluetooth() {
if (!mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.enable();
}
scanLeDevice(true);
}
private void disableBluetooth() {
if (mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.disable();
}
}
private final BluetoothGattCallback gattCallback = new BluetoothGattCallback() {
#Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
Log.i("onConnectionStateChange", "Status: " + status);
switch (newState) {
case BluetoothProfile.STATE_CONNECTED:
gatt.discoverServices();
break;
case BluetoothProfile.STATE_DISCONNECTED:
Log.e("gattCallback", "STATE_DISCONNECTED");
Log.i("gattCallback", "reconnecting...");
BluetoothDevice mDevice = gatt.getDevice();
mGatt = null;
connectBluetooth(mDevice);
break;
default:
Log.e("gattCallback", "STATE_OTHER");
break;
}
}
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
mGatt = gatt;
List<BluetoothGattService> services = mGatt.getServices();
Log.i("onServicesDiscovered", services.toString());
Iterator<BluetoothGattService> serviceIterator = services.iterator();
while(serviceIterator.hasNext()){
BluetoothGattService bleService = serviceIterator.next();
if(bleService.getUuid().toString().contains("abcd")){
//Toast.makeText(context,"Got the service",Toast.LENGTH_SHORT);
BluetoothGattCharacteristic readChar1 = bleService.getCharacteristics().get(0);
for (BluetoothGattDescriptor descriptor : readChar1.getDescriptors()) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
mGatt.writeDescriptor(descriptor);
mGatt.setCharacteristicNotification(readChar1, true);
}
//mGatt.readCharacteristic(readChar1);
BluetoothGattCharacteristic readChar2 = bleService.getCharacteristics().get(1);
for (BluetoothGattDescriptor descriptor : readChar2.getDescriptors()) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
mGatt.writeDescriptor(descriptor);
mGatt.setCharacteristicNotification(readChar2, true);
}
//mGatt.readCharacteristic(readChar2);
BluetoothGattCharacteristic writeChar1 = bleService.getCharacteristics().get(2);
for (BluetoothGattDescriptor descriptor : writeChar1.getDescriptors()) {
descriptor.setValue( BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
mGatt.writeDescriptor(descriptor);
mGatt.setCharacteristicNotification(writeChar1, true);
}
writeCharac(mGatt,writeChar1,123);
}
}
//gatt.readCharacteristic(therm_char);
}
public void writeCharac(BluetoothGatt gatt, BluetoothGattCharacteristic charac, int value ){
if (mBluetoothAdapter == null || gatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
/*
BluetoothGattCharacteristic charac = gattService
.getCharacteristic(uuid);
*/
if (charac == null) {
Log.e(TAG, "char not found!");
}
int unixTime = value;
String unixTimeString = Integer.toHexString(unixTime);
byte[] byteArray = hexStringToByteArray(unixTimeString);
charac.setValue(byteArray);
boolean status = mGatt.writeCharacteristic(charac);
if(status){
Toast.makeText(context,"Written Successfully",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(context,"Error writing characteristic",Toast.LENGTH_SHORT).show();
}
}
public byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len/2];
for(int i = 0; i < len; i+=2){
data[i/2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i+1), 16));
}
return data;
}
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic
characteristic, int status) {
Log.i("onCharacteristicRead", characteristic.toString());
String characteristicValue = characteristic.getValue().toString();
Log.d("CHARACTERISTIC VALUE: ", characteristicValue);
gatt.disconnect();
}
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic
characteristic) {
String value = characteristic.getValue().toString();
Log.d(TAG,value);
}
};
Although the BLE API is asynchronous in nature, the actual signal transmission is inevitably synchronous. You have to wait for the previous connect/write/read call to callback before starting any connecting/writing/reading operation.
In your code onServicesDiscovered(BluetoothGatt gatt, int status) function, you called mGatt.writeDescriptor(descriptor) twice before trying to write the characteristic. The API will refuse to start your write request as it is being busy writing the descriptor, and return false for your mGatt.writeCharacteristic(charac) call.
So just wait for the writeDescriptor to callback before calling writeCharacteristic. This nature is not well documented but you can find some source here and here.
Thanks #reTs and #pooja for suggestions. The issue was due to these two lines
mGatt = nullconnectBluetooth(mDevice);
in STATE_DISCONNECTED. I had figured it out but don't remember the exact reason. Posting it just in case it is helpful.

Android Bluetooth Low Energy readRemoteRssi

I can't figure out how to get the 'onReadRemoteRssi' callback work.
My code is very simple :
final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();
BluetoothGatt gatt;
mBluetoothAdapter.startLeScan(new LeScanCallback() {
#Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] record) {
gatt = device.connectGatt(getApplicationContext(), false, new BluetoothGattCallback() {
#Override
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
super.onReadRemoteRssi(gatt, rssi, status);
Log.d(TAG, "rssi is : " + rssi);
}
});
}
});
gatt.readRemoteRssi(); //returns true
The callback is never called.
Does anyone have any idea ?
Thanks !
Put readRemoteRssi() in the callback onConnectionStateChange() of BluetoothGattCallback.
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
#Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
boolean rssiStatus = mBluetoothGatt.readRemoteRssi();
broadcastUpdate(intentAction);
// Attempts to discover services after successful connection.
Log.i(TAG, "Attempting to start service discovery:" +
mBluetoothGatt.discoverServices());
}
}
};
And also put the onReadRemoteRssi in BluetoothGattCallback function   
#Override
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status){
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.d(TAG, String.format("BluetoothGatt ReadRssi[%d]", rssi));
}
}
http://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#readRemoteRssi()
Async call to start reading signal strength.
http://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onReadRemoteRssi(android.bluetooth.BluetoothGatt,%20int,%20int)
Callback after the read finishes.
Need to connect before read
reference here
Continual Bluetooth LE Signal Strength on Android
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(deviceAddress);
BluetoothGatt bluetoothGatt = getBluetoothGatt(device);
if (bluetoothGatt == null) {
return false;
}
boolean rdRemoteRssi = bluetoothGatt.readRemoteRssi();
Log.d(FTAG, "BluetoothGatt readRemoteRssi : " + rdRemoteRssi);
return true;
It will call onReadRemoteRssi call back.Need to connect before call this API.

Categories

Resources