• Hey,

    I'm using the HID Keyboard example - espruino.com/Puck.js+Keyboar­d plus simple LED on/off with button press/release - to try to send a single keypress to an iPad.

    While it sometimes works, once it's cut off it does nothing: the LED still lights when pressed so the code's still working, but there's no effect on the iPad. The Puck is still paired and connected with the iPad.

    Now, I've noticed github.com/espruino/Espruino/iss­ues/1101 and some other ideas, but what's really tricky is the limitation that the Puck must be disconnected from the IDE to pair it with the iPad: only one connection at a time. It means I have no error messages visible to debug the problem.

    My NoName™ FT232 USB-to-serial board is not working for some reason - probably lack of flow control - and the wiring is unwieldy, so I was thinking the other Puck I got from Kickstarter might be an easy way to do it. Failing that, I might rope a spare Pico in to act as a dumb serial converter.

    So, I guess my question is, what's a straightforward way to cross-connect the serials of one Puck with another Puck, so the IDE (or at least the command-line errors) can be viewed while still connected as a HID device? Or, any other approaches to try?

    Thanks,
    Tom

  • Wow, that's pretty extreme! I'd say try using a Pico if your USB-TTL converter doesn't work - the flashing code for espruino.com/ESP8266 actually sets a Pico up as a pass-through.

    With Puck-Puck there's a bit of a catch-22. The serial port takes power, so won't initialise itself if the Puck is powered on without serial connected (the RX pin pulled high). Obviously if you connect 2 Pucks together neither will initialise, so you'd have to manually enable serial on one first with Serial1.setup.

    I actually fixed a whole bunch of HID-related bugs just recently, so first it might be worth trying the attached zip file.

    I'm still trying to get it working stably, but the attached build just happens to work fine by the look of it. There are 2 issues that might cause problems that the recent build fixes:

    • If you try and send a key while disconnected it generates an error, but that stops you sending any more HID commands
    • If you disconnect then reconnect, the connecting device expects Puck.js to remember some info about it, but Puck.js didn't - and that can cause some problems.

    1 Attachment

  • Ah, okay... I'm DFU'ing that build now, thanks.

    I was thinking exactly of that Pico pass-through code before I wondered if I could use a second puck. I see what you mean about the Catch-22.

    Anyway, I'll try this out. FYI, this is how it's being used:

  • Cool - what's the idea? Is that some kind of rubbery gauntlet thing?

  • It's actually rigid: Thermomorph / Polymorph, ie. polyester plastic that melts in hot water.

    It's so that when I'm relaxing and recovering from back pain, lying down, I can just turn page on iBooks on iPad by sending a "right" keypress. That way I don't have to hold the iPad or reach up to turn page, thus saving my shoulder and upper back muscles from unnecessary tension.

    Incidentally, I haven't managed to get the new firmware talking yet. In fact, it's having trouble connecting to the Web IDE. I think my Mac needs a reboot. Still trying.

  • Nope.. this build seems to just do a full reset (RGB LEDs all to full for about a second, then off, then a short red blink) when I try to connect to it via Web IDE, or pair it with the iPad.

    I'm going to DFU it again to make sure it's not my code, but I doubt it.

  • That's really neat! I'd love to see Puck.js used for some more stuff like this!

    I guess you could detect long presses (or maybe even use the magnetometer) and mimic other keypresses with it.

    That's odd - maybe it's an issue with saved code (I had to move the saved code location and it might be messing up the pairing).

    Can you try this on a working firmware, and then uploading the new one?

    var f = require("Flash");
    f.erasePage(0x75000);
    f.erasePage(0x76000);
    f.erasePage(0x77000);
    
  • Okay, that did the trick: I DFU'ed to 1.91, did the lines above, and then DFU'ed to 1.91.715. It now pairs more successfully.

    However, it hasn't been entirely successful. It took about three goes of code tweaking, re-upload, resets, unpair/pair before the iPad would actually do the "page right" function. It's working okay now, even after an NRF.disconnect(). I'll keep an eye on it and see if it stops working again.

    FYI: at least with this firmware, onInit() doesn't seem to work. Once reconnected, dump() yields garbage.

  • Thanks for checking - I'll make sure I do something about wiping the old saved code in the final version.

    Odd about the dump() problems though. I'll take another look - it's all really flaky at the moment for some reason - I've had a lot of problems with the Nordic peer management stuff :(

  • (Incidentally, I've just written up the project)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Debugging HID/Keyboard with serial to another Puck?

Posted by Avatar for tom.gidden @tom.gidden

Actions