Avatar for werty1st

werty1st

Member since Sep 2015 • Last active Dec 2022
  • 3 conversations
  • 18 comments

Most recent activity

    • 2 comments
    • 741 views
  • in Puck.js, Pixl.js and MDBT42
    Avatar for werty1st

    Should it be possible to turn the Puck into an Fido2/U2F device?

    I found this
    https://wiki.makerdiary.com/nrf52-u2f/bu­ilding/
    and this
    https://github.com/uru-card/uru-card

  • in Puck.js, Pixl.js and MDBT42
    Avatar for werty1st

    just an info how far i am. no help required.

    i think the puck crashes. i have to attach a serial console.

    Puck:

    var IrData = [];
    
    function setService(){
      NRF.setServices({
        0xBCDE : {
          
          0xFF01 : { /*clear buffer*/
            writable : true,
            onWrite : function(evt) {
              //digitalWrite([LED3,LED2,LED1], evt.data[0]);
              if (evt.data[0]==255){
                IrData = [];
                LED3.set();
                setTimeout(()=>{LED3.reset();},1000);
              }
            }
          },
          0xFF02 : { /*fill buffer*/
            writable : true,
            onWrite : function(evt) {
              var array1 = new Uint8Array(evt.data);
              array1.map(val=>{
                IrData.push(val/10);
              });
            }
          },
          0xFF03 : { /*exec buffer*/
            writable : true,
            onWrite : function(evt) {
              if (evt.data[0]==255){
                LED2.set();
                setTimeout(()=>{LED2.reset();},1000);
              }
              //Puck.IR(IrData);
            }
          },
          0xFF04 : { /*reserved*/
            writable : true,
            onWrite : function(evt) {
              console.log( new Uint8Array(evt.data));
            }
          }
        }
      });
    }
    
    setService();
    
    function advertise()
    {
      var voltage = Math.round( NRF.getBattery() * 1000)/1000 ;
      voltage = voltage.toString();
    
      var data = {
        0x180F : [Puck.getBatteryPercentage()],
        0x1801 : [ voltage.split('') ],
        0x1809 : [Math.round(E.getTemperature()+1 /*device specific offset*/)]
      };
    
      var options = {
        name: "Puck2",
        interval: 1000
      };
    
      NRF.setAdvertising(data,options);
    }
    advertise();
    

    Node Red send IR Payload in chunks

     msg.payload = [ 8.9111328125, 4.5166015625, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.54931640625, 1.708984375, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 1.77001953125, 0.45776367187, 41.015625, 8.94165039062, 4.48608398437, 0.51879882812, 0.57983398437, 0.48828125, 1.77001953125, 0.51879882812, 0.57983398437, 0.54931640625, 1.708984375, 0.51879882812, 1.73950195312, 0.45776367187, 1.77001953125, 0.51879882812, 0.57983398437, 0.54931640625, 1.67846679687, 0.48828125, 0.64086914062, 0.54931640625, 0.57983398437, 0.51879882812, 0.57983398437, 0.54931640625, 0.57983398437, 0.54931640625, 0.57983398437, 0.51879882812, 1.708984375, 0.54931640625, 0.57983398437, 0.48828125, 1.73950195312 ];
    
    var data = msg.payload;
    
    //return if no array
    if (!Array.isArray(data)){
        msg.payload = [];
        return msg;
    }
    
    //float to byte
    var byteArray = data.map(i=> Math.min(Math.max( Math.round(i*10), 1), 255) );
    
    var len = byteArray.length;
    var steps = Math.floor(len / 20);
    var outArrays = [];
    var i = 0;
    while (i < len) {
        outArrays.push(byteArray.slice(i, i += 20));
    }
    
    outArrays.map(data=>{
        msg.payload = data;
        node.send(msg);
    })
    
    

    EspruinoHub
    commit 97871d43d66edaefd47fb4f577008aedd82b1035­
    Author: Gordon Williams gw@pur3.co.uk
    Date: Tue Feb 20 10:17:05 2018 +0000

    <MQTT> Connected
    <HTTPProxy> Bleno State poweredOn
    <HTTPProxy> Bleno.startAdvertising Success
    <HTTPProxy> Bleno.setServices Success
    <Discover> Starting scan...
    <Discover> Scanning started.
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF01 => "255"
    <Discover> Scanning stopped.
    <Connect> e9:05:8c:a7:64:ab: Connecting...
    <Connect> Connected.
    <Connect> e9:05:8c:a7:64:ab: Getting Service...
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF01 => "255"
    <Connect> e9:05:8c:a7:64:ab: found service: bcde
    <Connect> e9:05:8c:a7:64:ab: found characteristic: ff01
    <Connect> e9:05:8c:a7:64:ab: Written.
    <Connect> e9:05:8c:a7:64:ab: Written.
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[89,45,5,6,5,18,5,6,5,18,5,18,5,18,5,6,­5,18,5,6]"
    <Connect> e9:05:8c:a7:64:ab: Getting Service...
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[5,6,5,6,5,6,5,6,5,17,5,6,5,17,5,6,5,6,­5,18]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[5,18,5,6,5,6,5,18,5,6,5,17,5,18,5,6,5,­6,5,18]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[5,18,5,6,5,18,5,89,45,5,6,5,18,5,6,5,1­7,5,17,5]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[18,5,6,5,17,5,6,5,6,5,6,5,6,5,6,5,17,5­,6,5]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[17,5,6,5,6,5,18,5,18,5,6,5,6,5,18,5,6,­5,18,5]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[17,5,6,5,6,5,18,5,18,5,6,5,18,5,255,89­,45,5,6,5]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[18,5,6,5,18,5,18,5,18,5,6,5,18,5,6,5,6­,5,6,5]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[6,5,6,5,18,5,6,5,18,5,6,5,6,5,17,5,18,­5,6,5]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[6,5,18,5,6,5,18,5,18,5,6,5,6,5,18,5,18­,5,6,5]"
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[18,5,3,6,1,42]"
    <Connect> e9:05:8c:a7:64:ab: found characteristic: ff02
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF03 => "255"
    <Connect> e9:05:8c:a7:64:ab: Disconnecting due to lack of use (after 10 secs)
    <Connect> e9:05:8c:a7:64:ab: Disconnecting.
    <Connect> e9:05:8c:a7:64:ab: Disconnected
    
    Wed Feb 21 2018 22:20:01 GMT+0100 (CET)
    
    45:68:9e:41:77:b4 - ? (RSSI -58)
      fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0­,0,0,0,0,0,0,0,0,0,0,0,0]}
    69:23:86:23:8f:47 - ? (RSSI -62)
      fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0­,0,0,0,0,0,0,0,0,0,0,0,0]}
    6e:d0:2f:84:f7:06 - ? (RSSI -87)
      fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0­,0,0,0,0,0,0,0,0,0,0,0,0]}
    6f:c6:f2:d8:2a:93 - ? (RSSI -71)
      fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0­,0,0,0,0,0,0,0,0,0,0,0,0]}
    googlB - ? (RSSI -83)
      fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0­,0,0,0,0,0,0,0,0,0,0,0,0]}
    Puck1 - Puck1 (RSSI -88)
      1801 => {"type":"Buffer","data":[51,46,53,57,57]­}
      1809 => {"temp":19}
      180f => {"battery":100}
    Puck2 - Puck2 (RSSI -87)
      1801 => {"type":"Buffer","data":[50,46,55,52,49]­}
      1809 => {"temp":23}
      180f => {"battery":89}
    
    
    • 3 comments
    • 2,582 views
  • in Puck.js, Pixl.js and MDBT42
    Avatar for werty1st

    Hi,

    i try to send some IR Codes via nodered + mqtt + puck to turn on my soundbar on chromecast activity.

    msg.payload =  [ 8.9111328125, 4.5166015625, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.54931640625, 1.708984375, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125 ];
    

    Topic:

    /ble/write/e9:05:8c:a7:64:ab/BCDE/ABCE
    

    The Problem is that the EspruinoHub crashes after it receives the message:

    <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/ABCE => "[8.9111328125,4.5166015625,0.48828125,0­.6103515625,0.48828125,1.77001953125,0.4­8828125,0.6103515625,0.48828125,1.770019­53125,0.48828125,1.77001953125,0.4577636­7187,1.77001953125,0.48828125,0.61035156­25,0.48828125,1.77001953125,0.4577636718­7,0.64086914062,0.48828125,0.64086914062­,0.48828125,0.6103515625,0.48828125,0.64­086914062,0.48828125,0.64086914062,0.488­28125,1.73950195312,0.48828125,0.6408691­4062,0.48828125,1.73950195312,0.48828125­,0.64086914062,0.48828125,0.6103515625,0­.48828125,1.77001953125,0.48828125,1.770­01953125,0.45776367187,0.64086914062,0.4­8828125,0.6103515625,0.48828125,1.770019­53125,0.48828125,0.6103515625,0.54931640­625,1.708984375,0.48828125,1.77001953125­,0.45776367187,0.64086914062,0.48828125,­0.6103515625,0.48828125]"
    <Discover> Scanning stopped.
    <Connect> e9:05:8c:a7:64:ab: Connecting...
    <Connect> Connected.
    <Connect> e9:05:8c:a7:64:ab: Getting Service...
    <Connect> e9:05:8c:a7:64:ab: found service: bcde
    <Connect> e9:05:8c:a7:64:ab: found characteristic: abce
    /home/pi/EspruinoHub/lib/util.js:36
        buf.writeUInt8(o.charCodeAt(i), i);
                         ^
    
    TypeError: o.charCodeAt is not a function
        at Object.exports.obj2buf (/home/pi/EspruinoHub/lib/util.js:36:22)­
        at /home/pi/EspruinoHub/lib/connect.js:193:­41
        at /home/pi/EspruinoHub/lib/connect.js:63:9­
        at Service.<anonymous> (/home/pi/EspruinoHub/node_modules/noble­/lib/service.js:53:7)
        at Object.onceWrapper (events.js:315:30)
        at emitOne (events.js:116:13)
        at Service.emit (events.js:211:7)
        at Noble.onCharacteristicsDiscover (/home/pi/EspruinoHub/node_modules/noble­/lib/noble.js:261:13)
        at emitThree (events.js:136:13)
        at NobleBindings.emit (events.js:217:7)
    

    If i send the hole command as a string to /ble/write/e9:05:8c:a7:64:ab/nus/nus_tx it works.

    So i'm questioning what are the limitations for self defined Services?
    Can i send the IR Codes that way?

    How "looks" the evt.data Object of the onWrite function?
    How can one read that console.log as long as the puck is connected to the IDE?

    onWrite : function(evt) { // optional
            console.log("Got ", evt.data);
          }
    

    Thank you very much.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for werty1st

    With both of them. I already increased the

    setTimeout(job, 1000);
    

    to 2000 without success.

    I will try this command later:
    https://github.com/sandeepmistry/node-bl­uetooth-hci-socket#linux-1

  • in Puck.js, Pixl.js and MDBT42
    Avatar for werty1st

    Its a

    1. ID 0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0
    2. ID 050d:065a Belkin Components F8T065BF Mini Bluetooth 4.0 Adapter

    Do you know why that happends? Doesn't the code stop scanning before sending?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for werty1st

    The dongel has Bluetooth 4.0 and not 4.1.
    https://github.com/sandeepmistry/noble#b­leno-compatibility
    With a Raspi 3.0 its working.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for werty1st

    I cant send a write command to the puck:

    <Config> Config loaded
    <MQTT> Connecting...
    <HTTP> Server is listening on 1888
    <MQTT> Connected
    <HTTPProxy> Bleno State poweredOn
    <HTTPProxy> Bleno.startAdvertising Success
    <HTTPProxy> Bleno.setServices Success
    <Discover> Starting scan...
    <Discover> Scanning started.
    <MQTT> /ble/write/e9:05:8c:a7:64:ab/nus/nus_tx => "digitalPulse(LED3, 1, 200);\n"
    <Discover> Scanning stopped.
    <Connect> e9:05:8c:a7:64:ab: Connecting...
    <Connect> e9:05:8c:a7:64:ab: Error Connecting: Error: Command Disallowed (0xc)
    <Discover> Scanning started.
    

    I only found this information:
    https://github.com/sandeepmistry/noble/i­ssues/658

    I had a look into the EspruinoHub code and i saw that the scanning is interruptet if a write message needs to be sent.

    /* Write to the given device */
    exports.write = function(device, service, characteristic, data) {
      if (isBusy) {
        queue.push(function() { exports.write(device,service,characteris­tic,data); });
        return;
      }
      isBusy = true;
      getConnectedDevice(device, function(err, connection) {
        if (err) return setNotBusy();
    
        connection.getCharacteristic(util.uuid2n­oble(service), 
                                     util.uuid2noble(characteristic),
         function(err,char) {
           if (err) return setNotBusy();;
           writeToCharacteristic(char, util.obj2buf(data), function() {
               log(connection.name+": Written.");
               setNotBusy();
             });
         });
      });
    };
    

    and

    function serviceQueue() {
      if (!queue.length) {
        if (connections.length==0) // no open connections
          discovery.restartScan();
        return;
      }
      if (connections.length < MAX_CONNECTIONS) {
        var job = queue.shift();
        discovery.stopScan();
        setTimeout(job, 1000);  
      }
    }
    
    function setNotBusy() {
      isBusy = false;
      serviceQueue();
    }
    

    Can it still be related to the dongle i use?

  • in General
    Avatar for werty1st

    If i install the the espruino module local and not global it works:

    :~/Downloads/espruino$ node node_modules/espruino/bin/espruino-cli.j­s 
    Espruino Command-line Tool 0.0.36
    -----------------------------------
    
    Using first port, {"path":"/dev/ttyACM0","usb":[1155,22336­],"description":"Espruino board"}
    Connecting to '/dev/ttyACM0'
    |_|_|_|___|
              |_| http://espruino.com
     1v95 Copyright 2017 G.Williams
    
    >Connected
    
    
Actions