Node Red node to decrypt MTDot Box survey and demo

Home Forums mDot/xDot Node Red node to decrypt MTDot Box survey and demo

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20853
    Nicolas Alberto
    Participant

    Hi,
    I am using the mLinux Gateway and TTN. I would like to decrypt the Lora Demo and survey messages from the MTDot box using node red. Could someone send me the export of the starter kit that comes with the AEP Gateway?

    Or do you know where to find a node that would be able to decrypt the payload from the MTDot Box?

    Thank you

    Nicolas

    #20860
    Steve Kovarik
    Moderator

    Hello Nicolas

    Here is a link to a Node-Red “flow” that will decrypt the “LoRa Demo” sensor
    data from the MTDOT-BOX.
    https://webfiles.multitech.com/mmm/LoRa_Demo_ParserFlow.txt

    If the Conduit’s inherent “LoRa Network Server” is disabled, and the
    device is configured as a simple packet forwarder to TTN, I don’t think
    Node-Red will work, because all packets are simply forwarded to TNN.

    Survey messages are stored on the MTDOT-BOX and can be extracted using a
    Developer Board as described at the link below.

    Configuration Mode

    Use the command AT+GSDF to get the Survey Data from the MTDOT-BOX

    -Best Regards

    #20863
    Nicolas Alberto
    Participant

    Thank a lot
    I have used some of the code provided and adapted it to make it work for the lora demo.

    Here is the code to import into node red if someone else need this functionality

    
    [{"id":"2d94ec93.0f2ed4","type":"function","z":"1ce26990.3fbf36","name":"MtDot Payload Decrypt","func":"var data_type = {\n\tnone : 0x00,\n\tled1 : 0x01,\n\tled2 : 0x02,\n\tlux_max : 0x03,\n\tlux_min : 0x04,\n\tlux_curr : 0x05,\n\tbaro_max : 0x06,\n\tbaro_min : 0x07,\n\tbaro_curr : 0x08,\n\ttemp_max : 0x09,\n\ttemp__min : 0x0A,\n\ttemp_curr : 0x0B,\n\taccel_max : 0x0C,\n\taccel_min : 0x0D,\n\taccel_curr : 0x0E,\n\tconfiguration : 0x0F,\n\tgpio_in : 0x10,\n\tgpio_out : 0x11,\n\tcurrent_max : 0x12,\n\tcurrent_min : 0x13,\n\tcurrent_curr : 0x14,\n\tgps_latitude : 0x15,\n\tgps_longitude : 0x16,\n\tgps_time : 0x17,\n\tgps_date : 0x18,\n\tgps_lock : 0x19,\n\tqos_up : 0x1A,\n\tqos_dwn : 0x1B,\n\trf_out : 0x1C,\n\tdata_mark : 0x1D,\n};\n\nvar data_struc = {\n\tdata_valid : 0,\n\tblock_start :0,\n\ttemperature : 0,\n\tx_pos : 0,\n\ty_pos : 0,\n\tz_pos : 0,\n\tbaro_pressure : 0,\n\tlux : 0,\n\tpkt_timer :0,\n\trf_pwr : 0,\n\tsf_val : 0,\n\trssi_up : 0,\n\tsnr_up : 0,\n\trssi_dwn : 0,\n\tsnr_dwn :0 ,\n\tlat_deg : 0 ,\n\tlat_min : 0,\n\tlong_deg : 0,\n\tlong_min : 0,\n\tnum_sats : 0 ,\n\tgps_status : 0,\n};\n\n//context.global.data_out = context.global.data_out || data_struc;\nvar pData = {};\n\nvar msg_pntr = 0;\nvar temp = 0;\n\nwhile (msg_pntr < msg.payload.length){\n\tswitch (msg.payload[msg_pntr]){\n\tcase data_type.lux_max:\n\tcase data_type.lux_min:\n\tcase data_type.lux_curr:\n\t\tpData.lux = msg.payload[++msg_pntr] << 8 \n\t\tpData.lux |= msg.payload[++msg_pntr];\n\t\tpData.lux = pData.lux * 0.24;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.baro_max:\n\tcase data_type.baro_min:\n\tcase data_type.baro_curr:\n\t\tpData.baro_pressure = msg.payload[++msg_pntr]<<16;\n\t\tpData.baro_pressure |= msg.payload[++msg_pntr]<<8;\n\t\tpData.baro_pressure |= msg.payload[++msg_pntr];\n\t\tpData.baro_pressure = pData.baro_pressure * 0.25;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.accel_max:\n\tcase data_type.accel_min:\n\tcase data_type.accel_curr:\n\t\tpData.x_pos = ((msg.payload[++msg_pntr] << 24) >> 24) * 0.0625;\n\t\tpData.y_pos = ((msg.payload[++msg_pntr] << 24) >> 24) * 0.0625;\n\t\tpData.z_pos = ((msg.payload[++msg_pntr] << 24) >> 24) * 0.0625;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.temp_min:\n\tcase data_type.temp_max:\n\tcase data_type.temp_curr:\n\t\tpData.temperature = msg.payload[++msg_pntr] << 24;\n\t\tpData.temperature |= msg.payload[++msg_pntr] << 16;\n\t\tpData.temperature = (pData.temperature >> 16) * .0625;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.configuration:\n\t\tpData.pkt_timer = msg.payload[++msg_pntr];\n\t\tmsg_pntr++\n\t\tbreak;\n\tcase data_type.current_max:\n\tcase data_type.current_min:\n\tcase data_type.current_curr:\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.gps_latitude:\n\t\tpData.lat_deg = (msg.payload[++msg_pntr] << 24) >> 24;\n\t\tpData.lat_min = msg.payload[++msg_pntr];\n\t\ttemp = msg.payload[++msg_pntr] << 8 \n\t\ttemp |= msg.payload[++msg_pntr];\n\t\tpData.lat_min = pData.lat_min + (temp * 0.0001);\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.gps_longitude:\n\t\tpData.long_deg = (msg.payload[++msg_pntr] << 24);\n\t\tpData.long_deg |= (msg.payload[++msg_pntr] << 16);\n\t\tpData.long_deg = pData.long_deg >> 16;\n\t\tpData.long_min = msg.payload[++msg_pntr];\n\t\ttemp = msg.payload[++msg_pntr] << 8 \n\t\ttemp |= msg.payload[++msg_pntr];\n\t\tpData.long_min = pData.long_min + (temp * 0.0001);\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.gps_time:\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.gps_date:\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.gps_lock:\n\t\tmsg_pntr++;\n\t\tpData.gps_status = msg.payload[msg_pntr] & 0x0F;\n\t\tpData.num_sats = msg.payload[msg_pntr++] >> 4;\n\t\tbreak;\n\tcase data_type.qos_up:\n\t\tpData.rssi_up = msg.payload[++msg_pntr] << 24;\n\t\tpData.rssi_up |= msg.payload[++msg_pntr] << 16;\n\t\tpData.rssi_up = pData.rssi_up >> 16;\n\t\tpData.snr_up = (msg.payload[++msg_pntr] << 24) >> 24;\n\t\tpData.rf_pwr = (msg.payload[++msg_pntr] << 24) >> 24;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.qos_dwn:\n\t\tpData.rssi_dwn = msg.payload[++msg_pntr] << 24;\n\t\tpData.rssi_dwn |= msg.payload[++msg_pntr] << 16;\n\t\tpData.rssi_dwn = pData.rssi_dwn >> 16;\n\t\tpData.snr_dwn = ((msg.payload[++msg_pntr] << 24) >> 24) / 4;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.rf_out:\n\t\tpData.rf_pwr = (msg.payload[++msg_pntr] << 24) >> 24;\n\t\tmsg_pntr++;\n\t\tbreak;\n\tcase data_type.data_mark:\n\t\tif (msg_pntr == 0) {\n\t\t\tpData = data_struc;\n\t\t\tpData.block_start = 1;\n\t\t\tmsg_pntr++;\n\t\t}\n\t\telse if (msg_pntr == (msg.payload.length - 1) && (pData.block_start === 1)) {\n\t\t\t\tpData.data_valid = 1;\n\t\t\t\tmsg_pntr++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tpData = data_struc;\n\t\t\t\tmsg_pntr = msg.payload.length;\n\t\t\t\t}\n\t\tbreak;\n\tdefault:\n\t\tpData = data_struc;\n\t\tmsg_pntr = msg.payload.length;\n\t}\n}\n\n\nmsg.payload = pData;\n//msg.payload = {\"x_pos\":-0.0625,\"y_pos\":0,\"z_pos\":0.9375,\"baro_pressure\":101314,\"lux\":36.96,\"temperature\":24.8125};\nreturn msg;","outputs":1,"noerr":0,"x":372,"y":103,"wires":[[]]}]
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.