• At the moment I am using this code and the winnus library on nodejs to connect throught the bluetooth in a crude way to send key commands to demonstrate the capability of the puckjs for our application.

    Puckjs code

    var  on = false;
    var buttonID = "button_left";
    
    var flashLED = function() {
      on = !on;
      LED2.write(on);
      var interval;
      if(on) {
        interval = 5;
      } else {
        interval = 3000;
      }
      setTimeout(flashLED, interval);
    };
    
    flashLED();
    
    
    var buttonWatcher = function() {
      LED2.write(true);
      console.log(buttonID);
    };
    
    setWatch(buttonWatcher, BTN, { repeat:true, edge:'falling', debounce:50 });
    

    Nodejs code:

    var winnus = require("winnus");
    var robot = require('robotjs')
    
    var all_devices = []
    var device;
    
    var name = process.argv[2];
    all_devices = winnus.getDevices();
    
    all_devices.forEach(function(d) {
        if(d.name.includes(name)) {
            device = d;
        }
    });
    console.log(device);
    
    console.log("connecting..");
    winnus.connect(device, (data) => {
        console.log("data: " + JSON.stringify(data));
        if(data.includes('button_c')) {
        	robot.typeString('c');
        }
        else if(data.includes('button_left')) {
        	robot.keyTap('right');
        }
        else if(data.includes('button_right')) {
        	robot.keyTap('left');
        }
    });
    winnus.write('on;\n');
    
    
    

    Obviously not an ideal solution.

About

Avatar for Boydy @Boydy started