[riot-notifications] [RIOT-OS/RIOT] pkg/semtech-loramac: add uplink_counter get/set functions (#11917)

Francisco notifications at github.com
Thu Jul 25 15:44:53 CEST 2019


<!--
The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.
-->

### Contribution description

<!--
Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes
-->

This PR exposes` _set_uplink_counter()` as part of the public api for `semtech_loramac`. It also adds it as a shell command. 

This is used by #11915 to be able to save and set the frame counter after a reboot on a node that doesn't have eeprom support. The use case for exposing the function is similar, being able to set the uplink counter to user defined values so there is no need to reset the network server.

### Testing procedure

<!--
Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output
-->

- Basic check:

`make BOARD=b-l072z-lrwan1 -C tests/pkg_semtech-loramac/ flash term`

Get and set the up link counter.

```
loramac get ul_ctr
2019-07-25 15:32:41,771 - INFO # loramac get ul_ctr
2019-07-25 15:32:41,773 - INFO # Uplink Counter: 3
> loramac set ul_ctr 8
2019-07-25 15:32:54,262 - INFO #  loramac set ul_ctr 8
loramac get ul_ctr
2019-07-25 15:32:59,406 - INFO #  loramac get ul_ctr
2019-07-25 15:32:59,408 - INFO # Uplink Counter: 8
```

- Functionality check: 

`make BOARD=b-l072z-lrwan1 -C tests/pkg_semtech-loramac/ flash term`

Set proper keys, and a high datarate. Manipulate the ul_ctr so the network server rejecs the incoming packets and then set it to a higher value so it accepts them again:

```
> 2019-07-25 15:40:56,624 - INFO #  main(): This is RIOT! (Version: 2019.10-devel-118-gb6999-pr_loramac_uplink_setget)
2019-07-25 15:40:56,627 - INFO # All up, running the shell now
>  loramac set deveui 00EB7BF2F1B8D06C
2019-07-25 15:41:07,073 - INFO #  loramac set deveui 00EB7BF2F1B8D06C
loramac set appeui 70B3D57ED001FD5FCA
2019-07-25 15:41:13,747 - INFO #  loramac set appeui 70B3D57ED001FD5F
: loramac set appskey 24C03C182530A3C70F1F9702A49939CA
2019-07-25 15:41:18,724 - INFO #  loramac set appskey 24C03C182530A3C70F1F9702A49939CA
: loramac set nwkskey 14601248D522BCD93C2DDFA6BF86B496
2019-07-25 15:41:23,085 - INFO #  loramac set nwkskey 14601248D522BCD93C2DDFA6BF86B496
: loramac set devaddr 26011847
2019-07-25 15:41:26,144 - INFO #  loramac set devaddr 26011847
: loramac set rx2_dr 3
2019-07-25 15:41:29,152 - INFO #  loramac set rx2_dr 3
: loramac set dr 5
2019-07-25 15:41:32,877 - INFO #  loramac set dr 5
: loramac join abp
2019-07-25 15:41:35,280 - INFO #  loramac join abp
2019-07-25 15:41:35,282 - INFO # Join procedure succeeded!
: loramac tx hello cnf
2019-07-25 15:41:46,408 - INFO #  loramac tx hello cnf
2019-07-25 15:41:47,538 - INFO # Received ACK from network
2019-07-25 15:41:47,540 - INFO # Message sent with success
> loramac tx hello cnf
2019-07-25 15:41:49,665 - INFO #  loramac tx hello cnf
2019-07-25 15:41:49,670 - INFO # Cannot send: dutycycle restriction
> loramac tx hello cnf
2019-07-25 15:41:52,583 - INFO #  loramac tx hello cnf
2019-07-25 15:41:53,713 - INFO # Received ACK from network
2019-07-25 15:41:53,715 - INFO # Message sent with success
: loramac set ul_ctr 0
2019-07-25 15:42:01,926 - INFO #  loramac set ul_ctr 0
> loramatx hello cnf
2019-07-25 15:42:06,386 - INFO #  loramac tx hello cnf
2019-07-25 15:42:21,888 - INFO # Fail to send: no ACK received
> loramaset ul_ctr 8
2019-07-25 15:42:29,362 - INFO #  loramac set ul_ctr 8
> loramatx hello cnf 8
2019-07-25 15:42:31,193 - INFO #  loramac tx hello cnf
2019-07-25 15:42:32,323 - INFO # Received ACK from network
2019-07-25 15:42:32,325 - INFO # Message sent with success

```
- Run the test in #11915 

### Issues/PRs references

<!--
Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
-->

Required by #11915.
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11917

-- Commit Summary --

  * pkg/semtech-loramac: add uplink_counter get/set functions

-- File Changes --

    M pkg/semtech-loramac/contrib/semtech_loramac.c (12)
    M pkg/semtech-loramac/contrib/semtech_loramac_getset.c (24)
    M pkg/semtech-loramac/include/semtech_loramac.h (16)
    M sys/shell/commands/sc_loramac.c (15)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11917.patch
https://github.com/RIOT-OS/RIOT/pull/11917.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11917
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190725/fec0a2e5/attachment.htm>


More information about the notifications mailing list