Skip to content

Bluetooth Low Energy (BLE) library to create BLE servers on Linux

License

Notifications You must be signed in to change notification settings

phylomeno/dotnet-ble-server

Repository files navigation

.NET BLE Server

Main Pipeline MIT License NuGet

.NET BLE Server is a library to support creation of BLE peripherals on Linux using .NET Core.

Under the hood the library uses BlueZ. The provided API aims to preserve the object structure of BlueZ whilst minimizing the aspects of the D-Bus communication.

Examples

Advertisement

using (var serverContext = new ServerContext())
{
    var advertisementProperties = new AdvertisementProperties
    {
        Type = "peripheral",
        ServiceUUIDs = new[] { "12345678-1234-5678-1234-56789abcdef0"},
        LocalName = "A",
    };

    await new AdvertisingManager(serverContext).CreateAdvertisement(advertisementProperties);
}

Simple GATT Application

using (var serverContext = new ServerContext())
{
    var gattServiceDescription = new GattServiceDescription
    {
        UUID = "12345678-1234-5678-1234-56789abcdef0",
        Primary = true
    };

    var gattCharacteristicDescription = new GattCharacteristicDescription
    {
        CharacteristicSource = new SampleGattApplication.ExampleCharacteristicSource(),
        UUID = "12345678-1234-5678-1234-56789abcdef1",
        Flags = new[] {"read", "write", "writable-auxiliaries"}
    };
    var gattDescriptorDescription = new GattDescriptorDescription
    {
        Value = new[] {(byte) 't'},
        UUID = "12345678-1234-5678-1234-56789abcdef2",
        Flags = new[] {"read", "write"}
    };
    var gab = new GattApplicationBuilder();
    gab
        .AddService(gattServiceDescription)
        .WithCharacteristic(gattCharacteristicDescription, new[] {gattDescriptorDescription});

    await new GattApplicationManager(serverContext).RegisterGattApplication(gab.BuildServiceDescriptions());
}

Useful references

Resource Link
BlueZ GATT API documentation https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt
Presentation BLE on Linux https://elinux.org/images/3/32/Doing_Bluetooth_Low_Energy_on_Linux.pdf

About

Bluetooth Low Energy (BLE) library to create BLE servers on Linux

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages