ChrisChuah 0 Posted November 23, 2020 Hi, In my fmx application running in windows 32, when i call the TBluetoothLE.DiscoverDevices(4000), the function does not return any event back. When it is run on iOS application, the function will return the event back as EndDiscovery Why is this event is not called in Windows 32? Is there something that i forgot? ===== Code ======== procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Lines.Clear; Memo1.Lines.Add('Scanning for devices'); BluetoothLE1.DiscoverDevices(4000); end; ==== End Code ====== Why isnt this function below not called in Windows 10? procedure TForm1.BluetoothLE1EndDiscoverDevices(const Sender: TObject; const ADeviceList: TBluetoothLEDeviceList); Share this post Link to post
DelphiUdIT 188 Posted November 23, 2020 I have never been able to connect a BLE device with any version of Windows. If you want to use BLE with Windows you have to use WinRT api (i.e. you have to create a UWP application). I've heard you can use BLE with Windows with a special BL stack, but I don't know anything about it. Like you I was able to use BLE with other devices like Android 32 or 64 without any problem. Bye Share this post Link to post
Guest Posted November 24, 2020 (edited) maybe help you http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_Bluetooth_Low_Energy HELP SYSTEM: Platform Support Platform Bluetooth Low Energy Client Server Windows(*) 10+ 10+ (**) macOS 10.7+ 10.9+ iOS 5+ 6+ Android 4.3+ 5+ Note: Windows Server does not support Bluetooth, see General Bluetooth Support in Windows. Note: WinRT Bluetooth API provides support for BLE advertising data through the manufacturer-specific data field, but it does not fully implement GATT Server functionalities. Note: The iOS property list includes configuration for Bluetooth LE. Attention: Applications running on Windows platform lower than Windows 10 do not support Bluetooth LE. Place a TBluetoothLE Component Use the new TBluetoothLE component to implement the RTL BluetoothLE feature for server and client applications. TBluetoothLE includes the System.Bluetooth unit in your application and internally calls TBluetoothLEManager.Current to get an instance of TBluetoothLEManager. TBluetoothLEManager is the main class for Bluetooth Low Energy communications. Note: TBluetoothLEManager.Current always returns the same instance of TBluetoothLEManager. You do not need more than one instance of TBluetoothLEManager. Discovering Devices BluetoothLE does not work as the Classic Bluetooth, you do not need to pair the devices. BluetoothLE clients need to discover BluetoothLE servers. Notes: Applications running on Windows platform lower than Windows 10 need to pair the devices before discovering BluetoothLE servers. For more information, see Windows Bluetooth FAQ. The WinRT API for Windows 10+ platforms allows to scan for devices without the need to pair them. Use the DiscoverDevices method to discover BluetoothLE servers. procedure DoScan; const HeartRateService: TBluetoothUUID = '{0000180D-0000-1000-8000-00805F9B34FB}'; begin BluetoothLE1.DiscoverDevices(2500) // The parameter is the timeout in milliseconds. BluetoothLE1.DiscoverDevices(2500, [HRService]) // It only exposes devices with the Heart Rate service to the BluetoothLE client. end; After this period of time, the OnEndDiscoverDevices event is fired. Once you discovered the device you can start getting the services and characteristics from the standard profile as outlined below. Edited November 24, 2020 by Guest Share this post Link to post
ChrisChuah 0 Posted November 24, 2020 I tried that with the discover device and it does not send a end discover callback. It was stuck there. Share this post Link to post
ChrisChuah 0 Posted November 24, 2020 What other BLE component can be used for windows deployment if the default TBluetoothLE is not working for windows 10 Share this post Link to post
Guest Posted November 24, 2020 (edited) The WinSoft it's a company that have "many mini-components" for all platforms by RAD Studio last, but dont have any for MSWindows Bluetooth. https://winsoft.sk/products.htm nSoftwares: (Available in all major Windows development environments) - We offer free, fully-functional 30-day trials https://www.nsoftware.com/ipworks/ble/ https://www.serialio.com/support/bluesnap/windows/how-pair-bluesnap-smart-windows-10-ble Here, a project by Fernando Rizzato (MVP Leader from South America) Chat via Bluetooth for Android, macOS and Windows (in Portuguese-BR) https://fernandorizzato.com/2017/04/20/um-chat-via-bluetooth-para-android-macos-e-windows/ Download sources at: https://cc.embarcadero.com/item/30766 Developer Skill Sprint: Spelunking Bluetooth Low Energy Devices https://community.embarcadero.com/blogs/entry/developer-skill-sprint-spelunking-bluetooth-le (In Windows * * Bluetooth (LE) must be coupled with the device manager (in German) https://www.delphipraxis.net/189298-bluetooth-low-energy-delphi-6-a-3.html Edited November 24, 2020 by Guest Share this post Link to post
DelphiUdIT 188 Posted November 24, 2020 Bluetooth "classic" and Bluetoooth "LE" are different things !!! With Windows (any version) you can use BClassic after pairing the devices. And you can use normal api from (TBlutooth component for example). To use BLE in Windows application the BLE devices should be able to pairing with OS. But BLE pure devices (like industrial sensor devices, or other commercial devices) doesn't understand the "piairing" conditions, because it's a no sense. They work on the GATT services basis. So the normal Windows application cannot use BLE. Again, the BClassic and BLE use different radio spectrum tipologies. 3 hours ago, ChrisChuah said: What other BLE component can be used for windows deployment if the default TBluetoothLE is not working for windows 10 Microsoft told that the UWP applications using the WinRT api (that are different from the standard Blutooth api) are able to use the BLE. Also, there should be some Bluetooth stacks that may work in Windows with BLE. Take care: some devices (like many smartphones) have the Blutooth radio that works both in BClassic and BLE. This means that you can pair a smartphone and somtimes use the BLE. @emailx45: i'll look at you suggestions, but i think that they speak about BLE with pair conditions. Bye Share this post Link to post
DelphiUdIT 188 Posted November 24, 2020 Quote Windows 10 supports LE Bluetooth peripherals automatically pairing to a single PC, after all devices have been provisioned and enabled during the manufacturing process. Users do not need to keep LE devices paired and connected after both the host PC and bundled devices are supplied power for the first time. These peripherals can still be used as regular Bluetooth devices, and maintain full functionality when out of range of the host PC. However, if the peripherals are unpaired and within range of the host PC, they will automatically re-pair and connect. This is the explanation why in Windows 10 it is not necessary to "pair" BLE devices. But the devices must be able to pair, which normal BLEs don't. Share this post Link to post
ChrisChuah 0 Posted November 24, 2020 Thanks for the reference to the delphi sample. Seems that for MacOS, iOS and Android, there is an event OnEndDiscoverDevices called when there is a timeout set in the DiscoverDevices function. However, in Windows 10, this event is not called. Instead the event DiscoveredDevice is called. Hence, have to modify the codes to detect that if windows, have to add a timer for timeout to stop the discovery of devices. Would this be a good option? what would you do? please advice regards chris Share this post Link to post
DelphiUdIT 188 Posted November 24, 2020 From Help: Quote Platform Support Platform Notes Windows Timeout is ignored because DiscoverDevices triggers the OnEndDiscoverDevices event immediately. Always returns True. OS X OnEndDiscoverDevices always occurs some time after the specified Timeout, never before. Always returns True. iOS OnEndDiscoverDevices always occurs some time after the specified Timeout, never before. Always returns True. Android OnEndDiscoverDevices always occurs after the specified Timeout, never before. You should "have" the event immedialtly if all is working. I doubt that the BLE is working without any pairing (i cannot try beacuse i don't have any BLE that Windows can see …). If you want to test it after a period, I recommend that you test it after 10.24 seconds. This time comes from a Bluetooth 4.0 specification and is the maximum (worse) response time of a Bluetooth device. I use half of that time (5.2 seconds) and BLE devices always respond ... obviously not tested on Windows platform but on Android. I normally use around seven BLE devices via GATT. There are some answers on Stackoverflow about that (if i remember good). 31 minutes ago, ChrisChuah said: what would you do? Since I have to work with BLE devices that Windows cannot see, I have given up on developing BLE applications on Windows. Tell us if you will be luckier. Bye Share this post Link to post
DelphiUdIT 188 Posted November 24, 2020 Now that you have tickled the Bluetooth topic, which I had filed, I tried again with the new PC, which has an Intel Bluetooth compared to the one I tested with which had a BroadComm, and in fact the BLE devices are seen correctly without pair them. To see them I use the TBluetoothLE component and the DiscoverLEDevice event which is called for each BLE device found. Share this post Link to post
Rollo62 539 Posted November 25, 2020 16 hours ago, DelphiUdIT said: I tried again with the new PC, which has an Intel Bluetooth compared to the one I tested with which had a BroadComm, I assume the "Intel" is an integrated BLuetooth, while for the "Braodcom" you used an external USB-Bluetooth stick, is that correct ? Share this post Link to post
DelphiUdIT 188 Posted November 25, 2020 @Rollo62: No, both old (Acer I7 Intel) and new PC (Asus I7 Intel) have the integrated Bluetooth. The old one was ( RIP) 3 years old, the new is less then one year old. I think that the malfunction of the old one was about the compatibility with BLE radio spectrum, may be the Bradcomm Bluetooth was not fully certified for BLE. I tried also in the past with old versions of Windows 10 and different Bluetooth constructors with no success. But the failure probably also depends on the implementation of the Windows Bluetooth (stack), which only in Windows 10 and after several releases of the same has been made fully functional. In an old test, while in Windows 10 the BLE devices were not seen, in an Oracle virtual machine with MAC OSX (I don't remember the exact version, I think Sierra) the BLEs were seen .... very curious. Now, in the next weeks (thanks LOCKDOWN ) i restart testing BLE on Windows with various hardware. Bye Share this post Link to post
Rollo62 539 Posted November 25, 2020 Have you checked out the functionality with some tools, like https://www.microsoft.com/de-de/p/bluetooth-le-lab/9n6jd37gwzc8?activetab=pivot:overviewtab https://www.microsoft.com/de-de/p/bluetooth-le-explorer/9n0ztkf1qd98?activetab=pivot:overviewtab https://www.nirsoft.net/utils/bluetooth_viewer.html https://www.nirsoft.net/utils/bluetoothcl.html https://sensboston.github.io/BLEConsole/ Of course the Nordic tools should be great too, but thats already developer tools for the MCU's, but they have a lot of helpful tools as well. https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-desktop Maybe someone knows better tools for Windows, since I usually work with Android/iOS. 1 Share this post Link to post
DelphiUdIT 188 Posted November 25, 2020 @Rollo62: Thanks for your links. I already use the Nordic microcontrollers, and in particular the BLE devices I was talking about in this post ... they are really them …. Bye Share this post Link to post
ChrisChuah 0 Posted December 11, 2020 I tested out the BLE on windows 10 and it seems that the device needs to be paired up in the Windows Bluetooth screen first by adding it to it. If not, while you tried to get services from the device, it will prompt that the device is not paired up. Share this post Link to post
DelphiUdIT 188 Posted December 12, 2020 On 12/11/2020 at 2:43 AM, ChrisChuah said: I tested out the BLE on windows 10 and it seems that the device needs to be paired up in the Windows Bluetooth screen first by adding it to it. If not, while you tried to get services from the device, it will prompt that the device is not paired up. Yes, this is true. Windows 10 works only with paired BLE devices. After the first time, means the first time that you paired the devices, Windows 10 do this operation automatically, For some devices the manually paired is not necessary. The devices that i use are without auth protocol and Windows 10 paried them automatically when my app tries to scan and get gatt services. Share this post Link to post
almcneil15 0 Posted February 3, 2021 I have a BLE device with custom firmware in it that I have succesfully paired on the windows bluetooth screen. When I call DiscoverDevices and pass UUID of the service I am looking for, the function returns true. However, it the event OnEndDiscoverDevices does not fire. If I use a timeout and fire that event manually, the list DiscoveredDevices is empty. I thought that pairing the BLE device to Windows first would solve this issue, but even after pairing I am getting the same results. Does anyone know of a work around? For the record, I can use the Bluetooth LE Explorer app on windows and see the device and its services and characteristics. Share this post Link to post
DelphiUdIT 188 Posted February 3, 2021 (edited) Under Windows you must use "OnDiscoverLEDevice" event. It will be fired for every device discovered. The "OnEndDiscoverDevices" is not fired in Windows, it works on Android Platform. Hope the answer wil be usefull. Bye Edited February 3, 2021 by DelphiUdIT Share this post Link to post
almcneil15 0 Posted February 4, 2021 Thanks so much for the response. I am ysing Rad Studio 10.2 FMX, and my TBluetoothLE component does not have a method called "OnDiscoverLEDevice" or "DiscoverLEDevice". Is this something that has been introduced in a newer version of FMX? Share this post Link to post
DelphiUdIT 188 Posted February 4, 2021 This is the reference page for Tokyo release: http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.Bluetooth.TDiscoverLEDeviceEvent That is the same in the Sydney edition. I don't know if the method is hidden when in use with FMX framework in Tokyo edition. Bye Share this post Link to post
Rollo62 539 Posted February 4, 2021 13 hours ago, DelphiUdIT said: Under Windows you must use "OnDiscoverLEDevice" event. How do you detect end-of-discovery, do you run a timer in parallel ? Share this post Link to post
DelphiUdIT 188 Posted February 4, 2021 Quote How do you detect end-of-discovery, do you run a timer in parallel ? Yes, stay on BLE specifications the maximum response time should be around 10 seconds. I normaly use about 5 seconds (timer or timeout) (5.2 seconds exactly) and Always all the devices respond. But the logic to "list" the device is different: in Android I use the "end" event, while in Windows I use the "single" discovery event. This should be in that way: if the "end" discovery event works, the "single" discovery event doesn't work and vice versa. I don't know if in the last updates somthing is changed, but surely in that way is working. Bye Share this post Link to post
Rollo62 539 Posted February 4, 2021 Yes, in Macos/iOS/Android I use both events, the OnDeviceLE to show an early response, and the EndDiscovery to proceed further. So an additional timer would mimick the Android/iOS behavior well. Still I don't use BLE on Windows, which is another construction site, but its on my roadmap. Share this post Link to post
almcneil15 0 Posted February 5, 2021 (edited) I was able to get my device to pair to windows and then discover its services and characteristics. My device is to work like a simple UART bridge, with and Rx and Tx characteristic. My program successfully sends out the Tx message. However, when an Rx message is recieved, the event "OnCharacteristicRead" does not seem to be fired, therefore my code does not successfully get the message. Is there an issue in windows firing this event? The same application on iOS works as it should. *EDIT* This ended up not being a windows issue but an issue in the BLE device firmware I needed to address. Edited February 5, 2021 by almcneil15 Share this post Link to post