Re: Sending more than 20 bytes with BLE
Posted: Tue May 22, 2018 8:29 am
Thank you very much for you respond JoaoLopesF ! Ok, now i understand how it works. Can you show me an example of the function in which you split the data when sending if the message if too long, and how you process the message upon receiving a \n while receiving ?Ble has this limit, but you treat the long messages as several messages within the limit, dividing them when sending and joining them when receiving by yourself
What I do to work with larger messages:
- All messages (mobile and esp32) ends with a specific character (in my case \n)
- On Android (Java and now Kotlin) or iOS (swift 4):
- When sending if the message is large,
I split it in pieces and send it (with a small delay forced between them in Android, IOS not need it)
Tip: If I have more than one message to send in moment, I just join it with delimiter \n and send all to one call of routine that split it
to Ble, generating few messages instead call it for each message.
- In Esp32, idem only that does not need the delay
- When receiving messages (app or Esp32), I work with a buffer, and only process the messages upon receiving a \n (since the message can be divided into several pieces)
Now I working to balance use of Esp32 cpu cores. The work of split/join ble messages is now to in task in CPU 1, leaving CPU 0 to system (Ble, timers (tg), etc)
My idea is when I have time, put together a complete solution:
- Android and iOS app and Esp-IDF and put in github.
Hope this helps.