English
Language : 

AN91162 Datasheet, PDF (26/43 Pages) Ramtron International Corporation – Creating a BLE Custom Profile
Creating a BLE Custom Profile
Event Handler Registration
Unlike other Components’ startup, the BLE Component requires the registering of an event callback function while starting
the Component. This function is called to handle BLE events, including general events such as stack ON and events at the
GAP/GATT layer such as connection, disconnection, and write command. The General event handler function is defined in
BLEProcess.c in the example project. You can either place it in a separate file or in main.c. See Table 5 for a description of the
events that are included in the switch statement. In the function definition shown below, each case is empty. We will add code
to handle each event in the next section.
void GeneralEventHandler(uint32 event, void * eventParam)
{
/* Structure to store data written by Client */
CYBLE_GATTS_WRITE_REQ_PARAM_T *wrReqParam;
/* 'RGBledData[]' is an array to store 4 bytes of RGB LED data*/
uint8 RGBledData[RGB_CHAR_DATA_LEN];
switch(event)
{
case CYBLE_EVT_STACK_ON:
/* This event is generated when BLE stack is ON */
break;
case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:
/* This event is generated whenever Advertisement starts or stops */
break;
case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
/* This event is generated at GAP disconnection. */
break;
case CYBLE_EVT_GATTS_WRITE_REQ:
/* This event is generated when the connected Central */
/* device sends a Write request. */
/* The parameter ‘eventParam’ contains the data written */
break;
case CYBLE_EVT_GATT_DISCONNECT_IND:
/* This event is generated at GATT disconnection. */
break;
default:
}
}
break;
These events are the basic events to be handled in the application to allow a successful BLE connection. These events are
explained in Table 5. Other events that can be generated by the BLE Component are described in the BLE_Stack.h file in
“CYBLE_EVENT_T” enum.
www.cypress.com
Document No. 001-91162 Rev. *A
26