• Hi there,

    I am trying to use the Puck.js as a central device, connecting to a peripheral device (BTLE actuator).
    I suppose that the procedure is as following:

    1. NRF.requestDevice() with either name or id of the peripheral device already known and used as filter
    2. connect the gatt
    3. bond with .startBonding

    Whenever my Puck.js executes the gatt.connect(), I have 2 problems appearing: First one is that the Puck.js disconnects from the IDE, and second one is that connection fails with error "ERROR Connection Timeout".

    I tried to execute the code found here http://www.espruino.com/Reference#l_Blue­toothRemoteGATTServer_startBonding

    var gatt;
    NRF.requestDevice({ filters: [{ name: 'My BT actuator name' }] }).then(function(device) {
      console.log("found device");
      return device.gatt.connect();
    }).then(function(g) {
      gatt = g;
      console.log("connected");
      return gatt.startBonding();
    }).then(function() {
      console.log("bonded", gatt.getSecurityStatus());
      gatt.disconnect();
    }).catch(function(e) {
      console.log("ERROR",e);
    });
    

    First step of requesting the device seems to be OK as I can read found devicein the console when the puck.js doesn't disconnect from the IDE.

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v92 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >
    =undefined
    found device
    ERROR Connection Timeout
    >
    

    Any idea on what goes wrong?

  • First, I'd update your firmware to 1v94 - that could help you a lot :)

    Does it work if you don't have the bonding part in there?

    Also, just wondering if right after connecting you see all 3 LEDs light up at once - that'd signal an internal error that it rebooted to try and recover from.

  • first attempt: upgrade to 1v94 then reload same code. Result: same

    second attempt: remove the bonding part in code:

        var gatt;
        NRF.requestDevice({ filters: [{ name: 'My BT actuator name' }] }).then(function(device) {
          console.log("found device");
          return device.gatt.connect();
        }).then(function(g) {
          gatt = g;
          gatt.disconnect();
        }).catch(function(e) {
          console.log("ERROR",e);
        });
    

    And log:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v94 Copyright 2017 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >
    =undefined
    found device
    ERROR Connection Timeout
    >
    
  • Another try with bonding code removed caused the puck.js to disconnect from the IDE again.

  • BTW, can I expect from the Puck.js to stay connected to the IDE even when connected to a peripheral device? In other terms, can the Puck.js be at the same time a peripheral AND a central device?

  • OK I tried with another peripheral device and it works. I restarted my BTLE actuator and it works . looks like I made a wrong operation on it...

  • can I expect from the Puck.js to stay connected to the IDE even when connected to a peripheral device?

    Yes, you should - it's only if something goes very wrong in the Nordic libs that it restarts. If we can get steps I can reproduce here then I might be able to do something with it though.

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

Bonding process between a Puck.js and another BTLE peripheral

Posted by Avatar for Jean-Philippe_Rey @Jean-Philippe_Rey

Actions