请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC1352P7工具/软件:
你好我的朋友,
我正在开发一项定制 BLE 服务、在该 服务中、外设通过连接到该服务的“写入特性“的描述符公开一条通知。
但是,无论我做什么, GATT_Notification () 函数都会返回状态代码 5 ,由于内部嵌套的回调结构,跟踪它并不是非常简单。
如果你能帮助我,什么是 ERNO ,我会很感激 5. 出现了什么问题?
// this must be called from the application context:
void provision_profile_send_notification(void) {
if (value_charc_handle_for_notif == 0xFFFF) {
return;
}
bStatus_t status = 0;
// notification object:
attHandleValueNoti_t notification = {
.handle = value_charc_handle_for_notif, .len = 5, .pValue = NULL};
notification.pValue = (uint8_t *)GATT_bm_alloc(
notif_connHandle, ATT_HANDLE_VALUE_NOTI, 5, NULL);
if (notification.pValue != NULL) {
// Now it's safe to copy data
memcpy(notification.pValue, &dummy_large_data[0], 5);
// making sure that central has enabled notifications:
uint16_t cccValue =
GATTServApp_ReadCharCfg(notif_connHandle, fast_report_cccd);
if (cccValue & GATT_CLIENT_CFG_NOTIFY) {
// Send the notification
status = GATT_Notification(notif_connHandle, ¬ification, 0x01);
if (status != SUCCESS) {
Display_printf(dispHandle, 12, 0, "Notification failed: %d",
status);
GATT_bm_free((gattMsg_t *)¬ification, ATT_HANDLE_VALUE_NOTI);
} else {
Display_printf(dispHandle, 12, 0, "Notification sent");
}
} else {
Display_printf(dispHandle, 12, 0,
"-[WARNING]--------> Notification not enabled!");
}
}
}如您所推断、中央器件可以成功启用 CCC 描述符、但在下一步中、我要将通知发送回中央器件时会失败、显示为 5。
换句话说、上述代码片段会生成以下日志:
通知失败:5.
我的 SDK 版本为 8.30.1.1、我使用的是 DMM。