Reputation: 71
_scanStream = flutterReactiveBle
.scanForDevices(withServices: <Uuid>[]).listen((device) {
_foundBleUARTDevices.add(device);
for (var element in _foundBleUARTDevices) {
print(
"${element.serviceUuids}---${element.name}---${element.id}---${element.serviceData}---${element.rssi}");
}
I am using the above code snippet to scan for BLE devices and on discovering and printing them out, the UUID is an empty list, and when I try to scan with a specific UUID no device is found. I am using ESP32 as the BLE device and android as the platform to run/debug the app
Upvotes: 1
Views: 740
Reputation: 71
after waiting for hours, I got no answer from anyone and I had to keep trying, and what I find out is that I can actually connect to the BLE device without the Service UUID but just the id which is the BLE device mac address I think.
I used the below snippet to establish the connection:
void _connectToDevice() {
// We're done scanning, we can cancel it
// _scanStream.cancel();
// Let's listen to our connection so we can make updates on a state change
Stream<ConnectionStateUpdate> _currentConnectionStream = flutterReactiveBle
.connectToAdvertisingDevice(
id: _ubiqueDevice.id,
prescanDuration: const Duration(seconds: 3),
withServices: <Uuid>[]);
_currentConnectionStream.listen((event) {
print(":::::::: ${event.connectionState.name}");
});
}
so I will now proceed to see how I can read and write to the characteristics, i hope someone find this helpful
Upvotes: 1