bt_gatt_service_create()
Description
Function to create a GATT service and prepare characteristics to be added to it. Only 128-bit (16-byte) UUIDs are available for creation.
GATT server is limited to 40 attributes, 10 services, 13 characteristics of which 7 can be used for notifications.
Take note that system services also use these limits. Refer to the system services page for more information.
Syntax
bt_gatt_service_create(service_uuid[]);
Parameters
Variable | Input |
|---|---|
| Service UUID. Must be up to 16 bytes (128-bits) length. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Successfully created a GATT service. |
SCRIPT_OPERATION_FAILED | Possible reasons:
|
SCRIPT_NO_ACCESS | Bluetooth GATT server is not initialized. |
SCRIPT_PARAM_INVALID | Possible reasons:
|
Function call example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <socket>
#include <bluetooth>
new service_uuid[UUID_LENGTH_128_BIT] = [0x08, 0x07, 0x06, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB];
main()
{
bt_init();
bt_gatt_server_init();
bt_gatt_service_create(service_uuid);
for(;;)
{
Delay(100);
}
}