相关疑难解决方法(0)

以编程方式与Android 4.4+上的BLE设备配对

有没有人有一个完整的工作示例,说明如何以编程方式配对使用密码输入(即6位数PIN)或Android 4.4或更高版本的数字比较的BLE( Bluetooth Classic)设备?通过'以编程方式'我的意思是我告诉Android PIN - 用户不会被提示.

在SO上有很多类似的问题,但它们要么a)关于蓝牙经典,b)旧(之前setPin()createBond()公开),或c)未答复.

我的理解如下.

  1. 您连接到设备并发现其服务.
  2. 您尝试阅读"受保护"特征.
  3. 设备返回身份验证错误.
  4. Android以某种方式启动配对,你告诉它PIN.
  5. 您现在可以阅读该特征.

我已经使用创建设备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阅读它时,我收到一个如下配对请求通知: …

android bluetooth bluetooth-lowenergy pairing

32
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

bluetooth ×1

bluetooth-lowenergy ×1

pairing ×1