JoEmbedded 0 Posted December 18, 2021 Hello Forum, I developed an IoT Sensor with BLE-Hardware (Nordic CPU, https://github.com/joembedded/Open-SDI12-Blue ), which works excellent and I can access it easily (and without pairing) via Web-Bluetooth API (HTML/JS) an Windows and Android. Now, while trying the same in RAD Studio (using WIndows 11), it seems ONLY paired devices are accepted for "DiscoverServices()". This makes (especially for BLE) no sense... I recognised a flag in the Windows Settings to "allow this for special APPs", like MS LE Explorer. I found for the "TBluetoothLEDevice*" entry a Flag "Paired" Does anybody know, if there is a automatic solution? Thanky for your help! Jo ( JoEmbedded.de ) //This is from the RAD Studio BLE-Scanner-Demo (just C, but Data is same for Delphi) void __fastcall TTPDiscoverServices::Invoke(void){ TBluetoothLE *BLEh = FForm->BluetoothLE1; TBluetoothLEDeviceList *DLh = BLEh->DiscoveredDevices; TBluetoothLEDevice* BTDev= DLh->Items[FForm->ListBox1->ItemIndex]; bool bres; if(!BTDev->Paired){ bres=false; ::MessageBox(NULL,L"Device not paired?",L"**Error**",MB_OK); }else{ //original: if(!FForm->BluetoothLE1->DiscoveredDevices->Items[FForm->ListBox1->ItemIndex]->DiscoverServices()) bres = BTDev->DiscoverServices(); // Jo: Exception Win11 for unpaired Devices ::MessageBox(NULL,bres?L"Discover OK":L"Discover Error",L"**Discover**",MB_OK); } if(!bres) TThread::Synchronize(NULL, SynchronizeProc); } Share this post Link to post
corneliusdavid 214 Posted December 20, 2021 Delphi has the TBeacon component that can be configured to listen to BLE devices without pairing: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_Beacons 1 Share this post Link to post
mikerabat 20 Posted December 20, 2021 Which Delphi version are you using? I once fixed a few things in Bluetooth LE here https://quality.embarcadero.com/browse/RSP-20296 - let me know if that might help you. kind regards Mike Share this post Link to post
JoEmbedded 0 Posted December 20, 2021 Hello Mike, thanks for the link! I am using C++Builder/Delphi 10.4 Version 27.0.40680.420 (Community Edition) on Windows 11 I wrote a complete Driver for Web-Bluetooth (Vanilla JS), which works excellent in Chrome/Edge on Win10/11 and Android and in a sandbox also on iOs. ( https://joembedded.github.io/ltx_ble_demo/ble_api ) Since a BLE-Connection is bi-directional, it is possible to reduce the Client Side to the aboslute minimum and let the Embedded-Stack do all more difficult things. The advantages of JS are: NO APP to install, easy deployment and highportability. However: A nice PWA as UI is much more work than using RAD Studio 😉 In my case it seems, if a device is paired, everythink works fine with RAD Studio, but not if unpaired. But if as in my case one PC/Phone is used to set up many sensors, paring with each one does not make sense. De Docs to Rel10.x mention explicitely, that pairing is not necessary any more (Sorry, did not find this in English: https://docwiki.embarcadero.com/RADStudio/Sydney/de/Verwenden_von_Bluetooth_Low_Energy -> "BluetoothLE arbeitet nicht wie Classic Bluetooth, Sie müssen die Geräte nicht koppeln. " ) Other question (as Alternative) : Would it be possible to Start Pairing from RAD? Thanks for Your Support! Best regards, Jo ( Joembedded.de ) Share this post Link to post
corneliusdavid 214 Posted December 20, 2021 5 hours ago, JoEmbedded said: Would it be possible to Start Pairing from RAD? Yes: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_Classic_Bluetooth#Discovering_and_Pairing_with_Remote_Devices 1 Share this post Link to post
JoEmbedded 0 Posted December 20, 2021 Thank you very much! That is interesting, did not recognbise this. Pairing for Classic Bluetooth makes sense und should work with LE too. I'll try to use it. Best regards, Jo Share this post Link to post
mikerabat 20 Posted December 20, 2021 Actually the fix I posted to Embarcadero was exactly that and a few things more. Basically they used an outdated API and needed pairing. The code there should fix that. Let me know if you can find it - if not let me know. Maybe I can send you the fixed Windows BlueTooth LE stuff directly (I guess I may not post stuff here 😉 ) kind regards MIke Share this post Link to post
TimCruise 2 Posted December 20, 2021 18 hours ago, corneliusdavid said: Delphi has the TBeacon component that can be configured to listen to BLE devices without pairing: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_Beacons This part is COOL! I have ordered a copy of your book!!! Share this post Link to post
corneliusdavid 214 Posted December 20, 2021 18 minutes ago, TimCruise said: I have ordered a copy of your book!!! Excellent! There's a whole chapter devoted to Bluetooth (class & low-energy). BLE builds on Classic and Beacons build on BLE. It was a hard chapter to research. I hope it helps! Share this post Link to post
JoEmbedded 0 Posted December 20, 2021 Hello Mike, thank you very much for Your offer. But I think I wait (and hope Embarcadero will migrate to 64-Bit, I started in 1988 with Turbo-C, so no hurry...). In the meantime I'll continue my work on the Progressive-Web-APP (still a lot 2do...) Best regards, Jo Share this post Link to post
mikerabat 20 Posted December 20, 2021 40 minutes ago, JoEmbedded said: Hello Mike, thank you very much for Your offer. But I think I wait (and hope Embarcadero will migrate to 64-Bit, I started in 1988 with Turbo-C, so no hurry...). In the meantime I'll continue my work on the Progressive-Web-APP (still a lot 2do...) Best regards, Jo Hey Jo! Actually there is already a 64bit compiler so.... I don't know what you are waiting for 😉 anyway.... the probelm is not the compiler but rather the api used aka WinRT and the fixes are put in there in Delhi11 . So either update to this version or check the fixes. I can remember that I also put them on stackoverflow: https://stackoverflow.com/questions/61890445/delphi-bluetooth-le-heart-rate-profile-access Share this post Link to post