This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to send 16 bit element array[10000] in BLE nus service in nrf52?

Hello,

I am using 12 bit ADC in my application but data element more than 8bit is not send correctly, Also not receiving Array[10000] element. I am using nrf52.

Thank You, Ram

Parents
  • Several ways to do this, all of them covered numerous times in the forum. I'm a fan of doing something like this for 16 bits or two bytes (from here you can work out the for loops and counters required)

    nus_to_send_array[0] = (Array[0] & 0xFF00) >> 8;
    nus_to_send_array[1] = (Array[0] & 0x00FF);
    ...
    nus_to_send_array[18] = (Array[9] & 0xFF00) >> 8;
    nus_to_send_array[19] = (Array[9] & 0x00FF);
    
    ble_attempt_to_send(nus_to_send_array, sizeof(nus_to_send_array));
    
Reply
  • Several ways to do this, all of them covered numerous times in the forum. I'm a fan of doing something like this for 16 bits or two bytes (from here you can work out the for loops and counters required)

    nus_to_send_array[0] = (Array[0] & 0xFF00) >> 8;
    nus_to_send_array[1] = (Array[0] & 0x00FF);
    ...
    nus_to_send_array[18] = (Array[9] & 0xFF00) >> 8;
    nus_to_send_array[19] = (Array[9] & 0x00FF);
    
    ble_attempt_to_send(nus_to_send_array, sizeof(nus_to_send_array));
    
Children
Related