Skip to content

Commit

Permalink
Merge pull request #3 from exendahal/doc/update_readme
Browse files Browse the repository at this point in the history
doc: update document for root page
  • Loading branch information
exendahal authored Feb 10, 2024
2 parents 5be7817 + 0773f27 commit 5a2dfe6
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 81 deletions.
82 changes: 79 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

.NET BlueZ Server is a powerful library designed to facilitate the creation of Bluetooth Low Energy (BLE) peripherals and efficiently manage centrals on Linux using .NET Core. Leveraging the capabilities of BlueZ under the hood, this library offers a seamless API that preserves the object structure of BlueZ while streamlining D-Bus communication for a more developer-friendly experience.
This library builds upon [.NET BLE Server](https://github.com/phylomeno/dotnet-ble-server), introducing specialized methods for handling connected centrals to BLE peripherals.

[![Bluez.NET.Server](https://img.shields.io/nuget/v/Bluez.NET.Server)](https://www.nuget.org/packages/Bluez.NET.Server/)


## Key features
Expand All @@ -13,8 +15,82 @@
- Get all paired devices
- Get central object path on Read and Write request

## Examples

### Demo Example
Find demo project under example directory
Find demo project under `/example` directory

Create BLE peripheral

```
ServerContext _CurrentServerContext = new ServerContext();
await BleAdvertisement.RegisterAdvertisement(_CurrentServerContext);
await BleGattApplication.RegisterGattApplication(_CurrentServerContext);
DeviceManager.SetDevicePropertyListenerAsync(_CurrentServerContext, OnDeviceConnectedAsync);
```

Listen to Central property change

```
private async void OnDeviceConnectedAsync(IDevice1 device, PropertyChanges changes)
{
foreach (var change in changes.Changed)
{
Console.WriteLine($"{change.Key}:{change.Value}");
}
}
```

Get BLE Adapter

```
AdapterManager.GetAdapter(_CurrentServerContext);
```

Turn ON/OFF BLE Adapter

```
var isAdapterOn = AdapterManager.SetAdapterPowerOn(_CurrentServerContext);
var isAdapterOff = AdapterManager.SetAdapterPowerOff(_CurrentServerContext);
```

Get paired devices

```
var devices = await DeviceManager.GetDeviceListAsync(_CurrentServerContext);
```

Remove paired device

```
await DeviceManager.RemoveDeviceAsync(_CurrentServerContext, iDevice);
```

Get Device from the Address

```
var device = await DeviceManager.GetDeviceAsync(_CurrentServerContext, address);
```

Get Device from the object path

```
var device = await DeviceManager.GetDeviceByObject(_CurrentServerContext, address);
```

Pair device

```
var paired = await device.GetPairedAsync();
if (!paired)
{
var response = await DeviceManager.PairDeviceAsync(_CurrentServerContext,device);
}
```

## Useful references
| Resource | Link |
|-----------------------------------------|------------------------------------------------------------------------------------------------|
| BlueZ GATT API documentation | [https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt](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](https://elinux.org/images/3/32/Doing_Bluetooth_Low_Energy_on_Linux.pdf) |

More:
[.NET Bluez Server](https://github.com/exendahal/dotnet_bluez_server)
81 changes: 3 additions & 78 deletions src/dotnet_bluez_server/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

.NET BlueZ Server is a powerful library designed to facilitate the creation of Bluetooth Low Energy (BLE) peripherals and efficiently manage centrals on Linux using .NET Core. Leveraging the capabilities of BlueZ under the hood, this library offers a seamless API that preserves the object structure of BlueZ while streamlining D-Bus communication for a more developer-friendly experience.
This library builds upon [.NET BLE Server](https://github.com/phylomeno/dotnet-ble-server), introducing specialized methods for handling connected centrals to BLE peripherals.

[![Bluez.NET.Server](https://img.shields.io/nuget/v/Bluez.NET.Server)](https://www.nuget.org/packages/Bluez.NET.Server/)


## Key features
Expand All @@ -15,81 +13,8 @@
- Get all paired devices
- Get central object path on Read and Write request

## Examples

### Demo Example
Find demo project under /example directory

Create BLE peripheral

```
ServerContext _CurrentServerContext = new ServerContext();
await BleAdvertisement.RegisterAdvertisement(_CurrentServerContext);
await BleGattApplication.RegisterGattApplication(_CurrentServerContext);
DeviceManager.SetDevicePropertyListenerAsync(_CurrentServerContext, OnDeviceConnectedAsync);
```

Listen to Central property change

```
private async void OnDeviceConnectedAsync(IDevice1 device, PropertyChanges changes)
{
foreach (var change in changes.Changed)
{
Console.WriteLine($"{change.Key}:{change.Value}");
}
}
```

Get BLE Adapter

```
AdapterManager.GetAdapter(_CurrentServerContext);
```

Turn ON/OFF BLE Adapter

```
var isAdapterOn = AdapterManager.SetAdapterPowerOn(_CurrentServerContext);
var isAdapterOff = AdapterManager.SetAdapterPowerOff(_CurrentServerContext);
```

Get paired devices

```
var devices = await DeviceManager.GetDeviceListAsync(_CurrentServerContext);
```

Remove paired device

```
await DeviceManager.RemoveDeviceAsync(_CurrentServerContext, iDevice);
```

Get Device from the Address

```
var device = await DeviceManager.GetDeviceAsync(_CurrentServerContext, address);
```

Get Device from the object path

```
var device = await DeviceManager.GetDeviceByObject(_CurrentServerContext, address);
```

Pair device

```
var paired = await device.GetPairedAsync();
if (!paired)
{
var response = await DeviceManager.PairDeviceAsync(_CurrentServerContext,device);
}
```
Find demo project under example directory

## Useful references
| Resource | Link |
|-----------------------------------------|------------------------------------------------------------------------------------------------|
| BlueZ GATT API documentation | [https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt](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](https://elinux.org/images/3/32/Doing_Bluetooth_Low_Energy_on_Linux.pdf) |
More:
[.NET Bluez Server](https://github.com/exendahal/dotnet_bluez_server)

0 comments on commit 5a2dfe6

Please sign in to comment.