English
Language : 

UM1870 Datasheet, PDF (41/58 Pages) STMicroelectronics – BlueNRG-MS development kits
UM1870
BlueNRG-MS chat demo application
6.2.1
6.2.2
6.2.3
First, BlueNRG-MS must be set up on both devices. In order to do this, a series of ACI
commands need to be sent to the processor.
Initialization
BlueNRG-MS’s stack must be correctly initialized before establishing a connection with
another Bluetooth LE device. This is done with two commands
• ACI_GATT_INIT
• BLE Chat, “Server” role:
– ACI_GAP_INIT(Role=0x01): peripheral.
BLE Chat, “Client role:
– ACI_GAP_INIT(Role=0x04): central.
Peripheral & central BLE roles must be specified inside the GAP_INIT command. See ACI
documentation for more information on these commands and on those that follow.
Add service and characteristics
The chat service is added on the BLE chat, server role device using the following command:
aci_gatt_add_serv(UUID_TYPE_128, service_uuid, PRIMARY_SERVICE, 7,
&chatServHandle);
Where service_uuid is the private service UUID 128 bits allocated for the chat service
(Primary service).
The command will return the service handle in chatServHandle.
The TX characteristic is added using the following command (on BLE Chat, Server role
device):
aci_gatt_add_char(chatServHandle, UUID_TYPE_128, charUuidTX, 20,
CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, 0, 16, 1, &TXCharHandle);
Where charUuidTX is the private characteristic UUID 128 bits allocated for the TX
characteristic (notify property). The characteristic handle is also returned (on
TXCharHandle).
The RX characteristic is added using the following command (on BLE Chat, Server role
device):
aci_gatt_add_char(chatServHandle, UUID_TYPE_128, charUuidRX, 20,
CHAR_PROP_WRITE|CHAR_PROP_WRITE_WITHOUT_RESP,
ATTR_PERMISSION_NONE, GATT_SERVER_ATTR_WRITE,16, 1, &RXCharHandle);
Where charUuidRX is the private characteristic UUID 128 bits allocated for the RX
characteristic (write property). The characteristic handle is also returned (on
RXCharHandle).
See ACI documentation for more information on these commands as well as those that
follow.
Set security requirements
BlueNRG-MS exposes a command that the application can use to specify its security
requirements. If a characteristic has security restrictions, a pairing procedure must be
DocID027602 Rev 1
41/58
58