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.

How to retrieve the handle of the service used for GATT_DelService command

Other Parts Discussed in Thread: CC2540

Hi,

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

I am trying to delete the already registered service and its characteristics in the BLE stack.

I have executed the GATT_AddService command for adding a new service and GATT_AddAttribute command for characteristics. When I try to deleted the newly added service and characteristics unless I find the handle for the service the GATT_DelService command getting failure.

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> - 04:14:10.584

-Type           : 0x01 (Command)

-OpCode         : 0xFDFD (GATT_DelService)

-Data Length   : 0x02 (2) byte(s)

Handle         : 0x0001 (1)

Dump(Tx):

0000:01 FD FD 02 01 00                               ......

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

[18] : <Rx> - 04:14:10.600

-Type           : 0x04 (Event)

-EventCode     : 0x00FF (Event)

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

Event         : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)

Status         : 0x01 (1) (Failure)

OpCode         : 0xFDFD (GATT_DelService)

DataLength     : 0x00 (0)

Dump(Rx):

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

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

 

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

[29] : <Tx> - 04:18:27.998

-Type           : 0x01 (Command)

-OpCode         : 0xFDFD (GATT_DelService)

-Data Length   : 0x02 (2) byte(s)

Handle         : 0x0003 (3)

Dump(Tx):

0000:01 FD FD 02 03 00                               ......

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

[30] : <Rx> - 04:18:28.029

-Type           : 0x04 (Event)

-EventCode     : 0x00FF (Event)

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

Event         : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)

Status         : 0x00 (0) (Success)

OpCode         : 0xFDFD (GATT_DelService)

DataLength     : 0x00 (0)

Dump(Rx):

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

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

 

I can able to list the handle of services and characteristics of the connected BLE device (Server) in cleint side of BLE stack using GATT_DescAllCharsDescs command. Similarly is there any HCI command to get the handle of the existing services/characteristics from the Server BLE stack itslef. 

Kindly guide me to retrieve the handle of the Services, or how to delete the exisiting services in the Server BLE Stack. 

Thanks in advance. 

Regards,

Ramesh Kumar

  • Hi Ramesh,

    Use the ATT_FindInfoReq HCI command to return a table of attributes with their UUIDs and handles. From there, determine the handle of your service and pass that to the function GATT_DelService . When scanning using the ATT_FindInfoReq, be sure to pass 0x0001-0xFFFF as the range of handles to scan.
  • Hi,

    CLient executes ATT_FindInfoReq HCI command is used to return a table of attributes with their UUIDs and handles from the Service side where it has been registered.

    I want to delete the existing service, where it has been registered in Server itself. I have been tried to delete the service with the handle received from the ATT_FindInfoReq in Client side, but no service has been available from it.

    Unless I give the correct handle of the service, GATT_DelService command is not deleting the service, which is available in Server side.

    I am thinking that, we can request the list of handles received from the client side using ATT_FindInfoReq command, and sent to Server??

    Hope you understand my query now, or let me know if not clear.

    Thanks and REgards,
    Ramesh Kumar
  • Ramesh,

    Take a look at sections 3-4 of this document: http://processors.wiki.ti.com/index.php/LPRF_BLE_NPGATT. You'll see their setup is very similar to yours (client PC app controlling network processor (CC2540 USB dongle).

    The example script (client) adds two services to the server(dongle), along with their associated characteristics. The client then uses ATT_FindInfoReq to verify the GATT table that is registered with the server. Using the data received from the ATT_FindInfoReq, the handle of the service to be deleted can be determined by the client. Once you have determined the handle, you can pass that information to the GATT_DelService command.

    I hope this helps. If you are able to share more information about your end application, and what you are trying to achieve by adding and deleting services, maybe I can suggest a better way.