Hi everyone,
i have an Characteristic with attr_md.vloc = BLE_GATTS_VLOC_STACK;
. Is it possible, when i send a notifcation to use params.p_data
and params.len
to send data from a different location?
Thanks in advance, Cheers!
Hi everyone,
i have an Characteristic with attr_md.vloc = BLE_GATTS_VLOC_STACK;
. Is it possible, when i send a notifcation to use params.p_data
and params.len
to send data from a different location?
Thanks in advance, Cheers!
When transmitting a notification, you should provide a pointer to where the data is located, and that is not relatead to BLE_GATTS_VLOC_STACK.
When creating a characteristic, setting attr_md.vloc = BLE_GATTS_VLOC_STACK;
means that "Attribute Value is located in stack memory, no user memory is required". This sets where the data in a characteristic is stored, and that is independent of the "origin" of the data to transmit in a notification.
In the ble_app_uart example in SDK 6.0.0 in the \Board\pca10001\s110\experimental-folder, notifications are transmitted using sd_ble_gatt_hvx(..) the following way:
uint32_t ble_nus_send_string(ble_nus_t * p_nus, uint8_t * string, uint16_t length)
{
ble_gatts_hvx_params_t hvx_params;
if (p_nus == NULL)
{
return NRF_ERROR_NULL;
}
if ((p_nus->conn_handle == BLE_CONN_HANDLE_INVALID) || (!p_nus->is_notification_enabled))
{
return NRF_ERROR_INVALID_STATE;
}
if (length > BLE_NUS_MAX_DATA_LEN)
{
return NRF_ERROR_INVALID_PARAM;
}
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = p_nus->rx_handles.value_handle;
hvx_params.p_data = string;
hvx_params.p_len = &length;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
return sd_ble_gatts_hvx(p_nus->conn_handle, &hvx_params);
}
Hey Kristin, thanks for your reply and sorry for the delay. Alright, thus it would be possible to set the location of the memory of the characteristic to 'BLE_GATTS_VLOC_STACK;', thus if the client writes something in the characteristic he writes on the stack. But, if i want to notify the client, i can use a other memory location (just for the notification) and the actual value of the characteristic stays the same?
Hey Kristin, thanks for your reply and sorry for the delay. Alright, thus it would be possible to set the location of the memory of the characteristic to 'BLE_GATTS_VLOC_STACK;', thus if the client writes something in the characteristic he writes on the stack. But, if i want to notify the client, i can use a other memory location (just for the notification) and the actual value of the characteristic stays the same?