Getting Puck device name and ID

Posted on
  • Hello, I've just been playing with a Puck.js for the first time, and I must say, it's quite incredible!

    I was just wondering if there's a way to retrieve the device name and ID once it's connected in the browser, as js vars. I see that these appear as console logs, upon connection, but I can't find a way to access them. Is there a general "get device info" function or something?

    I've been successfully working with button clicks, LEDs, light, temperature and magnet sensing, but am failing to find any documentation for this, although it seems like something that'd be essential for dynamically working with multiple devices. Thank you!

  • Thanks! You can get the type of device with process.env.BOARD and as @Wilberforce mentions you can get a unique serial number with getSerial.

    You can also get the Puck's MAC address with NRF.getAddress() - while you can't get the actual name, you can fake it by adding "Puck.js " to the last 4 digits of that MAC address.

  • Thank both, that's very helpful! I have got the first 2 working, but I think I'm using NRF.getAddress() wrong, as I'm getting the following error: "Uncaught Error: Function "getAddress" not found!"

    My code is as follows:

    Bluetooth.println('BOARD:'+process.env.B­OARD); // works
    Bluetooth.println('SERIAL:'+getSerial())­; // works
    Bluetooth.println('MAC:'+NRF.getAddress(­)); // does not work
    

    Am I doing anything obviously wrong? Does NRF need to be used differently?

  • Never mind - looks like I needed a firmware update! All good now :)

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

Getting Puck device name and ID

Posted by Avatar for primalanomaly @primalanomaly

Actions