BLE_Service

Description

The data type used to declare a service.

Syntax

    BLE_Char *arrayOfChars[] = {&char1, &char2, ...};
    BLE_Service service =
    {
      UUID,
      numChars, arrayOfChars
    };

Parameters

UUID: The 2 or 16 byte identifier for the service. 2 byte UUID’s are reserved for officially adopted services. For creating a 16 byte UUID for custom services, see this reference.

numChars: The number of characteristics in the service and the number of elements in arrayOfChars.

arrayOfChars: A pointer to an array of BLE_Char’s, declared using the syntax above or below in the example.

Example

    #include <BLE.h>

    byte char1Value = 0;
    int char2Value = 0;
    long char3Value = 0;
    String char4Value = String("Hello, world!");

    BLE_Char char1 =
    {
     {0xF1, 0xFF},
     BLE_READABLE | BLE_WRITABLE,
     "Characteristic 1"
    };

    BLE_Char char2 =
    {
     {0xF2, 0xFF},
     BLE_READABLE,
     "Characteristic 2"
    };

    BLE_Char char3 =
    {
     {0xF3, 0xFF},
     BLE_WRITABLE,
     "Characteristic 3"
    };

    BLE_Char char4 =
    {
     {0xF4, 0xFF},
     BLE_NOTIFIABLE,
     "Characteristic 4"
    };

    BLE_Char *simpleServiceChars[] = {&char1, &char2, &char3, &char4};

    BLE_Service simpleService =
    {
     {0xF0, 0xFF},
     4, simpleServiceChars
    };
Guide Home