I am new to developing BLE stuff. So I am using Android 5.1, I need to send more than 20 byte data over BluetoothGATT. So onServicesDiscovered() callback, I did the following:
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status){
Log.d(TAG, "Services discovered " + status);
if(status == 0)
{
mHandler.sendMessage(Message.obtain(null, MSG_PROGRESS, "Enabling Sensor..."));
enableSensor(gatt);
//enableNotification(gatt);
boolean mtuStatus = gatt.requestMtu(512);
Log.d(TAG, "mtu status: " + mtuStatus);
}
else
{
Log.d("TAG", "Services not discovered properly: " + status);
}
}
the mtuStatus returned is true. But when I writecharacteristic to device, it gives me error code 6.
I have also implemented onMtuChanged Callback which is never triggered.
@Override
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status){
Log.d(TAG, "new mtu: " + mtu + "status: " + status);
}
What am I missing?