This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Send 16 bits instead of 8 bits over BLE

Hello,

I'd like to send 16 bits data over ble instead of 8 bits

gatts_value.offset = 0;
gatts_value.len = len;
gatts_value.p_value = data;

err_code = sd_ble_gatts_value_set(conn_handle, value_handle, &gatts_value);

for len I set the value to 2 and cast the 16 bits to 8 bits by (uint8_t*)data.

Unfortunately I get this error:

APP ERROR: 12, line: 105, file: src/bluetooth/base_service.c

EDIT: line 105 is err_code = sd_ble_gatts_value_set(conn_handle, value_handle, &gatts_value);

Please help me.

Thank you in advance

~Taz

Parents
  • So I tried doing this:

    uint16_t val = 300;
    static uint8_t data[2];
    data[0] = (uint8_t)(val >> 8);
    data[1] = (uint8_t)(val);
    update_characteristic(conn_handle,value_handle, sizeof(data),(uint8_t*)data)
    

    and in update_characteristic:

    gatts_value.offset = 0;
    gatts_value.len = len;
    gatts_value.p_value = data;
    err_code = sd_ble_gatts_value_set(conn_handle, value_handle, &gatts_value);
    APP_ERROR_CHECK(err_code);
    

    Still getting error at the app error check:

    APP ERROR: 12, line: 105, file .....

    What am I doing wrong?

Reply
  • So I tried doing this:

    uint16_t val = 300;
    static uint8_t data[2];
    data[0] = (uint8_t)(val >> 8);
    data[1] = (uint8_t)(val);
    update_characteristic(conn_handle,value_handle, sizeof(data),(uint8_t*)data)
    

    and in update_characteristic:

    gatts_value.offset = 0;
    gatts_value.len = len;
    gatts_value.p_value = data;
    err_code = sd_ble_gatts_value_set(conn_handle, value_handle, &gatts_value);
    APP_ERROR_CHECK(err_code);
    

    Still getting error at the app error check:

    APP ERROR: 12, line: 105, file .....

    What am I doing wrong?

Children
No Data
Related