Skip to content

Commit

Permalink
Merge pull request #2 from exendahal/fix/change_example_directory
Browse files Browse the repository at this point in the history
Change the directory for library and example.
  • Loading branch information
exendahal authored Feb 10, 2024
2 parents 8acdf66 + 50c52e7 commit 5be7817
Show file tree
Hide file tree
Showing 428 changed files with 23 additions and 10,014 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/ble-server-linux/bin/Debug/net8.0/ble-server-linux.dll",
"program": "${workspaceFolder}/example/bin/Debug/net8.0/ble-server-linux.dll",
"args": [],
"cwd": "${workspaceFolder}/ble-server-linux",
"cwd": "${workspaceFolder}/example",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/ble-server-linux/ble-server-linux.csproj",
"${workspaceFolder}/example/ble-server-linux.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
Expand All @@ -19,7 +19,7 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/ble-server-linux/ble-server-linux.csproj",
"${workspaceFolder}/example/ble-server-linux.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
Expand All @@ -33,7 +33,7 @@
"watch",
"run",
"--project",
"${workspaceFolder}/ble-server-linux/ble-server-linux.csproj"
"${workspaceFolder}/example/ble-server-linux.csproj"
],
"problemMatcher": "$msCompile"
}
Expand Down
4 changes: 2 additions & 2 deletions DotnetBleServer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29418.71
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example-server-linux", "ble-server-linux\ble-server-linux.csproj", "{AE3AAA32-DFE6-4CAD-BE3D-0CFBA5C75EC4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example-server-linux", "example\ble-server-linux.csproj", "{AE3AAA32-DFE6-4CAD-BE3D-0CFBA5C75EC4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotnetBleServer", "dotnet_ble_server\dotnetbleserver.csproj", "{0D775919-ECF4-4C71-92ED-D7D70D9BF59F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotnetBluezServer", "src\dotnet_bluez_server\dotnetbleserver.csproj", "{0D775919-ECF4-4C71-92ED-D7D70D9BF59F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
81 changes: 4 additions & 77 deletions 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,79 +13,8 @@
- Get all paired devices
- Get central object path on Read and Write request

## Example
### 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);
}
```

## 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)
Binary file removed ble-server-linux/bin/Debug/net7.0/Avalonia.Base.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ble-server-linux/bin/Debug/net7.0/Avalonia.Skia.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ble-server-linux/bin/Debug/net7.0/Avalonia.X11.dll
Binary file not shown.
Binary file removed ble-server-linux/bin/Debug/net7.0/Avalonia.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ble-server-linux/bin/Debug/net7.0/HarfBuzzSharp.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ble-server-linux/bin/Debug/net7.0/SkiaSharp.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ble-server-linux/bin/Debug/net7.0/Tmds.DBus.dll
Binary file not shown.
Binary file removed ble-server-linux/bin/Debug/net7.0/ble-server-linux
Binary file not shown.
Loading

0 comments on commit 5be7817

Please sign in to comment.