UM2264
BlueNRG-1 remote
control demo application
DocID030868 Rev 1
33/55
See BlueNRG-1 BLE stack API documentation for more information on these and following
commands.
9.1.2
Define advertising data
The BLE remote control application advertises certain manufacturing data as follows:
/* Set advertising device name as Node */
const uint8_t scan_resp_data[] = {0x05,AD_TYPE_COMPLETE_LOCAL_NAME,'N','o','d','e'}
/* Set scan response data */
hci_le_set_scan_response_data(sizeof(scan_resp_data),scan_resp_data);
/* Set Undirected Connectable Mode */
aci_gap_set_discoverable(ADV_IND, (ADV_INTERVAL_MIN_MS*1000)/625,
(ADV_INTERVAL_MAX_MS*1000)/625, PUBLIC_ADDR, NO_WHITE_LIST_USE, 0, NULL, 0, NULL, 0,
0);
/* Set advertising data */
hci_le_set_advertising_data(sizeof(adv_data),adv_data);
On the BlueNRG-1 development platform (STEVAL-IDB007V1), the temperature sensor
value is set in the
adv_data
variable.
9.1.3
Add service and characteristics
The BLE Remote Control service is added via:
aci_gatt_add_service(UUID_TYPE_128, &service_uuid, PRIMARY_SERVICE, 7,
&RCServHandle);
Where
service_uuid
is the private service 128-bit UUID allocated for the BLE remote
service (ed0ef62e-9b0d-11e4-89d3-123b93f75cba).
The command returns the service handle in
RCServHandle
.
The BLE remote control characteristic is added using the following command:
#if ENABLE_SECURITY
aci_gatt_add_char(RCServHandle, UUID_TYPE_128, &controlPointUuid, 1,
CHAR_PROP_READ|CHAR_PROP_WRITE|CHAR_PROP_WRITE_WITHOUT_RESP|CH AR_PROP_SIGNED_WRITE,
ATTR_PERMISSION_AUTHEN_READ|ATTR_PERMISSION_AUTHEN_WRITE,
GATT_NOTIFY_ATTRIBUTE_WRITE,16,1,&controlPointHandle);
#else
aci_gatt_add_char(RCServHandle, UUID_TYPE_128, &controlPointUuid, 1,
CHAR_PROP_READ|CHAR_PROP_WRITE|CHAR_PROP_WRITE_WITHOUT_RESP, ATTR_PERMISSION_NONE,
GATT_NOTIFY_ATTRIBUTE_WRITE, 16, 1,&controlPointHandle);
#endif
Where
controlPointUuid
is the private characteristic 128-bit UUID allocated for BLE
remote control characteristic (ed0efb1a-9b0d-11e4-89d3-123b93f75cba) and
controlPointHandle
is the BLE remote control characteristic handle.
If security is enabled, the characteristic properties must be set accordingly to enable
authentication on
controlPointUuid
characteristic read and write.
9.1.4
Connection with a BLE Central device
When connected to a BLE central device (another BlueNRG-1 or any Bluetooth
®
smart
ready device), the
controlPointUuid
characteristic is used to control the BLE remote
control platform LED. Each time a write operation is performed on
controlPointUuid
,
the
aci_gatt_attribute_modified_event()
callback is raised and the selected
LEDs are turned on or off.