How to send notification?

2 posts / 0 new
Last post
ben.stickrod@bi...
Offline
Last seen:5 years 3 months ago
加入:2015-10-26 16:51
How to send notification?

I am wanting to send a notification with a specified set of data (not necessarily the data in the characteristic).

Is this the correct way to send a notification? Things do not seem to be working correctly. The notification works when I use prf_server_send_event, but if I am updating the characterisitc rapidly, I get multiples of the same data, not individual notifications with unique data.

void sendEventData(prf_env_struct *p_env, bool indication, uint16_t handle, uint8_t length, uint8_t *pData)
{
// Allocate the GATT notification message
struct gattc_event_ind *req = ke_msg_alloc(GATTC_EVENT_IND,
KE_BUILD_ID(TASK_GATTC, p_env->con_info.conidx), p_env->con_info.prf_id,
sizeof(struct gattc_event_ind) + length);

if(req != NULL)
{
// Fill in the parameter structure
req->type = ((indication) ? GATTC_INDICATE : GATTC_NOTIFY);
req->handle = handle;
req->length = length;
memcpy(req->value, pData, length);

// Send the event
ke_msg_send(req);
}
}

Device:
MT_dialog
Offline
Last seen:4 days 12 hours ago
工作人员
加入:2015-06-08 11:34
Hi ben,

Hi ben,

您可以检查如何发送notifications from the app_ble_peripheral example in the SDK 5.

Thanks MT_dialog