UUID 和 GUID 问题

发布于 2024-11-14 15:35:22 字数 828 浏览 1 评论 0原文

请不要将此标记为重复。我已经浏览了有关该主题的所有帖子,但无法解决我的问题。

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱殇璃 2024-11-21 15:35:22

我已经阅读了 UUID 的 j2me 实现的源代码,它似乎只是表明您省略了大括号和连字符,即使用:

new UUID("7dc53df5703e49b38670b1c468f47f1f", false)

如果您使用 true 参数,它需要一个短格式的 UUID(即 8 个字符长)

我最初的答案是基于 J2SE 实现的,即:

不是字符串中 UUID 的构造函数:

UUID aUUID = UUID.fromString("")

字符串所在位置:

7dc53df5-703e-49b3-8670-b1c468f47f1f

对于您的 UUID(即从 Guid 字符串中删除前导“{”和尾随“}”)

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:

new UUID("7dc53df5703e49b38670b1c468f47f1f", false)

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:

isn't the constructor for a UUID from a string:

UUID aUUID = UUID.fromString("")

where the string is:

7dc53df5-703e-49b3-8670-b1c468f47f1f

in the case of your UUID (i.e. remove the leading '{' and trailing '}' from the Guid string)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文