- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 Xamarin 编写代码。我正在开发我的 IOS 应用程序,它允许我读取 BLE 设备、服务、特征值和通知激活。
我的 BLE 信标有一个包含两个自定义特征的自定义服务,并且都使用 CCCD 实现了通知。
我的 ble 设备工作正常 我用 BLE 扫描仪应用程序测试它,它工作正常,没有任何问题。我可以读取值并且可以激活这两个特征的通知。 See picture here .
我使用 xamarin 编写的应用程序可以正常工作(读取服务、特征值......)唯一没有工作的问题是通知的激活。这是代码的一部分:
public UUID Charac_UUID0 = UUID.FromString("0000beef-1212-efde-1523-785fef13d123");
public UUID Charac_UUID = UUID.FromString("0000b1e0-1212-efde-1523-785fef13d123") ;
public UUID Descr_UUID = UUID.FromString("00002902-1212-efde-1523-785fef13d123");
protected BluetoothGattCharacteristic _charac;
....
....
this._charac = App.Current.State.SelectedService.GetCharacteristic(Charac_UUID0);
BluetoothLEManager.Current.ConnectedDevices[App.Current.State.SelectedDevice].SetCharacteristicNotification(_charac, true);
BluetoothGattDescriptor descriptor = _charac.GetDescriptor(Descr_UUID0);
descriptor.SetValue(BluetoothGattDescriptor.EnableNotificationValue.ToArray());
BluetoothLEManager.Current.ConnectedDevices[App.Current.State.SelectedDevice].WriteDescriptor(descriptor);
代码总是在 descriptor.SetValue
给我一个错误,它告诉我描述符是 NULL,这意味着 _charac.GetDescriptor
没有返回任何值。
我怀疑描述符 UUID 值 (Descr_UUID) 不正确。我不知道如何确定 Descr_UUID,但我在互联网上看到很多例子,人们将特性的自定义 UUID 替换为 2902,在我的例子中,128 个描述符 UUID 等于 00002902-1212- efde-1523-785fef13d123
.
但是这里有个问题。两个特征的描述符 UUID 将相同,因为两个特征的基本 UUID 相同?
有什么解决办法吗?
最佳答案
3 年后,我相信您已经明白了,但是,2902 是客户端特征配置的 16 位值 Descriptor ,而且我相信它也应该使用“BASE UUID”来膨胀,而不仅仅是使用您的特征描述符。看到这个:answer
这将使用 BASE UUID 将您的 16(或 32)位 uuid 转换为完整的 128 位 uuid:
public static UUID ConvertUuid(uint uuid)
{
const long msbMask = 0x0000000000001000;
const ulong lsb = 0x800000805f9b34fb;
var msb = msbMask | ((ulong)(uuid & uint.MaxValue) << 32);
return new UUID((long)msb, unchecked((long)lsb));
}
关于ios - GetDescriptor() 空值/128 位 UUID 描述符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39907507/
我试图再次将反射的 UUID 转换回实际的 UUID 对象,但找不到方法,当我打印反射值时它看起来是正确的,但在尝试转换时我找不到方法。 package main import ( "fmt"
我想知道 UUID 是否是唯一的,即使它们是在不同的系统上生成的,这些系统可能采用不同的算法。例如,如果您在 MySQL 和 .Net 中生成了一堆 UUID,碰撞的可能性会更高,还是所有系统都使用完
是否可以一个接一个地创建两个重复的 UUID?我不熟悉 UUID 是如何生成的,但我猜想如果您在同一毫秒内从同一 MAC 地址创建了两个单独的 UUID,那么它们将完全相同。这是真的吗? 我想我是在问
当我使用 python uuid 模块中的 UUID() 函数检查我们的测试 uuid 之一时,我遇到了这种奇怪的行为。 从 uuid 导入 UUID uuid1 = UUID('00000000-0
开始使用 java.util.UUID。我的问题是如果我有两个 UUID 变量,比如 u1 和 u2,并且我想检查它们是否相等,我可以安全地使用表达式 u1 == u2 还是必须编写 u1 .equa
我浏览了 python UUID 模块的文档。 >>> uuid.uuid4() UUID('82fe5629-6680-4b13-a4e3-7a082f10e038') >>> uuid.uuid4
我正在创建一个程序,我在其中大量使用 UUID 来识别用户和组等内容。鉴于 UUID 已经被占用的可能性极低,我是否应该担心发生碰撞的可能性? 最佳答案 这在很大程度上取决于 A)您的要求 B)底层实
您应该使用哪个版本的 UUID?我看到很多帖子解释了每个版本的含义,但我很难弄清楚什么最适合哪些应用程序。 最佳答案 有两种不同的方式生成 UUID。 如果您只需要一个唯一 ID,则需要版本 1 或版
我知道我们可以轻松提取 uuid 版本号。有没有可靠的方法来提取时间戳、MAC 地址等信息? 谢谢! 最佳答案 符合标准的 UUID 可能是多种变体之一,它看起来像这样: AAAAAAAA-BBBB-
我可以干净地使用私有(private) UUID 变体/版本吗? 我使用我基本上认为是大整数的随机 UUID。现在,我想生成一个“私有(private)”UUID,它不基于众所周知的 5 个变体/版本
我已阅读 man 页面,但我不明白 name 和 namespace 的用途。 For version 3 and version 5 UUIDs the additional command lin
我目前正在项目中使用 boost::uuids::uuid,并且我想序列化包含 boost::uuids::uuid 的对象。我尝试了下面的简单示例,但出现错误: /usr/include/boost
我正在使用 Datastax Java 驱动程序在 Cassandra 数据库中执行基本的插入语句。我的主键列是uuid类型。从我在官方文档中看到的,在 Cassandra 中调用 uuid() 函数
会抛出异常吗? UUID() 是否会悄无声息地失败?是否有任何情况下“myStatus”来自 myStatus = True myUUID = uuid.UUID( someWeirdValue )
在我的 Android 应用程序中,我有这种采用 UUID 的方法。不幸的是,当我这样做时: OverviewEvent overviewevent = eventAdapter.getOvervie
我有一个简单的 mongo 迁移框架,它正在执行一些传递给它的脚本。 现在我想将我的 LUUID 迁移到 UUID。我写了以下内容: function fixIds(collectionName) {
我有一个非常奇怪的问题是我得到一个有效的 UUID 不是一个有效的 UUID,例如: 'fd31b6b5-325d-4b65-b496-d7e4d16c8a93' is not a valid UUI
我正在测试 Goa对于一个 API。我想使用 uuid 作为 ID 数据类型。我在 controller.go 中修改了以下函数: // Show runs the show action. func
我有一个包含 uuid 和系统列的表。我需要一个查询来仅返回具有 system=1 的 uuid,而不返回具有 system= 1 和 2 的 uuid 最佳答案 SELECT * FROM
我很想了解在 Avro 中编码一种非常特定类型的数据的最佳实践:UUID。 最佳答案 到目前为止,我发现的唯一方法是定义自定义 UUID: { "namespace" : "your.namesp
我是一名优秀的程序员,十分优秀!