Hi everybody!!
I have some problems with my code when I receive a string from my app in Android. I need to send some string (utf8 format) from my App to Arduino (over bluetooth BLE), and get data in a SdCard (in Arduino). The strings are two and the first string is:
The output for Serial.print(“String:”); print U (the result that I expect), but only the first time… and next doesn’t print anything…
When I need to send the last one string I only receive trash… But if I forward the last string again, now the string received it’s Ok!!
I have also sent the first string (the string received is Ok) and next restart Arduino and finally send the last string and the string received ( the last one) is Ok!!
What do I need to do to solve this problem?
Thanks in advance!
Your detailed error symptoms should make it easy for a real BLE expert to diagnose your problem.
In the meantime, all I have for you are some observations and hypotheses …
Your BLE version is current.
NullTerminateStrings – Instructs the BluetoothLE component to terminate strings with a null byte (true) or not (false) when sending string data to a connected device.
I don’t see any place in your arduino code where you check for 0 as a null terminator. Instead you use \n. By not including any expected null terminator, are you forcing the arduino to keep accepting data until its gullet (buffer) overflows? (Are you guilty of torturing your arduino?)
The transmission blocks …
There is room for slipshod type conversion here. I hope the AI2 block is not fouling up interpretation of the long text string as a list. On the other hand, the errors are not consistent, so that points more to a timing problem.
Timing issues?
You use the same UUIDs for sending and receiving, thus sharing a channel with the Arduino. Is this a good practice? Might the Arduino be interrupting the AI2’s transmissions randomly? (I don’t know.)
I don’t remember seeing in your Arduino code any inclusion of a BLE library, or calls to procedures with BLE type functions. Might you be missing something on that end?
That should get you started, until a BLE expert arrives.
And I also changed the strings deleting '\n' y Mit App!
The communication between Mit App and BLE works fine!
Thank you very much ABG you are very kind!
Greetings!!