Avatar for sammachin

sammachin

Member since Nov 2016 • Last active Aug 2021
  • 12 conversations
  • 34 comments

Most recent activity

  • in General
    Avatar for sammachin

    Sure, I updated the title to try and make it easier to find but putting it on the docs page seems like a good idea,
    There's probabbly a few more of these AL keys that could do interesting things with iOS, I also found that sending keyboard modfier 17 toggles the voice input keyboard.

  • in General
    Avatar for sammachin

    SUCCESS!
    After a bit more experimenting (aka brute forcing) I managed to figure out how to call the 2nd report. This code will add the ability to toggle the on screen keyboard in iOS devices when connected to a BLE keyboard from espruino.
    We extend the built in keyboards report with the additional codes and then set that wiht servies so you can still use all the existing features of ble_hid_keyboard like kb.tap(kb.KEY.A, 0);

    I've tested this on a pixl.js running 2.09 against an iPhone running iOs 14.6 so it works until Apple decide to change something!

    var kb = require("ble_hid_keyboard");
    
    togleReport = new Uint8Array([
    // 2nd Report for iOS Toggle Keyboard  
      0x05, 0x0C,                     // Usage Page (Consumer)
      0x09, 0x01,                     // Usage (Consumer Control)
      0xA1, 0x01,                     // Collection (Application)
      0x85, 0x02,                     //     Report Id (2)
      0x15, 0x00,                     //     Logical minimum (0)
      0x25, 0x01,                     //     Logical maximum (1)
      0x75, 0x01,                     //     Report Size (1)
      0x95, 0x01,                     //     Report Count (1)
    
      0x0A, 0xAE, 0x01,               //     Usage (AL Keyboard Layout)
      0x81, 0x06,                     //     Input (Data,Value,Relative,Bit Field)
      0xC0                            // End Collection
    ]);
    //Append the new report to the built in kb report
    var report = new Uint8Array(kb.report.length + togleReport.length);
    report.set(kb.report);
    report.set(togleReport, kb.report.length);
    
    //Set services with new combined report
    NRF.setServices(undefined, { hid : report });
    
    //Call this function to toggle the on screen keyboard
    function toggleKB(){
      NRF.sendHIDReport([2,1], function() {
        NRF.sendHIDReport([2,0], function() {}); 
      });
    }
    
    
    
    
  • in General
    Avatar for sammachin

    no joy with sending it as a keycode or a modifier, built a little app that just steped through each code to see what would happen!

    With a little more digging it seems like the way to toggle it is to send AL Keybard Layout as one of the Application Launch Buttons on the USB HID spec, (section 15)

    I found this SO post https://stackoverflow.com/questions/2218­1883/bluetooth-le-hid-eject-key-code which looks like they're creating a second report object with the Application Launch buttons and then sending that for the toggle, but I couldn't figure out how to translate that into espruino to send the alternate report in NRF.sendHIDReport, is there a way to select the report ID?

  • in General
    Avatar for sammachin

    Hi Gordon,

    Sorry yes should have said I was doing the key up event as well just posted the keycode bit for clarity

    Thats a good point about the maxium I'll try that, do I need to raise both Logical Maxiumum and Usage Maximum ?

    Also I was confused about the vaule of the Keycodes are they Hex or Dec? the library seems to have hex for the modifiers and dec for the keycodes? are they just interchangable

  • in General
    Avatar for sammachin

    I'm setting up a Puck to work with my iPhone as a BLE keyboard, all good so far but iOS has an annoying habit that it disables the on screen keyboard if there's a hardware one connected.
    You can toggle the on-screen keyboard using the eject key on Apple Keyboards, which I belive is keycode 0x92.

    I'd like to be able to send this from my puck so I don't have to keep disconnecting the keyboard in bluetooth each time.

    Any ideas how to do this? I've tried

    NRF.sendHIDReport([0,0,146,0,0,0,0,0]
    

    and

    NRF.sendHIDReport([0,0,0x92,0,0,0,0,0]
    

    without any luck

    • 12 comments
    • 1,469 views
  • Avatar for sammachin

    Did a bit more digging on this and some testing with my espriunio WiFi.
    The 0x7780 error seems to relate to a problem with the certificate chain, likely due to the server using a self signed cert. I get this error thrown with the EsprinoWiFi as well as the Pixl.
    I'm a bit out of my depth but supposedly if you call mbedtls with MBEDTLS_SSL_VERIFY_NONE set then it will ignore the cert chain, I think this line says that should be set in esprunio though? https://github.com/espruino/Espruino/blo­b/master/libs/network/network.c#L599

    Yes I was uploading to flash already, seems like this might be just too much for the nRF52 to deal with on its own, I think I need to look at offloading the SSL to something else like an ESP-32 instead of the ESP-8266 that I'm using anyway
    Its rather annoying that Tesla are forcing the powerwall to use SSL with a self signed cert, the whole project works really nicely if I could just overcome that issue.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for sammachin

    I did some more testing last night;

    Firstly trying to fetch the pur3 page with the pixl returns an out of memory error

    TLS check
    http
    TLS yes?
    =undefined
    Uncaught InternalError: Failed! mbedtls_ssl_handshake returned Not enough memory
    

    Then I tried with my EspruinoWiFi, fetches the pur3 page fine but on the internal IP I get the same 0x7780 error, with a bit of googling this error seems to be related to the certificate chain, as my device uses a self signed cert this makes sense.

    So there are now 2 problems:
    The pixl still can't make an HTTPS request even to a 'good' host
    Espruino doesn't like self signed certs.
    Is there any way to set a flag to ignore the certificate validation and just accept the cert, like the -k option in curl?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for sammachin

    Ok tried that with a modified bit of code to remove the vector font and just log to console but I get an error

    TLS check
    http
    TLS yes?
    =undefined
    Uncaught InternalError: Failed! mbedtls_ssl_handshake returned -0x7780
    
    
Actions