This sketch is aimed at The Things Network, but it should work for other
networks as well. It employs personalization, over-the-air activation
has not been tested yet.
This:
- Removes support for the Pinoccio Scout RGB led and just uses a single
led (using LED_BUILTIN) on all boards.
- Fixes some indentation.
- Uses a constant for the TX interval, and increases it to comply with
the duty cycle limits.
- Uses more explicit radio settings, instead of referring to the "ping"
settings defined by LMIC.
- Uses os_runloop_once() instead of os_runloop(), so the example can be
more easily modified to do other things in addition to radio RX and
TX.
- Shows how to use LMIC_UNUSED_PIN for unused pins.
This should decrease the likelyhood of a naming conflict, and making it
const might help the compiler optimize.
In the future, configuring pins might change to use some initialization
function to pass the pin mapping, but for now this approach seems simple
and efficient.
By uncommenting a maco in config.h, this inversion is enabled, and
communication between nodes can be enabled. This should be used just for
debugging, though.
By setting some more parameters (frequency, txpower), RX and TX now work
properly. Whenever a packet is received, reception is now restarted.
It now also updates leds to indicate reception status. The led is red (on
Pinoccio, or off for normal Arduino boards) when no packet was received
in 2500ms, green (or off) when there was. Whenever a packet is received, the LED
very briefly blinks to indicate this.
Packets are sent about once every second. When a packet is received, the
next TX is rescheduled to prevent TX collisions (in a very basic way).