Solved Bluetooth Device Discovery
-
@sierdzio said in Bluetooth Device Discovery:
In general, a word of warning - BLE is a mess on Android. And what's worse, on each platform (Win, mac, iOS, Linux) it works differently :-(
I'm using Qt 5.9, 5.10, 5.11 with BT LE on Android and iOS devices without problems:
- using an Addimat Waiter Lock to LogIn
- using a BT LE NFC Reader to get NFC functionality for iOS (to get the ID Apple hides) or Android devices without NFC Chip
- using custom BT LE device to measure mobile network signals
Also there's my example app "ekke's BT LE Example App" at github https://github.com/ekke/ekkesBTLEexample and also in Apple iOS AppStore and Google Play Store
perhaps it helps you @admkrk ? -
@sierdzio I can only assume the phone supports BLE since the device is discovered by the phone. I tried installing that app and got the same results as I do with mine; no devices found, however. The permissions are set in the manifest, and I was able to discover devices yesterday. I am unsure if it is good or bad that the other app could not find the device either.
Unfortunately, I only have the one phone, a Samsung, to work with and the one device. I ordered a different device, but that is on a slow boat from China so I will not see it for a while. In the mean time, I will take a look at ekkescorner's code and see if I am overlooking something simple.
Thanks for the ideas, it is hard to find a solution when I cannot figure out what the problem is.
-
@ekkescorner said in Bluetooth Device Discovery:
@sierdzio said in Bluetooth Device Discovery:
In general, a word of warning - BLE is a mess on Android. And what's worse, on each platform (Win, mac, iOS, Linux) it works differently :-(
I'm using Qt 5.9, 5.10, 5.11 with BT LE on Android and iOS devices without problems
Well, good for you and good to know :-) On my side, I've run into a myriad of issues:
- bugs in my code (obviously) :-)
- bugs in Qt (reported ofc. Some have been fixed already)
- bugs in operating systems (esp. Windows here, but also some Android implementations)
- bugs on specific devices (like the mentioned Nexuses, and a few others)
- bugs on specific devices with specific system and when specific Android SDK was used
Annoying to the point that I'd be reluctant to do any BLE-related projects in the future. I hope things improve in the future.
-
@sierdzio oooh. so I was in luck that my BT LE Apps are working well at customer site ;-)
-
I had some serious issues (with android) with subscribing to BTL services of my target device. Turns out, on android it's a 2 step process on iOS 1 step.
Took me way to long to get behind that issue.But besides that initial challenge, no problems with Qt BTLE, Its a good bit slower on android than on iOS (discovery and connect). But, I learned to accept that as part of android ;-)
-
I think I have partially solved my problem. My thorough reading of the example (cough) missed this little bit.
Note: It is a prerequisite that the remote devices actively advertise their presence.
I did not set up the device, so I do not know if that is actually the problem or not, but I think it is. Since the guy who did has not answered my email, I tried hard coding a simple socket. I got the address from a previous attempt that failed discovery, but did give me an address. That brought up the pairing dialog from my phone, which changed the activity on the device (LED), even if it did not seem to communicate.
It might be slow, but at least I am making progress.
-
Now I feel really stupid. It helps greatly if you you actually handle the button clicks. It is now working with everything hard coded, so I should not have a problem making it work right.
-
@admkrk happens to all of us ;)
that's why it's helpful to post actual code, most often someone else is able to spot the error.
Good luck progressing.
-
Thanks, I normally would have posted code, but I could not narrow the problem down and posting a huge wall of text would not have helped much, especially since it is pretty much the example I linked. For this last bit, I did not realize the code was an issue until I checked for errors. I did write the functions in C++, I just forgot to call them in the QML.
-
Well my solution was not acceptable. I can understand why, as the user would have to manually enter the address and uuid, I did not care for it either. I ran the desktop example, and it found the device. I made two changes and my copy of the original example is now finding the device. I do not think the first one made a difference, I started the agent without arguments. The one that made a difference was a no brainer once I reread the add device function
void Device::addDevice(const QBluetoothDeviceInfo &info) { //if(info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) //{ DeviceInfo *d = new DeviceInfo(info); devices.append(d); //} }
Anyway, I thought I should update this with the real solution to fixing the example I was using.