gpt4 book ai didi

android - 谷歌眼镜上的 rfcomm 蓝牙

转载 作者:行者123 更新时间:2023-11-30 03:12:13 24 4
gpt4 key购买 nike

我有一个 Android 应用程序 [1],我部分地想将其移植到 google-glass - 这个应用程序使用蓝牙 rfcomm。现在我面临以下问题:当我使用我的连接代码时,我在玻璃上看到一个配对对话框 - 显示一个大数字并要求点击以确认。但这很奇怪——因为我通常必须在电话上输入我的 4 位数密码——我也遇到了身份验证问题(闻起来像是因为不让我输入密码引起的)有人在 google-glass 上使用 bluetooth-rfcomm 吗?

[1] https://github.com/ligi/DUBwise

最佳答案

我遇到了这样的问题!在这个post我把我的完整解决方案解决了这个问题。

但基本上配对是这样完成的:

在广播接收器中

    if(BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action)){
BluetoothDevice device = ListDev.get(selectedDevice);
byte[] pinBytes = getStrFromName(device.getName(),7,11).getBytes(); // My devices had their own pin in their name, you can put a constant pin here or ask for one...
try {
Method m = device.getClass().getMethod("setPin", byte[].class);
m.invoke(device, pinBytes);
try {
device.getClass().getMethod("setPairingConfirmation", boolean.class).invoke(device, true);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}

因此在此示例中,pin 是自动设置的,但您始终可以向用户请求 pin。

希望对您有所帮助!

关于android - 谷歌眼镜上的 rfcomm 蓝牙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20751927/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com