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

Merge Lacuna Basic MAC #11

Draft
wants to merge 141 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
5556c1d
Arduino: Add Arduino-specific files
matthijskooijman Nov 15, 2016
c722c99
Arduino: Make export script work on OSX
matthijskooijman Nov 30, 2016
5d96aaa
Arduino: Optionally remove existing directory when exporting
matthijskooijman Nov 30, 2016
3b8bc60
Arduino: Simplify examples
matthijskooijman Dec 7, 2016
3ccfb5b
Arduino: Adapt Arduino code to basicmac
matthijskooijman May 23, 2019
1505722
Arduino: Update examples for BasicMAC
matthijskooijman Feb 12, 2020
d747876
Move DECL_ON_LMIC_EVENT from lmic.c to lmic.h
matthijskooijman May 23, 2019
dc99921
Fix AES encryption on 16-bit platforms
matthijskooijman Nov 11, 2015
81de5e1
Fix os_rlsbf4() and os_rmsbf4() when int is smaller than 32 bits
matthijskooijman Feb 17, 2016
a0d1a61
Add alternative AES implementation
matthijskooijman Jun 10, 2016
88c1220
Allow disabling class B suport
matthijskooijman Feb 4, 2016
edd6924
Add extern "C" blocks around header files when using C++
matthijskooijman Feb 12, 2020
48388d5
Fix compilation for SX1272
matthijskooijman May 23, 2019
aa24fc4
Let printf %F accept s4_t instead of int
matthijskooijman May 24, 2019
d07233f
Let debug_printf accept long modifier (e.g. %ld)
matthijskooijman Apr 15, 2020
fde3108
Allow printing timestamps in raw ticks
matthijskooijman Apr 15, 2020
7a60a5d
Prepend all debug prints with a timestamp
matthijskooijman May 27, 2019
cfee5b8
Use %ld for printing 32-bit values
matthijskooijman Apr 15, 2020
e8348c9
Add more debug output
matthijskooijman Aug 8, 2016
8402e34
Add more verbose debug output
matthijskooijman Jun 27, 2017
8230d35
Support boards without reset connected
matthijskooijman May 27, 2019
703cdd4
Arduino: Wait for serial on startup
matthijskooijman Feb 12, 2020
2570d6b
Arduino: Use 115200 for serial in otaa example
matthijskooijman Feb 12, 2020
5dacd66
Sx126x: Enable DIO3 als TCXO control
matthijskooijman Oct 31, 2019
935d460
Sx126x: Remove unneeded cast
matthijskooijman Oct 31, 2019
7f02397
Arduino: Support SX126x pin configuration
matthijskooijman Oct 31, 2019
20afaf1
Arduino: Support BUSY pin for SX126x
matthijskooijman Oct 31, 2019
d27018c
Arduino: Do not disable IRQs on hal_failed
matthijskooijman Oct 31, 2019
5011e02
Arduino: Use random nonces (HACK)
matthijskooijman Oct 31, 2019
dc7428c
Sx126x: Print warnings before disabling IRQs
matthijskooijman Jan 15, 2020
bd39b0a
Scheduling: Do not print with interrupts disabled
matthijskooijman Jan 15, 2020
e1c2bc5
Arduino: Make libc printf work on non-AVR too
matthijskooijman Jan 15, 2020
1aa3edb
Schedule RX/TX timeout after starting RX/TX
matthijskooijman Jan 15, 2020
931d301
Arduino: Support separate RX and TX enable pins
matthijskooijman Feb 12, 2020
32114b3
Enable interrupts on assertion failure
matthijskooijman Feb 12, 2020
f8bee92
Arduino: Support controlling a TCXO pin
matthijskooijman Feb 12, 2020
9a323b6
Arduino: Add pinout for some standard boards
matthijskooijman Feb 12, 2020
781f2f5
SX127x: Remove useless part from debug print
matthijskooijman Feb 12, 2020
02d4a31
Arduino: Fix NSS initialization
matthijskooijman Feb 12, 2020
f3841c0
Arduino: Remove raw.ino example
matthijskooijman Feb 12, 2020
ffec276
Fix some signed vs unsigned comparisons
matthijskooijman Mar 26, 2020
245c43e
Mark unused functions unused
matthijskooijman Mar 26, 2020
f74ec70
Fix undefined casting in GetRandom
matthijskooijman Mar 26, 2020
52b5642
Arduino: Fix unused parameter warnings
matthijskooijman Mar 26, 2020
d03014f
Fix unused parameter warnings
matthijskooijman Mar 26, 2020
75f527c
Fix for aes_encrypt() conflict with built-in function on ESP8266 and …
lyusupov Mar 16, 2020
eb3621a
Add some debug prints related to channel config
matthijskooijman Mar 5, 2020
f4d97a4
README: Add some info about current status
matthijskooijman Feb 12, 2020
b19dce4
Merge tag 'v2.2'
matthijskooijman Apr 16, 2020
cfca8e9
Rename min/max macros to os_min/os_max
matthijskooijman Apr 16, 2020
b83bb94
Sx126x: Fix compilation failure due to radio_cw rename
matthijskooijman Apr 16, 2020
503dd9f
Replace all tabs by spaces
matthijskooijman Apr 16, 2020
42efdda
Arduino: Update library.properties
matthijskooijman Apr 16, 2020
cedc925
Bump version to 2.2.1
matthijskooijman Apr 16, 2020
4c399a2
README: Fix typo
matthijskooijman Apr 16, 2020
d8c82e8
Arduino: Show how to enable sx126x radio support
matthijskooijman May 5, 2020
63023a0
Arduino: Rename top-level include to basicmac.h
matthijskooijman May 4, 2020
3305d8e
Arduino: Rename examples to basicmac-abp/otaa
matthijskooijman May 4, 2020
e2841f7
Arduino: Fix FSK channel in basicmac-abp example
matthijskooijman May 5, 2020
2fe8715
Arduino: Remove extra comma from debug output
matthijskooijman May 22, 2020
cf7bf9c
Arduino: Enable DEBUG_TX/RX by default
matthijskooijman May 26, 2020
b789d1d
Arduino: Wait for join to complete in basicmac-otaa example
matthijskooijman May 22, 2020
fa4ef16
Arduino: Fix printing of downlink data size
matthijskooijman May 26, 2020
b9e74a6
Arduino: Add empty lines around "Starting" message
matthijskooijman May 26, 2020
c4977f2
Introduce isFsk and isLora helper functions
matthijskooijman May 21, 2020
e328468
Remove some assumptions on constant values
matthijskooijman May 21, 2020
897766d
debug: Add some prints for exceptional TX situations
matthijskooijman Apr 16, 2020
c7a5db2
debug: Remove duplicate entry for EV_ADR_BACKOFF
matthijskooijman May 5, 2020
599b61e
debug: Simplify RX debug messages
matthijskooijman May 21, 2020
5335f99
debug: Fix message about next join
matthijskooijman May 21, 2020
a60e701
debug: Simplify bandwidth in RX prints
matthijskooijman May 21, 2020
eaabb27
debug: Include CR, nocrc and IH in TX/RX_MODE prints
matthijskooijman May 21, 2020
c7f4ff0
debug: Split TX/RX prints by modulation
matthijskooijman May 21, 2020
77307ef
debug: add [verbose_]debug_printf_continue macros
matthijskooijman May 21, 2020
b71a8dd
debug: Print frame counter as unsigned
matthijskooijman May 21, 2020
389cbd3
debug: Handle a zero framecounter properly
matthijskooijman May 21, 2020
b9d13d8
debug: Add DEBUG_JOBS macro
matthijskooijman May 22, 2020
a509eba
Expose LMIC_disableDC always
matthijskooijman May 5, 2020
0f54546
Remove EV_SHUTDOWN constant
matthijskooijman May 5, 2020
3ecfc59
Fix unused osjob parameter warnings
matthijskooijman May 5, 2020
f9d00f4
Remove forward declaration of startScan
matthijskooijman May 5, 2020
8c2316c
Make rx1DrOff signed
matthijskooijman May 5, 2020
3d7a5e7
Fix potential infinite loop in rps2dndr
matthijskooijman May 5, 2020
bb2462d
Fix some more warnings
matthijskooijman May 5, 2020
9632795
Change LMIC.errcr to cr_t
matthijskooijman May 5, 2020
f24e397
Add LMIC_STATIC_ASSERT macro
matthijskooijman May 21, 2020
2cc01a3
Fix warning in assert
matthijskooijman May 21, 2020
420e915
Remove sameSfBw function
matthijskooijman May 5, 2020
d189edc
Make RPS-building more clear
matthijskooijman May 5, 2020
0a09a6f
Replace decDR with lowerDR
matthijskooijman May 20, 2020
68b8206
dr2hsym: Use updr2rps instead of accessing REGION directly
matthijskooijman May 21, 2020
9ca1ec4
Calculate LMIC.dndr earlier
matthijskooijman May 21, 2020
3010a4e
Report EV_TXDONE slightly later for data packets
matthijskooijman May 22, 2020
42456b1
Support custom datarates
matthijskooijman May 21, 2020
a4fd7d0
Add LMIC_selectChannel to manually choose channel
matthijskooijman May 25, 2020
4edad96
Include TX_RAMPUP in channel selection
matthijskooijman May 26, 2020
7caf7dc
sx126x: Fix random write in GetRandom
matthijskooijman May 26, 2020
a493acb
Arduino: Fix comment
matthijskooijman Jun 12, 2020
cc25499
sx126x: Factor out regulator and DIO setup
matthijskooijman Jun 17, 2020
a42d65c
AU915: DR6 = SF8BW500
reissjason May 4, 2019
20b58e2
Fix typo in constant name (#14)
pe1mew Jul 5, 2020
2f72bc9
debug: Rename itoa to prevent conflicts
matthijskooijman Jul 3, 2020
934a8ad
arduino: Make basicmac-abp example compile for US915
matthijskooijman Jul 4, 2020
8d73349
github: Autocompile Arduino examples
matthijskooijman Jul 3, 2020
3b5bcdd
Fix warnings on 16-bit architectures
matthijskooijman Jul 4, 2020
277571d
Fix warnings
matthijskooijman Jul 4, 2020
12e6dd5
Work around double definition of REGION
matthijskooijman Jul 4, 2020
3e21aa3
aes-ideetron: Remove unused declaration
matthijskooijman Jul 4, 2020
d49f97c
github: Compile examples with -Werror
matthijskooijman Jul 4, 2020
f6757c1
radio: Use ASSERT, not assert
matthijskooijman Jul 5, 2020
52c849c
basicloader: Update submodule URL
matthijskooijman Jul 5, 2020
1c826fa
basicloader: Update to correct version
matthijskooijman Jul 5, 2020
aa4e3dc
stm32: Fix const-related warning
matthijskooijman Jul 6, 2020
6e52925
projects: Compile with -Werror
matthijskooijman Jul 5, 2020
a374aaa
github: Autocompile projects
matthijskooijman Jul 5, 2020
15fc2d1
arduino: Default to using the SX1262
matthijskooijman Jul 14, 2020
4197982
hal: Define hal_pin_tcxo only for sx127x
matthijskooijman Jul 14, 2020
587776f
sx126x: No longer use DIO3 as TCXO control by default
matthijskooijman Jul 14, 2020
abd286a
github: Compile examples for SX1261 too
matthijskooijman Jul 15, 2020
7bd00ca
arduino: Improve pin checks
matthijskooijman Jul 15, 2020
c94c2cc
arduino: Fix running with busy = LMIC_UNUSED_PIN
matthijskooijman Jul 15, 2020
3e09a97
hal: No longer use DIO2 to control RXTX by default
matthijskooijman Jul 15, 2020
8f38325
Merge pull request #17 from LacunaSpace/dio3-tcxo-optional
matthijskooijman Jul 15, 2020
23e33fd
arduino: Add some more links and comments to standard-pinmaps
matthijskooijman Jul 15, 2020
5eb2d76
arduino: Add ARDUINO_TTGO_LoRa32_V1 board pinout
wlgrw Jul 8, 2020
85a7a81
github: Compile arduino examples for ESP32 too
matthijskooijman Jul 15, 2020
19e2962
arduino: Show how to select SX1261
matthijskooijman Jul 15, 2020
fdb1f6f
arduino: Improve region handling
matthijskooijman Jul 15, 2020
b704b72
arduino: Fix TXRX-related comment in basicmac-otaa
matthijskooijman Jul 15, 2020
35a3f65
EU868: Add new h0 band
matthijskooijman Jul 15, 2020
22731d9
TTGO T-Beam pinmap
lyusupov Jul 8, 2020
32933af
Merge pull request #15 from lyusupov/T_BEAM
matthijskooijman Oct 10, 2020
2c0764d
arduino: Remove hw.h content
matthijskooijman Nov 1, 2020
68f76e5
arduino: Change license to BSD
matthijskooijman Nov 1, 2020
b506988
Fix link in README
matthijskooijman Nov 2, 2020
04035d8
arduino: Fix typo in (disabled) config macro
matthijskooijman Nov 3, 2020
f67f43f
sx126x: Fix GetRandom
matthijskooijman Nov 3, 2020
cfb7f3d
sx126x: Use random generator for random seed
matthijskooijman Nov 3, 2020
3e92fb1
github: Use standard version of arduino-test-compile
matthijskooijman Nov 6, 2020
001a3aa
github: Create and store Arduino library
matthijskooijman Nov 26, 2020
ddd274e
Merge remote-tracking branch 'origin/master' into lacuna-master-merge
mkuyper Dec 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/compile-arduino-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Compile Arduino examples
on: [push, pull_request]
jobs:
build:
name: ${{ matrix.board }} / ${{ matrix.region }} / ${{ matrix.transceiver }}
runs-on: ubuntu-latest
env:
PLATFORM_DEFAULT_URL: https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://dl.espressif.com/dl/package_esp32_index.json,https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,https://lacunaspace.github.io/arduino-STM32L4-Lacuna/package_STM32L4_Lacuna_boards_index.json
strategy:
matrix:
board:
- arduino:avr:mega
- arduino:samd:arduino_zero_edbg
- esp8266:esp8266:generic
- esp32:esp32:ttgo-lora32-v1
- lacunaspace:stm32l4:Lacuna-LS200
# Just a random STM32 board
- STM32:stm32:Nucleo_64:pnum=NUCLEO_F401RE
region:
- CFG_eu868
- CFG_us915
transceiver:
- BRD_sx1272_radio
- BRD_sx1276_radio
- BRD_sx1261_radio
- BRD_sx1262_radio
include:
# Older compilers (used by STM32 and ESP) seem to get confused
# by the REGION initializers and produce (seemingly unfixable)
# missing-field-initializers warnings. So just ignore these
# for these boards.
- board: esp8266:esp8266:generic
extra_flags: -Wno-error=missing-field-initializers
# The STM32 cores have unused-parameter warnings in the core,
# so these (this also ignores the same warnings in the sketch
# and library, which is not ideal, but this seems to be the
# only way to fix this).
- board: lacunaspace:stm32l4:Lacuna-LS200
extra_flags: -Wno-error=unused-parameter -Wno-error=missing-field-initializers
- board: STM32:stm32:Nucleo_64:pnum=NUCLEO_F401RE
extra_flags: -Wno-error=unused-parameter -Wno-error=missing-field-initializers

# Run the entire matrix, even if one failed
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Generate Arduino library
# Generate twice, once to be moved into the Arduino directory and
# once to compile the examples from
run: |
./target/arduino/export.sh BasicMacCustom
./target/arduino/export.sh BasicMacArduino

- name: Compile all examples
uses: ArminJo/arduino-test-compile@v3
with:
arduino-board-fqbn: ${{ matrix.board }}
platform-default-url: ${{ env.PLATFORM_DEFAULT_URL }}
sketch-names-find-start: ./BasicMacArduino/examples/
# Normally, all .ino files are treated as separate sketches, but
# this is just a secondary .ino file that does not need to be
# separately compiled.
sketches-exclude: standard-pinmaps
build-properties: >
{"All": "
-DBASICMAC_DUMMY_PINMAP
-D${{matrix.region}}
-D${{matrix.transceiver}}
-Werror
${{matrix.extra_flags}}
"}
42 changes: 42 additions & 0 deletions .github/workflows/compile-projects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Compile projects
on: [push, pull_request]
jobs:
build:
name: ${{matrix.target}}
runs-on: ubuntu-latest
strategy:
matrix:
target:
# List taken from ex-join project, there might be more valid
# combinations.
- b_l072z_lrwan1
- nucleo_l073rz-sx1276mb1las
- nucleo_l073rz-sx1272mbed
- nucleo_l073rz-sx1276mb1mas
- nucleo_l053r8-sx1276mb1las
- nucleo_l053r8-sx1261mbed
- nucleo_l053r8-sx1262mbed

# Run the entire matrix, even if one failed
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Install compiler
run: sudo apt install gcc-arm-none-eabi

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax

- name: Install python packages
run: python -m pip install lz4 pycryptodome click intelhex pyyaml

- name: Compile project
run: |
make -C projects/ex-join TARGET="${{matrix.target}}" || exit 1
21 changes: 21 additions & 0 deletions .github/workflows/create-arduino-lib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Create Arduino Library
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Generate Arduino library
run: |
# Create two directory levels, so the inner one ends up in the
# generated zip
mkdir ArduinoLibrary
./target/arduino/export.sh ArduinoLibrary/Basicmac

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ArduinoLibrary
path: ArduinoLibrary
142 changes: 141 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Basic MAC
# BasicMAC

[Basic MAC](https://basicmac.io) is a portable implementation of the LoRa
Alliance®'s LoRaWAN® specification in the C programming language. It is a fork
Expand All @@ -13,3 +13,143 @@ Branch | Travis CI
#### Getting Started

View the [Getting Started Guide](https://basicmac.io/guide/gettingstarted.html).


## This repository
This repository contains an Arduino port of the BasicMAC library.
However, the port is done without changing the structure of the
repository itself, so development can continue on other targets at the
same time.

### Development status

This master branch should be working, testing and contributions are
welcome. There are still some rough edges, so this should not be
considered a finished version. The final 2.2 release by Semtech was only
recently integrated and has seen limited testing.

Initially, development of this repository has been quite unstable, with
lots of history editing and rebasing, but the intention is to keep the
master branch stable now (i.e. no force pushes). Rebasing and history
editing might still happen in other branches and is encourage in
pullrequests to keep history clean.

The API is still likely to change in a breaking way, especially wrt
configuration.

### Notable and breaking changes

This section lists notable changes, in particular those that can break
existing sketches. For full details, see the git changelog.

- 2020-07-14: On Arduino, the default config is changed to SX1262. If
your board uses SX1276 (the old default), you need to modify
`target-config.h` in the library.

- 2020-07-14: On SX126x, DIO3 is no longer configured to control a TCXO
by default. If your board needs this, it must be explicitly enabled.
On Arduino, set the `tcxo` field of the pin map to
`LMIC_CONTROLLED_BY_DIO3`. With Makefile-based stm32, define
`LMIC_DIO3_CONTROLS_TCXO` on the compiler commandline.

- 2020-07-14: On SX126x, DIO2 is no longer configured to control a TXRX
antenna switch by default. If your board needs this (most likely it
does), it must be explicitly enabled. On Arduino, set the `tx`
field of the pin map to `LMIC_CONTROLLED_BY_DIO2`. With
Makefile-based stm32, define `LMIC_DIO2_CONTROLS_TXRX` on the
compiler commandline.

### Relation to other projects

BasicMAC is a privately developed fork of LMIC, which was released
publically by Semtech in 2019. In 2020, Semtech has announced it no
longer intends to develop or support BasicMAC, so this repository is
intended to become the primary repository for BasicMAC.

This repository borrows heavily from the Arduino LMIC port that was
first published at https://github.com/matthijskooijman/arduino-lmic/.
There are some other LMIC versions (notably
https://github.com/mcci-catena/arduino-lmic) for Arduino based off
matthijskooijman's version and have seen more development, but no effort
has been made to incorporate any changes from there.

Ideally, all of these LMIC and BasicMAC-based projects would unify their
efforts in a repository that is not Arduino-specific, but given that
there have been signficant changes in both BasicMAC and the MCCI
versions compared to the original IBM LMIC version, this might be a
challenge (both technically, and project-wise).

### Using this repository on Arduino

This repository is not directly usable as an Arduino library, in order
to keep the directory structure more generic. To use it in Arduino,
there is a bash script that generates an Arduino library out of it. To do so,
make a git checkout of this repository and from the root of it, run:

./target/arduino/export.sh --link ~/Arduino/libraries/BasicMAC

The `--link` parameter makes the script generate symlinks into the
original repository, allowing you to make changes to the library there
and have them reflected in the Arduino version directly. If you omit
`--link`, copies will be made instead.

The directory name passed is created and becomes the library directory,
it should be in your Arduino sketchbook's `libraries` directly (the path
shown should work with the default Arduino IDE configuration).

This script was tested on Linux, should work on OSX as well, might work
on Windows (if you have bash).

### Using this repository without Arduino

To build and upload without Arduino, a makefile-based build system is
present in the `projects` subdirectory. It currently only supports
STM32, on some specific boards.

To use it, go into the example project directory (`projects/ex-join`)
and run `make`.

Some effort has been made to keep these builds working, but actual
testing of the code in this repository has only been done under Arduino
(Makefile-based builds are only automatically compile-tested), so the
Makefile-based builds might very well be broken.

### Hardware support

This port is intended to work on any Arduino board, regardless of
architecture. It was tested on AVR, SAMD and STM32 boards, and with
SX1272, SX1276 and SX1262 radios.

Unfortunately, BasicMAC is quite a bit bigger than LMIC, so it seems it
does not fit in an atmega328p anymore. PROGMEM optimizations have not
been applied yet, but those would only free up RAM, not flash (and now
the ttn-otaa example compiles down to 35k of flash, with only 32k
available).

So far, only EU868 has been tested. Other regions are supported, but are
not currently tested.

### Converting from LMIC

BasicMAC is based on LMIC and largely works in the same way. Sketches
can likely be largely reused, though some small changes need to be made.
See for example [this commit][migrate-examples] for the changes needed to the examples.

Additionally the pinmap was significantly changed, so look at one of the
current examples to see how that looks now.

[migrate-examples]: https://github.com/LacunaSpace/basicmac/commit/1505722c912c8cb0cfff2e18b115f9f2c1a62d0f
=======
[Basic MAC](https://basicmac.io) is a portable implementation of the LoRa
Alliance®'s LoRaWAN® specification in the C programming language. It is a fork
of IBM's LMiC library, and supports multiple regions, which are selectable at
compile and/or run time. It can handle Class A, Class B, and Class C devices.

#### Status
Branch | Travis CI
-------|----------
[`master`](https://github.com/mkuyper/basicmac/tree/master) | [![Build Status](https://travis-ci.com/mkuyper/basicmac.svg?branch=master)](https://travis-ci.com/mkuyper/basicmac)

#### Getting Started

View the [Getting Started Guide](https://basicmac.io/guide/gettingstarted.html).
Loading