Hello_Sensor modification

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi

I have more than 32 bit sensor data and i tried to send this data over BLE. I modify hello_sensor but enable to send sensor data. I have problem on db_pdu.pdu[6]='3' I can send only one number which is less than 10. How i can send complete integer value for example my sensor read temperature which is 200 degree Fahrenheit. Any one can explain me how i can send 32 bit data?

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

In each BLE connection event you can send up 20 bytes of data. A 32 bit value will consume 4 of those bytes. There are a few methods for breaking up 32 bit integer into four 8 bit values that utilize bit-wise operations, pointers, etc. This part is completely up to your discretion. Once broken up, the simplified way of loading them into your GATT db is to load them one by one:

db_pdu.pdu[0] = byte_one;

db_pdu.pdu[1] = byte_two;

db_pdu.pdu[2] = byte_three;

db_pdu.pdu[3] = byte_four;

This can be run in a loop with the code that breaks apart the 32-bit value, but I split it up here for understanding.

Alternatively, you can take a look at the wiced_sense app which uses a method of incrementation to the GATT db which is highly efficient.

Lastly, do not rule out scaling to maximize the amount of data you can send, or to minimize power consumption. If you don't require the highest degree of accuracy in your application, go ahead and divide the value by 10, send it, and multiply it back out on the other side. This may save you one or two bytes.

Jacob

View solution in original post

0 Likes
1 Reply
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

In each BLE connection event you can send up 20 bytes of data. A 32 bit value will consume 4 of those bytes. There are a few methods for breaking up 32 bit integer into four 8 bit values that utilize bit-wise operations, pointers, etc. This part is completely up to your discretion. Once broken up, the simplified way of loading them into your GATT db is to load them one by one:

db_pdu.pdu[0] = byte_one;

db_pdu.pdu[1] = byte_two;

db_pdu.pdu[2] = byte_three;

db_pdu.pdu[3] = byte_four;

This can be run in a loop with the code that breaks apart the 32-bit value, but I split it up here for understanding.

Alternatively, you can take a look at the wiced_sense app which uses a method of incrementation to the GATT db which is highly efficient.

Lastly, do not rule out scaling to maximize the amount of data you can send, or to minimize power consumption. If you don't require the highest degree of accuracy in your application, go ahead and divide the value by 10, send it, and multiply it back out on the other side. This may save you one or two bytes.

Jacob

0 Likes