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.

[参考译文] LP-EM-CC2340R5:写入 GATT 特征的问题

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

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1447612/lp-em-cc2340r5-the-problem-of-writing-a-gatt-characteristic

器件型号:LP-EM-CC2340R5
主题中讨论的其他器件:CC2340R5

工具与软件:

下午好!
我使用 cc2340r5和 simplelink_lowpower_f3_sdk_8_10_01_02。
我的程序基于 basic_ble 并进行了一些逻辑修改。

我尝试使用 GATT 将一个值写入另一个器件的特征。  但是、当我执行 GATT_WriteCharValue 时、我会得到 faultISR()。

下面是我用于创建特征记录查询的函数

bStatus_t GATT_API::writeCharValue(uint16_t conn_handle, uint16_t char_handle) {
    uint8_t* value = (uint8_t*)ICall_malloc(sizeof(uint8_t) * 2);
    value[0] = 7;
    value[1] = 0;
    attWriteReq_t pReq = {
        .handle = char_handle,
        .len = sizeof(value),
        .pValue = value,
        .sig = 0,
        .cmd = 0,
    };

    BLEAppUtil_entityId_t taskId = BLEAppUtil_getSelfEntity();
    bStatus_t status = GATT_WriteCharValue(conn_handle, &pReq, taskId);
    return status;
}


在此之前、我使用 GATT_DiscCharsByUUID 查询响应获得了特征的句柄。

attReadByTypeRsp_t *pRsp = &(gattMsg->msg.readByTypeRsp);

 for (uint8_t i = 0; i < pRsp->numPairs; i++) {
    conn_dev_info->service_.cmd_char_handle_ =
    BUILD_UINT16(pRsp->pDataList[i], pRsp->pDataList[i + 1]);
}


我不知道我在使用此功能条目时做了什么错误。 并且似乎没有通过 UUID 记录特征的方法(尽管有一个供读取)

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

    UPD。 我设法解决了问题。 我没有正确地将指针分配给 pValue。

    当使用 GATT_BM_alloc 而不是 iCall_malloc 时、一切都正常运行。

    如果任何人需要有关 GATT_BM_ALLOC 的更多信息、请 在此链接中使用 GATT API 的文档

    问题已解决、我将关闭此 TT