Hi everyone,
I'm using a Particle Photon 2 as a BLE Central device, and I’m trying to connect to my iPhone running the nRF Connect app as the Peripheral. The goal is for the Photon to scan for a specific Service UUID, connect, and subscribe to a Notifiable Characteristic.
Scanning works, it finds the correct device that is advertising my custom UUID, but whenever it gets to the characteristic portion, it always fails.
getCharacteristicByUUID is always false and ledChar.subscribe() is never reached.
BleUuid serviceUuid("cfb05646-569a-4275-9f52-6324ddb63a6a");
BleUuid charUuid("00001525-1212-EFDE-1523-785FEABCD123");
BlePeerDevice peer;
BleCharacteristic ledChar;
void loop() {
if (!peer.connected()) {
int scanCount = BLE.scan(scanResults, scanResultsCount);
if (scanCount > 0) {
for (int i = 0; i < scanCount; i++) {
BleUuid foundServiceUuid;
size_t svcCount = scanResults[i].advertisingData().serviceUUID(&foundServiceUuid, 1);
if (svcCount > 0 && foundServiceUuid == serviceUuid) {
peer = BLE.connect(scanResults[i].address());
if (peer.connected()) {
Log.info("Connected to Peripheral");
if (peer.getCharacteristicByUUID(ledChar, charUuid)) {
Log.info("Found characteristic. Subscribing...");
ledChar.subscribe(assignReceivedValue);
} else {
Log.info("Characteristic Not Found.");
}
}
}
}
}
}
else {
// do something with ledChar
}
}
On nRF Connect, my Advertiser uses the correct Service UUID and my Server uses the same Service UUID and then the Characteristic UUID under it.
I am decently sure that the UUID's I set match, as I've had to have checked it around 20 times at this point.
I'm pretty new to learning this sort of stuff and coding in general, and I'm honestly at a loss here, so any help would be greatly appreciated.