This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC1352P7:BLE 通知不起作用:始终返回错误代码 5

Guru**** 2577385 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1575416/cc1352p7-ble-notification-does-not-work-always-returns-error-code-5

器件型号: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, &notification, 0x01);
            if (status != SUCCESS) {
                Display_printf(dispHandle, 12, 0, "Notification failed: %d",
                               status);
                GATT_bm_free((gattMsg_t *)&notification, 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。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我发现了此问题、但供将来参考:


    我当时在身份验证部分使用 0x01、因为 gatt.h 文件除了 0x01 和 0x02 以外没有提及任何内容、但我将其更改为 0x00、这修复了问题。