![Cypress EZ-BLE PRoC AN9684 Скачать руководство пользователя страница 36](http://html1.mh-extra.com/html/cypress/ez-ble-proc-an9684/ez-ble-proc-an9684_getting-started_2705915036.webp)
Getting Started With EZ-
BLE™ PRoC™ Module
www.cypress.com
Document No.: 001-96841 Rev. **
36
Figure 47. System Initialization Firmware
B L E S t a c k E v e n t H a n d l e r
The BLE stack within the BLE Component generates a list of events to provide the BLE interface status and data to the
application firmware through the BLE stack event handler registered during the CyBle_Start API call. The event handler must
handle basic events from the stack and configure the stack with the application information to successfully establish and
maintain the BLE link. For the
‗Find Me‘ application that you are creating, the BLE stack event handler must process all the
events described in
Table 5
.
The flow chart and the firmware for handling the BLE stack events are shown in
Figure 48
and
Figure 49.
Table 5. Bluetooth Low Energy Stack Events
BLE Stack Event Name
Event Description
Event Handler Action
CYBLE_EVT_STACK_ON
Bluetooth Low Energy firmware stack
within the BLE Component initialized
successfully
Start Advertisement and reflect
advertisement state on the LEDs
CYBLE_EVT_GAP_DEVICE_DISCONNECTED
Bluetooth
Low
Energy
link
is
disconnected from the peer device
Start re-advertisement and reflect
advertisement state on the LEDs
CYBLE_EVT_GAP_DEVICE_CONNECTED
Bluetooth
Low
Energy
link
is
established with the peer device
Update
the
Bluetooth
Low
Energy link state on the LEDs
CYBLE_EVT_TIMEOUT
Bluetooth Low Energy stack generic
timeout event
Configure the device in hibernate
mode
if
you
received
an
advertisement timeout event
CYBLE_API_RESULT_T apiResult;
CYBLE_STATE_T bleState;
/* Enable Global Interrupts */
CyGlobalIntEnable;
/* Start the BLE component and register a stack callback
routine */
apiResult = CyBle_Start(StackEventHandler);
if
(apiResult != CYBLE_ERROR_OK)
{
/* BLE stack initialization failed, check
your configuration */
CYASSERT(0);
}
/* Register service specific callback routine for IAS */
CyBle_IasRegisterAttrCallback(IasEventHandler);