• Hi... Can Puck.js receives message from iBeacon (on iPhone0? Can someone please help evaluate the following code?

    function Bond(){
      NRF.requestDevice({ filters: [{ services: ['e20a39f4-73f5-4bc4-a12f-17d1ad07a961']­ }]  }).then(function(d) {
        console.log("found device", d);
        device = d;
         return new Promise(function(resolve) {
          setTimeout(resolve, 1000);
          console.log("delayed for 1000ms...");
        });
      }).then(function() {
          console.log("end delay");
        return device.gatt.connect();     **// Disconnects from Web IDE here**
      }).then(function(g) {
        gatt = g;
        console.log("connected");
        return new Promise(function(resolve) {
          setTimeout(resolve, 10000);
          console.log("delayed for 10000ms...");
        });
      }).then(function() {
          console.log("end delay");
        return gatt.startBonding(1);
      }).then(function() {
        console.log("bonded", gatt.getSecurityStatus());
        gatt.disconnect();
      }).catch(function(e) {
        console.log("ERROR",e);
      });
    }
    

    Output:

    >Bond()
    =undefined
    found device BluetoothDevice {
      "id": "48:f0:b4:af:22:60",
      "rssi": -42,
      "data": new Uint8Array([2, 1, 26, 17, 7, 97, 169, 7, 173, 209, 23, 47, 161, 196, 75, 245, 115, 244, 57, 10, 226, 7, 255, 76, 0, 16, 2, 11, 64]).buffer,
      "manufacturer": 76,
      "manufacturerData": new Uint8Array([16, 2, 11, 64]).buffer,
      "services": [
        "e20a39f4-73f5-4bc4-a12f-17d1ad07a961"
       ]
     }
    delayed for 1000ms...
    end delay
    
    **<Disconnect from Web IDE>**
    
  • Hi - if you're trying to receive beacon data you don't actually need to be connected. Just the following code:

     NRF.requestDevice({ filters: [{ services: ['e20a39f4-73f5-4bc4-a12f-17d1ad07a961']­ }]  }).then(function(d) {
        console.log("found device", d);
    

    Is probably enough. Does the manufacturerData field (reported as new Uint8Array([16, 2, 11, 64]).buffer) contain the data that you need?

  • Is there a way to decrypt the manufacturer data so that I can verify? Also, at what condition should device is needed to be connected?

    Thank you.

  • Generally you connect to a device if you want to transmit things to it (or receive a lot of data, or data that is encrypted).

    I'm not really sure what the data is - it's not part of the bluetooth spec. Apple defines what is in it, so you'd have to try and find out from their docs.

    However it looks from here like the main advertising data is actually in a 'scan response' packet, which unfortunately can't be read by Puck.js at the moment (it requires Puck.js to request information from the iPhone without connecting, which it doesn't do right now) - so it's possible that unless those 4 bytes of manufacturer data contain what you want you might be out of luck (at least until that functionality is added).

  • Since I wrote the iOS App to advertise message via iBeacon, I will try to verify and if it works, I'll post it here. Thanks for the link that was very useful. :-)

    Btw, what are these data? [2, 1, 26, 17, 7, 97, 169, 7, 173, 209, 23, 47, 161, 196, 75, 245, 115, 244, 57, 10, 226, 7, 255] preceding 76?

  • .data is the raw BLE data that got received - the other data has been decoded from it... eg. the service UUID "e20a39f4-73f5-4bc4-a12f-17d1ad07a961" that was received is 226,10,57,244,... which you can see (backwards) in the advertising data:

    2,1,26,17,7,97,169,7,173,209,23,47,161,1­96,75,245,115,244,57,10,226,7,...
                ^^^^^^^^^^^^^^^^^^^^^^^^^^SERVICE^^^^^^^­^^^^^^^^^^^^^^^   
    
    255,76,0,16,2,11,64
        ^^^^^APPLE^^^^^ 
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Unable to connect to iBeacon device found in NRF.requestDevice

Posted by Avatar for user88803 @user88803

Actions