I want to implement a GATT Server in Delphi and Windows 10.
I tried this example with Delphi 10.2.
procedure TForm1.FormCreate(Sender: TObject);
var
ggs: TBluetoothGattServer;
service: TBluetoothGattService;
pp: TBluetoothPropertyFlags;
chara: TBluetoothGattCharacteristic;
begin
btLE.Enabled := True;
ggs := btLE.GetGattServer;
if ggs <> nil then
Begin
service := ggs.CreateService
(StringToGUID('{27EFDF1D-2D6F-4AB2-9783-E288DB80D5F1}'),
TBluetoothServiceType.Primary);
chara := ggs.CreateCharacteristic(service,
StringToGUID('{90C16494-5AD1-48AD-B567-952359AAB3F1}'),
[TBluetoothProperty.Notify, TBluetoothProperty.Indicate,
TBluetoothProperty.Read, TBluetoothProperty.Write], 'RemodeLEServer');
ggs.AddService(service);
btLE.Enabled := True;
end
else
showmessage('impossibile creare il service ');
end;
But it gives this exception in "CreateService" function:
Not supported on this platform
Microsoft says since "Windows 10 Creators Update" it supports GATT Server.
But according to Embarcadero, they say:
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.
So the TBluetoothLE seems not to support GATT Server on Windows 10. Is there any other way to implement GATT Server on Windows 10?
I want to simulate a Bluetooth Keyboard on Windows for Android.
Related
I have a web app which uses web bluetooth api. GATT server is running on STM32 microcontroller. Web app works good on Android devices, but it keeps disconnecting on Windows 11 in a Chrome browser. I used WireShark to track BLE packets. The disconnection reason is following: "Remote user terminated connection (0x13)".
I have tested web bluetooth on the same windows device with a different GATT server running on my Android phone. In this case it worked well. What can be an issue?
The peripheral is sending a malformed GATT packet.
Packet 163, Read By Group Response, contains 156 bytes of Attribute Protocol data. It contains a list of services, each is 20 bytes, consisting of (start handle, end handle, service uuid). The list contains 7 valid entries. After that follows an entry which is truncated to 14 bytes. That entry should not be present in the list since it does not fit. So, it seems the GATT server software running on the peripheral is buggy.
The client is supposed to continue the search by sending a new Read By Group Request containing a start handle that is +1 of the last retrieved end handle.
I am trying to get BLE ported to Windows.
I found how to use BluetoothGATTGetServices to get the device services, but I am not sure is there a way to scan for BLE devices and obtain the hDevice handle? I found ways to obtain the handle using paired devices, but in my case the device is not paird.
Depends on the protocols you are trying to implement, but standart service for advertising and scanning is GAP, which is interconnected with GATT. Make sure your device has both of the services and than implement the method for scanning for bluetooth devices. As I understand you are trying to make some sort of application for the computer which would scan for the devices. I don't know much about BLE development for windows but i guess you can implement some simple python script like
import bluetooth
devices = bluetooth.discover_devices(lookup_names = true)
for addr, name in devices:
print("adress :", addr)
print("name :", name)
I'm using domain socket (gRPC) to exchange data between processes, the following code:
rpcListener, err = net.Listen("unix", "path\\to\\my\\uds.sock")
if err != nil {
l.Errorf("start gRPC server failed: %s", err)
return
}
will throw following error
start gRPC server failed: listen unix path\to\my\uds.sock: socket: An address incompatible with the requested protocol was used.
On windows 10, this works ok, is windows-server-2008/windows-7 not support domain socket?
There are bugs listing on golang net package, but only point out Windows, not specific windows release.
MSDN listed the erorr: WSAEAFNOSUPPORT
There also a C# same error thread here
From AF_UNIX comes to Windows
:
Beginning in Insider Build 17063, you’ll be able to use the unix socket (AF_UNIX) address family on Windows to communicate between Win32 processes.
So, it looks like that there is no support for it in older versions of Windows like Windows 7 and Windows Server 2008 and even in older versions of Windows 10.
I have probably a very simple question.
When I initialize the port in Windows 10 the control message sent to USB device is incomplete. Windows sends the speed, but all other parameters are zeros (ie parity, nbits etc). I have checked the raw data received by the endpoint, I have also sniffed the communication on the cable - and Windows does not send this data.
Is this the standard virtual serial windows driver issue?
I am using the 32feet bluetooth library to connect to a device that supports Serial Port Profile (SPP). I try to connect like this:
using (BluetoothClient client = new BluetoothClient())
{
var address = new BluetoothAddress(0xecfe7e11c3af);
BluetoothEndPoint endPoint = new BluetoothEndPoint(address, BluetoothService.SerialPort);
client.Connect(endPoint);
var stream = client.GetStream();
System.Threading.Thread.Sleep(10000);
}
Everything is great until the Connect method is called. At this point, Windows interrupts the program flow with a bubble alert that says
"A bluetooth device is trying to connect -- click to allow this"
At which point the user is led through a wizard that ends up installing drivers and a Bluetooth virtual COM port shows up in Device Manager. I don't want this to happen -- I want to simply access the stream and communicate directly with the device without windows intervening. Is this possible? What can be done to tell Windows to keep out of my business?
I'm attempting to connect to a Bluetooth 4.0 device. I've done something similar in the past with a 2.0 device and Windows does not interfere in this case.
Have a look at http://SimpleBluetooth4Win.SourceForge.net
It's a small wrapper library that uses the windows bluetooth networking API that could help you.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa362932%28v=vs.85%29.aspx
In particular if your bluetooth USB dongle or bluetooth device has been correctly recognized by the appropriate drivers and the remote bluetooth device is already paired with the PC, you don't need to install a bluetooth virtual COM port that shows up in Device Manager but you simply use the write or read calls to access directly the stream for communicating with the paired device.