SWRU271I October 2010 – January 2020 CC2540 , CC2540T , CC2541 , CC2541-Q1 , CC2640R2F
As Section 5.5.4.1 describes, when an application starts up it must add the GATT services it supports. Each profile needs a global AddService function that can be called by the application. Some of these services are defined in the protocol stack, such as GGS_AddService and GATTServApp_AddService. User-defined services must expose their own AddService function that the application can call for profile initialization. Using SimpleProfile_AddService() as an example, these functions should do the following:
As described in Section 5.5.4.2.1.4, a pointer to one of these arrays initialized in the profile. In the AddService function, several supported connections are declared and memory is allocated for each array. One CCC is defined in the simpleGATTProfile but the profile may contain additional CCCs.
CCC values do not change between power downs and bonded device connections because they are stored in NV. For each CCC in the profile, the GATTServApp_InitCharCfg() function must be called. This function initializes the CCCs with information from a previously bonded connection. If the function cannot find the information, set the initial values to default values.
This function passes the attribute table of the profile to the GATTServApp so the attributes of the profile are added to the application-wide attribute table, which is managed by the protocol stack. The GATTServApp function assigns handles for each attribute. This function also passes pointers the callback of the profile to the stack to initiate communication between the GATTServApp and the profile.