TI CC2540 Bluetooth low energy Sample Applications Guide v1.4.1 SWRU297 Version 1.4.1
Page 19 of 36
Copyright © 2011-2015 Texas Instruments, Inc
To disconnect press Joystick Center again. To reconnect to the same device again press
Joystick Center again.
7.1.3 Record Filter Configuration
Glucose record requests use filters to select the records that will be operated on by the request.
These filters are configured in the collector using compile time configuration.
In file glucoseCollector.c, macro GLUCOSE_FILTER_ENABLED controls whether filters are used.
When set to FALSE, operations that read, erase, or get the number of records will operate on all
records. When set to TRUE, these operations will use either a time filter or sequence number
filter, as configured in macro DEFAULT_FILTER_TYPE. When set to
CTL_PNT_FILTER_SEQNUM the collector will filter on sequence number. When set to
CTL_PNT_FILTER_TIME the collector will filter on time.
File glucoseCollector.c has hardcoded time and sequence number filter values. These are set in
variables filterTime1, filterTime2, filterSeqNum1, and filterSeqNum2.
7.2 Software Description
The application is implemented in the following files:
glucoseCollector.c: Main initialization, event handling and callback functions.
glucose_config.c: Characteristic configuration functions.
glucose_discovery.c: Service discovery functions.
glucose_ind.c: Indication and notification handling functions.
glucose_ctlpnt.c: Record access control point functions.
7.2.1 Initialization
The initialization of the application occurs in two phases: first, the GlucColl_Init function is called
by the OSAL. This function configures parameters in the central profile, GAP, and GAP bond
manager and also initializes GATT for client operation. It also sets up standard GATT and GAP
services in the attribute server. Then it sets an OSAL START_DEVICE_EVT event. This triggers
the second phase of the initialization, which can be found within the GlucColl_ProcessEvent
function. During this phase, the GAPCentralRole_StartDevice function is called to set up the
GAP functions of the application. Then GAPBondMgr_Register is called to register with the
bond manager.
7.2.2 Event Processing
The application has two main event processing functions, GlucColl_ProcessEvent and
GlucColl_ProcessOSALMsg.
Function GlucColl_ProcessEvent handles events as follows:
SYS_EVENT_MSG: Service the OSAL queue and process OSAL messages.
START_DEVICE_EVT: Start the device, as described in the previous section.
START_DISCOVERY_EVT: Start service discovery.
PROCEDURE_TIMEOUT_EVT: A glucose record access procedure has timed out.
Function GlucColl_ProcessOSALMsg handles OSAL messages as follows:
KEY_CHANGE messages: Call function GlucColl_HandleKeys to handle keypresses.
GATT_MSG_EVENT messages: Call function GlucCollProcessGATTMsg to handle
messages from GATT.
7.2.3 Callbacks
The application callback functions are as follows:
GlucCollCentralEventCB: This is the GAP event callback. It processes GAP events for
initialization, device discovery, and link connect/disconnect.