-
OK, so here we go with a basic template for connecting and sending commands.
There is a bit of an issue regarding the bonding timing out when the flag isn't set to True to force it to pair. Basically, if you haven't sent the pin to it within about 7 seconds it times out which isn't long enough to set it through the terminal and send it.
As I want to have the Pixl auto-connect to the camera as soon as it is switched on and stay connected, it would be a bit of a pain to have to go through the PIN entry process every time its switched on.
Because the camera stores the bonding and it literally only needs to be sent the PIN once, I have not set it the flag to True but instead made a separate function with it being to True to initially set it. That way as soon as the Pixl powers on every time after the PIN has been set then it connects immediately and we are ready to send real commands to it.
The process for initial bonding only then is
1) Switch the Pixl on
2) Wait for the PIN entry screen on the camera to timeout
3) Press Button 4 on the Pixl which will start a new bonding process with no timeout
4) Enter the PIN value from the console with pin="xxxxxx"
5) Press Button 3 on the Pixl which will then send the PIN and complete the bonding.All subsequent restarts of the Pixl will connect the camera automatically with it being ready to receive commands.
I have included an example byte array for a command (it triggers the Auto Focus on the camera) and this is then sent using Button 1 on the Pixl.
The full camera control protocol for the camera can be downloaded here
var characteristicWrite; var characteristicRead; var dev; var gatt; var pin=""; var ServUUId="291d567a-6d75-11e6-8b77-86f30ca893d3"; var CharUUID="5dd3465f-1aee-4299-8493-d2eca2f8e1bb"; function Connect(){ // Insert own camera MAC address in id // NRF.requestDevice({ filters: [{ id: "90:fd:9f:b8:ca:37 public" }] }).then(function(device) { dev=device; NRF.setSecurity({keyboard:1, mitm:1}); console.log("Connecting"); device.on('passkeyRequest', function() { console.log("passkey requested"); }); return device.gatt.connect(); }).then(function(g) { gatt = g; console.log("Connected"); return gatt.startBonding(); //< If the camera has been previously bonded the PIN pop-up will not be invoked // }).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"); characteristicWrite=characteristic; return characteristic.writeValue([0xFF, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00] ); }).then(function() { console.log("Done!"); }); } function Bond(){ // Insert own camera MAC address in id // NRF.requestDevice({ filters: [{ id: "90:fd:9f:b8:ca:37 public" }] }).then(function(device) { dev=device; NRF.setSecurity({keyboard:1, mitm:1}); console.log("Connecting"); device.on('passkeyRequest', function() { console.log("passkey requested"); }); return device.gatt.connect(); }).then(function(g) { gatt = g; console.log("Connected"); return gatt.startBonding(true);//< This will force the PIN pop-up to be invoked irrespective of previous bond// }).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"); characteristicWrite=characteristic; return characteristic.writeValue([0xFF, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00] ); }).then(function() { console.log("Done!"); }); } function SendPin(){ //Enter required PIN in console using pin="xxxxxx"// dev.sendPasskey(pin); } function WriteValNoConnect(){ //Writes Auto-Focus command to the connected camera without re-connection// characteristicWrite.writeValue([0xFF, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00] ); } function onInit(){ //Automatically connects the camera and establishes Characteristic to be written to// // If camera has been bonded the PIN pop-up will not be invoked// Connect(); } setWatch(function() { console.log("WRITING AUTO FOCUS COMMAND TO CAMERA"); WriteValNoConnect(); }, BTN, {edge:"rising", debounce:50, repeat:true}); setWatch(function() { console.log("NO FUNCTION ASSIGNED"); }, BTN2, {edge:"rising", debounce:50, repeat:true}); setWatch(function() { console.log("SENDING PIN : "+pin); SendPin(); }, BTN3, {edge:"rising", debounce:50, repeat:true}); setWatch(function() { console.log("BONDING"); Bond(); }, BTN4, {edge:"rising", debounce:50, repeat:true});
-
-
I had already removed the gatt.disconnect and wrote another function to write to it whilst it was still connected but couldn't get any joy in terms of the camera actioning the command.
I then thought to myself, "surely you haven't been stupid enough to be sending an invalid array to it have you?"
Turns out I had been exactly that stupid and been sending nine bytes instead of eight so we now - insert fanfare here - have a camera that bonds correctly and can be operated from the Pixl.
I won't have time now until the weekend to look at the notifications aspect but I'll be back to let you know how that worked out as soon as I've done so.
Many, many thanks for your help and patience with this.
-
Thanks for sticking with me on this and trying out the suggestions!>
No, thanks to you for sorting it out!
Which it now is with regard to the PIN.
Using the startBonding(true) invokes the PIN prompt every time and startBonding() connects without once it has been done once so everything is working as it should there as well.
I'm away for a couple of days from this evening so can look at it more when I get back but my challenge now is to send commands while maintaining the connection.
When I'm connected to the camera, its stops advertising so functions with NRF.requestDevice can't find it and a composite function that bonds and then sends does connect but the camera isn't actioning the write to the characteristic that I'm sending.
Apologies for my ignorance over this but is there a way to stay connected and just use BluetoothRemoteGATTCharacteristic.writeValue(data) as a single command ?
-
Hmm... If only you had an expensive imaging device somewhere that you
could use :)Yes, all the gear, no idea ;)
Connecting in nRF and sending the wrong PIN results in the same behaviour, so there is a connection failed message on the camera which then is replaced by the no device connected screen as per the sequence when doing it from the Pixl.
This is an nRF session where I connect and put in the wrong PIN and then re-connect and put in the correct PIN
nRF Connect, 2019-02-04 Pocket Cinema Camera 4K A:1C2 (90:FD:9F:B8:CA:37) D 18:46:51.954 gatt.close() D 18:46:51.957 wait(200) V 18:46:52.158 Connecting to 90:FD:9F:B8:CA:37... D 18:46:52.158 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE) D 18:46:52.406 [Server callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 18:46:52.406 [Server] Device with address 90:FD:9F:B8:CA:37 connected I 18:46:52.406 [Server] MTU changed to 64 D 18:46:52.453 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 18:46:52.453 Connected to 90:FD:9F:B8:CA:37 D 18:46:52.457 wait(1600ms) D 18:46:52.484 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED V 18:46:54.072 Discovering services... D 18:46:54.072 gatt.discoverServices() D 18:46:54.087 [Callback] Services discovered with status: 0 I 18:46:54.087 Services discovered V 18:46:54.115 Generic Access (0x1800) - Device Name [R] (0x2A00) - Appearance [R] (0x2A01) Device Information (0x180A) - Manufacturer Name String [R] (0x2A29) - Model Number String [R] (0x2A24) Unknown Service (291d567a-6d75-11e6-8b77-86f30ca893d3) - Unknown Characteristic [W] (5dd3465f-1aee-4299-8493-d2eca2f8e1bb) - Unknown Characteristic [I] (b864e140-76a0-416a-bf30-5876504537d9) Client Characteristic Configuration (0x2902) - Unknown Characteristic [N] (6d8f2110-86f1-41bf-9afb-451d87e976c8) Client Characteristic Configuration (0x2902) - Unknown Characteristic [N R W] (7fe8691d-95dc-4fc5-8abd-ca74339b51b9) Client Characteristic Configuration (0x2902) - Unknown Characteristic [W] (ffac0c52-c9fb-41a0-b063-cc76282eb89c) - Unknown Characteristic [R] (8f1fd018-b508-456f-8f82-3d392bee2706) D 18:46:54.116 gatt.setCharacteristicNotification(b864e140-76a0-416a-bf30-5876504537d9, true) D 18:46:54.119 gatt.setCharacteristicNotification(6d8f2110-86f1-41bf-9afb-451d87e976c8, true) D 18:46:54.122 gatt.setCharacteristicNotification(7fe8691d-95dc-4fc5-8abd-ca74339b51b9, true) V 18:47:09.481 Writing request to characteristic 5dd3465f-1aee-4299-8493-d2eca2f8e1bb D 18:47:09.481 gatt.writeCharacteristic(5dd3465f-1aee-4299-8493-d2eca2f8e1bb, value=0xFF04000000010000) D 18:47:09.904 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11) D 18:47:09.920 [Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_PIN (0) D 18:47:18.238 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10) I 18:47:18.238 Bonding failed D 18:47:21.182 [Server callback] Connection state changed with status: 0 and new state: DISCONNECTED (0) I 18:47:21.182 [Server] Device disconnected D 18:47:21.196 [Callback] Connection state changed with status: 22 and new state: DISCONNECTED (0) E 18:47:21.197 Error 22 (0x16): GATT CONN TERMINATE LOCAL HOST I 18:47:21.197 Disconnected D 18:47:21.290 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED D 18:47:48.789 gatt.close() D 18:47:48.791 wait(200) V 18:47:48.992 Connecting to 90:FD:9F:B8:CA:37... D 18:47:48.992 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE) D 18:47:49.292 [Server callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 18:47:49.292 [Server] Device with address 90:FD:9F:B8:CA:37 connected I 18:47:49.292 [Server] MTU changed to 64 D 18:47:49.400 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) D 18:47:49.400 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED I 18:47:49.400 Connected to 90:FD:9F:B8:CA:37 V 18:47:49.422 Discovering services... D 18:47:49.422 gatt.discoverServices() D 18:47:50.038 [Callback] Services discovered with status: 0 I 18:47:50.039 Services discovered V 18:47:50.062 Generic Access (0x1800) - Device Name [R] (0x2A00) - Appearance [R] (0x2A01) Device Information (0x180A) - Manufacturer Name String [R] (0x2A29) - Model Number String [R] (0x2A24) Unknown Service (291d567a-6d75-11e6-8b77-86f30ca893d3) - Unknown Characteristic [W] (5dd3465f-1aee-4299-8493-d2eca2f8e1bb) - Unknown Characteristic [I] (b864e140-76a0-416a-bf30-5876504537d9) Client Characteristic Configuration (0x2902) - Unknown Characteristic [N] (6d8f2110-86f1-41bf-9afb-451d87e976c8) Client Characteristic Configuration (0x2902) - Unknown Characteristic [N R W] (7fe8691d-95dc-4fc5-8abd-ca74339b51b9) Client Characteristic Configuration (0x2902) - Unknown Characteristic [W] (ffac0c52-c9fb-41a0-b063-cc76282eb89c) - Unknown Characteristic [R] (8f1fd018-b508-456f-8f82-3d392bee2706) D 18:47:50.062 gatt.setCharacteristicNotification(b864e140-76a0-416a-bf30-5876504537d9, true) D 18:47:50.065 gatt.setCharacteristicNotification(6d8f2110-86f1-41bf-9afb-451d87e976c8, true) D 18:47:50.068 gatt.setCharacteristicNotification(7fe8691d-95dc-4fc5-8abd-ca74339b51b9, true) V 18:48:01.291 Writing request to characteristic 5dd3465f-1aee-4299-8493-d2eca2f8e1bb D 18:48:01.291 gatt.writeCharacteristic(5dd3465f-1aee-4299-8493-d2eca2f8e1bb, value=0xFF04000000010000) D 18:48:01.778 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11) D 18:48:01.778 [Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_PIN (0) D 18:48:12.993 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12) I 18:48:12.994 Device bonded I 18:48:13.021 Data written to 5dd3465f-1aee-4299-8493-d2eca2f8e1bb, value: (0x) FF-04-00-00-00-01-00-00 A 18:48:13.021 "(0x) FF-04-00-00-00-01-00-00" sent V 18:48:19.171 [Server] Cancelling server connection... D 18:48:19.171 server.cancelConnection(device) V 18:48:19.179 Disconnecting... D 18:48:19.179 gatt.disconnect() D 18:48:19.191 [Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0) I 18:48:19.191 Disconnected D 18:48:20.229 [Server callback] Connection state changed with status: 0 and new state: DISCONNECTED (0) I 18:48:20.229 [Server] Device disconnected D 18:48:20.259 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
Changing the NRF.setSecurity doesn't change the behaviour and the PIN prompt will only be invoked on the camera and the passkeyRequest triggered if startBonding is included.
I changed the Write function so that it retains the startBonding but doesn't disconnect after writing to the characteristic. This leaves the PIN prompt up on the camera in the waiting state so gives me a chance to then pass the PIN to it but again it invokes the connection failure on the camera.
With the behaviour being identical by passing the wrong PIN when connected through nRF it does appear to point to the the problem being the PIN being mangled on its way from the Pixl.
-
-
-
-
-
What happens is the PIN prompt appears on the camera and stays there until I sent it the value, it then shows a connection failed message for about 10 seconds and then shows a message saying no device is attached .
I have attached some (blurry!) pictures of the camera during this process.
Not sure if the no device connected is a bit of a red herring though as the camera shows this when you connect to it via nRF for example but aren't bonded yet.
For reference, here is an nRF log of performing the same process manually from an unbonded phone (so its essentially in the same state as the Pixl) to the camera and writing the same value to the characteristic UUID 5dd3465f-1aee-4299-8493-d2eca2f8e1bb
It is at the point of sending the value to that characteristic that the PIN screen is invoked on the camera and in this log I have obviously entered the PIN on the phone to complete the process and then am able to send to the characteristic and then register and receive notifications on the other characteristic.
nRF Connect, 2019-02-04 Pocket Cinema Camera 4K A:1C2 (90:FD:9F:B8:CA:37) V 11:08:00.011 Connecting to 90:FD:9F:B8:CA:37... D 11:08:00.011 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE) D 11:08:00.274 [Server callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 11:08:00.274 [Server] Device with address 90:FD:9F:B8:CA:37 connected I 11:08:00.275 [Server] MTU changed to 64 D 11:08:00.384 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) D 11:08:00.384 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED I 11:08:00.384 Connected to 90:FD:9F:B8:CA:37 D 11:08:00.392 wait(1600ms) V 11:08:02.007 Discovering services... D 11:08:02.007 gatt.discoverServices() D 11:08:02.023 [Callback] Services discovered with status: 0 I 11:08:02.023 Services discovered V 11:08:02.051 Generic Access (0x1800) - Device Name [R] (0x2A00) - Appearance [R] (0x2A01) Device Information (0x180A) - Manufacturer Name String [R] (0x2A29) - Model Number String [R] (0x2A24) Unknown Service (291d567a-6d75-11e6-8b77-86f30ca893d3) - Unknown Characteristic [W] (5dd3465f-1aee-4299-8493-d2eca2f8e1bb) - Unknown Characteristic [I] (b864e140-76a0-416a-bf30-5876504537d9) Client Characteristic Configuration (0x2902) - Unknown Characteristic [N] (6d8f2110-86f1-41bf-9afb-451d87e976c8) Client Characteristic Configuration (0x2902) - Unknown Characteristic [N R W] (7fe8691d-95dc-4fc5-8abd-ca74339b51b9) Client Characteristic Configuration (0x2902) - Unknown Characteristic [W] (ffac0c52-c9fb-41a0-b063-cc76282eb89c) - Unknown Characteristic [R] (8f1fd018-b508-456f-8f82-3d392bee2706) D 11:08:02.052 gatt.setCharacteristicNotification(b864e140-76a0-416a-bf30-5876504537d9, true) D 11:08:02.054 gatt.setCharacteristicNotification(6d8f2110-86f1-41bf-9afb-451d87e976c8, true) D 11:08:02.058 gatt.setCharacteristicNotification(7fe8691d-95dc-4fc5-8abd-ca74339b51b9, true) V 11:08:15.364 Writing request to characteristic 5dd3465f-1aee-4299-8493-d2eca2f8e1bb D 11:08:15.364 gatt.writeCharacteristic(5dd3465f-1aee-4299-8493-d2eca2f8e1bb, value=0xFF04000000010000) D 11:08:15.819 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11) D 11:08:15.837 [Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_PIN (0) D 11:08:24.100 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12) I 11:08:24.100 Device bonded I 11:08:24.125 Data written to 5dd3465f-1aee-4299-8493-d2eca2f8e1bb, value: (0x) FF-04-00-00-00-01-00-00 A 11:08:24.126 "(0x) FF-04-00-00-00-01-00-00" sent V 11:08:36.136 Writing request to characteristic 5dd3465f-1aee-4299-8493-d2eca2f8e1bb D 11:08:36.136 gatt.writeCharacteristic(5dd3465f-1aee-4299-8493-d2eca2f8e1bb, value=0xFF04000000010000) I 11:08:36.196 Data written to 5dd3465f-1aee-4299-8493-d2eca2f8e1bb, value: (0x) FF-04-00-00-00-01-00-00 A 11:08:36.196 "(0x) FF-04-00-00-00-01-00-00" sent V 11:08:47.245 Disabling notifications for 7fe8691d-95dc-4fc5-8abd-ca74339b51b9 D 11:08:47.245 gatt.setCharacteristicNotification(7fe8691d-95dc-4fc5-8abd-ca74339b51b9, false) D 11:08:47.246 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0000) I 11:08:47.311 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 00-00 A 11:08:47.311 "Notifications and indications disabled" sent V 11:08:47.313 Notifications and indications disabled for 7fe8691d-95dc-4fc5-8abd-ca74339b51b9 V 11:08:50.416 Enabling notifications for 7fe8691d-95dc-4fc5-8abd-ca74339b51b9 D 11:08:50.416 gatt.setCharacteristicNotification(7fe8691d-95dc-4fc5-8abd-ca74339b51b9, true) D 11:08:50.417 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0100) I 11:08:50.479 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00 A 11:08:50.479 "Notifications enabled" sent V 11:08:50.481 Notifications enabled for 7fe8691d-95dc-4fc5-8abd-ca74339b51b9 V 11:08:58.285 Disabling indications for b864e140-76a0-416a-bf30-5876504537d9 D 11:08:58.285 gatt.setCharacteristicNotification(b864e140-76a0-416a-bf30-5876504537d9, false) D 11:08:58.286 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0000) I 11:08:58.377 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 00-00 A 11:08:58.377 "Notifications and indications disabled" sent V 11:08:58.378 Notifications and indications disabled for b864e140-76a0-416a-bf30-5876504537d9 V 11:08:59.207 Enabling indications for b864e140-76a0-416a-bf30-5876504537d9 D 11:08:59.208 gatt.setCharacteristicNotification(b864e140-76a0-416a-bf30-5876504537d9, true) D 11:08:59.209 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0200) I 11:08:59.303 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00 A 11:08:59.303 "Indications enabled" sent V 11:08:59.304 Indications enabled for b864e140-76a0-416a-bf30-5876504537d9 I 11:08:59.352 Indication received from b864e140-76a0-416a-bf30-5876504537d9, value: (0x) FF-05-00-00-01-07-01-02-00 A 11:08:59.352 "(0x) FF-05-00-00-01-07-01-02-00" received
-
Many thanks for that.
We now have some real progress of sorts.
The second option you provided worked in terms of invoking the PIN on the camera screen.
The first option just went straight through as per the original version and did not invoke the PIN or fire the passkeyRequest.
I inserted that part into the second one just to confirm that it does fire and it does.
So, this is the version I have been working with
function WriteToCamera_V1(){ var gatt; NRF.requestDevice({ filters: [{ id: "90:fd:9f:b8:ca:37 public" }] }).then(function(device) { dev=device; NRF.setSecurity({keyboard:1}); console.log("Connecting"); device.on('passkeyRequest', function() { console.log("passkey requested"); //dev.sendPasskey("123456"); }); return device.gatt.connect(); }).then(function(g) { gatt = g; console.log("Connected"); return gatt.startBonding(true); //<---- 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!"); }); }
When I trigger it from the Button, it produces the following in the console
> WRITE TO CAMERA_V1 Connecting Connected bonded { "connected": true, "encrypted": false, "mitm_protected": false, "bonded": true } passkey requested Writing To Characteristic Done! >
The problem is that it executes the write characteristic and disconnects before I've had any sort of opportunity to pass the PIN to it.
I put in a dummy PIN that I've commented out to test that it would send it to the camera and it does send it and the camera invokes a failed connect message as expected with it being the wrong PIN.
What I've done to give myself a chance to send the correct PIN is to split the bond function out without the write characteristic part which I activate off one button, then change the PIN value in the console (using the variable 'p' ) and then fire a separate function to do the sendPasskey off another button.
As soon as I fire the sendPasskey function the camera (Line 6) does the immediate disconnect in the same way as if I'd sent it the wrong PIN in the main function and produces the following :
Connecting Connected bonded { "connected": true, "encrypted": false, "mitm_protected": false, "bonded": true } >p="314390" ="314390" SENDING PIN Uncaught InternalError: BLE task completed that wasn't scheduled (3/0) >
My guess at the moment (with a dummy and a correct PIN producing the same outcome) is that I'm doing something wrong that is somehow related to Comments 6 & 7 from User63214 when he was attempting to do the same?
-
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-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!"); }); }
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(function(g) { gatt = g; console.log("Connecting"); 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"); 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.
-
-
-
The camera control service is UUID: 291D567A-6D75-11E6-8B77-86F30CA893D3
The commands to the camera are sent on characteristic UUID: 5DD3465F-1AEE-4299-8493-D2ECA2F8E1BB
And we request notifications on characteristic UUID: B864E140-76A0-416A-BF30-5876504537D9
If you connect a phone to the camera with the nRF app then sending anything to the command characteristic UUID then it immediately invokes the PIN display on the camera screen.
-
Thanks for the response.
The camera is the Blackmagic Pocket 4K Cinema Camera (though it is also used with other cameras from the same manufacturer).
Camera control spec is here :
https://documents.blackmagicdesign.com/DeveloperManuals/BlackmagicCameraControl/20181019-740d71/BlackmagicCameraControl.pdfThe camera displays a PIN on its setup screen which I would then want to respond to.
I have created an Android app that controls all of the camera parameters and now I'm wanting to create a small hardware controller based around the Pixl but I'm floundering at this first step.
-
-
Done a quick mod job pressing a Puck into service as a Record Start/Stop control.