Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

BLE only transmitting 8 bytes

nRF5 SDK 17.2.0, nRF52840

Okay, I am just so lost. I am trying to set a characteristic's gatts value BEFORE connecting such that it is a 192 byte array. However when I read the characteristic's data on lightblue, it's just 8 bytes long. I have adjusted the MTU and I get confirmation of this via RTT to a length of 250ish bytes so that seems okay. I've looked through tutorials and am just getting nowhere.

This is an example of how I am trying to set the data BEFORE connecting to the other device. The custom_value arg is just me passing the name of the array.

uint32_t ble_diaper_data_update_temperature(ble_diaper_t *p_diaper, uint8_t *custom_value)
{
  ble_gatts_value_t value;
  ret_code_t        err_code;

  // Initialize value struct.
  memset(&value, 0, sizeof(value));

  value.offset = 0;
  value.len = sizeof(custom_value)/sizeof(custom_value[0]);
  value.p_value = custom_value;
      
  err_code = sd_ble_gatts_value_set(p_diaper->conn_handle, p_diaper->temp_handles.value_handle, &value);
  VERIFY_SUCCESS(err_code);

  return err_code;
}

Parents
  • Hi Jonathan

    I don't think they way you set the length will work. This trick using sizeof works on arrays, but not on a pointer to an array. 

    Could you check what the value of the value.len field is using the logger or debugger?

    The confusing part is why you can read 8 bytes. I would expect sizeof(custom_value)/sizeof(custom_value[0]) to equal 4...

    Best regards
    Torbjørn

Reply
  • Hi Jonathan

    I don't think they way you set the length will work. This trick using sizeof works on arrays, but not on a pointer to an array. 

    Could you check what the value of the value.len field is using the logger or debugger?

    The confusing part is why you can read 8 bytes. I would expect sizeof(custom_value)/sizeof(custom_value[0]) to equal 4...

    Best regards
    Torbjørn

Children
Related