UUID 和 GUID 问题
请不要将此标记为重复。我已经浏览了有关该主题的所有帖子,但无法解决我的问题。
我在 J2ME 中有一个应用程序,用于搜索具有特定 UUID 的蓝牙服务:
UUID[] uuidSet = { new UID("100000",true) };
int[] attrSet = {0x0100, 0x0003, 0x0004};
int transID = agent.searchServices(attrSet,uuidSet,remoteDevice,this);
我在 VB.NET 中有一个桌面应用程序,使用 32feet.NET 库创建具有特定 GUID 的新蓝牙服务。
Sub startBluetoothListener()
Dim lsnr As New BluetoothListener(MyConsts.MyServiceUuid, record)
lsnr.Start()
Dim conn As New BluetoothClient
Dim peerStream As Stream
End Sub
Class MyConsts
Public Shared ReadOnly MyServiceUuid As Guid _
= New Guid("{7dc53df5-703e-49b3-8670-b1c468f47f1f}")
End Class
现在根据规则,为了正常运行,GUID/UUID 应该匹配。然而,在 .NET 中,GUID 表示为十六进制字符串,而在 JAVA 中则不同。我在 google 上搜索了很多有关如何同步 J2ME 和 .NET GUID/UUID 的信息,但没有成功。
Please don't mark this as duplicate. I have gone through all posts on this topic but couldn't solve my problem.
I have an application in J2ME that searches for bluetooth services with a particular UUID:
UUID[] uuidSet = { new UID("100000",true) };
int[] attrSet = {0x0100, 0x0003, 0x0004};
int transID = agent.searchServices(attrSet,uuidSet,remoteDevice,this);
I have a desktop application in VB.NET using 32feet.NET library that creates a new bluetooth service with a particular GUID.
Sub startBluetoothListener()
Dim lsnr As New BluetoothListener(MyConsts.MyServiceUuid, record)
lsnr.Start()
Dim conn As New BluetoothClient
Dim peerStream As Stream
End Sub
Class MyConsts
Public Shared ReadOnly MyServiceUuid As Guid _
= New Guid("{7dc53df5-703e-49b3-8670-b1c468f47f1f}")
End Class
Now as per rules, in order to function both GUID/UUID should match. However in .NET the GUID is represented as a hexadecimal string and in JAVA it's different. I googled a lot about how to sync the J2ME and .NET GUID/UUID but could not succeed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经阅读了 UUID 的 j2me 实现的源代码,它似乎只是表明您省略了大括号和连字符,即使用:
如果您使用 true 参数,它需要一个短格式的 UUID(即 8 个字符长)
我最初的答案是基于 J2SE 实现的,即:
I've read the source for the j2me implementation of UUID, and it simply seems to indicate that you omit the braces and the hyphens i.e. use:
if you use the true parameter, it expects a short-form UUID (i.e. 8 characters long)
My original answer was based on the J2SE implementation, viz: