有没有人有一个完整的工作示例,说明如何以编程方式配对使用密码输入(即6位数PIN)或Android 4.4或更高版本的数字比较的BLE(非 Bluetooth Classic)设备?通过'以编程方式'我的意思是我告诉Android PIN - 用户不会被提示.
在SO上有很多类似的问题,但它们要么a)关于蓝牙经典,b)旧(之前setPin()和createBond()公开),或c)未答复.
我的理解如下.
我已经使用创建设备mBed上运行nRF51-DK和赋予它的单个特性.
我设置了安全参数,如下所示:
ble.securityManager().init(
true, // Enable bonding (though I don't really need this)
true, // Require MitM protection. I assume you don't get a PIN prompt without this, though I'm not 100% sure.
SecurityManager::IO_CAPS_DISPLAY_ONLY, // This makes it us the Passkey Entry (PIN) pairing method.
"123456"); // Static PIN
Run Code Online (Sandbox Code Playgroud)
然后在我使用的特征
requireSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM);
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试使用Nordic Master Control Panel阅读它时,我收到一个如下配对请求通知: …