BlueNRG-1 chat demo application
BLE Chat client role:
aci_gap_init(GAP_CENTRAL_ROLE, 0, 0x08, &service_handle, &dev_name_char_handle,
&appearance_char_handle);
Peripheral and central BLE roles must be specified in the aci_gap_init() command.
See the BlueNRG-1 BLE stack API documentation for more information on these and
following commands.
7.1.2
Add service and characteristics
The chat service is added to the BLE chat server device via:
aci_gatt_add_service(UUID_TYPE_128, &service_uuid, PRIMARY_SERVICE,
7,&chatServHandle);
Where service_uuid is the private service 128-bit UUID allocated for the chat service
(Primary service). The command returns the service handle in chatServHandle. The TX
characteristic is added using the following command on the BLE Chat server 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 128-bit UUID allocated for the TX
characteristic (notify property). The characteristic handle is returned on the
TXCharHandle variable.
The RX characteristic is added using the following command on the BLE Chat server
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 128-bit UUID allocated for the RX
characteristic (write property). The characteristic handle is returned on the RXCharHandle
variable.
See the BlueNRG-1 BLE stack API documentation for more information on these and
following commands.
7.1.3
Enter connectable mode
The server device uses GAP API commands to enter the general discoverable mode:
aci_gap_set_discoverable(ADV_IND, 0, 0, PUBLIC_ADDR, NO_WHITE_LIST_USE,8,local_name,
0, NULL, 0, 0);
The local_name parameter contains the name presented in advertising data, as per
Bluetooth core specification version 4.2, Vol. 3, Part C, Ch. 11.
7.1.4
Connection with central device
Once the server device is discoverable by the BLE chat client device, the client device uses
aci_gap_create_connection()to connect with the BLE chat server device:
aci_gap_create_connection(0x4000, 0x4000, PUBLIC_ADDR, bdaddr, PUBLIC_ADDR, 40, 40,
0, 60, 2000 , 2000);
Where bdaddr is the peer address of the client device.
Once the two devices are connected, you can set up corresponding serial terminals and
type messages in either of them. The typed characters are stored in two respective buffers
and when the return key is pressed:
28/55
DocID030868 Rev 1
UM2264
Need help?
Do you have a question about the STEVAL-IDB007V1M SPBTLE-1S and is the answer not in the manual?