FYI, I worked on the RN2483 this week-end, and I finally was able to send some datas on the server. here is the debug script I used, in case you need it:
var rxbuf=[];
var initState=0;
var devAddr="YOUR_DEV_ADDR";
var nwkSKey="YOUR_NETWORK_SESSION_KEY";
var appSKey="YOUR_APPLICATION_SESSION_KEY";
Serial1.setup(57600, { tx:B6, rx:B7 });
Serial1.on('data', function (data){
if(data.indexOf('\n')>-1)
{
console.log(rxbuf);
if(rxbuf.indexOf("mac_tx_ok")>-1)
digitalWrite(LED2,1);
else
digitalWrite(LED2,0);
rxbuf=[];
}
else
rxbuf+=data;
});
function loraReset(){Serial1.print("sys reset\r\n");}
function loraGetVer(){Serial1.print("sys get ver\r\n");}
function loraGetVcc(){Serial1.print("sys get vdd\r\n");}
function loraGetHWEUI(){Serial1.print("sys get hweui\r\n");}
function loraSetDevAddr(addr){Serial1.print("mac set devaddr "+addr+"\r\n");}
function loraSetNwkSKey(key){Serial1.print("mac set nwkskey "+key+"\r\n");}
function loraSetAppSKey(key){Serial1.print("mac set appskey "+key+"\r\n");}
function loraSetADR(state){
var OnOff=( (state=="ON") || (state=="on") || (state=="On") )?"on":"off";
Serial1.print("mac set adr "+OnOff+"\r\n");}
function loraGetDR(){Serial1.print("mac get dr\r\n");}
function loraGetChannel(){Serial1.print("mac get ch\r\n");}
function loraGetBand(){Serial1.print("mac get band\r\n");}
function loraGetRxDelay2(){Serial1.print("mac get rxdelay2\r\n");}
function loraGetpwridx(){Serial1.print("mac get pwridx\r\n");}
function loraJoinABP(){Serial1.print("mac join ABP\r\n");}
function loraGetStatus(){Serial1.print("mac get status\r\n");}
function convertToHex(str) {
var hex = '';
for(var i=0;i<str.length;i++) {
hex += ''+str.charCodeAt(i).toString(16);
}
return hex;
}
function loraTRX(data){
digitalWrite(LED2,0);
console.log("Sending: "+data);
Serial1.print("mac tx uncnf 1 "+convertToHex(data)+"\r\n");
//setTimeout(loraGetStatus,150);
}
function init()
{
switch(initState)
{
case 0:
console.log("LoRa init begin...");
console.log("resetting...");
loraReset();
initState++;
break;
case 1:
//console.log("\nVersion:");
//loraGetVer();
initState++;
break;
case 2:
//console.log("\nVCC:");
//loraGetVcc();
initState++;
break;
case 3:
console.log("\nHW EUI:");
loraGetHWEUI();
initState++;
break;
case 4:
console.log("\nSetting devAddr");
loraSetDevAddr(devAddr);
initState++;
break;
case 5:
console.log("\nSetting nwkSKey");
loraSetNwkSKey(nwkSKey);
initState++;
break;
case 6:
console.log("\nSetting appSKey");
loraSetAppSKey(appSKey);
initState++;
break;
case 7:
console.log("\nDisabling Adaptative Data Rate");
loraSetADR("off");
initState++;
break;
case 8:
//console.log("\nRetrieving data rate...");
//loraGetDR();
initState++;
break;
case 9:
//console.log("\nRetrieving channel...");
//loraGetChannel();
initState++;
break;
case 10:
//console.log("\nRetrieving band...");
//loraGetBand();
initState++;
break;
case 11:
//console.log("\nRetrieving rxDelay2...");
//loraGetRxDelay2();
initState++;
break;
case 12:
//console.log("\nRetrieving power output index value...");
//loraGetpwridx();
initState++;
break;
case 13:
console.log("\nJoining ABP...");
loraJoinABP();
initState++;
break;
case 13:
console.log("\nStatus: ");
loraGetStatus();
initState++;
break;
case 14:
initState=-1;
break;
default:break;
}
if(initState!=-1)
setTimeout(init,50);
}
function BTNHandle()
{
var a=getTime().toString().slice(7,9);
loraTRX(a);
}
setTimeout(init,1000);
setWatch(BTNHandle,BTN,{repeat:true,edge:'falling',debounce:50});
save();
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.
FYI, I worked on the RN2483 this week-end, and I finally was able to send some datas on the server. here is the debug script I used, in case you need it: