problem of interaction of two devices puck.js v2.1

Posted on
  • Hello!
    I am studying the interaction of two puck devices.js
    I need to transfer data from one device to another.
    I use tutorials from the Internet.
    A strange error occurs at the getPrimaryService stage.

    My Code:

    var gatt;
    NRF.requestDevice({ timeout: 5000, filters: [{ namePrefix: 'Puck.js 4bcd' }] }).then(function(device) {
       return device.gatt.connect();
    }).then(function(g) {   
        gatt = g;  
        console.log("4");
    return gatt.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e");
    }).then(function(service) {  
      console.log("5");
      return service.getCharacteristic("6e400002-b5a3-f393-e0a9-e50e24dcca9e");  
    }).then(function(characteristic) {
      console.log("6");
      return characteristic.writeValue("LED3.set()\n");
    }).then(function() {
      gatt.disconnect();
      console.log("OK!");
    });
    
    

    When I call this code

    return gatt.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e");
    

    An error appears:

    Uncaught Error: Unhandled promise rejection: ERR 0x11 (BUSY)
    

    Execution stops, information does not go to the second device.
    I don't understand what the problem is, I couldn't find an answer on the Internet.

  • the code works, maybe it is allready connected, try a reset() and run the code again, maybe add an output of every step along with the number, just to make it easier for you to see the steps.

    var gatt=0;
    NRF.requestDevice({ timeout: 5000, filters: [{ namePrefix: 'eL-M1' }] }).then(function(device) {
      console.log("1",device);
       return device.gatt.connect();
    }).then(function(g) {   
        gatt = g;  
        console.log("4",g);
    return gatt.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e");
    }).then(function(service) {  
      console.log("5",service)
      return service.getCharacteristic("6e400002-b5a3-f393-e0a9-e50e24dcca9e");  
    }).then(function(characteristic) {
      console.log("6",characteristic);
      return characteristic.writeValue("LED3.set()\n");
    }).then(function() {
      gatt.disconnect();
      console.log("OK!");
    });
    
  • Just to check, what firmware version is on the Pucks? It could help to ensure you're on the latest firmware on both of them (although this code should have worked for years)

  • I've tried a lot of things.
    reboot,reset...
    even hard reset!
    nothing helps. It drives me a little crazy.

    the output of your code (that's how I checked it too)

    1 BluetoothDevice: {
      "id": "e2:54:81:aa:af:05 random",
      "rssi": -41,
      "data": new Uint8Array([2, 1, 6, 13, 9, 80, 117, 99, 107, 46, 106, 115, 32, 97, 102, 48, 53]).buffer,
      "name": "Puck.js af05"
     }
    4 BluetoothRemoteGATTServer: {
      "device": BluetoothDevice: {
        "id": "e2:54:81:aa:af:05 random",
        "rssi": -41,
        "data": new Uint8Array([2, 1, 6, 13, 9, 80, 117, 99, 107, 46, 106, 115, 32, 97, 102, 48, 53]).buffer,
        "name": "Puck.js af05",
        "gatt":  ...
       },
      "connected": true }
    Uncaught Error: Unhandled promise rejection: ERR 0x11 (BUSY)
    
  • 2v09.87 ? That's the firmware version? That's from 4 years ago - so yes, absolutely, you need to update the firmware on both devices - I'm not surprised you're having issues

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

problem of interaction of two devices puck.js v2.1

Posted by Avatar for user159492 @user159492

Actions