5.3.1 Peripheral Role
The peripheral GAPRole task is defined in peripheral.c and peripheral.h. For descriptions of the full API including commands, configurable parameters, events, and callbacks, see Section B.
The general steps to use this module are the following:
- Initialize the GAPRole parameters, see Section B.2. Do this initialization in the application initialization function (that is, SimpleBLEPeripheral_init()).
- Initialize the GAPRole task. Do this initialization when processing START_DEVICE_EVT. This initialization involves passing function pointers to application callback functions. Section B.3 defines these callbacks.
- Send GAPRole commands from the application. The following is an example of the application using GAPRole_TerminateConnection().
NOTE
The return value from the Bluetooth Low Energy protocol stack only indicates whether the attempt to terminate the connection was initiated successfully. The termination of connection event sent to the application asynchronously and is described in the following example. The API in Section B.3 lists the return parameters for each command and associated callback function events.
- The GAPRole task processes most of the GAP-related events passed to it from the Bluetooth Low Energy protocol stack. The task forwards some events to the application. The following is an example tracing the GAP_LINK_TERMINATED_EVENT from the Bluetooth Low Energy protocol stack to the application.