Search code examples
c#.net-corebluetooth-lowenergyraspberry-pi3dbus

Bluetooth GATT server using D-Bus and .Net Core


I am trying to run a Bluetooth GATT server on raspberry pi 3 and raspbian OS. Based on this post, the BlueZ D-Bus api can be used in .Net Core by Tmds.DBus library and its C# interfaces can be generate using Tmds.DBus tool. I have read Bluez docs and most of the existing samples (based on python and c), but i can't understand how to define and advertise the GATT server in .Net Core.

Can anyone provide a .Net sample or any other solution?


Solution

  • Creating a BLE peripheral is one of the more tricky things to do with BlueZ D-Bus API. You will need to create a GATT server and an advertisement. Unlike the GATT client, creating the server requires for objects to be registered on the dbus.

    I am not familiar with .NET, but it is the ability to register objects in D-Bus is the key to getting a GATT server working. From this example I found the key word is : RegisterObjectAsync

    Using that keyword, I then did a search and turned up this library as using it:

    https://github.com/phylomeno/dotnet-ble-server

    This looks like it should be of interest to you.