Change the puck UUID?

Posted on
  • I'd like to change the puck UUID; not just a service UUID or a beacon ID, but the base UUID. Is this possible?

    Thanks!

  • You mean the MAC address?

    I'm afraid it's not at the moment - it is taken out of a register which I believe is set at the factory (however if Espruino itself were changed I believe it might be able to ignore that)

  • Think he means this for example

    Connected to device UUID: 5D9D6DC0-8162-4DF5-97F7-544733A0B978 Named: Puck.js de81

  • Correct I don't want to change BDADDR (programmed at the factory). I tried to use nrf.setAdvertising() as shown in the iBeacon discussion (http://forum.espruino.com/conversations/­298200/) , but couldn't get it to work for changing the UUID. All of the iBeacons I use for the application I'm developing have the same UUID for ease of location and then use the Major and Minor.

    Something I'm missing?

  • All of the iBeacons I use for the application I'm developing have the same UUID for ease of location and then use the Major and Minor.

    So they're iBeacons?

    I don't think normal Bluetooth LE has the concept of a UUID for a Puck (@Adam79 I think that's a UUID that the connecting computer has created - the Puck doesn't broadcast that)

    iBeacons broadcast their own UUIDs - see this forum post - I think it'll tell you all you need about how to set Puck.js up as an iBeacon with its own UUID: http://forum.espruino.com/conversations/­298200/

  • Hi @Gordon, thanks for the reply. I had indeed found that conversation, but it didn't work for me. I think the problem stems from bootcode that I had set and can't seem to get rid of.

    I've read past conversations about issues and tried what I found. See attached; what am I doing wrong to clear the flash and get rid of bootcode?


    1 Attachment

  • Ahh - I have no idea why yet, but I think something's got confused in the hardware - I've had this once or twice before. Try disconnecting and reconnecting the battery (usually you can do it just by gently lifting it away from the PCB)

  • @Gordon - that didn't work. I had gotten to this point by using "save on send", so I enabled that again and used "var foo;" and was finally able to clear it out that way. I had even reloaded the boot code. Somehow that area of flash isn't getting cleared properly by any other method. I'd say there is a bug if I had to guess... I'd imagine this is going to cause others to have issues, so it bears looking into if you can do so. See attached screen grab.

    Now, on to my task. I tried the following, but don't see the UUID/major, minor being advertised when I use my iBeacon scanners on the iPhone. It is based on the previously mentioned conversation:

    var advertise = function(options) {
      var d = new Uint8Array([
        0x02, // Number of bytes after first AD structure
        0x01, // BLE_GAP_AD_TYPE_FLAGS
        0x04, // BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED
        0x1A, // Length
        0xFF, // BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DA­TA
        0x4C, 0x00, // 0x004C == Apple
        0x02, 0x15, // iBeacon type + length
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,// iBeacon proximity uuid
        0x80, 0x00, // major
        0x34, 0xab, // minor
        0xc5]); // 2'c complement RSSI at 1 meter distance in dBm
      
      d.set(options.uuid,9);
      if (options.major!==undefined) d.set([options.major>>8,options.major],2­5);
      if (options.minor!==undefined) d.set([options.minor>>8,options.minor],2­7);
      if (options.rssi!==undefined) d.set([(options.rssi<0)?(options.rssi+25­6):options.rssi],29);
      
      var e = [].slice.call(d);
      NRF.setAdvertising(e, {interval:100});
    };
    
    advertise({
      uuid : [0xDA, 0xB5, 0x9C, 0x4F, 0xA4, 0xD6, 0xEE, 0x28, 0x6B, 0xFE, 0x8E, 0x00, 0x00, 0xBB, 0xC2, 0xBB], // ibeacon uuid
      major : 0x8000, // optional
      minor : 0x1234, // optional
      rssi : -59 // optional RSSI at 1 meter distance in dBm
    });
    

    1 Attachment

  • Actually can you try:

    require("ble_ibeacon").advertise({
      uuid : [0xDA, 0xB5, 0x9C, 0x4F, 0xA4, 0xD6, 0xEE, 0x28, 0x6B, 0xFE, 0x8E, 0x00, 0x00, 0xBB, 0xC2, 0xBB], // ibeacon uuid
      major : 0x8000, // optional
      minor : 0x1234, // optional
      rssi : -59 // optional RSSI at 1 meter distance in dBm
    });
    

    I literally just added this. If it doesn't show up in iOS you could use something like nRF Connect and see if that can find it.

    (it's documented at http://www.espruino.com/Puck.js+iBeacon)

    I've improved the flash save code ready for the 1v92 release so that might help - your timeout errors are strange though. You're completely sure you did reboot it by removing the battery? so the red LED flashed again?

    Whenever i noticed that issue, a reboot solved it

  • HI @Gordon; Yes, I rebooted it. I've even reloaded the flash completely (DFU). I'm still having flash issues, it seems. I can't even make this behave enough to load the code snippet above. See the attached screen grab. This is after doing the DFU update. I can't even get it to load code. I think somehow my flash is corrupted in this device. Do you concur? I have a spare but haven't used it yet...


    1 Attachment

  • @Gordon - last post of the day; need to move to another task. I switched to a 'virgin' device and can't get the code snippet to load. I must be making some noob mistake here. I just copied the code you provided above into the editor window and clicked the 'send to espruino' button. It seems to send, but a dump(); shows nothing. I tried copy and paste directly into the espruino window to no avail. See the attachment above; I get the same behavior. I must be doing something stupid here?

  • That's fine - dump() won't say anything because there's no 'code' saved - it's just data that's been sent to the Bluetooth stack. Although I'll make a note to see if any of it can be reconstructed.

    On the other Puck, you could try:

    var f = require("Flash");
    f.erasePage((120 - 3) * 4096);
    f.erasePage((120 - 2) * 4096);
    f.erasePage((120 - 1) * 4096);
    

    This will blow away all the saved code - it doesn't get removed when you update the firmware I'm afraid. When 1v92 is released it should fix any issues like that though.

  • Thanks @Gordon for putting up with the noob... I'll be looking out for 1v92 and I'll work on the beacon code some more, probably over the weekend.

    I hope you can tell that I love the puck, btw... Quick question: is there a version of this code that will run on the Nordic 10040 Dev Kit? I'd love to be able to use the work you've done on a board with easier access to IO and power supplies.

  • The nRF52832DK? Should be... Try the file in http://www.espruino.com/binaries/travis/­master/

  • @Gordon -- cool! Loaded it up, connected, loaded my LBS service code and it all works just fine. Seems the LED's and buttons have the polarity switched though... No big deal at all!

    Nice...

  • Yes, it's because they really are switched on the board. 0 is on, 1 is off - and the interpreter doesn't (yet) flip the states behind the scenes for you.

  • Hi Gordon. I have Puck.js with ibeacon. There is an Android application associated with BaaS http://www.contexthub.com/ configured so - when entering the zone ibeacon the server is running in webhook telegram bot with a value of 1 or 0, "Hello Artscada" (1) at the exit - "Bye Artscada "(0).
    Question. Can washer interpret magnetometer. For example 0-200 - broadcast UUID1, 200-500 broadcast UUID2, 500-800 broadcast UUID3, ........... UUIDn

  • Example of realization. We deliver clean water in bottles of 20 liters, often miss the time of the call to service delivery. If you put Puck upstairs and into a bottle with a ball magnet. Broadcast UUID1 .... UUID9 10% increments over time will give the average daily water consumption. UUID10 - an appeal to the bot ordering water and paying https://t.me/legendarobot


    1 Attachment

    • apparat_dlya_vodyi_(LD-AEL_160)-100-B.jpg
  • How is the code?

    1. Magnetometer woke up every hour
    2. Submitted UUIDn - according to the band.
    3. End
      All the logic in the Telegram Bot. Learning JavaScript :). Thank you.
  • Yes, that sounds like it would work perfectly! I did a demo of Puck.js with a magnet on a ping-pong ball as a float, and it broadcast as an Eddystone beacon only when the water had reached a certain level.

    Only thing I'd say if you would want to ensure that the magnet on the float actually floated close to Puck.js - if it was right over the other side of the water cooler it might be harder to detect...

  • Tell me please. Can I change the puck.js "transmission power (db)" as in conventional ibeacon in the range of "+4 dbm" to "-40 dbm"

  • Thank you

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

Change the puck UUID?

Posted by Avatar for billsalt @billsalt

Actions