bt_gatt_server_start()
Description
Registers all created GATT services and makes them visible.
Bluetooth advertising must be set up for the device to start advertising as connectable. Refer to the GATT server guide for more information.
In the event that the GATT server attributes have been altered and a GATT client device was either previously connected or connected prior to the registration of all services, it may be necessary for the client to perform a service rediscovery to access the updated GATT server attributes.
Syntax
bt_gatt_server_start();
Parameters
This function has no parameters.
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Successfully registered all services. |
SCRIPT_OPERATION_FAILED | Failed to register one or more services. |
SCRIPT_NO_ACCESS | Bluetooth GATT server is not initialized. |
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];
new characteristic_uuid[UUID_LENGTH_128_BIT] = [0x05, 0x12, 0x96, 0x99, 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);
bt_gatt_chrc_create(characteristic_uuid, BT_GATT_PROP_READ | BT_GATT_PROP_NOTIFY, 20, 0);
bt_gatt_server_start();
for (;;)
{
Delay(100);
}
}