Finding the Id of the puck programatically

Posted on
  • Hi

    I have used Puck.connect to get a connection to my Puck. Now I would like to know its four-character Id.
    Also, I'd love to find some documentation on the methods available on Puck? In the API documentation there is a section on the Puck class (here: http://www.espruino.com/Reference#Puck) but it seems to be missing a lot of stuff - for instance there is nothing in there about Puck.connect?

    Cheers
    Clare.

  • @user9517 / Clare

    Check this (API) reference site... and - beside the Puck class you already found - every other class starting with Blue... and you will be out of the 'blues'...

    Espruino devices are so called JavaScript standalone microcontroller. There is no operating system or a like as a separate entity. All you need is part of the language, in this case JavaScript and it's implementation of globals, functions, and classes / modules,...

    Bluetooth - and many other things - are not just working on Puck. Espruino supports lot of different devices. Some they haver their specifc class, because that's only available on that particular device. But all other stuff runs on all devices - almost: some devices are a bit more short on resources - FLASH and RAM and appliances - and therefore the build - or loaded Espruino firmware - does not include all the things to leave some space for you applications. With Puck though, you are on the safe side.

    A good starting place for examples is https://www.espruino.com/Puck.js - especially the https://www.espruino.com/Pixl.js+Multiplayer+Pong - a Ping Pong - game. You will say: I do not have Pixl, I have Puck... right... but you can see there how two BLE devices can talk to each other... and on the forum you find plenty of conversations and posts that deal with the subject of BLE devices finding each other, connect to one another, and exchanging data. After all, it is not a Puck thing, it is a BluetoothLE thing...

  • Sun 2018.10.28

    Hi Clare @user95170 how is the Hackathon going?


    Have you checked out NRF.findDevices(callback, options)

    https://www.espruino.com/Reference#t_l_NRF_findDevices

    "prints something like:"

    [
      BluetoothDevice {
        "id": "c0:52:3f:50:42:c9 random",
        "rssi": -65,
        "data": new ArrayBuffer([ ... ]),
        "name": "Puck.js 8f57"
       }
     ]
    



    Also check out this forum post:

    Getting Puck device name and ID

    http://forum.espruino.com/conversations/314210/

  • Ooh thank you.

    Hack went brilliantly! Our time machine : http://youtu.be/EjgwNEOZt8w
    #hackmcr #msf18

    Awards are not till 7pm so we won't know if we won anything till then, but the judges all told us they were very impressed! We have had so much fun. We didn't managed to deploy it to the cloud in the end but we got it working locally.

  • I'm probably a bit late to this but...

    In the API documentation there is a section on the Puck class (here: http://www.espruino.com/Reference#Puck) but it seems to be missing a lot of stuff - for instance there is nothing in there about Puck.connect?

    Ahh - those are the functions that are available when running JavaScript on Puck.js itself.

    Puck.connect is a command that you run in your web browser, which uses the Puck.js library. There's some information on it at http://www.espruino.com/Puck.js+Web+Bluetooth but there isn't actually a proper reference. I'll make a note to add one, but in the mean time if you look at the source there are some examples at the top, and if you scroll down to the bottom, the exported functions are there with explanation for each.

    Now I would like to know its four-character Id.

    The 4 character ID at the end is just the last 4 digits of the device's MAC Address.

    You can get it on the Puck itself with the command NRF.getAddress().substr(-5).replace(":","") -
    which takes the address in the form aa:bb:cc:dd:ee:ff, strips off the last
    5 characters, and removes the colon.

  • That's just what I needed, thank you for all your help Gordon!

    Our team won Best in Show for our time machine, out of 57 teams, first time an all-female team has won. We are very happy and proud. Video of awards ceremony available here : https://www.youtube.com/watch?v=twSjbmGJrnA

  • Wow, that's amazing! Congratulations!

    It's particularly impressive given I don't think you'd used Espruino before, you got the Puck 3 days before the hackaton, and then went on to win best in show?

  • That's correct! 😊😊

  • That was my fourth time at Hack Manchester though and I've been a software engineer for 18 years. 😊

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Finding the Id of the puck programatically

Posted by Avatar for user95170 @user95170

Actions