-1

Hi I'm trying to get some measurement data from a ble decice and display it in my flutter app. I'm also using flutter_reactive_ble

I have two characteristics, one for reading and one for writing. I subscribe an event listener to the readCharacteristic and then I write a request just like below

_ble!.writeCharacteristicWithoutResponse(characteristicWrite, value: [0x99, 0x00, 0x19]);

As the value parameter i'm sending a list of hex value. Every value has it's role, as the ble's manual defines below: enter image description here

I'm using the hex values of the manual's example, and the device sends me the 10 first measurements, which is correct, because every req response has maximum 10 measurements. The thing is that, in the scenario of having 20 measurements, I can't get the last 10. I tried of doing the following

await _ble!.writeCharacteristicWithoutResponse(characteristicWrite, value: [0x99, 0x00, 0x01, 0x99]);

I added 0x01 in the values list, because the manual says

value 1: continue with next group

But data is not getting sent.

How is it possible to get all the measurements, and further more, get for example the 5 last? Can anybody help me or give me a hint? Thank you for your time

we_mor
  • 478
  • 5
  • 20
  • 1
    The data always has to be 3 bytes long that you send. i.e. `[0x
    , 0x, 0x]`. You haven't said how to calculate the check sum but In your second example you too many bytes. It looks like you have an extra command. i.e. `[0x
    , 0x, 0x, 0x]`. Take out the `0x00` and make sure the checksum is correct and that should work.
    – ukBaz Dec 07 '21 at 15:12
  • @ukBaz Thank you for the response. The manual says the following `The checksum is calculated by adding up all the other bytes of the message (including the header) and then select the lowest 7 Bit and write them in the 7 LSB of the checksum byte. The MSB of the checksum byte is always 0.` – we_mor Dec 07 '21 at 15:18
  • @ukBaz So in order to receive all the data, should I call an extra `writeCharacteristic` method with a header of `0x99` and `0x01` command and `0x1A` as the checksum? – we_mor Dec 07 '21 at 15:26
  • 1
    Yes. After you receive the first 10 measurements you need to do a second write requesting the next 10 i.e. `[0x99, 0x01, 0x1A]` – ukBaz Dec 07 '21 at 16:00
  • 1
    @ukBaz Yes, that's it, it's working! Thank you for helping me! – we_mor Dec 08 '21 at 09:20

1 Answers1

1

The data always has to be 3 bytes long that you send. i.e.

[0x<header>, 0x<command>, 0x<checksum>]

In your second example you have too many bytes. It looks like you have an extra command. i.e.

[0x<header>, 0x<command>, 0x<command>, 0x<checksum>]

For the second write take out the 0x00 and make sure the checksum is correct. i.e:

[0x99, 0x01, 0x1A] 

You send this second write after you receive the first 10 measurements

ukBaz
  • 6,985
  • 2
  • 8
  • 31