Heerkog / MicroPythonBLEHID

Human Interface Device (HID) over Bluetooth Low Energy (BLE) GATT library for MicroPython.
GNU General Public License v3.0
204 stars 28 forks source link

How to test the mouse BLE ESP32 code? #11

Closed bx5974 closed 1 year ago

bx5974 commented 1 year ago

Hi,

I got the lib and examples into esp32,

I can connecto to the BLE keyboard / Mouse.

Can you please help with code to send sample keystrokes (on connect for testing purpose ) and sample code to move left/ right / up/ down mouse cursor once connected ?

MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32
Type "help()" for more information.
>>> exec(open('keyboard_example.py').read())

Notify with report:  (0, 0, 18, 0, 0, 0, 0, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 199, in <module>
  File "<string>", line 96, in start
  File "<string>", line 137, in send_string
  File "<string>", line 126, in send_char
  File "hid_services.py", line 934, in notify_hid_report
OSError: [Errno 12] ENOMEM
>>> import os
>>> os.listdir(".")
['boot.py', 'hid_services.py', 'joystick_example.py', 'keyboard_example.py', 'mouse_example.py']
>>>

I just tried adding self.send_string(" Hello World") in connect block but getting the above error

                if self.keyboard.get_state() is Keyboard.DEVICE_CONNECTED:
                    self.keyboard.set_keys(self.key0, self.key1, self.key2, self.key3)
                    self.keyboard.notify_hid_report()
                    #self.keyboard.set_keys(0x07)
                    self.send_string(" Hello World")
Heerkog commented 1 year ago

You may need to wait a little bit after having connected to send keystrokes. You may also need to wait a little bit between sending keystrokes.