1

so I just started experimenting with the Adafruit Feather nRF52840 board and have set up a working BLE connection between the board and another device.

Usually, everything works fine by sending data from the other device to the nRF52840, but sometimes, if I send 2 packets at the exact same time, the setWriteCallback is only registering one of them.

Is there a way I can work around this issue?

This is how I set up my callback in code:

void charact_write_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t *data, uint16_t len)
{
    if(data[0] == 2){
        Serial.print(data[1] == 0 ? "Left" : "Right");
        Serial.println(" Hand Touch occured");
    }
}

When both hands are actually touching and sending data to the device, this callback only receives one.

Thanks in advance and Greetings

Acimaz
  • 171
  • 1
  • 14
  • Do you have two sending devices? – Michael Kotzjan Sep 30 '21 at 21:03
  • No, it's one sending and one receiving device. The sending device can send 2 packages at the same time though. But of course, when thinking about it, it is 2 packets sent after each other in less than 1/72 seconds. – Acimaz Oct 01 '21 at 07:17
  • Thanks for clearing that up, I was wondering how you managed to send two "at the exact same time". Are you using write without response? – Michael Kotzjan Oct 01 '21 at 07:19
  • Hmm I would say it is a write without response. On the other device, I am using a plugin in unity which makes it possible to connect via BLE and write messages. So I can not tell you 100%. But the method I am using is not waiting for any response, that's why I think it is a write without response. – Acimaz Oct 01 '21 at 07:33
  • It is called "WriteCharacteristic" so I think it is using the underlying Android call writeCharacteristic(), though currently I am unsure which write type the plugin is using. The documentation tells me that there is a "setWriteType()" method which has to be called before writeCharacteristic() which will set it to response or no-response. – Acimaz Oct 01 '21 at 07:39
  • I just thought that a write without response could be "too fast". But that could be wrong – Michael Kotzjan Oct 01 '21 at 09:39
  • I was just thinking, that it could be related to the baud of 115200 when doing "Serial.begin(115200)". To my understanding this means that the device should be able to check for new packets 115200 per second. But I do not know how 2 packets can be distinguished. I have read something about a stop bit, maybe that could help? I am too unexperienced with arduino boards at the moment, so maybe someone can shed some light on this :D – Acimaz Oct 01 '21 at 10:44
  • It could be interesting to check if another BLE Peripheral will receive both writes in the same situation, it might help to determine which side is responsible for the issue (sender or receiver). You can make another Android device your new Peripheral by fixing (UUIDs, write without response) Peripheral part from this example - https://github.com/alexanderlavrushko/BLEProof-collection – alexander.cpp Oct 01 '21 at 12:51

0 Answers0