• Thanks for your help with this and again I have to apologise for being less than switched on in trying to make it work.

    I've made two versions of a function to write a value to the camera which I trigger with two of the buttons on the Pixl.

    This is the first one

    function WriteToCamera_V1(){
    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;
    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!");
    });
    }
    

    This version triggers all of the console log stages and doesn't return any errors, although it neither invokes the PIN pop up on the camera screen or executes the function.

    The second version of the function looks like this

    function WriteToCamera_V2() {
    var gatt;
    NRF.setSecurity({keyboard:1});
    NRF.connect("90:fd:9f:b8:ca:37").then(fu­nction(g) {
    gatt = g;
    console.log("Connecting");
    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");
    characteristic.writeValue([0xFF, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00] );
    }).then(function() {
    gatt.disconnect();
    console.log("Done!");
    });
    }
    

    Again, this one does not invoke the PIN pop up on the camera but it does produce the following errors in the console at the "Writing To Characteristic" point

    Writing To Characteristic
    Uncaught Error: Unhandled promise rejection: Error: BLE task 6 is already in progress
    Uncaught InternalError: BLE task completed that wasn't scheduled (3/0)
    

    I haven't included the additional passkeyRequest function (I was just trying to get the PIN pop-up to invoke on the camera for now) but I'm guessing that the second variation of the function is possibly the one that is more likely to be in the right direction for adding it?

    Again, I've got to apologise for my lack of understanding of how and where to put the passkeyRequest function example that you gave me but any example within one of my functions would be greatly appreciated.

About

Avatar for user97234 @user97234 started