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.

LAUNCHXL-CC2640R2: Adding Services with selfEntity parameter or not?

Part Number: LAUNCHXL-CC2640R2

Hi,

   I am porting sensortag_cc2650lp_app from BLE 2.2. to CC2640R2 SDK. I am using the porting guide, simple_peripheral and project_zero as references. At porting guide this is mentioned below.regarding Listing 30. ICall Registration.

// Register the current thread as an ICall dispatcher application
  // so that the application can send and receive messages via ICall to Stack.
  ICall_registerApp(&selfEntity, &syncEvent);

"The application supplies the selfEntity and syncEvent inputs. These inputs are initialized for the task of the client (for example, application) when the ICall_registerApp() returns are initialized. These objects are subsequently used by ICall to facilitate messaging between the application and server tasks. The syncEvent argument represents the Events Module handle for signaling and the selfEntity represents the destination message queue of the task. Each task registering with ICall have unique syncEvent and selfEntity identifiers."

I see at project zero that "selfEntity" is passed to LedService_AddService(), ButtonService_AddService(), DataService_AddService().

// Add services to GATT server and give ID of this task for Indication acks.
  LedService_AddService( selfEntity );
  ButtonService_AddService( selfEntity );
  DataService_AddService( selfEntity );

If passing "selfEntity" to xxxxxx_AddService() C API's is necessary then, I would need to modify all xxxxx_AddService() C API's to accept "selfEntity"? Is that right or wrong? Example, I would need to modify the Io_addService() below to have an argument for "selfEntity".

/*********************************************************************
 * @fn      Io_addService
 *
 * @brief   Initializes the IO Service service by registering
 *          GATT attributes with the GATT server.
 *
 * @return  Success or Failure
 */
bStatus_t Io_addService(void)
{
  // Allocate Client Characteristic Configuration table
  ioDataConfig = (gattCharCfg_t *)ICall_malloc(sizeof(gattCharCfg_t) *
                                                linkDBNumConns);
  if (ioDataConfig == NULL)
  {
    return (bleMemAllocError);
  }
  
  // Initialize Client Characteristic Configuration attributes
  GATTServApp_InitCharCfg(INVALID_CONNHANDLE, ioDataConfig);

  // Register GATT attribute list and CBs with GATT Server App
  return GATTServApp_RegisterService(ioAttrTbl,
                                      GATT_NUM_ATTRS(ioAttrTbl),
                                      GATT_MAX_ENCRYPT_KEY_SIZE,
                                      &ioCBs);
}

- kel

 

  • Hi,

    The selfEntity argument is only needed when your service contains characteristics with indication property, however, it does not hurt if your service does not have indication characteristics but pass selfEntity in the argument.
  • Christin Lee said:
    The selfEntity argument is only needed when your service contains characteristics with indication property

        I will take note on that. So far all service that I use don't have GATT_PROP_INDICATE set. So, I do not need to modify them.

    Christin Lee said:
    it does not hurt if your service does not have indication characteristics but pass selfEntity in the argument

        I will remember that for project zero the selfEntity at AddService C API's are maybe for future code improvement. At the moment selfEntity has no purpose at the AddService C API's below.

      // Add services to GATT server and give ID of this task for Indication acks.
      LedService_AddService( selfEntity );
      ButtonService_AddService( selfEntity );
      DataService_AddService( selfEntity );

    - kel

    it does not hurt if your service does not have indication characteristics but pass selfEntity in the argument