Gateway TLG8411V1 User Manual V1.0.0
27
July 2020
The LoRaScript sample code for converting base64 from rxpk to ASCII string is shown in List
4-3, and for sending txpk packet with base64 encoding is provided in List 4-4.
List 4-3 rxpk Data from Base64 to ASCII in LoRaScript
function onLoRaRx(data) {
//convert base64 to ascii encoding
var asciiStr = new Buffer(data, 'base64').toString('ascii');
debug_print("receive " + asciiStr);
}
List 4-4 Construct and Send a txpk Pakcet in LoRaScript
function onInit() {
setInterval(period_send, 1000); // send a txpk in every 1 second
}
function period_send () {
var msg = 'Hello World';
var msg_size = Buffer.byteLength(msg, 'asci');
var base64str = new Buffer(msg).toString('base64');
var json_obj = {
imme:true,
freq:915.5,
rfch:0,
powe:14,
modu:"LORA",
datr:"SF7BW125",
codr:"4/6",
ipol:false,
size:msg_size,
data:base64str
};
send_pkt(JSON.stringify(json_obj));
}
var lora_packet = require('lora-packet');
function onInit() {
debug_print("on init");
}
function onLoRaRx (data) {
debug_print("on Recv data");
var raw = JSON.parse(data);
var lorawan_packet = new Buffer(raw.data, 'base64');
if(lorawan_packet.length>12){
Содержание TLG8411V1
Страница 1: ...Gateway TLG8411V1 User Manual V1 0 0 July 2020 ...
Страница 36: ...Gateway TLG8411V1 User Manual V1 0 0 35 July 2020 Figure 4 2 Execution of Parsing LoRaWAN Packet in LoRaScript ...
Страница 52: ...Gateway TLG8411V1 User Manual V1 0 0 51 July 2020 8 Revisions 8 1 V1 0 0 First Release Version ...