• RX_PW_P1 is 0x20 (32) on arduino, that's 32 byte payload by my understanding? I had tried it with 16 bytes as well.

    My modified version of the module

    function b(a,c,e,b){this.CSN=c;this.CE=e;this.PAY­LOAD=b?b:16;this.cmd="";this.spi=a;this.­callbacks=[]}b.prototype.init=function(a­,c){digitalWrite(this.CE,0);digitalWrite­(this.CSN,1);this.setRXAddr(a);this.setT­XAddr(c);for(var b=17;22>=b;b++)this.setReg(b,this.PAYLOA­D);this.setReg(0,15);this.setReg(4,95);d­igitalWrite(this.CE,1)};b.prototype.setE­nabled=function(a){digitalWrite(this.CE,­a)};b.prototype.setReg=function(a,c){thi­s.spi.send([32|a,c],this.CSN)};b.prototy­pe.setAddr=function(a,c){c=
    c.clone();c.splice(0,0,32|a);this.spi.se­nd(c,this.CSN)};b.prototype.setRXAddr=fu­nction(a,c){void 0===c?c=1:this.setReg(2,this.getReg(2)|1­<<c);this.setAddr(10+c,2>c?a:[a[0]])};b.­prototype.setTXAddr=function(a){this.set­Addr(10,a);this.setAddr(16,a)};b.prototy­pe.getReg=function(a){return this.spi.send([0|a,0],this.CSN)[1]};b.pr­ototype.getAddr=function(a){a=this.spi.s­end([0|a,0,0,0,0,0],this.CSN);a.splice(0­,1);return a};b.prototype.getStatus=function(a){ret­urn this.getReg(7)};b.prototype.setDataRate=­
    function(a){var c={25E4:32,1E6:0,2E6:8};!a in c&&console.log("Unknown rate");this.setReg(6,this.getReg(6)&-41|­c[a])};b.prototype.getDataPipe=function(­){var a=this.getReg(7)&14;return 14==a?void 0:a>>1};b.prototype.getData=function(){f­or(var a=[97],c=0;c<this.PAYLOAD;c++)a.push(0);­a=this.spi.send(a,this.CSN);a.splice(0,1­);this.setReg(7,64);return a};b.prototype.send=function(a){this.set­Reg(7,48);digitalWrite(this.CE,0);this.s­etReg(0,14);this.spi.send(225,this.CSN);­a=a.clone();a.splice(0,0,160);this.spi.s­end(a,
    this.CSN);digitalWrite(this.CE,1);for(a=­1E3;a--&&!(this.getReg(7)&48););0>=a&&pr­int("TX timeout");a=!0;this.getReg(7)&16&&(print­("TX not received "+this.getReg(7)),a=!1);digitalWrite(thi­s.CE,0);this.setReg(0,15);digitalWrite(t­his.CE,1);this.setReg(7,48);return a};b.prototype.slaveHandler=function(){f­or(;void 0!==this.getDataPipe();){var a=this.getData(),c;for(c in a){var b=a[c];if(0===b&&""!==this.cmd){var d=this.cmd;this.cmd="";var f=this;setTimeout(function(){print("...>­"+d);var a=""+eval(d);print("...="+
    a);f.sendStringTimeout(a,500)},1)}else 0!==b&&(this.cmd+=String.fromCharCode(b)­)}}};b.prototype.masterHandler=function(­){for(;void 0!==this.getDataPipe();){var a=this.getData(),c;for(c in a){var b=a[c];if(0===b&&""!==this.cmd){b=this.c­md;this.cmd="";var d=this.callbacks.splice(0,1)[0];void 0!==d&&d(b)}else 0!==b&&(this.cmd+=String.fromCharCode(b)­)}}};b.prototype.sendString=function(a){­for(var c=0;c<=a.length;c+=this.PAYLOAD){for(var­ b=[],d=0;d<this.PAYLOAD;d++)b[d]=a.charC­odeAt(c+d);if(!this.send(b))return!1}ret­urn!0};
    b.prototype.sendCommand=function(a,b){th­is.callbacks.push(b);this.sendString(a)}­;b.prototype.sendStringTimeout=function(­a,b){var e=this;setTimeout(function(){e.sendStrin­g(a)},b)};exports.connect=function(a,c,e­,d){return new b(a,c,e,d)}
    

    BASE_CONFIG was 8, is now 12

    Difference in the minified code is the two setReg(0,11) calls are now setReg(0,15), and setReg(0,10) changed to setReg(0,14)

About

Avatar for DrAzzy @DrAzzy started