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: The problem of writing a GATT characteristic

Part Number: LP-EM-CC2340R5
Other Parts Discussed in Thread: CC2340R5

Tool/software:

Good afternoon,
I use cc2340r5 and simplelink_lowpower_f3_sdk_8_10_01_02 .
My program is based on basic_ble with some logical modifications.

I'm trying to write a value to another device's characteristic using GATT. But when I do GATT_WriteCharValue I get to faultISR().

Here is my function to create a characteristic record query

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;
}


Before that, I got the handle of the characteristic using the GATT_DiscCharsByUUID query response.

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]);
}


I can't figure out what I'm doing wrong with this feature entry. And it seems that there is no method of recording characteristics by UUID (although there is one for reading)

  • UPD. I managed to solve the problem. I wasn't allocating the pointer to pValue correctly.

    When using GATT_bm_alloc instead of ICall_malloc, everything works correctly.

    If anyone needs more information about GATT_bm_alloc, use the documentation for the GATT API at this link

    The problem is solved, I am closing this ticket