Hello,
Is the characteristic value data supplied to sd_ble_gatts_characteristic_add() and sd_ble_gatts_value_set() copied into the softdevice RAM, or does the softdevice refer to application RAM whenever client requests a characteristic read? I cannot find this information in the SDK docs.
Consider the following code:
#define BUFSIZE 64
char *str = malloc(BUFSIZE);
strcpy(str, "Hello world");
[...]
attr_char_value.init_len = strlen(str)+1;
attr_char_value.init_offs = 0;
attr_char_value.max_len = BUFSIZE;
attr_char_value.p_value = (uint8_t*) str;
uint32_t err_code = sd_ble_gatts_characteristic_add(
BLE_GATT_HANDLE_INVALID, &char_md, &attr_char_value, &blue_char_handle);
[...]
free(str);
In this example, will the "Hello world" string be copied into softdevice RAM, and thus can be free()'d safely, or will the application crash on read due to invalid pointer?