Showing results for 
Search instead for 
Did you mean: 

STM32WB55 and "Proper" way to send an array or struct over BLE to update characteristic.

Associate III

I am working on a WTM32WB55RG BLE application that reads a sensor via I2C and sends the output of some calculations to a BLE characteristic running on the p2pserver on the same WB55RG.  I'm able to successfully send an Integer to the BLE characteristic but I'm struggling to understand the "best" or "proper" way to send, let's say 6 x uint32_t for example.

Option 1:  Step 1:  Assemble the 6 x uint32_t in an array.  Step 2:  Then it appears I need to reverse the byte order before I send so when I look at the values in the iPhone ST BLE Toolbox I get recognizable data.  Step 3:  Make a call to Custom_STM_App_Update_Char(CUSTOM_STM_CharSensor, (uint8_t*) dataArray);   This is what I'm doing today.  I've tested it with 2 uint32_t in an array and it works, so assume it would work for 6.

Option 2:  I originally wanted to build a struct that contains all of the data (in case all data values to be sent aren't the same number of bytes) I want to send, but the byte order issue has me thinking "there must be a better way" and I am missing it.

So, my questions are:

  1. If you want to send 6 x uint32_t integers (or any other dataset of a fixed size) to a BLE characteristic how would you do it?  
  2. Bonus question is why do you have to manually reverse the bytes order before sending?  It seems like this is something BLE should take care of?  Maybe it does and I'm using it incorrectly.

Thank you very much.

Associate III

you can try 6 different characteristics instead of using an array or extend the characteristics size to 6 then store that in a variable and reverse it using a simple ascending or descending order program,