English
Language : 

AN91162 Datasheet, PDF (27/43 Pages) Ramtron International Corporation – Creating a BLE Custom Profile
Creating a BLE Custom Profile
Table 5. BLE Events
Event Name
CYBLE_EVT_STACK_ON
CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP
Event Description
BLE stack is initialized successfully after
calling CyBle_Start().
Peripheral advertising starts or stops.
CYBLE_EVT_GAP_DEVICE_DISCONNECTED
CYBLE_EVT_GATT_CONNECT_IND
The BLE connection between the Peripheral
and Central device is disconnected.
A connection has been established between
the Peripheral and a Central device.
CYBLE_EVT_GATT_DISCONNECT_IND
CYBLE_EVT_GATTS_WRITE_REQ
The connection with the Central device has
been disconnected.
A write request has been sent from the
GATT client device.
Event Handling
When BLE stack is ON, start the
advertisement.
Go into a low-power mode or
restart the advertisement.
Go into a low-power mode or
restart the advertisement.
Update the connection handle
variable.
Not used in this project.
Reset the GATT database
values.
Extract the data sent by the
GATT client and send the Write
response.
Start Advertisement
As the project is a GAP Peripheral, it needs to start advertisement to allow a GAP Central device to connect to it. There are
three events where advertisement will be started. Place the respective code in the general event callback function for the
following events:
a) When the system powers up and the BLE Stack is ON (event CYBLE_EVT_STACK_ON)
case CYBLE_EVT_STACK_ON:
/* BLE stack is on. Start BLE advertisement */
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
break;
b) When the advertisement timeout has occurred and the existing advertisement has stopped (event
CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP)
case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:
/* This event is generated whenever Advertisement starts or stops.
The exact state of advertisement is obtained by CyBle_State() */
if(CyBle_GetState() == CYBLE_STATE_DISCONNECTED)
{
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
}
break;
c) When the existing connection with a Central device has been
CYBLE_EVT_GAP_DEVICE_DISCONNECTED)
case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
/* This event is generated at GAP disconnection. */
/* Restart advertisement */
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
break;
disconnected
(event
www.cypress.com
Document No. 001-91162 Rev. *A
27