Hello!
I'm trying to discover an Arduino BLE service from an iphone.
This is the simple code running on the board:
#include <ArduinoBLE.h>
#include <Arduino.h>
BLEService randomService("8befd7c0-3e3f-11ea-b77f-2e728ce88125");
BLEFloatCharacteristic randomChar("8befd8c1-3e3f-11ea-b77f-2e728ce88125", BLERead | BLEWrite);
void setup() {
Serial.begin(9600);
Serial.println("Setting up....");
while (!Serial);
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("Random Service");
BLE.setAdvertisedService(randomService);
randomService.addCharacteristic(randomChar);
BLE.addService(randomService);
BLE.advertise();
Serial.println("Bluetooth device active, waiting for connections...");
}
void loop() {
float random = getrandomReading();
randomChar.writeValue(random);
BLE.poll();
delay(1000);
}
float getrandomReading() {
return random(0, 100);
}
I'm using LightBlue to debug, both on iPhone and on Android.
On Android, I can see the service with the id I'm setting, named "Random Service". On the iPhone, I see a service named Arduino, with a different id. I'm assuming the default id for the board.
On both devices, I can connect to the service and pull random numbers with blue light.
I've restarted the iPhone multiple times, to make sure that there are no caching issues on the iPhone device. Maybe caching doesn't work as I think on the iPhone.
Any ideas on what I might be missing?