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.

Adding a new GATT Service and its characteristic, updating existing characteristics permission

Other Parts Discussed in Thread: CC2540

Hi,

I am using CC2540 USB BLE Dongle with PC Application implemented in .Net.

I am trying to add and register a new service and its characteristics in the BLE stack.

When I execute the GATT_AddService command for adding a new service (0x3432), failure is received stating the service has not registered.

PC Environment:

-          CC2540 USB Dongle used (In this dongle flashed the image “HostTestReleaseCC2540Usb.hex” which is available as part of BLE Stack for CC254x-1.4.0)

-          PC Application is built on Microsoft Visual Studio 2010 - C# .Net 

 

Below is the command sequence executed and its response from the stack. 

--------------------------------------------------------------------

[17] : <Tx> - 08:02:14.196

-Type           : 0x01 (Command)

-OpCode         : 0xFDFC (GATT_AddService)

-Data Length   : 0x04 (4) byte(s)

UUID           : 0x3532 (13618)

NumAttrs       : 0x0002 (2)

Dump(Tx):

0000:01 FC FD 04 32 35 02 00                         .....(..

--------------------------------------------------------------------

[18] : <Rx> - 08:02:14.228

-Type           : 0x04 (Event)

-EventCode     : 0x00FF (Event)

-Data Length   : 0x06 (6) bytes(s)

Event         : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)

Status         : 0x01 (1) (Failure)

OpCode         : 0xFDFC (GATT_AddService)

DataLength     : 0x00 (0)

Dump(Rx):

0000:04 FF 06 7F 06 01 FC FD 00                    .........

--------------------------------------------------------------------

 

Also, I didn’t find any command to add new characteristic to the service.

When I try to update the permission of the existing characteristics, the stack gives a failure.

Below is the command sequence executed and its response from the stack.

 

--------------------------------------------------------------------

[19] : <Tx> - 08:02:24.749

-Type           : 0x01 (Command)

-OpCode         : 0xFDFE (GATT_AddAttribute)

-Data Length   : 0x03 (3) byte(s)

UUID           : 35:34

Permissions   : 0x01 (1) (GATT_PERMIT_READ)

Dump(Tx):

0000:01 FE FD 03 34 35 01                           .....*.

--------------------------------------------------------------------

[20] : <Rx> - 08:02:24.771

-Type           : 0x04 (Event)

-EventCode     : 0x00FF (Event)

-Data Length   : 0x06 (6) bytes(s)

Event         : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)

Status         : 0x01 (1) (Failure)

OpCode         : 0xFDFE (GATT_AddAttribute)

DataLength     : 0x00 (0)

Dump(Rx):

0000:04 FF 06 7F 06 01 FE FD 00                     .........

--------------------------------------------------------------------

 

Kindly let me know the how to add a new service and its characteristic in CC2540 BLE Stack. How to update the existing characteristics permission.

 

Thanks and Regards,

Ramesh Kumar

  • Hello,

    Please refer to the GATT_DB_OFF_CHIP Network Processor configuration on the wiki: processors.wiki.ti.com/.../CC254X_WITH_EXT_MCU

    You'll need to rebuild the Host Test project with this preprocessor setting enabled as the default hex file in the SDK is not built with this option.

    Best wishes
  • Hi JXS,

    Thanks for the reply.

    With GATT_DB_OFF_CHIP Network Processor configuration, now I can able to add service and add permission using GATT Commands.

    But, when I try to add a new custom service (new UUID) using GATT_AddService command stack is returning "Status : 0x16 (22) (Waiting)status.

    Some times I am receiving "Status : 0x17 (23) (Timed Out Performing Function)" when I am adding permission.

    I am getting the following reponse from BLE stack, when I try to add a new characteristic and trying to read the same.

    --------------------------------------------------------------------
    [40] : <Tx> - 07:53:44.846
    -Type : 0x01 (Command)
    -OpCode : 0xFDFE (GATT_AddAttribute)
    -Data Length : 0x03 (3) byte(s)
    UUID : 35:34
    Permissions : 0x04 (4) (GATT_PERMIT_AUTHEN_READ)
    Dump(Tx):
    0000:01 FE FD 03 35 34 04 ....54.
    --------------------------------------------------------------------
    [41] : <Warning> - 07:53:44.871
    The Last 4 Bytes In The Following Message Were Not Decoded
    (Message Has More Than The Expected Number Of Data Bytes)
    --------------------------------------------------------------------
    [42] : <Rx> - 07:53:44.867
    -Type : 0x04 (Event)
    -EventCode : 0x00FF (Event)
    -Data Length : 0x0A (10) bytes(s)
    Event : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
    Status : 0x00 (0) (Success)
    OpCode : 0xFDFE (GATT_AddAttribute)
    DataLength : 0x04 (4)
    Dump(Rx):
    0000:04 FF 0A 7F 06 00 FE FD 04 04 00 05 00 .............
    --------------------------------------------------------------------
    [43] : <Tx> - 07:53:49.540
    -Type : 0x01 (Command)
    -OpCode : 0xFDB4 (GATT_ReadUsingCharUUID)
    -Data Length : 0x08 (8) byte(s)
    ConnHandle : 0xFFFE (65534)
    StartHandle : 0x0001 (1)
    EndHandle : 0xFFFF (65535)
    Type : 35:34
    Dump(Tx):
    0000:01 B4 FD 08 FE FF 01 00 FF FF 35 34 ..........54
    --------------------------------------------------------------------
    [44] : <Rx> - 07:53:49.557
    -Type : 0x04 (Event)
    -EventCode : 0x00FF (Event)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
    Status : 0x17 (23) (Timed Out Performing Function)
    OpCode : 0xFDB4 (GATT_ReadUsingCharUUID)
    DataLength : 0x00 (0)
    Dump(Rx):
    0000:04 FF 06 7F 06 17 B4 FD 00 .........
    --------------------------------------------------------------------

    I am not sure whether I am using the right procedure to create the characteristic and access the same.

    Please help me to add a new custom service and its characteristic. If there are any sample to execute the services and chatacteristics.

    Thanks and REgards,
    Ramesh Kumar