Jump to content
JoEmbedded

Bluetooth LE only for paired Devices on Windows?

Recommended Posts

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"

 

image.png.2e82e093ba8ca0c9a2529ff81baf4199.png

 

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

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

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

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
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

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×