• The first version looks pretty promising to me... What were you doing previously that caused the pin popup to appear when you tried to connect though?

    Can you try this? It's the same, but will tell you when the camera is requesting a passkey.

    function WriteToCamera_V1(){
    var gatt;
    NRF.requestDevice({ filters: [{ id: "90:fd:9f:b8:ca:37 public" }] }).then(function(device) {
    NRF.setSecurity({keyboard:1});
    device.on('passkeyRequest', function() {
      console.log("passkey requested");
    });
    console.log("Connecting");
    return device.gatt.connect();
    }).then(function(g) {
    gatt = g;
    return gatt.getPrimaryService("291d567a-6d75-11­e6-8b77-86f30ca893d3");
    }).then(function(service) {
    return service.getCharacteristic("5dd3465f-1aee­-4299-8493-d2eca2f8e1bb");
    }).then(function(characteristic) {
    console.log("Writing To Characteristic");
    return characteristic.writeValue([0xFF, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00] );
    }).then(function() {
    gatt.disconnect();
    console.log("Done!");
    });
    }
    

    Another possibility is that the camera allows non-bonded connections, but will only respond to commands over a secure, bonded connection.

    In that case you could try:

    var gatt;
    NRF.requestDevice({ filters: [{ id: "90:fd:9f:b8:ca:37 public" }] }).then(function(device) {
      NRF.setSecurity({keyboard:1});
      console.log("Connecting"); 
      return device.gatt.connect();
    }).then(function(g) {
      gatt = g;
      console.log("Connected");
      return gatt.startBonding(); //<---- use startBonding(true) here to force re-pairing - might be handy for debug
    }).then(function() {
      console.log("bonded", gatt.getSecurityStatus());
    return gatt.getPrimaryService("291d567a-6d75-11­e6-8b77-86f30ca893d3");
    }).then(function(service) {
    return service.getCharacteristic("5dd3465f-1aee­-4299-8493-d2eca2f8e1bb");
    }).then(function(characteristic) {
    console.log("Writing To Characteristic");
    return characteristic.writeValue([0xFF, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00] );
    }).then(function() {
    gatt.disconnect();
    console.log("Done!");
    });
    

    Just to add that when I wrote:

    dev.on('passkeyRequest', function() {
      // then you need to call the following after you've had a chance to get it
      dev.sendPasskey("123456")
    });
    

    I didn't really mean that exact code - more like you get the passkeyRequest event and then at some point in the future you do sendPasskey - it doesn't have to be immediate obviously - and assuming you had saved device as a global variable you could just do it manually at the repl for now

About

Avatar for Gordon @Gordon started