#include <BLE.h>
char 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
};
void setup() {
ble.begin();
ble.addService(&simpleService);
ble.writeValue(&char1, char1Value);
ble.writeValue(&char2, char2Value);
ble.writeValue(&char3, char3Value);
ble.writeValue(&char4, char4Value);
ble.setAdvertName("Simple Profile");
ble.startAdvert();
}
void loop() {
ble.handleEvents();
// Increment the value of characteristic 1 every second
if (millis() % 1000 == 0)
{
char1Value++;
ble.writeValue(&char1, char1Value);
}
}