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 add a new Service UUID rather than Primary/Secondary Services

Other Parts Discussed in Thread: CC2640, 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 (0x3532), Invalid Parameter 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.

--------------------------------------------------------------------
[13] : <Tx> - 07:48:44.153
-Type           : 0x01 (Command)
-OpCode         : 0xFDFC (GATT_AddService)
-Data Length    : 0x04 (4) byte(s)
 UUID           : 0x3532 (13618)
 NumAttrs       : 0x0003 (3)
Dump(Tx):
0000:01 FC FD 04 32 35 03 00                         .....(..
--------------------------------------------------------------------
[14] : <Rx> - 07:48:44.206
-Type           : 0x04 (Event)
-EventCode      : 0x00FF (Event)
-Data Length    : 0x06 (6) bytes(s)
 Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
 Status         : 0x02 (0) (InvalidParameter)
 OpCode         : 0xFDFC (GATT_AddService)
 DataLength     : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 02 FC FD 00                      .........
--------------------------------------------------------------------

Kindly let me know whether apart from Primary and Secondary Services available in BLE Stack, we can able to add a new service (0x3532) and under this service I need to add my own characteristics.

Am I executing the proper GATT command to add a new service or any other step i need to follow to add a new service.

 

Thanks in advance.

 

Regards,

Ramesh Kumar

  • Hello Ramesh,

    This seems to be related to your other post: e2e.ti.com/.../437491 ?
    Did you rebuild the CC2540USB dongle fw with the GATT DB offchip?

    Best wishes
  • Hi Ramesh,

    As mentioned already, make sure you have defined GATT_DB_OFF_CHIP in your IAR build. This is described in:
    processors.wiki.ti.com/.../LPRF_BLE_NPGATT

    After compiling with the GATT_DB_OFF_CHIP set in IAR, your PC application should be able to talk to the cc2540USB using the TI vendor specific HCI commands. This API is described in the BLE Stack documentation, which you can find in your stack install at BLE_STACK_INSTALL_PATH\Documents\TI_BLE_Vendor_Specific_HCI_Guide.pdf.

    It appears you are using GATT_AddService with an invalid parameter. The Vendor specific HCI guide (page 189) explains that you can only add services as either primary or secondary as defined by the Bluetooth SIG. (UUID = 0x2800 and 0x2801 respectively). Your service can have its own custom UUID, but this data would be stored in the value of the service declaration.

    The PC application you're developing would handle the implementation of your custom service.

    It should be noted that we are working on a Simple Applications Processor project for the CC2640 that is set to release at the end of the month. It greatly simplifies the interface between the applications processor and the network processor, which might make your development efforts much easier.

  • Hi JXS,

    Thanks for the reply.

    With GATT_DB_OFF_CHIP Network Processor configuration, I can able to add service and add permission using GATT Commands. But my question is apart from Primary and Secondary Services, whether I can able to add my own custom services or not.

    Lyons has answered my question.

    Hi Lyons,

    As you mentioned all the attributes should be added in either Primary or Secondary services only. I am not clear on the point you mentioned above.
    "Your service can have its own custom UUID, but this data would be stored in the value of the service declaration. "

    How should I save my own custom UUID for the existing service. I can use the above feature to declare that the Service with my own Custom UUID. Or Custom Service UUID can be registerable from CC2640 project from the next month??

    *****************************************************************************************************************************

    I have one more query too, how to deleted the existing service from the Server BLE dongle. Since GATT_DelService requires handle of the existing service, which cannot able to retrieve from the Server side BLE.

    The related post is given below for reference.

    e2e.ti.com/.../440518

    Thanks and Regards,
    Ramesh Kumar
  • Ramesh,

    Happy to help. The service declaration is an attribute, which is comprised of a handle, UUID, and value. Service declaration UUIDs must be primary or secondary (0x2800, 0x2801) as mandated by the Bluetooth SIG. However, the value field of the service declaration attribute is user customizable. You can think of the value as your custom service UUID. See p179 of the TI_BLE_Vendor_Specific_HCI_Guide for an API function that uses this convention.

    • GATT_DiscPrimaryServiceUUID(0xFD86)
    • Used when a client wants to discover primary services on the server (like your PC with the CC2540)
    • Scans all primary service attributes on the server for one with a value matching the parameter (your custom service UUID)

    Attached is an example of a custom service, it has a service declaration and a few characteristic declarations and their values.

    It is up to your PC app to implement the Profile  that makes sense of your custom service (in the example above, this means writing code on the client app to understand that value 0xAAAA means CustomSensor1 Service for example). See page 9 figure 4 of the Vendor Specific HCI guide for clarification as to what code resides on the application processor(your PC) and which code resides on the network processor(CC2540).

    The simple application processor (SAP) project on the CC2640 aims to provide the user with a code base for not only the network processor, but also the applications processor, which makes development for the applications processor easier.

    Let me look into your second question, I hope this clears up your first.