Code Monkey home page Code Monkey logo

lorawan-parser's Introduction

Introduction

This LoRaWAN tool is for LoRaWAN developers who need know the details of LoRaWAN protocol.

With lorawan-parser, you can see all details of a LoRaWAN frame, like how is the frame structured, how data is encrypted and decrypted, what is DEVEUI / APPEUI / DEVADDR like etc.

Features

  • LoRaWAN 1.0
    • V1.0.2 / V1.0.2B
  • Support both ABP and OTAA mode device
  • Colorful terminal outputs (Windows MiniTTY not supported)
  • Cross platform (Tested on Ubuntu, Lubuntu, Raspberry Pi, OpenWRT, Windows)
  • LoRaWAN V1.1
    • Work in progress
  • Support Semtech packet forwarder v1 and v2 protocol
  • Live parse LoRaWAN motes message (To support RisingHF gateway or Semtech IoT Start Kit)

Usage

Refer to util/test/main.c to know the usage of lorawan API.

After compile find lwp.exe/lwp under util/parser/ directory to parse the LoRaWAN frame.

--------------------------------------------------------------------------------
Usage: lwp.exe [OPTIONS]
 -h, --help                     Help
 -v, --version                  Version 0.3.0

--------------------------------------------------------------------------------
 -c, --burst-parse  <file>      Parse lwp json format file
 -m, --maccmd       <hex>       Parse MAC command
 -p, --parse        [hex]       Parse packet
 -g, --pack         [hex]       Generate packet
 -f, --pktfwd       [file]      Packet forwarder mode
     --join                     Analyze JR and JA

--------------------------------------------------------------------------------
 -B, --band         <string>    PHY band EU868/US915/EU434/AU920/CN780/CN470
 -N, --nwkskey      <hex>       NwkSKey
 -A, --appskey      <hex>       AppSKey
 -K, --appkey       <hex>       AppKey

--------------------------------------------------------------------------------
 -T, --type         <string>    Frame type (JR/JA/UU/UD/CU/CD/P)
 -D, --devaddr      <hex>       DevAddr
     --ack                      FCtrl ACK
     --aareq                    FCtrl ADRACKReq
     --adr                      FCtrl ADR
     --classb                   FCtrl CLASSB
     --fpending                 FCtrl FPENDING
 -O, --fopts        <hex>       FOpts, LoRaWAN Options
 -C                 <hex>       Frame counter (hex)
     --counter      <int>       Frame counter (int)
 -P                 <hex>       Port (hex)
     --port         <int>       Port (int)

--------------------------------------------------------------------------------
     --appeui       <hex>       AppEui
     --deveui       <hex>       DevEui
     --anonce       <hex>       AppNonce (3 byets)
     --dnonce       <hex>       DevNonce (2 byets)
     --netid        <hex>       NetId (3 byets)
     --cflist       <hex>       CFList (16 bytes)
     --rx1droft     <int>       RX1DRoffset (0~7)
     --rx2dr        <int>       RX2DataRate (0~15)
     --rxdelay      <int>       RxDelay (0~15)
     --jr           <hex>       JoinRequest raw data
     --ja           <hex>       JoinAccept raw data

--------------------------------------------------------------------------------
     --motes        <file>      Motes/Nodes JSON file
     --nodes        <file>      Same as --motes

--------------------------------------------------------------------------------
 -b, --board        <file>      Board specific TX power table and RSSI offset
 -i, --iface        <string>    Network interface, default eth0

--------------------------------------------------------------------------------
Default AppKey/NwkSKey/AppSKey 2B7E151628AED2A6ABF7158809CF4F3C

Pack LoRaWAN frame

# Unconfirmed uplink
$ ./lwp --pack "00112233" -T UU --devaddr 01111111 --adr --ack --counter 1113 --port 2

# Confirmed uplink without payload
$ ./lwp --pack -T CU --devaddr 01111111 --adr --ack --aareq --counter 1113

# Unconfirmed downlink
$ ./lwp --pack "00112233" -T UD --devaddr 01111111 --adr --ack --port 2 --counter 1113

# Confirmed downlink without payload, frame pending set
$ ./lwp --pack -T CD --devaddr 01111111 --adr --ack --pending --counter 1113

# Join request
$ ./lwp --pack -T JR --deveui 0123456789ABCDEF --appeui 0000000000000001 --dnonce ABCD

# Join accept, --dnonce is used to generate NwkSKey and AppSKey
$ ./lwp --pack -T JA --devaddr 0123456 --anonce ABCDEF --netid 000008 --rx1droft 0 --rx2dr 0 --rxdelay 1 --dnonce ABCD

Parse LoRaWAN frame

# Parser with specified keys
$ ./lwp --parse "40 11 11 11 01 A0 59 04 02 0F A0 9D 7C 61 F3 FA B7" --nwkskey 2B7E151628AED2A6ABF7158809CF4F3C --appskey 2B7E151628AED2A6ABF7158809CF4F3C --appkey 2B7E151628AED2A6ABF7158809CF4F3C

# Parse with default key
$ ./lwp --parse "40 11 11 11 01 A0 59 04 02 0F A0 9D 7C 61 F3 FA B7"

Parse LoRaWAN MACCMD

$ lwp -T CD -m "02 30 01"

Parse JoinRequest and JoinAccept

# Parse JR/JA pair
$ ./lwp --join --jr "0001000000000000860100000000000086F79FB4C20660" --ja "202D9583ABA736C80F9700DB420A010554" --appkey "86000000000000008600000000000000"

Burst Parse LoRaWAN Frame

$ ./lwp -c lwp-config.json

To go further, user could fill their own LoRaWAN frames in a json file to parse it.

Packet Forwarder Mode

$ ./lwp --pktfwd global_conf.template.json --board lwp-board.json --iface eth0

Compile

Linux

Depends on tools libtool, automake. To build:

# install tools if it is not there
sudo apt-get install autoconf libtool

cd lorawan-parser
autoreconf -i
./configure
make

Windows

Codeblocks

lorawan-parser supports Codeblocks project. One could download Codeblocks from its official website.

CMake

Not supported yet. You are welcome to submit CMake patches.

Raspberry Pi

sudo apt-get install autoconf libtool
autoreconf -i
./configure
make

Big Endian Platform

Thank @huzhifeng help test on MIPS platform

autoreconf -i
./configure --enable-big-endian
make

Cross Compile

Raspberry Pi

git clone --depth 1 https://github.com/raspberrypi/tools

Add below path to system $PATH

// 64bits
$YOUR_PATH/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

// 32bits
$YOUR_PATH/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin

Generate Makefile

./configure --host=arm-linux CC=arm-linux-gnueabihf-gcc

Limitation

lorawan-parser only handles frames of which real frame counter is less than 0xFFFF, this is because an exact LoRaWAN frame only record low 16bits of the frame, the parser alwarys assumes the high 16bits is zero.

Frame counter enhancement

API is updated to receive frame counter 16 most-significante bits passed from user. This makes it possible to emunate the frame counter most significante bits when a frame is known to be valid

Contribute

Any kind of contributions are welcome, issue report, pull requests, WIKI, suggestions...

Before you send pull request, please try to make your code keep same style as the original one.

License

lorawan-paser and is licensed under The MIT License. Check LICENSE.txt for more information.

parson, AES, CMAC have its own licenses. Please follow links below to get the details.

Acknowledgement

lorawan-parser's People

Contributors

fistaco avatar jiapengli avatar jlesech avatar kratenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lorawan-parser's Issues

warning: format not a string literal and no format arguments [-Wformat-security]

lorawan-parser 370f14c brings a warning "format not a string literal and no format arguments [-Wformat-security]" to log_puts

For now I have no idea how fix it in a clean way.

I refered serveral articals:
http://stackoverflow.com/questions/9707569/c-array-warning-format-not-a-string-literal

All answers are similar, need replace strfmt to string, but this way will not work for log_puts, log_puts needs printf to receive dynamic parameters.

MIC calculation for MSG down

Hi,
the function "lw_mtype_msg_up" is used for parsing up & down messages. a little bit confusing but ok. But while calculating the MIC you use in BOTH cases the fcnt32 of up messages.

fcnt16 = ((uint32_t)msg[LW_DATA_OFF_FCNT+1]<<8) + msg[LW_DATA_OFF_FCNT];
fcntlsb = (uint16_t)cur->ufcnt;
fcntmsb = (uint16_t)(cur->ufcnt>>16);
if(fcnt16<fcntlsb){
    fcntmsb++;
}
lw_key.fcnt32 = ((uint32_t)fcntmsb<<16) + fcnt16;

lw_msg_mic(&mic, &lw_key);
if(mic.data != plmic.data){
    if(lw_key.fcnt32 == fcnt16){
        return LW_ERR_MIC;
    }
    lw_key.fcnt32 = fcnt16;
    lw_msg_mic(&mic, &lw_key);
    if(mic.data != plmic.data){
        return LW_ERR_MIC;
    }
}

Is this your intention or a bug?
I think the current implementation will give an error for framecounts > 16 bit. For down messages you should select the global 32bit down fcnt,

Cannot parse decoded packets from gr-lora

Hi, I am trying to parse packets received by gr-lora in Gnuradio.

The Packets are exported on Terminal and then I copy them and use them as parameter in the parser.

./lwp -p "67 f5 03 96 95 27 7e b8 83 42 8c 12 0e 8e f3 05 0e 79 e3 07 9d 79 34 72 cb 20 63 c2 71 dd c6 09 20 22 04 29 8d 32 5d 24 20 bf 5e eb 62 97 35 0c bb 79 79 d1 0d 8b 0e 80 10 ba 7c 12 2e 75 47 7e 4b d7 93 bb 2e 06 b1 b2 48 9c 80 39 30 61 10 1c f2 71 de 9d d8 95 7c d2 75 eb 5a a0 df 72 66 ba a4 af 58 b0 e5 f3 b7 1e 1c be f9 33 e7 e4 db b7 7f d7 ad 7e f5 6b 11 a8 e3"

but I get an error:
DATA MESSAGE PARSER error(-15)

The Class B bit is not displayed when present in the Fctrl

After switching to Class B, the device is setting the Class B bit in the FCtrl field.

decoding from Hex:  40FA5BBA04800A00EAB67D05
Decoded packet
--------------
Message Type = Data
            PHYPayload = 40FA5BBA04800A00EAB67D05

          ( PHYPayload = MHDR[1] | MACPayload[..] | MIC[4] )
                  MHDR = 40
            MACPayload = FA5BBA04800A00
                   MIC = EAB67D05

          ( MACPayload = FHDR | FPort | FRMPayload )
                  FHDR = FA5BBA04800A00
                 FPort =
            FRMPayload =

                ( FHDR = DevAddr[4] | FCtrl[1] | FCnt[2] | FOpts[0..15] )
               DevAddr = 04BA5BFA (Big Endian)
                 FCtrl = 80
                  FCnt = 000A (Big Endian)
                 FOpts =

          Message Type = Unconfirmed Data Up
             Direction = up
                  FCnt = 10
             FCtrl.ACK = false
             FCtrl.ADR = true

In my case, the FCtrl value is equal to '80' meaning 0101 0000
image
The Class B bit is really present but lorawan-parser don't display it:

APPEUI: 0000000000000000, DEVEUI: 6C77700000000000, DEVADDR: 04BA5BFA, ADR: 1, ADRACKREQ: 0, ACK :0, FCNT: 10 [0x0000000A], MIC: EAB67D05
No Port and FRMPayload```

Buffer overflow detected

When running ./lwp --parse "40 11 11 11 01 A0 59 04 02 0F A0 9D 7C 61 F3 FA B7" I got the following output:


--------------------------------------------------------------------------------
*** buffer overflow detected ***: ./lwp terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fad25fe67e5]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7fad2608811c]
/lib/x86_64-linux-gnu/libc.so.6(+0x117120)[0x7fad26086120]
./lwp[0x40b307]
./lwp[0x40c2de]
./lwp[0x401bde]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fad25f8f830]
./lwp[0x402049]
======= Memory map: ========
00400000-00420000 r-xp 00000000 08:07 941544                             /home/duranda/lorawan-parser/util/parser/lwp
0061f000-00620000 r--p 0001f000 08:07 941544                             /home/duranda/lorawan-parser/util/parser/lwp
00620000-00627000 rw-p 00020000 08:07 941544                             /home/duranda/lorawan-parser/util/parser/lwp
00627000-0062b000 rw-p 00000000 00:00 0 
0094f000-00970000 rw-p 00000000 00:00 0                                  [heap]
7fad25d59000-7fad25d6f000 r-xp 00000000 08:07 136364                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fad25d6f000-7fad25f6e000 ---p 00016000 08:07 136364                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fad25f6e000-7fad25f6f000 rw-p 00015000 08:07 136364                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fad25f6f000-7fad2612f000 r-xp 00000000 08:07 131955                     /lib/x86_64-linux-gnu/libc-2.23.so
7fad2612f000-7fad2632f000 ---p 001c0000 08:07 131955                     /lib/x86_64-linux-gnu/libc-2.23.so
7fad2632f000-7fad26333000 r--p 001c0000 08:07 131955                     /lib/x86_64-linux-gnu/libc-2.23.so
7fad26333000-7fad26335000 rw-p 001c4000 08:07 131955                     /lib/x86_64-linux-gnu/libc-2.23.so
7fad26335000-7fad26339000 rw-p 00000000 00:00 0 
7fad26339000-7fad26351000 r-xp 00000000 08:07 131919                     /lib/x86_64-linux-gnu/libpthread-2.23.so
7fad26351000-7fad26550000 ---p 00018000 08:07 131919                     /lib/x86_64-linux-gnu/libpthread-2.23.so
7fad26550000-7fad26551000 r--p 00017000 08:07 131919                     /lib/x86_64-linux-gnu/libpthread-2.23.so
7fad26551000-7fad26552000 rw-p 00018000 08:07 131919                     /lib/x86_64-linux-gnu/libpthread-2.23.so
7fad26552000-7fad26556000 rw-p 00000000 00:00 0 
7fad26556000-7fad2665e000 r-xp 00000000 08:07 131949                     /lib/x86_64-linux-gnu/libm-2.23.so
7fad2665e000-7fad2685d000 ---p 00108000 08:07 131949                     /lib/x86_64-linux-gnu/libm-2.23.so
7fad2685d000-7fad2685e000 r--p 00107000 08:07 131949                     /lib/x86_64-linux-gnu/libm-2.23.so
7fad2685e000-7fad2685f000 rw-p 00108000 08:07 131949                     /lib/x86_64-linux-gnu/libm-2.23.so
7fad2685f000-7fad26885000 r-xp 00000000 08:07 131906                     /lib/x86_64-linux-gnu/ld-2.23.so
7fad26a55000-7fad26a59000 rw-p 00000000 00:00 0 
7fad26a81000-7fad26a84000 rw-p 00000000 00:00 0 
7fad26a84000-7fad26a85000 r--p 00025000 08:07 131906                     /lib/x86_64-linux-gnu/ld-2.23.so
7fad26a85000-7fad26a86000 rw-p 00026000 08:07 131906                     /lib/x86_64-linux-gnu/ld-2.23.so
7fad26a86000-7fad26a87000 rw-p 00000000 00:00 0 
7ffc497ba000-7ffc497db000 rw-p 00000000 00:00 0                          [stack]
7ffc497db000-7ffc497dd000 r--p 00000000 00:00 0                          [vvar]
7ffc497dd000-7ffc497df000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted

It was compiled on Linux Mint 18.2 (based on Ubuntu 16.04).

Segmentation faults on Raspberry Pi 3

Hi @JiapengLi ,

I observed segmentation faults on Raspberry Pi3 when run ./util/test/test and ./util/parser/lwp
Raspberry Pi3 OS: 2016-05-27-raspbian-jessie.img
lorawan-parser revision: @e08fd428686919dbfd998408d8664c9f2f0ad0fe

Below is the detail, can you have a loot at it?thanks

pi@raspberrypi:~ $ mkdir -p git
pi@raspberrypi:~ $ cd git/
pi@raspberrypi:~/git $ sudo apt-get install -y autoconf libtool
pi@raspberrypi:~/git $ git clone https://github.com/JiapengLi/lorawan-parser.git
pi@raspberrypi:~/git $ cd lorawan-parser/
pi@raspberrypi:~/git/lorawan-parser $ autoreconf -i
pi@raspberrypi:~/git/lorawan-parser $ ./configure
pi@raspberrypi:~/git/lorawan-parser $ make
pi@raspberrypi:~/git/lorawan-parser $ git log -1
commit e08fd428686919dbfd998408d8664c9f2f0ad0fe
Author: Jiapeng Li <[email protected]>
Date:   Thu Jun 23 00:23:14 2016 +0800

    Parser MACCMD, add -T and -m support
pi@raspberrypi:~/git/lorawan-parser $ ./util/parser/lwp -T CD -m "02 30 01"     
MACCMD: 02 30 01 
MACCMD ( LinkCheckAns )
Margin: 48dB
GwCnt: 1
pi@raspberrypi:~/git/lorawan-parser $ ./util/test/test 

--------------------------------------------------------------------------------
Test Normal Message MIC

0AF8DA0E len:13

MIC is OK


--------------------------------------------------------------------------------
Test Normal Message Decrypt

Message MIC is OK

Segmentation fault
pi@raspberrypi:~/git/lorawan-parser $ ./util/parser/lwp -c util/parser/lwp-config.json 
File name: util/parser/lwp-config.json
Found configuration file

--------------------------------------------------------------------------------
         BAND:   EU868
      NWKSKEY:    <16> 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c 
      APPSKEY:    <16> 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c 
       APPKEY:    <16> 86 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 
        JOINR:    <23> 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 
        JOINA:    <17> 20 2d 95 83 ab a7 36 c8 0f 97 00 db 42 0a 01 05 54 
    0 MESSAGE:    <23> 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 
    1 MESSAGE:    <17> 20 2d 95 83 ab a7 36 c8 0f 97 00 db 42 0a 01 05 54 
    2 MESSAGE:    <17> 40 97 01 00 48 80 00 00 01 2e 3a 00 de 42 f0 72 d2 
    3 MESSAGE:    <17> a0 97 01 00 48 05 00 00 03 01 07 00 61 56 ed ba 18 
    4 MESSAGE:    <17> 40 97 01 00 48 80 01 00 01 63 8b 0e 20 9d e4 87 49 
    5 MESSAGE:    <17> a0 97 01 00 48 05 00 00 03 01 07 00 61 56 ed ba 18 
    6 MESSAGE:    <19> 40 97 01 00 48 e2 02 00 03 06 01 c9 b6 a5 8a 32 0e c7 37 
    7 MESSAGE:    <12> 60 97 01 00 48 00 01 00 35 9c 2e 00 
    8 MESSAGE:    <17> 40 97 01 00 48 80 03 00 01 c7 9d fc e7 d5 d3 d7 fa 
    9 MESSAGE:    <17> a0 97 01 00 48 05 02 00 03 01 07 00 61 5d 83 b2 fb 
   10 MESSAGE:    <19> 40 97 01 00 48 e2 04 00 03 06 01 f6 a5 65 eb c0 fc fb 7b 
   11 MESSAGE:    <12> 60 97 01 00 48 00 03 00 f8 26 10 45 
   12 MESSAGE:    <17> 40 97 01 00 48 80 05 00 01 a8 d6 54 2c 24 c2 cb f3 
   13 MESSAGE:    <17> 40 97 01 00 48 80 06 00 01 22 00 58 c3 79 d7 d3 5b 
     0 MACCMD:     <1> [80] 02 
     1 MACCMD:     <3> [A0] 02 30 01 
     2 MACCMD:     <5> [A0] 03 51 07 00 61 
     3 MACCMD:     <2> [80] 03 07 
     4 MACCMD:     <2> [A0] 04 04 
     5 MACCMD:     <1> [80] 04 
     6 MACCMD:     <5> [A0] 05 07 01 02 03 
     7 MACCMD:     <2> [80] 05 07 
     8 MACCMD:     <1> [A0] 06 
     9 MACCMD:     <3> [80] 06 ff 30 
    10 MACCMD:     <6> [A0] 07 00 01 23 45 11 
    11 MACCMD:     <2> [80] 07 03 
    12 MACCMD:     <2> [A0] 08 01 
    13 MACCMD:     <1> [80] 08 

--------------------------------------------------------------------------------
MSG: 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 
LoRaWAN R1
JOIN REQUEST
Join Request MIC is OK
MIC is OK [ B4 C2 06 60 ]
APPEUI: 86:00:00:00:00:00:00:01
DEVEUI: 86:00:00:00:00:00:00:01
DEVNONCE: 0x9FF7
DMSG: 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 

--------------------------------------------------------------------------------
MSG: 20 2d 95 83 ab a7 36 c8 0f 97 00 db 42 0a 01 05 54 
LoRaWAN R1
JOIN ACCEPT
Join accept encrypted payload:(17)
Segmentation fault
pi@raspberrypi:~/git/lorawan-parser $

About lorawan-parser develop branch

lorawan-parser develop branch brings below new features:

  • Support multiple nodes(ABP/OTAA)
  • Split log and main lorawan api
  • lora_gateway library is supported (parse on the fly will be added soon)
  • Add pack function

DeviceTimeReq/Ans not supported

Hello,

Thanks a lot for your amazing tool.
Unfortunately, you mentioned that the tool is LW 1.0.2B (1.0.3) compatible but it seems the DeviceTimeReq/Ans is not yet supported:

Device sending the DeviceTimeReq:

APPEUI: 0000000000000000, DEVEUI: 6C77700000000000, DEVADDR: 04BA5BFA, ADR: 1, ADRACKREQ: 0, ACK :0, FCNT: 7 [0x00000007], MIC: A17278FD
No Port and FRMPayload
MACCMD INVALID: 0D (FOpts)```

**And the reception of the DeviceTimeAns:**
```MSG: (UD <-) 60FA5BBA0400080000D91F764A3DE9B26752711E23D539D8
APPEUI: 0000000000000000, DEVEUI: 6C77700000000000, DEVADDR: 04BA5BFA, ADR: 0, ADRACKREQ: 0, ACK :0, FCNT: 8 [0x00000008], MIC: 23D539D8
MACCMD INVALID: 0DEDFD3B48D51170B78C03 (Port 0)```

Failed to build on macOS

I installed autoconf and automake via Homebrew. Both autoreconf -i and ./configure, make fails with

libtool: compile:  gcc -DPACKAGE_NAME=\"lorawan-parser\" -DPACKAGE_TARNAME=\"lorawan-parser\" -DPACKAGE_VERSION=\"1.0\" "-DPACKAGE_STRING=\"lorawan-parser 1.0\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DPACKAGE=\"lorawan-parser\" -DVERSION=\"1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FCNTL_H=1 -DHAVE_STDINT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_MALLOC=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_MUNMAP=1 -DHAVE_MEMSET=1 -I. -I../../../lib/libloragw/inc -I../../../lib -I../../../lw -g -O2 -MT loragw_spi.native.lo -MD -MP -MF .deps/loragw_spi.native.Tpo -c loragw_spi.native.c  -fno-common -DPIC -o .libs/loragw_spi.native.o
loragw_spi.native.c:32:10: fatal error: 'linux/spi/spidev.h' file not found
#include <linux/spi/spidev.h>
         ^
1 error generated.
make[3]: *** [loragw_spi.native.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

I guess it should be guarded by some macros?

Linux compile

Hello.
dd@alm-01:~/lora/server/lorawan-parser# make
Making all in lib
make[1]: Entering directory /home/dubanoze/lora/server/lorawan-parser/lib' make[1]: Nothing to be done forall'.
make[1]: Leaving directory /home/dubanoze/lora/server/lorawan-parser/lib' Making all in lw make[1]: Entering directory/home/dubanoze/lora/server/lorawan-parser/lw'
make[1]: Nothing to be done for all'. make[1]: Leaving directory/home/dubanoze/lora/server/lorawan-parser/lw'
Making all in util/parser
make[1]: Entering directory /home/dubanoze/lora/server/lorawan-parser/util/parser' /bin/bash ../../libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -o lwp main.o config.o ../../lib/lib.la ../../lw/liblorawan.la libtool: link: gcc -std=gnu99 -g -O2 -o lwp main.o config.o ../../lib/.libs/lib.a ../../lw/.libs/liblorawan.a ../../lw/.libs/liblorawan.a(lorawan.o): In functionlw_maccmd':
/home/dubanoze/lora/server/lorawan-parser/lw/lorawan.c:976: undefined reference to pow' /home/dubanoze/lora/server/lorawan-parser/lw/lorawan.c:993: undefined reference topow'
/home/dubanoze/lora/server/lorawan-parser/lw/lorawan.c:949: undefined reference to pow' collect2: error: ld returned 1 exit status make[1]: *** [lwp] Error 1 make[1]: Leaving directory/home/dubanoze/lora/server/lorawan-parser/util/parser'
make: *** [all-recursive] Error 1

DATA MESSAGE PARSE error(-8) and MACCMD error(-5)

Hi @JiapengLi ,
I'm trying to port lorawan-parser to OpenWrt, there no error/warning when compiling, but a lot of DATA MESSAGE PARSE error(-8) and MACCMD error(-5) when run test ./lwp -c lwp-config.json

I did some searching in the source code and found that:
-8 was defined in lw-macro.h

LW_ERR_JOINR_LEN        = -8,

-5 was defined in lw-macro.h too

LW_ERR_MACCMD           = -5,

But I don't know what caused these errors, can you have a look at this? thanks

My Makefile for OpenWrt:

cat package/utils/lorawan-parser/Makefile 
# Copyright (C) 2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=lorawan-parser
PKG_VERSION:=0.1
PKG_RELEASE:=1

PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/JiapengLi/lorawan-parser.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e08fd428686919dbfd998408d8664c9f2f0ad0fe
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz

PKG_LICENSE:=MIT

PKG_FIXUP:=autoreconf -i

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=Parser for LoRaWAN frame
  DEPENDS:=+libpthread
  URL:=https://github.com/JiapengLi/lorawan-parser
endef

define Package/$(PKG_NAME)/install
        $(INSTALL_DIR) $(1)/root/lora
        $(CP) $(PKG_BUILD_DIR)/util/parser/lwp $(1)/root/lora/lwp
        $(CP) $(PKG_BUILD_DIR)/util/parser/*.json $(1)/root/lora/
        $(CP) $(PKG_BUILD_DIR)/util/test/test $(1)/root/lora/lwp-test
endef

$(eval $(call BuildPackage,$(PKG_NAME)))

Error logs:

root@OpenWrt:~/lora# ./lwp -c lwp-config.json 
File name: lwp-config.json
Found configuration file

--------------------------------------------------------------------------------
         BAND:   EU868
      NWKSKEY:    <16> 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c 
      APPSKEY:    <16> 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c 
       APPKEY:    <16> 86 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 
        JOINR:    <23> 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 
        JOINA:    <17> 20 2d 95 83 ab a7 36 c8 0f 97 00 db 42 0a 01 05 54 
    0 MESSAGE:    <23> 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 
    1 MESSAGE:    <17> 20 2d 95 83 ab a7 36 c8 0f 97 00 db 42 0a 01 05 54 
    2 MESSAGE:    <17> 40 97 01 00 48 80 00 00 01 2e 3a 00 de 42 f0 72 d2 
    3 MESSAGE:    <17> a0 97 01 00 48 05 00 00 03 01 07 00 61 56 ed ba 18 
    4 MESSAGE:    <17> 40 97 01 00 48 80 01 00 01 63 8b 0e 20 9d e4 87 49 
    5 MESSAGE:    <17> a0 97 01 00 48 05 00 00 03 01 07 00 61 56 ed ba 18 
    6 MESSAGE:    <19> 40 97 01 00 48 e2 02 00 03 06 01 c9 b6 a5 8a 32 0e c7 37 
    7 MESSAGE:    <12> 60 97 01 00 48 00 01 00 35 9c 2e 00 
    8 MESSAGE:    <17> 40 97 01 00 48 80 03 00 01 c7 9d fc e7 d5 d3 d7 fa 
    9 MESSAGE:    <17> a0 97 01 00 48 05 02 00 03 01 07 00 61 5d 83 b2 fb 
   10 MESSAGE:    <19> 40 97 01 00 48 e2 04 00 03 06 01 f6 a5 65 eb c0 fc fb 7b 
   11 MESSAGE:    <12> 60 97 01 00 48 00 03 00 f8 26 10 45 
   12 MESSAGE:    <17> 40 97 01 00 48 80 05 00 01 a8 d6 54 2c 24 c2 cb f3 
   13 MESSAGE:    <17> 40 97 01 00 48 80 06 00 01 22 00 58 c3 79 d7 d3 5b 
     0 MACCMD:     <1> [80] 02 
     1 MACCMD:     <3> [A0] 02 30 01 
     2 MACCMD:     <5> [A0] 03 51 07 00 61 
     3 MACCMD:     <2> [80] 03 07 
     4 MACCMD:     <2> [A0] 04 04 
     5 MACCMD:     <1> [80] 04 
     6 MACCMD:     <5> [A0] 05 07 01 02 03 
     7 MACCMD:     <2> [80] 05 07 
     8 MACCMD:     <1> [A0] 06 
     9 MACCMD:     <3> [80] 06 ff 30 
    10 MACCMD:     <6> [A0] 07 00 01 23 45 11 
    11 MACCMD:     <2> [80] 07 03 
    12 MACCMD:     <2> [A0] 08 01 
    13 MACCMD:     <1> [80] 08 

--------------------------------------------------------------------------------
MSG: 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 
LoRaWAN R1
JOIN REQUEST
Join Request MIC is OK
MIC is OK [ B4 C2 06 60 ]
APPEUI: 86:00:00:00:00:00:00:01
DEVEUI: 86:00:00:00:00:00:00:01
DEVNONCE: 0x9FF7
DMSG: 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 

--------------------------------------------------------------------------------
MSG: 20 2d 95 83 ab a7 36 c8 0f 97 00 db 42 0a 01 05 54 
LoRaWAN R1
JOIN REQUEST

--------------------------------------------------------------------------------
MSG: 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 
LoRaWAN R1
JOIN REQUEST
Join Request MIC is OK
MIC is OK [ B4 C2 06 60 ]
APPEUI: 86:00:00:00:00:00:00:01
DEVEUI: 86:00:00:00:00:00:00:01
DEVNONCE: 0x9FF7
DMSG: 00 01 00 00 00 00 00 00 86 01 00 00 00 00 00 00 86 f7 9f b4 c2 06 60 

--------------------------------------------------------------------------------
MSG: 20 2d 95 83 ab a7 36 c8 0f 97 00 db 42 0a 01 05 54 
LoRaWAN R1
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 40 97 01 00 48 80 00 00 01 2e 3a 00 de 42 f0 72 d2 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: a0 97 01 00 48 05 00 00 03 01 07 00 61 56 ed ba 18 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 40 97 01 00 48 80 01 00 01 63 8b 0e 20 9d e4 87 49 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: a0 97 01 00 48 05 00 00 03 01 07 00 61 56 ed ba 18 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 40 97 01 00 48 e2 02 00 03 06 01 c9 b6 a5 8a 32 0e c7 37 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 60 97 01 00 48 00 01 00 35 9c 2e 00 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 40 97 01 00 48 80 03 00 01 c7 9d fc e7 d5 d3 d7 fa 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: a0 97 01 00 48 05 02 00 03 01 07 00 61 5d 83 b2 fb 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 40 97 01 00 48 e2 04 00 03 06 01 f6 a5 65 eb c0 fc fb 7b 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 60 97 01 00 48 00 03 00 f8 26 10 45 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 40 97 01 00 48 80 05 00 01 a8 d6 54 2c 24 c2 cb f3 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MSG: 40 97 01 00 48 80 06 00 01 22 00 58 c3 79 d7 d3 5b 
LoRaWAN version unknown
JOIN REQUEST
DATA MESSAGE PARSE error(-8)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)

--------------------------------------------------------------------------------
MACCMD error(-5)
root@OpenWrt:~/lora# 
root@OpenWrt:~/lora#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.