I'm trying to dynamically allocate some data, send it over NUS, and then free it, but I'm not sure when the SoftDevice is done with it and it's safe to free. Would the following code work safely (assuming I get NRF_SUCCESS)? Do I need to wait for some TX Complete event before it's safe to free it?
uint8_t length = 10;
void* some_data = malloc(length);
if (ble_nus_data_send(&m_nus, (uint8_t*)some_data, &length, m_conn_handle) == NRF_SUCCESS)
{
free(some_data);
}
Thanks