Avatar for user95552

user95552

Member since Nov 2018 • Last active Nov 2018
  • 1 conversations
  • 4 comments

Most recent activity

  • Avatar for user95552
    [Puck.js a766]# info E5:DD:7B:99:A7:66
    Device E5:DD:7B:99:A7:66
        Name: Puck.js a766
        Alias: Puck.js a766
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no
    

    still doesnt work.
    What confuses me is that I can connect using EspruinoHub and send code to the device so I know that the Raspberry Pi is supporting BLE but it doesnt seem to support HID.
    Does anyone know why?

  • Avatar for user95552

    replacing tap with

    NRF.sendHIDReport([2,0,4], function() {
      NRF.sendHIDReport([0,0,0]);
    });
    

    results in the same error. so probably not ble_hid_keyboard issue.

  • Avatar for user95552

    One additional piece of info. I tested this while connected bluetooth to my mac, everything worked without error. This only occurs when puck is connected to raspberry pi.
    I also used a much simpler code

    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    function btnPressed() {
      // Send 'a'
      kb.tap(kb.KEY.A, 0, function() {
        // Followed by capital 'A'
        kb.tap(kb.KEY.A, kb.MODIFY.SHIFT);
      });
    }
    
    // trigger btnPressed whenever the button is pressed
    setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50})­;
    

    got the exact same error.
    there is something wrong with ble_hid_keyboard on the raspberry pi.

  • Avatar for user95552

    Sorry for this newbie question, first day playing with this.
    Everything is latest. Have EspruinoHub started in systemctl.
    I can connect to the raspberrypi EspruinoHub ide, connect to Puck and upload code.
    Puck firmware 2v00
    Found some code in tutorials and hacked it together. All I want to achieve is to have a button press result in a keyboard type the letter p

    After sending the code I disconnect and reconnect
    Click on the puck and console says

    Uncaught Error: Got BLE error 0x8 (INVALID_STATE)
     at line 1 col 104
    ...0,0,0],function(){a&&a()})})
                                  ^
    in function "tap" called from line 6 col 36
        kb.tap(kb.KEY.P, 0,function(){});
    
    in function called from system
    >
    

    If I click the puck again I get

    Click 2
    

    Here is the full code:

    
    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    var clickcount = 0;
    var clickevent = null;
    
    
    setWatch((e) => {
      clickcount++;
      if (clickevent !== null) clearTimeout(clickevent);
    
      if (clickcount === 1) {
        setLEDS(false, true, false);
        kb.tap(kb.KEY.P, 0,function(){});
      } else if (clickcount === 2) {
        setLEDS(true, false, false);
        //kb.tap(kb.KEY.Z, 0);
      } else if (clickcount === 3) {
        setLEDS(false, false, true);
        //kb.tap(kb.KEY.S, 0);
      } else {
        setLEDS(true, true, true);
      }
    
      clickevent = setTimeout(() => {
        if (clickcount === 1) {
          console.log("Click 1");
        } else if (clickcount === 2) {
          console.log("Click 2");
    
        } else if (clickcount === 3) {
          console.log("Click 3");
    
        }
    
        clickcount = 0;
      }, 350);
    }, BTN, {
      edge: "rising",
      debounce: 50,
      repeat: true
    });
    
    setWatch((e) => {
      setLEDS(false, false, false);
      setTimeout(() => {
        clickevent = null;
      }, 400);
    }, BTN, {
      edge: "falling",
      debounce: 50,
      repeat: true
    });
    
    const setLEDS = (LED1on, LED2on, LED3on) => {
      LED1.reset();
      LED2.reset();
      LED3.reset();
    
      if (LED1on) LED1.set();
      if (LED2on) LED2.set();
      if (LED3on) LED3.set();
    };
    
    

    Thank you for helping me. I'm totally confused.

Actions