【发布时间】:2011-11-10 23:33:41
【问题描述】:
我正在尝试通过蓝牙将按键从 ubuntu 发送到我的 iPhone4。 即,开发一个非常原始的虚拟键盘。
问题让我的应用程序与 iPhone 通信(即使用 报告协议,这是 iPhone 所支持的全部)。事实上,我的 write(interruptChannelFD) 调用没有返回错误,但是
iPhone 端没有文字出现。 l2cap 通道已使用 blueZ 库打开。
问题 1:鉴于没有虚拟键盘可以做到这一点,它到底有多难?
我正处于 iPhone 和我的 linux box 连接并保持连接的阶段,没问题。
此外,所有perror() 调用都告诉我控制和中断通道套接字连接得很好。 (我所做的是将我的加密狗 hciconfig 到键盘设备类并使用
Collin Mulliner 的知名代码稍作修改——我必须输入一次密码,因为所有智能手机都需要)。
问题 2: 我应该可以只用write() 进入中断套接字而不用担心加密,对吧?我输入了密码,手机信任键盘。 (科林正在考虑可能的隐藏攻击,但我诚实地连接)
另外,据我了解,在 HID 设备的引导协议中,确切的报告 描述符 SPD 中指定的内容几乎不相关——报告格式无论如何都是固定的。所以...
问题 3:我是否错过了有关 报告协议 的一些重要内容。 我所做的是修改 Apple 键盘报告描述符并编写 进入插座(见下文)。
const uint8_t hid_spec[] = {
0x05, 0x01, // usage page
0x09, 0x06, // keyboard
0xa1, 0x01, // collection (Application)
0x85, 0x01, // report id (0x01)
0x05, 0x07, // usage page(keyboard)
0x19, 0xe0, // usage min
0x29, 0xe7, // usage max
0x15, 0x00, // logical min
0x25, 0x01, // logical max
0x75, 0x01, // report size
0x95, 0x08, // report count
0x81, 0x02, // input (dat var abs)
0x75, 0x08, // report size
0x95, 0x01, // report count
0x81, 0x01, // input (const)
// The following two outputs I don't seem to receive
0x75, 0x01, // report size
0x95, 0x05, // report count
0x05, 0x08, // usage page (LEDs)
0x19, 0x01, // usage min
0x29, 0x05, // usage max
0x91, 0x02, // OUTPUT1 (dat var abs)
0x75, 0x03,
0x95, 0x01,
0x91, 0x01, // OUTPUT2 (arr,const)
0x75, 0x08, // report size
0x95, 0x06, // report count
0x15, 0x00, // logical min
0x26, 0xff, 0x00 // logical max
0x05, 0x07
0x19, 0x00
0x2a, 0xff, 0x00,
0x81, 0x00,
// A total of 9 bits sent by now
// I tried remove the following fields
/********** BEGIN SNIP
0x75, 0x01,
0x95, 0x01,
0x15, 0x00,
0x25, 0x01,
0x05, 0x0c,
0x09, 0xb8,
0x81, 0x06,
0x09, 0xe2,
0x81, 0x06,
0x09, 0xe9,
0x81, 0x02,
0x09, 0xea,
0x81, 0x02,
0x75, 0x01,
0x95, 0x04,
0x81, 0x01,
**** END SNIP/
0xc0 // end coll
};
之后,我将以下 10 个字节写入中断通道:
pkg[0] = 0xa1; // BT HDR (DATA)
pkg[1] = 0x01; // REPORT ID 0x1 == kbd
pkg[2] = modifiers; // Ctrl, Shift, etc
pkg[3] = 0x00; // constant 0 (see descr)
// pkg[4] = 0x00; // the key code - entered before this point, according to HID usage tables.
pkg[5] = 0x00;
pkg[6] = 0x00;
pkg[7] = 0x00;
pkg[8] = 0x00;
pkg[9] = 0x00;
if (write(is, pkg, 10) <= 0) {
perror("write");
exit(-1);
}
【问题讨论】:
标签: iphone bluetooth usb hid usb-descriptor