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-11e6-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
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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.
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:
Just to add that when I wrote:
I didn't really mean that exact code - more like you get the
passkeyRequest
event and then at some point in the future you dosendPasskey
- it doesn't have to be immediate obviously - and assuming you had saveddevice
as a global variable you could just do it manually at the repl for now