Avatar for tronic98776

tronic98776

Member since Mar 2019 • Last active Mar 2020
  • 4 conversations
  • 23 comments

Most recent activity

    • 6 comments
    • 2,378 views
  • in Puck.js, Pixl.js and MDBT42
    Avatar for tronic98776

    I'm having trouble getting this to work. For eaxample here is what I'm trying to write to .boot0 and have it execute on device start-up, but it's not working for me:

    require("Storage").write(".boot0", `
    
    
    //function onInit() {
    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    function btnPressed() {
      // Send 'm'
      kb.tap(kb.KEY.M, 0);
      digitalWrite(LED3, true);
      setTimeout("digitalWrite(LED3, 0);", 100);
    }
    
    // trigger btnPressed whenever the button is pressed
    setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50})­;
    //}
    
    
    `);
    
    

    So i have nothing in save(), so do not enter the save() command into the terminal, I just send the above code onto the puck via the IDE, then disconnect from the IDE and restart the puck by cycling the power.

    I have tried both including the onInit and leaving it commented out as above.

    Do I have something wrong, or is it something to do with the ble_hid_keyboard service not working from boot0?

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

    Thank you Gordon. That should be perfect. I'll give it a try.

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

    I'm looking for a way to disable the hard-reset that is initiated by holding down the button on power up to clear out any previously saved code and bonding data. Is there a command I can add into my code that will prevent this function?

    I understand there are certain risks with doing this but I want to prevent the chance of erasing the code accidentally.

    I would like to still have the self-test function intact where you can power up the puck without loading the saved code and without deleting the saved code.

    many thanks

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

    Thanks for your help.

    I've found a workaround, it functions, but its not ideal and I doubt it's very efficient in terms of battery power. I check the RSSI (Signal Strength), and illuminate the LED depending on the result:

    NRF.setRSSIHandler(function(rssi) {
      sigStrength = rssi;
    });
    
    function checkRssi() {
    if (sigStrength > -51){
      digitalWrite(LED1,1);
    }
    else {digitalWrite(LED1,0);
    }
    }
      
    function myFunction() {
      myVar = setInterval(checkRssi, 3000);
    }
      
    myFunction();
    
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for tronic98776

    Thank you for your reply Robin

    But I had looked previously at those sections, and I have looked at the tutorials and can't find a relevant one. I'm not sure what I'm missing in the documentation you linked to, could you please be more specific.

    Perhaps I didn't explain what I wanted to do, I know how to make the LEDs turn on and off, but I want to trigger an LED when a Central device connects to my Puck via BLE using the active Ble HID keyboard service. I am able to connect to the Puck and use it to send keyboard commands to the central device, but I want the connection to trigger a function (like illuminate an LED on the Puck).

    Thank you.

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

    Hello

    I'm using a puck as a ble HID keyboard with NRF.setServices(undefined, { hid : kb.report }); based on this Tutorial:
    https://www.espruino.com/BLE+Keyboard

    What I'm looking for is a way to test if it is connected via bluetooth or not, for example to illuminate one of the LEDs when connected.

    I've looked through the documentation and searched the forum, but can't find anything.

    Help appreciated.

    Thanks

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

    OK, thanks @Gordon, so I think I understand the problem and why it won't work with the firmware as it is.

    It seems from this that what you want is actually a lot simpler than that.

    I'm afraid not.

    I assumed you wanted to be able to connect with another device while stopping the phone connecting

    This is correct. I want to connect the Puck to Phone A, send an HID string to it based on x-event, then, based on y-event I want the Puck to disconnect from Phone A or power-down and then be discoverable and able to connect to Phone B without Phone A ever auto-reconnecting.

    I assume that using an E.on function as well as an onInit won't solve my problem? as they are essentially the same thing?

    Is there a way to set the Puck to connect without bonding? Would that even work?

    Is there a way other than changing the MAC address of making the Puck appear to be a different/unknown device to a previously paired Phone?

    Can you think of any other ways around this other than a firmware update?

Actions