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.

CC2541: GATT_WriteCharValue - Unknown HCI command

Part Number: CC2541


Hi,

I am currently writing commands from my External MCU which is connected the CC2541 via UART. I am sending the HCI Command 'GATT_WriteCharValue' but I am receiving the Unknown HCI Command (0x01) error code on my External MCU.

My CC2541 is running the Custom GATT profile that is found in the simplePeripheral project as well as the BLE_BRDG project. I am specifically writing to the first custom characteristic 0xFFF1.

I tried simulating this using Btool and when I send the exact same hex data, it tells me that the same error code 0x01 and 'The Attribute Handle Given Was Not Valid On This Server.'

Am I sending the correct hex values? I have my suspicions that I am incorrectly writing the connhandle and the attribute handle. Here are the hex values I am sending in order for the GATT_WriteCharValue function:

0x01 //  Command
0x92 // Opcode
0xFD // Opcode
0x05 // Data Length
0xFE // Connection Handle
0xFF // Connection Handle
0xF1 // Attribute Handle
0xFF // Attribute Handle
0xB1 // Value to be written

I assumed connhandle is 0xFFFE just like the default is in Btool.

Thanks,

Al 

  • Hello,

    ConnHandle 0xFFFE is the loopback handle, not the active connection. Can you 1) dump the GATT table from BTool and 2) provide the BTool log as an attachment?

    Best wishes
  • Hi JXS,

    Thanks for your reply! I actually went ahead and used the "Discover UUID" command in Btool to get the attributes interface. I realized the connHandle should be 0, and my attribute handle is displayed in Btool as well.

    I then wrote a value from my MCU (server) to Simple Profile Char 1 but it didn't work because clicking the Read command on Simple Profile Char 1 did not get me the value that I expected. (I double checked the order that I wrote my hexcode commands in and it is identical to ones in the Btool log).

    In my MCU debugger, I recorded the RX hex data that you would receive after sending a Write command (ie: sending 0xA1) and it appears I don't get the identical output as I would in Btool. I see the 'GAP_HCI_ExtentionCommandStatus' correctly but I do not see the 'ATT_WriteRsp'. Instead I get the following codes:

    04 ff 0a 01 05 00 00 00 04 12 12 00 01

    I tried to look up ATT error codes but none of them matches what I see in the BLE HCI documents. The closest I get is the ATT_ErrorRsp.

    Do you have any insights or solutions on this problem? 

    Thanks,

    Al

  • It looks like the problem in my previous post is because of an error code "The Attribute Handle Given was not valid on this server" when I try to access the GATT server from my MCU.
    I send the same exact codes in BTool as I do from my MCU. Since my BTool is the Client and my MCU is the Server, are there specific permissions that each have? Is there something that is blocking my MCU from reading and writing charateristics from my MCU?

    Thanks,
    Al