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,17,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}
@werty1st started
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.
just an info how far i am. no help required.
i think the puck crashes. i have to attach a serial console.
Puck:
Node Red send IR Payload in chunks
EspruinoHub
commit 97871d43d66edaefd47fb4f577008aedd82b1035
Author: Gordon Williams gw@pur3.co.uk
Date: Tue Feb 20 10:17:05 2018 +0000