Bluetooth in Windows: service discovery SDP lazarus / 34-Windows ---------------------------------------------------------------------- Graham1 · 2021-10-12 22:51 In an earlier post I found how to look up BT devices using BluetoothAPIs.dll and Winsock2, and then how to connect, read and write to a specific port on a found device: https://forum.lazarus.freepascal.org/index.php/topic,53862.msg401002.h tml#msg401002 Now I'm trying to find how to discover what ports and services are available for the devices rather than just connecting to a hardcoded one. In the Python library BlueZ they have a function find_service that does what I want but I can't find the equivalent in the Windows API: https://pybluez.readthedocs.io/en/latest/api/find_service.html I couldn't find anything about it in the BT API documents at: https://docs.microsoft.com/en-us/windows/win32/api/bluetoothapis/ For Winsock I think it might be related to the lpafpProtocols in the WSAQuerySet but I'm not sure how to set and access it: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/ I tried looking in the JWA source in C:\Pascal\fpc\3.2.0\source\packages\winunits-jedi\src but wasn't sure what to look for. Does anybody have an example of how to do this, or a Pascal version of the Python function mentioned above? Thanks! ---------------------------------------------------------------------- Graham1 · 2021-10-14 04:20 I'm making some progress. I've found that for each device I locate in the initial loop of WSALookupServiceBegin and WSALookupServiceNext I need to perform a secondary Lookup loop for the RFCOMM_Protocol_UUID and the device's BT address. So I can now list the RFCOMM services for the devices and I can see the 'Serial Port' service line I'm after. But how to I get to the channel number? My flags include LUP_RETURN_ADDR OR LUP_RETURN_BLOB but the port number in the address just shows 0. I think that is intended as the COM port number for the connecting device rather than the channel for the BT device itself. I think it must be in the Blob data but I'm not sure how to access that. Can anyone point me in the right direction? Thanks!