CSoft.Communication.Bluetooth
11.0.2
See the version list below for details.
dotnet add package CSoft.Communication.Bluetooth --version 11.0.2
NuGet\Install-Package CSoft.Communication.Bluetooth -Version 11.0.2
<PackageReference Include="CSoft.Communication.Bluetooth" Version="11.0.2" />
<PackageVersion Include="CSoft.Communication.Bluetooth" Version="11.0.2" />
<PackageReference Include="CSoft.Communication.Bluetooth" />
paket add CSoft.Communication.Bluetooth --version 11.0.2
#r "nuget: CSoft.Communication.Bluetooth, 11.0.2"
#:package CSoft.Communication.Bluetooth@11.0.2
#addin nuget:?package=CSoft.Communication.Bluetooth&version=11.0.2
#tool nuget:?package=CSoft.Communication.Bluetooth&version=11.0.2
CSoft.Communication.Bluetooth
经典蓝牙 RFCOMM/SPP 通讯包。BluetoothClassic 按设备地址连接远端串口服务,实现 IPhysicalPort。BluetoothClassic_Server 监听标准 SPP 服务,使用 Guid 区分连接,实现 IPhysicalPort_Server。BLE GATT 设备请使用 CSoft.Communication.BLE。 低功耗蓝牙包
安装与运行条件
dotnet add package CSoft.Communication.Bluetooth --version 11.0.2
| 目标或平台 | 使用条件 |
|---|---|
net8.0、net9.0、net10.0、net11.0 |
Windows 和 Linux 使用 32feet.NET 的经典蓝牙提供程序。适配器和对端设备都要支持经典蓝牙 RFCOMM/SPP。 |
netstandard2.0 |
提供兼容资产。能否发现或连接设备取决于宿主选中的蓝牙提供程序。 |
| Linux | 启用 BlueZ 和系统 D-Bus,并确认进程有权访问蓝牙适配器。 |
连接前打开蓝牙,并按设备要求完成配对。远端需提供标准串口服务 00001101-0000-1000-8000-00805f9b34fb。可以用 BluetoothClassic.DiscoverDevicesAsync() 获取设备的 Name 和 Address。设备名称相同时,优先使用扫描结果中的地址。
客户端
将设备地址作为程序的第一个参数。TopPort 把接收字节交给 TimeParser,适合简单文本调试。实际协议可换成匹配帧格式的解析器。
using Communication.Bluetooth;
using Parser.Parsers;
using System.Text;
using TopPortLib;
await using var client = new TopPort(new BluetoothClassic(args[0]), new TimeParser());
client.OnReceiveParsedData += data =>
{
Console.WriteLine(Encoding.UTF8.GetString(data));
return Task.CompletedTask;
};
await client.OpenAsync();
await client.SendAsync(Encoding.UTF8.GetBytes("ping"));
Console.ReadLine();
服务端
收到连接后用 clientId 向该连接回送数据。StartConsuming 每次处理当前读取到的一块字节,协议消息边界需要由应用解析。
using Communication.Bluetooth;
using Communication.Extensions;
await using var server = new BluetoothClassic_Server();
server.OnClientConnect += (clientId, reader) =>
{
reader.StartConsuming(data => server.SendDataAsync(clientId, data));
return Task.CompletedTask;
};
await server.StartAsync();
Console.ReadLine();
客户端可用 CloseAsync() 主动关闭,服务端可用 StopAsync() 主动停止监听并释放连接。两个示例退出作用域时会异步释放资源。
接入 Pigeon
引用 CSoft.Communication.Bluetooth 11.0.2 后,NuGet 会一并还原 CSoft.TopPortLib、CSoft.CommTask 和 CSoft.Communication 11.0.2。使用本地包时,先按仓库说明配置本地包源。
客户端把 BluetoothClassic 交给 TopPort,再把该端口交给 PigeonPort。服务端把 BluetoothClassic_Server 和每客户端的分帧器工厂交给 TopPort_Server,再用 PigeonPort_Server 包装。分帧器和 Req/Rsp 由应用协议决定。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CSoft.TopPortLib (>= 11.0.2)
- InTheHand.Net.Bluetooth (>= 4.2.5)
- System.Buffers (>= 4.6.1)
-
net10.0
- CSoft.TopPortLib (>= 11.0.2)
- InTheHand.Net.Bluetooth (>= 4.2.5)
- Tmds.DBus (>= 0.95.2)
-
net11.0
- CSoft.TopPortLib (>= 11.0.2)
- InTheHand.Net.Bluetooth (>= 4.2.5)
- Tmds.DBus (>= 0.95.2)
-
net8.0
- CSoft.TopPortLib (>= 11.0.2)
- InTheHand.Net.Bluetooth (>= 4.2.2)
- Tmds.DBus (>= 0.95.2)
-
net9.0
- CSoft.TopPortLib (>= 11.0.2)
- InTheHand.Net.Bluetooth (>= 4.2.5)
- Tmds.DBus (>= 0.95.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.3 | 47 | 11/13/2026 |
| 11.0.2 | 55 | 11/13/2026 |
| 11.0.1 | 48 | 11/12/2026 |
| 11.0.0 | 51 | 11/12/2026 |
| 10.6.2 | 195 | 5/28/2026 |
| 10.6.1 | 132 | 5/28/2026 |
| 10.6.0 | 132 | 5/27/2026 |
| 10.5.1 | 108 | 5/25/2026 |
| 10.5.0 | 135 | 5/25/2026 |
| 10.4.11 | 140 | 5/20/2026 |
| 10.4.10 | 133 | 5/19/2026 |
| 10.4.9 | 131 | 5/19/2026 |
| 10.4.8 | 132 | 5/18/2026 |
| 10.4.7 | 130 | 5/18/2026 |
| 10.4.6 | 125 | 5/15/2026 |
| 10.4.5 | 130 | 5/14/2026 |
| 10.4.3 | 133 | 5/14/2026 |
| 10.4.1 | 125 | 5/11/2026 |
| 10.4.0 | 131 | 5/11/2026 |
| 10.3.1 | 130 | 5/7/2026 |
依赖 CSoft.TopPortLib 11.0.2,安装经典蓝牙包即可使用新版 Pigeon。
继续提供 .NET 8、9、10、11 和 .NET Standard 2.0 资产。