0

I'm writing a byte array of data into a BLE device in Android. After calling mGatt.writeCharacteristic(characteristicToWrite); The onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) callback method is invoked. If the write operation was successful status would have been 0 ie GATT_SUCCESS = 0, Instead of that i m receiving status as 7 ie GATT_INVALID_OFFSET = 0x7. Why does this happen? Can anybody help me. Thanks in advance peers.

Febin K R
  • 886
  • 2
  • 11
  • 21

1 Answers1

0

Because the peripheral running the GATT server is incorrectly written.

I assume you have a "long" value, meaning a value larger than fits in one ATT packet. Then the Invalid Offset error should be sent back in the following case:

If the prepare Value Offset is greater than the current length of the attribute value then all pending prepare write values shall be discarded for this client, the queue shall be cleared and then an Error Response shall be sent with the «Invalid Offset».

But whenever Android writes a Long value, it sets each chunk's offset to the accumulated sum of the previous chunks' lengths.

So just check what happens on the peripheral.

Emil
  • 16,784
  • 2
  • 41
  • 52