can someoen please help me understand if i am sending data over my BLE charactersitics properly? for context, i am using core bluetooth on the ios side and i am finding that it is not being updated thatifnromation is being sent from the arduino. please help
#include <ArduinoBLE.h>
const char* deviceServiceUuid = "19b10000-e8f2-537e-4f6c-d104768a1214";
const char* deviceServiceCharacteristicUuid = "19b10001-e8f2-537e-4f6c-d104768a1214";
const char* uuid2 = "19b10002-e8f2-537e-4f6c-d104768a1214";
BLEService gestureService(deviceServiceUuid);
BLECharacteristic gestureCharacteristic(deviceServiceCharacteristicUuid, BLERead | BLEWrite, 20);
BLECharacteristic hello(uuid2, BLERead | BLEWrite, 20);
unsigned long previousMillis = 0;
const long interval = 10000; // interval in milliseconds (10 seconds)
void setup() {
Serial.begin(9600);
while (!Serial);
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("VolumeSensor");
BLE.setAdvertisedService(gestureService);
gestureService.addCharacteristic(gestureCharacteristic);
gestureService.addCharacteristic(hello);
BLE.addService(gestureService);
hello.setEventHandler(BLEWrite, helloCharacteristicRead);
BLE.advertise();
Serial.println("BLE peripheral device started, waiting for connections...");
}
void helloCharacteristicRead(BLEDevice central, BLECharacteristic characteristic) {
hello.writeValue("Hello from hello characteristic!");
}
void loop() {
BLEDevice central = BLE.central();
if (central) {
Serial.print("Connected to central: ");
Serial.println(central.address());
while (central.connected()) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
String volume = "10"; // Example volume value
gestureCharacteristic.writeValue("volume");
gestureCharacteristic.writeValue("String from gesture characteristic!");
hello.writeValue("");
Serial.print("Volume: ");
Serial.println(volume);
delay(10);
}
}
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}