c# - Plugin.BLE(1.3.0) for xamarin.Forms 没有在特征中获取数据字节
问题描述
我正在开发表单应用程序,我正在连接到设备并需要获取数据。我能够搜索设备、连接并获取服务,但对于服务,我无法从其特性中读取数据。
Services = await device.GetServicesAsync();
try
{
selectedServiceGuid = Services[6].Id;
Service = await device.GetServiceAsync(selectedServiceGuid);
}
catch (TimeoutException ext)
{
}
catch (Exception ex)
{
}
Characteristic = await Service.GetCharacteristicAsync(Guid.Parse("f000aa41-0451-4000-b000-000000000000"));
if (Characteristic.CanRead)
{
var c = await Characteristic.ReadAsync();
Console.WriteLine(c.ToArray());
}
if (Characteristic.CanUpdate)
{
Characteristic.ValueUpdated += (s, ee) =>
{
Debug.WriteLine("characteristic.ValueUpdated");
Device.BeginInvokeOnMainThread(() =>
{
UpdateDisplay(Characteristic);
});
};
await Characteristic.StartUpdatesAsync();
}
在所有索引处获取 byte[] 0,使用 await Characteristic.ReadAsync() 读取。任何人都面临/面临同样的问题?
解决方案
推荐阅读
- swiftui - 自 Xcode 13 / iOS15 以来,获取“公共数据库中不允许自定义区域”
- javascript - 从 MongoDB 中的一个文档中获取基于另一个文档的属性的结果
- android - msfconsole 在任何源中都找不到 nokogiri-1.8.0
- python - 抽五张牌获得红桃 A 和黑桃 A 的概率
- amazon-web-services - 未找到主要源和源版本的子模块错误存储库
- exception - Jasypt BasicTextEncryptor 解密不起作用
- python - Python - 异常处理
- django - Django makemessages 使用 django-admin 和 manage.py 都失败
- azure-web-app-service - Azure Front Door Visual Studio 远程调试
- mysql - 如何在聚合sequelize中使用include