Skip to content

脚本可以运行但是连接主机的时候会报错 #25

@wszme

Description

@wszme
       def RequestPasskey(self, device):
        print("RequestPasskey (%s)" % (device))
        passkey = ""
        kb = ev.InputDevice(glob.glob('/dev/input/by-path/*event-kbd')[0])
        print(kb)
        print("connecting")
        passkey = input("Tell me your pin")
        print(passkey)
        # for event in kb.readoop():
        #     data = ev.categorize(event)  #ev 来自相关设备和键盘的事件
        #     if event.type != ev.ecodes.EV_KEY:
        #         continue
        #     elif data.keystate == 0: # ignore keyup
        #         continue
        # 
        #     key = ev.ecodes.KEY[event.code][4:]
        #     if key == 'ENTER': # we are done
        #         break
        #     elif key in ['1','2','3','4','5','6','7','8','9','0']:
        #         passkey = passkey + key

        set_trusted(device)
        return int(passkey)

注释的地方报错了,还有两个包两个包没有装上(GLib, Gio)上面是我的解决方案;
然后我就用input方法替换取pin码的操作,可以连接成功,能够连接上设备了,但是接下来也不能实现按键和鼠标的操作,不知道是为什么,请求帮助,在线急等,求回复,谢谢,求联系方式。
希望能够帮助我万分感谢。
这里是我的环境
BlueZ(>=5)这个没有找到没有装(我现在正在准备找这个然后开始安装这个)再次期待能联系我

  • python==3.6
  • [PyGObject] ==3.26.1
  • [evdev] ==1.3.0
  • [pydbus]==0.6.0
  • [PyBlueZ] ==0.23
    一下是报错信息
    device /dev/input/by-path/platform-i8042-serio-0-event-kbd, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0"
    Traceback (most recent call last):
    File "/home/b0g3/桌面/bluetest/dbus.py", line 43, in on_method_call
    result = getattr(self, method_name)(*args)
    File "/home/b0g3/桌面/bluetest/agent.py", line 83, in RequestPasskey
    for event in kb.readoop():
    AttributeError: 'InputDevice' object has no attribute 'readoop'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions