Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnrc_lorawan: encode LoRaWAN port in netif header #16080

Merged
merged 4 commits into from
Jun 17, 2021

Conversation

jia200x
Copy link
Member

@jia200x jia200x commented Feb 23, 2021

Contribution description

This PR encodes the LoRaWAN port in a GNRC netif header.
The benefit of doing this is that we can reuse txtsnd and similar commands. From now on it's possible to use GNRC LoRaWAN (almost) out of the box in any GNRC application (e.g examples/default).

This PR also deprecates NETOPT_LORAWAN_TX_PORT and introduces a CONFIG_GNRC_NETIF_LORAWAN_NETIF_HDR to enable this functionality (and don't abruptly change the API of users).

Testing procedure

The following things should be tested:

  • Check that examples/gnrc_lorawan works out of the box. The send command was replaced by txtsnd
  • Try sending frames in port 0. Frame shouldn't be sent.
  • Try GNRC LoRaWAN with examples/default:
CFLAGS=-DCONFIG_GNRC_NETIF_LORAWAN_NETIF_HDR USEMODULE=gnrc_lorawan BOARD=b-l072z-lrwan1 make flash term

Check that's possible to communicate.

Issues/PRs references

None so far

@jia200x jia200x added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Area: LoRa Area: LoRa radio support labels Feb 23, 2021
@jia200x jia200x requested a review from akshaim February 24, 2021 09:39
@leandrolanzieri leandrolanzieri added the Process: deprecation Integration Process: The PR is deprecating a feature or API label Feb 26, 2021
@leandrolanzieri leandrolanzieri added this to the Release 2021.04 milestone Feb 26, 2021
@github-actions github-actions bot added Area: doc Area: Documentation Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: network Area: Networking Area: sys Area: System labels Jun 9, 2021
@jia200x
Copy link
Member Author

jia200x commented Jun 9, 2021

rebased!

@MrKevinWeiss
Copy link
Contributor

I was able to run on my board with credentials from @jia200x:

CFLAGS=-DCONFIG_GNRC_NETIF_LORAWAN_NETIF_HDR USEMODULE='gnrc gnrc_netdev_default auto_init_gnrc_netif gnrc_txtsnd gnrc_pktdump gnrc_lorawan sx1272' DRIVER=sx1272 BOARD=nucleo-l452re make flash term -C examples/default/
2021-06-14 16:29:27,977 # ifconfig 3 up
txtsnd 05 whateverIwant
2021-06-14 16:29:37,458 # txtsnd 05 whateverIwant
2021-06-14 16:29:37,462 # usage: txtsnd <if> [<L2 addr>|bcast] <data>
txtsnd 3 01 whateverIwant
2021-06-14 16:29:46,082 # txtsnd 3 01 whateverIwant
txtsnd 3 02 whateverIwant
2021-06-14 16:30:03,595 # txtsnd 3 02 whateverIwant
> 2021-06-14 16:30:07,415 # PKTDUMP: data received:
2021-06-14 16:30:07,419 # ~~ SNIP  0 - size:   4 byte, type: NETTYPE_UNDEF (0)
2021-06-14 16:30:07,421 # 00000000  DE  AD  BE  ED
2021-06-14 16:30:07,426 # ~~ SNIP  1 - size:   9 byte, type: NETTYPE_NETIF (-1)
2021-06-14 16:30:07,429 # if_pid: 3  rssi: -32768  lqi: 0
2021-06-14 16:30:07,429 # flags: 0x0
2021-06-14 16:30:07,431 # src_l2addr: (nil)
2021-06-14 16:30:07,433 # dst_l2addr: 02
2021-06-14 16:30:07,436 # ~~ PKT    -  2 snips, total size:  13 byte
> ifconfig
2021-06-14 16:43:07,631 # ifconfig
2021-06-14 16:43:07,641 # Iface  3  HWaddr: 26:01:5C:73  Frequency: 869524963Hz  RSSI: 117  BW: 125kHz  SF: 9  CR: 4/5  Link: up 
2021-06-14 16:43:07,648 #            TX-Power: 14dBm  State: SLEEP  Demod margin.: 0  Num gateways.: 0 
2021-06-14 16:43:07,650 #           IQ_INVERT  
2021-06-14 16:43:07,653 #           RX_SINGLE  OTAA  L2-PDU:255

Note, the BOARD_PROVIDES_NETIF cannot be overridden so I had to manually add all the modules since I have using a shield on a generic nucleo.

@MrKevinWeiss
Copy link
Contributor

I also went through the documentation and played around with it

USEMODULE=sx1272 DRIVER=sx1272 BOARD=nucleo-l452re make flash term -C examples/gnrc_lorawan/
device
weiss@mobiweiss:~/wd/RIOT$ USEMODULE=sx1272 DRIVER=sx1272 BOARD=nucleo-l452re make flash term -C examples/gnrc_lorawan/
make: Entering directory '/home/weiss/wd/RIOT/examples/gnrc_lorawan'
Building application "gnrc_lorawan" for "nucleo-l452re" with MCU "stm32".

"make" -C /home/weiss/wd/RIOT/boards/nucleo-l452re
"make" -C /home/weiss/wd/RIOT/boards/common/nucleo
"make" -C /home/weiss/wd/RIOT/core
"make" -C /home/weiss/wd/RIOT/cpu/stm32
"make" -C /home/weiss/wd/RIOT/cpu/cortexm_common
"make" -C /home/weiss/wd/RIOT/cpu/cortexm_common/periph
"make" -C /home/weiss/wd/RIOT/cpu/stm32/periph
"make" -C /home/weiss/wd/RIOT/cpu/stm32/stmclk
"make" -C /home/weiss/wd/RIOT/cpu/stm32/vectors
"make" -C /home/weiss/wd/RIOT/drivers
"make" -C /home/weiss/wd/RIOT/drivers/netdev
"make" -C /home/weiss/wd/RIOT/drivers/periph_common
"make" -C /home/weiss/wd/RIOT/drivers/sx127x
"make" -C /home/weiss/wd/RIOT/sys
"make" -C /home/weiss/wd/RIOT/sys/auto_init
"make" -C /home/weiss/wd/RIOT/sys/crypto
"make" -C /home/weiss/wd/RIOT/sys/div
"make" -C /home/weiss/wd/RIOT/sys/fmt
"make" -C /home/weiss/wd/RIOT/sys/frac
"make" -C /home/weiss/wd/RIOT/sys/hashes
"make" -C /home/weiss/wd/RIOT/sys/iolist
"make" -C /home/weiss/wd/RIOT/sys/isrpipe
"make" -C /home/weiss/wd/RIOT/sys/luid
"make" -C /home/weiss/wd/RIOT/sys/malloc_thread_safe
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/link_layer/lorawan
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/netapi
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/netif
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/netif/hdr
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/netif/init_devs
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/netif/lorawan
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/netreg
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/pkt
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/pktbuf
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/pktbuf_static
"make" -C /home/weiss/wd/RIOT/sys/net/gnrc/pktdump
"make" -C /home/weiss/wd/RIOT/sys/net/link_layer/eui_provider
"make" -C /home/weiss/wd/RIOT/sys/net/link_layer/l2util
"make" -C /home/weiss/wd/RIOT/sys/net/netif
"make" -C /home/weiss/wd/RIOT/sys/newlib_syscalls_default
"make" -C /home/weiss/wd/RIOT/sys/od
"make" -C /home/weiss/wd/RIOT/sys/pm_layered
"make" -C /home/weiss/wd/RIOT/sys/random
"make" -C /home/weiss/wd/RIOT/sys/random/tinymt32
"make" -C /home/weiss/wd/RIOT/sys/shell
"make" -C /home/weiss/wd/RIOT/sys/shell/commands
"make" -C /home/weiss/wd/RIOT/sys/stdio_uart
"make" -C /home/weiss/wd/RIOT/sys/tsrb
"make" -C /home/weiss/wd/RIOT/sys/xtimer
"make" -C /home/weiss/wd/RIOT/sys/ztimer
   text	   data	    bss	    dec	    hex	filename
  54144	    196	   6472	  60812	   ed8c	/home/weiss/wd/RIOT/examples/gnrc_lorawan/bin/nucleo-l452re/gnrc_lorawan.elf
/home/weiss/wd/RIOT/dist/tools/openocd/openocd.sh flash /home/weiss/wd/RIOT/examples/gnrc_lorawan/bin/nucleo-l452re/gnrc_lorawan.elf
### Flashing Target ###
Open On-Chip Debugger 0.11.0+dev-00035-g8d6f7c922-dirty (2021-03-16-15:33)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : DEPRECATED target event trace-config
srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : clock speed 500 kHz
Info : STLINK V2J29M18 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.247800
Info : stm32l4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32l4x.cpu on 0
Info : Listening on port 40869 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32l4x.cpu       hla_target little stm32l4x.cpu       reset

Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000c50 msp: 0x20000200
Info : device idcode = 0x20016462 (STM32L45/L46xx - Rev Y : 0x2001)
Info : flash size = 512kbytes
Info : flash mode : single-bank
Info : Padding image section 1 at 0x0800d444 with 4 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x0800d448 .. 0x0800d7ff
auto erase enabled
wrote 54344 bytes from file /home/weiss/wd/RIOT/examples/gnrc_lorawan/bin/nucleo-l452re/gnrc_lorawan.elf in 2.447983s (21.679 KiB/s)

verified 54340 bytes in 1.679086s (31.604 KiB/s)

Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
shutdown command invoked
Done flashing
/home/weiss/wd/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200"  
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2021-06-15 10:04:59,602 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
ifconfig 3 set deveui ****
2021-06-15 10:05:08,276 # ifconfig 3 set deveui ****
2021-06-15 10:05:08,282 # success: set long address on interface 3 to ****
> ifconf 3 set appeui ****
2021-06-15 10:05:12,332 # ifconfig 3 set appeui ****
2021-06-15 10:05:12,337 # success: set AppEUI on interface 3 to ****
> ifconf 3 set appkey ****
2021-06-15 10:05:15,134 # ifconfig 3 set appkey ****
2021-06-15 10:05:15,139 # success: set AppKey on interface 3 to *****
> ifconfig up
2021-06-15 10:05:17,129 # ifconfig 3 up
ifconfig
2021-06-15 10:05:39,385 # ifconfig
2021-06-15 10:05:39,394 # Iface  3  HWaddr: 26:01:4B:CA  Frequency: 869524963Hz  RSSI: 117  BW: 125kHz  SF: 12  CR: 4/5  Link: up 
2021-06-15 10:05:39,401 #            TX-Power: 14dBm  State: SLEEP  Demod margin.: 0  Num gateways.: 0 
2021-06-15 10:05:39,403 #           IQ_INVERT  
2021-06-15 10:05:39,407 #           RX_SINGLE  OTAA  L2-PDU:255  
2021-06-15 10:05:39,408 #           
> txtsnd 3 7B "Hello RIOT!"
2021-06-15 10:06:00,146 # txtsnd 3 7B "Hello RIOT!"
> 2021-06-15 10:06:03,844 # PKTDUMP: data received:
2021-06-15 10:06:03,849 # ~~ SNIP  0 - size:  12 byte, type: NETTYPE_UNDEF (0)
2021-06-15 10:06:03,854 # 00000000  00  65  11  11  01  65  22  22  02  65  33  33
2021-06-15 10:06:03,859 # ~~ SNIP  1 - size:   9 byte, type: NETTYPE_NETIF (-1)
2021-06-15 10:06:03,861 # if_pid: 3  rssi: -32768  lqi: 0
2021-06-15 10:06:03,862 # flags: 0x0
2021-06-15 10:06:03,863 # src_l2addr: (nil)
2021-06-15 10:06:03,865 # dst_l2addr: 01
2021-06-15 10:06:03,869 # ~~ PKT    -  2 snips, total size:  21 byte
ifconfig 3 set dr 2
2021-06-15 10:06:09,770 # ifconfig 3 set dr 2
2021-06-15 10:06:09,774 # success: set datarate on interface 3 to 2
> ifconfig 3 link_check
2021-06-15 10:06:17,546 # ifconfig 3 link_check
2021-06-15 10:06:17,548 # success: set option
> txtsnd 3 01 "Join the RIOT!"
2021-06-15 10:06:28,251 # txtsnd 3 01 "Join the RIOT!"
> ifconfig 3 ack_req
2021-06-15 10:06:40,114 # ifconfig 3 ack_req
2021-06-15 10:06:40,116 # success: set option
> txtsnd 3 01 "My confirmable message"
2021-06-15 10:06:47,956 # txtsnd 3 01 "My confirmable message"
> txtsnd 3 01 "My confirmable message"
2021-06-15 10:07:01,212 # txtsnd 3 01 "My confirmable message"
> txtsnd 3 01 "My confirmable message"
2021-06-15 10:07:05,979 # txtsnd 3 01 "My confirmable message"
> 
application interface

Screenshot from 2021-06-15 10-14-16

@MrKevinWeiss
Copy link
Contributor

If you can just fix the cpp check issues, squash rebase all that fun stuff I think we should be OK.

@leandrolanzieri leandrolanzieri dismissed their stale review June 15, 2021 13:19

My comments were addressed

@jia200x
Copy link
Member Author

jia200x commented Jun 15, 2021

addressed and amended directly

Copy link
Contributor

@MrKevinWeiss MrKevinWeiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, nice cleanup, ACK.

@leandrolanzieri
Copy link
Contributor

Please squash @jia200x !

@leandrolanzieri leandrolanzieri added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines and removed Area: doc Area: Documentation Area: sys Area: System labels Jun 16, 2021
@github-actions github-actions bot added Area: doc Area: Documentation Area: sys Area: System labels Jun 16, 2021
@jia200x jia200x added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 16, 2021
Copy link
Contributor

@leandrolanzieri leandrolanzieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: LoRa Area: LoRa radio support Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Process: deprecation Integration Process: The PR is deprecating a feature or API Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants