如何获得Android 5.0以上版本的工作蓝牙HID主机 [英] How to get Bluetooth HID host on Android 5.0+ working

查看:1489
本文介绍了如何获得Android 5.0以上版本的工作蓝牙HID主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个蓝牙HID设备,我需要得到的工作的上一个的Nexus 7平板电脑2013运行我的应用程序运行自定义生成于Android 5.0分叉。所以:

I have a bluetooth HID device that I need to get working with my app running on a Nexus 7 2013 tablet running custom build forked from android 5.0. so:


  • @hide 不是一个约束

  • 更改AOSP允许

  • 任何Android版本5.0 * - * 5.1细

  • @hide is not a constraint
  • Changes to AOSP are permitted
  • Any Android version 5.0* - 5.1* is fine

现在我的设备带有键盘,并发送和接受一些特定厂商的HID报告。通过的工作的,我的意思是发送和接收的所有HID报告

Now my device has a keyboard, AND sends and accepts some vendor-specific HID reports. By working, I mean sending and receiving all HID reports

,似乎是:


  1. HidService 服务广播 BluetoothInputDevice.ACTION_REPORT 意图所有输入HID报告[我的应用程序有一个广播接收器接收 ACTION_REPORT 意图]

  1. The HidService service broadcasts BluetoothInputDevice.ACTION_REPORT intents for all input HID reports [My app has a BroadcastReceiver to receive ACTION_REPORT intents]

BluetoothInputDevice 提供了像 setReport其他接口()送出数据() 连接()等通过 HidService

BluetoothInputDevice provides other interfaces like setReport(), sendData(), connect() etc through HidService.

BluetoothInputDevice 使用 HidService 来提供HID设备接口。

BluetoothInputDevice uses HidService to provide HID device interface.

HidService.java 是JNI封装在 com_android_bluetooth_hid.cpp

com_android_bluetooth_hid.cpp ,在 HidService 的初始化,将注册自己的回调Bluedroid

com_android_bluetooth_hid.cpp, on initialization of HidService, will register its own callbacks to Bluedroid

我添加日志AOSP追踪电话,似乎所有上述是正确的。

I have added logs to AOSP to trace calls and seems all the above is correct.

get_report_callback() com_android_bluetooth_hid.cpp 不会被调用,因此,我的应用程序不接受 ACTION_REPORT 意图。

The get_report_callback() in com_android_bluetooth_hid.cpp never gets called, and consequently, My app does not receive ACTION_REPORT intents.

如果我发送无效 ACTION_REPORT 从我的应用程序的意图,那么我的广播接收器接收的意图。

If I send dummy ACTION_REPORT intents from my app, then my BroadcastReceiver receives those intents.

我的HID设备连接和工作,因为我看到在关键领域的EditText我的应用程序内收到。

My HID device is connected and working, as I do see keys received in edittext field within my app.

有什么办法,我可以接受我的应用我的设备的HID报告?通过意图或通过任何其他方式?

Is there any way I could receive my device's HID reports in my app? through intents or through any other way?

如果我能获得通过意图,是否有我错过了任何一步?我基本上只是广播接收器意图过滤器和蓝牙 BLUETOOTH_ADMIN 接收HID报告的权限。

If I could receive through Intents, is there any step that I missed? I basically just have BroadcastReceiver with intent filter and BLUETOOTH and BLUETOOTH_ADMIN permissions for receiving HID reports.

如果必须使用任何其它方法,请建议

If any other method must be used, please suggest.

推荐答案

BluetoothInputDevice没有在所有的工作。

BluetoothInputDevice didn't work at all.

我用的/ dev / hidraw *从C code访问蓝牙hidraw设备。

I used /dev/hidraw* from C code to access the bluetooth hidraw devices.

MAC地址并非为/ dev / hidraw *节点的报道。

mac address is NOT reported by /dev/hidraw* nodes.

在Android的5.x中他们的工作和所有的设置/发送/ recv的报告操作工作。得到未经测试。

In Android 5.x they work and all set/send/recv report operations are working. get not tested.

在Android版6.x中,​​只有recv的操作是从/ dev / hidraw工作。设置/发送不工作。得到未经测试。

On Android 6.x, only recv operation is working from /dev/hidraw. set/send are not working. get not tested.

我将发布更新时,我有更好的回答。

I will post update when I have better answer.

这篇关于如何获得Android 5.0以上版本的工作蓝牙HID主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆