I recently started working with a PSoC project that uses BLE. To get an understanding of how BLE works with PSoC, I've tried using the CySmart app with the "Find Me" code example programmed on a CY8CPROTO-063-BLE PSoC 6 BLE prototyping kit. This project lets me read and write data on the PSoC. One problem I'm having though, is when I try to do the following in a characteristic on the app:
- Write a number of characters to the PSoC (in the ASCII-box on the app), it writes the data as expected
- Press read - it displays the characters that were written as expected
- Write a number of characters (less bytes than before) to the PSoC, it writes the data as expected (i suppose?)
- Press read - it displays the most recently written characters, but followed by the rest of the characters of the first write (the characters of the first write that excedes the number of recently written characters)
I'm having a hard time figuring out why the read data isn't cleared whenever a new write is executed. Can someone clarify if this is an error in the "Find Me" code example, or if I'm missing some understanding on the topic?
If the number of bytes write in the GATT database is less than the previous written values then the GATT DB will contains the already stored values and the new values(based on total length). So, you have to write the unwanted bytes with zero value based on the total length of the GATT data.