Avatar for tronic98776


Member since Mar 2019 • Last active Sep 2019
  • 3 conversations

Most recent activity

  • 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){
    else {digitalWrite(LED1,0);
    function myFunction() {
      myVar = setInterval(checkRssi, 3000);
  • 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


    I'm using a puck as a ble HID keyboard with NRF.setServices(undefined, { hid : kb.report }); based on this Tutorial:

    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.


  • 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?

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

    So, if I follow your steps above it works.
    But it doesn't work if I add it to the onInit.

    Here are the first few lines of my code:

    function onInit() {
    var kb = require("ble_hid_keyboard");
    NRF.setAddress("c3:92:e6:f6:f6:f6 random");
    NRF.setServices(undefined, { hid : kb.report });

    Also, when I add the setAddress to my onInit it seems to also prevent the HID service from starting, as when I connect to my android with the onInit as above it no longer connects as a BLE HID.

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

    So I'm still having no success with this:

    NRF.setAddress("yy:yy:xx:xx:xx:xx random");

    With yy:yy being the same as the original hardcoded MAC address to match the address type and avoid the INVALID_BLE_ADDR.

    The Puck still advertises and connects to my phone with the original hard-coded MAC address.

    The exact steps I have taken.
    I am using the web IDE in chrome. On the right hand side I have my BLE HID code (which is all functioning correctly). I connect the Puck to the web Ide. Upload my code from the RHS on to the puck. I then enter NRF.setAddress("C3:92:xx:xx:xx:xx random"); into the command on the left hand side. It returns undefined. I type save(). I type NRF.disconnect(). The Puck disconnects from the web ide. I restart the Puck, by lifting and releasing the battery. I then open the bluetooth settings on my android phone, scan for a new device, I find the Puck, connect and pair with it. I then click on the Puck in my Android bluetooth settings to check the MAC address and it displays the same hard-coded address that is returned when i type NRF.getAddress() into the ide. So as far as I can tell I am not successfully changing the MAC address.

    I just tried here and it works fine

    @Gordon, can you please tell me that exact steps you took to get the change to work

    I really appreciate your help on this Gordon.

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

    Thank you @Gordon.

    Just to make sure I understand - you're connecting to the Puck from a device like a PC or phone?

    That is correct I am using the Puck as a Ble HID Keyboard, I want to connect it to my phone, use it to pass a string of characters to the phone (based on an event), then (based on another event) I want to disconnect the Puck from the phone (without touching the phone) and have it not auto-reconnect to the phone.

    I had looked at changing the MAC address using each of the 3 variations as I wasn't sure from reading the documentation what each type of address was. It seemed a little confusing to me have a static address that is random?

    NRF.setAddress("xx:xx:xx:xx:xx:xx public");
    NRF.setAddress("xx:xx:xx:xx:xx:xx random");

    But none of them seemed to have any effect on the device's mac address. I including the line in my onInit() function, I tried having it outside of the function, uploading my code and using the save() command. I have also tried entering it into the command line directly. When entering into the command line on the web IDE, it returns "undefined", then when I check for the change by entering NRF.getAddress(), it just returns the original default MAC address of the Puck. I have tried save(), on the device, then power cycling the puck, but the changes are still not working.

    If I can get the MAC address to successfully change with the NRF.setAddress, then this should work as a solution, because I can create a random string on init of the Puck, which will hopefully prevent reconnection to the phone as it will not appear to be a previously paired/bonded device.

    On another note, (although this wasn't a solution for me) I was able to change the advertised name with:


    But I couldn't find a way of resetting this back to the default "puck.js xxxx" where I think the xxxx was the last few characters of the MAC address. Is there a command to reset this back to factory default?

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

    I'm trying to prevent the puck from automatically reconnecting to a device that it has previously been connected to and paired with. So after the puck has been connected and paired with a device, I want to action a reset/power cycle of the puck and for it to not connect to the device again unless I go through the connection process again on the device.

    I know that I can just select "forget this device" from bluetooth settings on the device, but I want a way of implementing this from the puck itself (ie via a button press).

    My initial plan was to set it to create a device name containing a random string on init, and then calling a reset() on the button press. This plan failed as the phone/laptop device that the puck has been paired with ignores the fact that the bluetooth device name has changed and still reconnects. I assume it looks at the underlying MAC address instead.

    Does anybody know a way of implementing this?

    Perhaps there is a mode I can set which enables connection without pairing?

    Many thanks.