balena-dslr-js

A js tool to run on a pi zero w to control cameras via gphoto2
git clone git://archive.git.mtrnord.blog/balena-dslr/balena-dslr-js.git
Log | Files | Refs | README | LICENSE

index.ts (989B)


      1 import bleno from 'bleno';
      2 import { bleService } from './bluetoothService';
      3 
      4 
      5 const name = "CameraControlService"
      6 
      7 //
      8 // Wait until the BLE radio powers on before attempting to advertise.
      9 // If you don't have a BLE radio, then it will never power on!
     10 //
     11 bleno.on('stateChange', function (state) {
     12     if (state === 'poweredOn') {
     13         //
     14         // We will also advertise the service ID in the advertising packet,
     15         // so it's easier to find.
     16         //
     17         bleno.startAdvertising(name, [bleService.uuid], function (err) {
     18             if (err) {
     19                 console.log(err);
     20             }
     21         });
     22     }
     23     else {
     24         bleno.stopAdvertising();
     25     }
     26 });
     27 
     28 bleno.on('advertisingStart', function (err) {
     29     if (!err) {
     30         console.log('advertising...');
     31         //
     32         // Once we are advertising, it's time to set up our services,
     33         // along with our characteristics.
     34         //
     35         bleno.setServices([
     36             bleService
     37         ]);
     38     }
     39 });