Avatar for Gordon


Member since Sep 2013 • Last active Jan 2019

Most recent activity

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


    Yes, I think either device would be fine for that. I'll have a quick check tomorrow to be absolutely sure though.

    By the look of it you may have to pair with the device first before it'll appear in the Smart Lock list, which may mean you have to turn it into something like a media control (play/stop/pause button) - but even so that's just a few lines of code.

    The act of just broadcasting its existence shouldn't be anything that draws a bunch of power so a Puck would work fine for you for around a year's battery life.

    So... you may be able to just power on the device and make it work as you say, it may require some tweaking. However I'd seriously recommend uploading some code to the device (http://www.espruino.com/Puck.js+Security­) because potentially as it comes out of the box somebody in range in a different flat could just reprogram it to do something else :)

    I'll find out for sure tomorrow though

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

    Ahh - yes, it was a 1.94.something build in the video I think... But still, new ones will likely be a good deal more reliable :)

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

    I really think compiled is a bad idea here - execution speed really will not be your issue at all.

    Specifying SS_PIN for spi.send will automatically set it low and then high after, so you shouldn't need the d(SS_PIN, LOW); anyway.

    Please could you try just:

    function echo(){
        var r=spi.send(0x55,SS_PIN);
       print("echo response:",r);

    Do you have SS_0 pulled high? It seems that if it wasn't the chip might go into UART mode which might cause some pretty strange behaviour.

    HOWEVER looking at http://www.solutions-cubed.com/content/D­ownloads/Breakout%20Modules/DATASHEET_BM­019.pdf I don't think just sending 0x55 should work anyway...

    That's the command, but it looks like commands need to be wrapped up - see page 20 of that document. For example their Arduino code does:

     digitalWrite(SSPin, LOW);
     SPI.transfer(0x00); // SPI control byte to send command to CR95HF
     SPI.transfer(0x04); // Send Receive CR95HF command
     SPI.transfer(0x03); // length of data that follows is 0
     SPI.transfer(0x26); // request Flags byte
     SPI.transfer(0x01); // Inventory Command for ISO/IEC 15693
     SPI.transfer(0x00); // mask length for inventory command
     digitalWrite(SSPin, HIGH);

    In fact it's kind of obvious that just sending 0x55 wouldn't return the right response because data on SPI is clocked in as it is clocked out... So the data you're receiving is being sent by the device even before it has received the command.

    You could try this - which is just the Arduino code that's been hastily converted to Espruino. It might work - if called after your initial setup stuff?

    function Inventory_Command() {
     var i = 0;
    // step 1 send the command
     spi.write([0x00, // SPI control byte to send command to CR95HF
      0x04, // Send Receive CR95HF command
      0x03, // length of data that follows is 0
      0x26, // request Flags byte
      0x01, // Inventory Command for ISO/IEC 15693
      0x00], SS_PIN); // mask length for inventory command
     // ignoring delay(1); 
    // step 2, poll for data ready
    // data is ready when a read byte
    // has bit 3 set (ex: B'0000 1000')
     digitalWrite(SS_PIN, 0);
     // Write 3 until bit 3 is set
     while ((spi.send(0x03) & 0x08) != 8);
     digitalWrite(SS_PIN, 1);
     // ignoring delay(1); 
    // step 3, read the data
     digitalWrite(SS_PIN, LOW);
     var rx = spi.send([0x02,0,0]); // SPI control byte for read
     var data = spi.send(new Uint8Array(rx[2]));
     digitalWrite(SS_PIN, HIGH);
     console.log("Got data", data);
  • Avatar for Gordon

    Try upgrading the firmware? 1v96 is quite old now.

    Tried just now with 2v01 and:

    var controls = require("ble_hid_controls");
    NRF.setServices(undefined, { hid : controls.report });
    setWatch(function() {
      // Play/stop music
    }, BTN, {repeat:true});

    and it works great playing/pausing videos on an iPad mini.

    I paste the code, connect to Puck, upload it, disconnect, then attempt to connect from my iPhone.

    This is exactly what I did, but do get the pairing message on mine.

    It might be worth powering the Puck up with a long-press of the button, as that will clear any pairing info out of it - just in case that was some kind of problem.

    Also, I should add that if I'm on the Bluetooth settings screen on the iPad then I do see it when doing NRF.findDevices(print) (reporting "manufacturer": 76,, which is 0x004c - apple's ID.

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

    ok - SPI should be pretty straightforward I hope, and from what I can see all the example code for the BM019 uses SPI too.

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

    Thanks - I think it'd help to see your code.

    Sometimes if people are used to Arduino they'll write code like while (Serial1.available()==0); - but that doesn't play well with Espruino and could cause issues if you were trying to do something like that? The best thing is to respond to data in the Serial1.on('data',...) handler.

  • in ESP32
    Avatar for Gordon

    Ok, in that case I'd suggest:

    /filename="([^"]+)"/g.exec("form-data; name=\"file\"; filename=\"file.txt\"")[1]

    Which matches filename="..." and returns what's inside the quotes

  • in Espruino Work
    Avatar for Gordon

    There is the What is this? sticky post as the very first post on this forum that tries to explain what this forum is for.

  • in Pico / Wifi / Original Espruino
    Avatar for Gordon

    Yep, I believe it'll just return NaN until it's got enough Satellites in range to give you a proper reading. You can check with isNaN(fix.lat)

  • in The Place for Patreon Patrons
    Avatar for Gordon

    Thanks! I'll get that updated - I actually had your forum details because you've been a member since 2015 - I just needed to update the list from Patreon.