Commit graph

100 commits

Author SHA1 Message Date
Matthijs Kooijman
ba1265d5d2 Change library name to "LMIC-Arduino"
The reference to IBM in the library name is, by now, confusing. Better
start with the primary name, "LMIC" and add "Arduino" to indicate this
is an arduino-specific port.
2017-12-05 09:00:47 +01:00
Matthijs Kooijman
1e79447d82 Update url in library.properties
The original LMIC site is apparently no longer available and it is
better to point to this repository anyway.
2017-12-05 08:54:49 +01:00
Matthijs Kooijman
0b8d6feda3 Bump version to 1.5.0+arduino-2 2017-11-28 10:38:59 +01:00
Matthijs Kooijman
9eae2eb815 Fix compilation with LMIC_DEBUG_LEVEL > 1
I added a variable to assist in printing the deadline for scheduled
jobs, but then decided to leave out the variable. Apparently, I left one
use of this variable in, breaking the build. Looking at it again, it's
probably best to keep the variable, though it's now renamed to be a bit
more logical.

This fixes #114.
2017-08-30 08:47:35 +02:00
Matthijs Kooijman
87e75f6d6f Add additional debug output at level 2 2017-07-24 14:52:45 +02:00
Matthijs Kooijman
c2d591cd95 Put printf format strings in flash on AVR
This adds a lmic_printf macro that adds PSTR() around the format string
argument to put it into flash, and calls printf_P() instead of printf()
to get the format string from flash while printing. This greatly reduces
the RAM usage when LMIC_DEBUG_LEVEL is > 0 (and does not affect the
generated code otherwise).
2017-07-24 14:52:10 +02:00
Matthijs Kooijman
b2b71c2486 Remove unused room from AESKEY variable
The original LMIC AES implementation uses this variable to store
10x16 bytes of round keys, but for the other implementations (only
IDEETRON right now) this is only used to store the main key. In the
latter case, this variable only needs to be 16 bytes long, saving 160
bytes of RAM.
2017-07-24 14:30:13 +02:00
Matthijs Kooijman
6e098863f4 Emit EV_TXCOMPLETE earlier
Before, when no packet was received in RX2, there would be a 3-5 second
delay (for EU868) before calling `processDnData()` and emitting
EV_TXCOMPLETE. This was the `DNW2_SAFETY_ZONE` to prevent a subsequent
TX to collide with a downlink packet that was ongoing but not locked on
to.

With this change, `txDelay()` is used to still delay the subsequent TX,
without delaying the `EV_TXCOMPLETE` event, which allows battery-powered
devices that wait for this event before sleeping to get an extra 3-5
seconds of sleep for each transmitted packet, improving battery life.

Closes: #16
2017-07-24 14:28:31 +02:00
Matthijs Kooijman
90bc0492b6 Print downlink ack status in ttn-otaa example too
When a packet is received that has the ack flag set, print a notice
about that.
2016-08-10 09:32:55 +02:00
Matthijs Kooijman
e34a44350b Add some basic debug output 2016-08-09 23:30:18 +02:00
Matthijs Kooijman
0567e468c0 Add ttn-otaa example
This is very similar to the ttn-abp example, except that it uses OTAA
for setting up a session instead of setting it up statically.
2016-08-09 23:15:15 +02:00
Matthijs Kooijman
1ef31f567f Remove u8_t and s8_t typedefs
The ESP core uses these same typedefs, but for 8-bit values instead of
8-byte values, so this prevents compilation on the ESP core. Ideally,
all of these custom LMIC typedefs should be replaced by the standard
types, but this is a change better made upstream. For now, only u8_t
and s8_t are replaced by their standard equivalent, to make things work
on ESP.
2016-08-09 23:06:40 +02:00
Matthijs Kooijman
e9ae35136b Rename aes_encrypt to lmic_aes_encrypt
Apparently the ESP core already has a function named aes_encrypt, so
this helps to compile this library on that platform.
2016-08-09 23:06:23 +02:00
Matthijs Kooijman
57b5dc6f63 Fix compilation with USE_ORIGINAL_AES
lmic.c was using a define before including the file that defined it.
2016-08-09 22:56:00 +02:00
Matthijs Kooijman
eaa006625d Print downlink ack status in examples
When a packet is received that has the ack flag set, print a notice
about that.
2016-08-09 22:50:11 +02:00
Matthijs Kooijman
9b8898aca9 Only print the length of received data in example
Previously, the raw data was printed, but since that is likely binary
data, this just prints the length. This should be sufficient to let
people know there is data and then write proper decoding for it.
Printing in hex would be useful, but printing an array of bytes in hex
is a bit cumbersome in Arduino.
2016-08-09 22:49:56 +02:00
Matthijs Kooijman
72f0d5df7b Do not clear LMIC.pendTxConf in LMIC_startJoining()
`pendTxConf` is used to track whether the current TX data packet should
request confirmation. It is set by `LMIC_setTxData2()` and only used by
`buildDataFrame()`, so it plays no role during a join. When an automatic
join was started after queueing a confirmed uplink, clearing
`pendTxConf` causes the uplink to be send unconfirmed after the join is
complete, which does not seem like the intended behaviour.

Simply not touching `pendTxConf` in `LMIC_startJoining()` should
preserve the confirmed status properly throughout the join procedure.
2016-08-09 22:28:55 +02:00
Matthijs Kooijman
c4496ee680 Reset LMIC.txCnt after joining
During joining, LMIC.txCnt is used to keep track of retransmissions.
Normally, it is cleared in `LMIC_startJoining()` or `LMIC_setTxData()`
so it is 0 for each new packet. However, when an automatic joining
attempt is started when data is queued, txCnt would not be reset between
the join and the actual datapacket. If more than one join attempt was
needed, txCnt is non-zero and the data packet will be retried multiple
times. Since LMIC.pendTxConf is not set, the packets will not request an
ack, so the full number of retries is always used.

This is fixed by clearing txCnt after the join completes.
2016-08-09 22:28:55 +02:00
Matthijs Kooijman
099719078e Only use valid channels during joining
In 03ec06b (Reduce the default channel list), the list of join channels
was reduced. However, in `initJoinLoop()`, a random channel was selected
for the first join attempt, using a hardcoded amount of join channels,
which still had the old value.

This means that half of the join attempts would use an invalid channel,
configuring a frequency of 0Mhz into the radio, preventing the join
request from being received. Each subsequent join uses a next channel,
so after at most three join requests valid channels are used again.
Eventually a join would complete, but this bug might cause extra delays
in joining.
2016-08-09 22:28:55 +02:00
Matthijs Kooijman
3b993de018 Add example pin mapping for the LoRa Nexus board 2016-08-09 22:28:44 +02:00
Matthijs Kooijman
05f99c8191 Remove some duplicate text from the README 2016-08-09 22:28:44 +02:00
Matthijs Kooijman
0cf58e2648 Note succesful testing on the Arduino 101 2016-08-09 22:28:43 +02:00
Matthijs Kooijman
418d90272e Improve RX2 handling
This modifies the TTN example to use SF9 for the RX2 window, so RX2
should work on TTN out of the box. Also, the documentation about this is
udpated.
2016-08-09 22:28:26 +02:00
Matthijs Kooijman
e008cdfd11 Put S_Table from the Ideetron AES code in PROGMEM
This uses the macros previously created for the original AES code to put
these values in PROGMEM in a portable manner.
2016-08-09 22:27:41 +02:00
Matthijs Kooijman
c6476c9e2f Add alternative AES implementation
The original LMIC AES implementation is optimized for fast execution on
32bit processors, but it ends up taking a lot of flash space on 8-bit
AVR processors. This commit adds an alternative AES implementation
written by Ideetron, which is a lot smaller, but also about twice as
slow as the original imlementation. This new implementation is selected
by default, but the original can be used by modifying config.h.
2016-08-09 22:27:41 +02:00
Matthijs Kooijman
e98efadb70 Rename ttn example to ttn-abp
Also add some comments to make it more clear that this uses the ABP
(Activation by personalisation) variant of LoRaWAN.
2016-08-09 22:27:41 +02:00
Matthijs Kooijman
f3d9c95c3c Allow compensating for clock inaccuracy by increasing the RX windows
When using beacons and ping slots, there is already support for
measuring the actual clock drift and compensating for it. However, class
A nodes have no beacons to measure their drift, so this commit allows
them to configure the maximum clock error (e.g. +/- 1%) and increases
the receive windows to ensure that even with the worst-case clock
values, messages will be received.

Note that because the receive window is measures in symbols, with a high
drift rate and/or high datarate the resulting receive window might be
smaller than it should be. This could be slightly improved by using all
10 bits available in the hardware register (currently only 8 bits are
used).

Also note that this moves the calculation of rxsyms into schedRx12,
since the receive window length can be different between RX1 and RX2
(previously it was set only for RX1 and kept around). As a side effect,
this probably breaks FSK reception, since txDone checks rxsyms to see if
it is DR_FSK and sets the length differently. With the current code,
schedRx12 will override that rxsyms value for RX2. However, I could not
find where rxsyms is ever set to DR_FSK (and it does not seem sane to
use that variable like that), so I wonder if FSK reception will work at
all.
2016-08-09 22:27:41 +02:00
Matthijs Kooijman
08d37a1163 Fix README on timing issues
It seems I miscalculated the symbol time used in an example. Also, this
commit adds a note about the fastest datarate used in LoRaWAN
(previously only the LoRa maximum was mentioned).
2016-08-09 22:27:41 +02:00
Matthijs Kooijman
e933ce3b2f Remove some unused fields from lmic_t when DISABLE_BEACONS is defined 2016-08-09 22:27:41 +02:00
Matthijs Kooijman
d7c5f15e80 Reuse schedRx2() for RX1 as well
This reduces some code duplication, and prepares for an upcoming change
that makes the scheduling a bit more complex.

To reflect the more generic usage of this function, it is renamed to
schedRx12.
2016-08-09 22:27:09 +02:00
Oliv4945
2354716631 Process dn2Dr from joinAccept 2016-08-09 22:21:29 +02:00
Oliv4945
a951ac7076 Parse rxDelay from joinAccept
The LoraWAN spec 1R0 specifies that a value of 0 is one second
2016-08-09 22:21:29 +02:00
Oliv4945
cac94966b3 Add rxDelayvariable to prepare joinAccept parsing 2016-08-09 22:21:29 +02:00
Frank Leon Rose
124b02ba87 Fix LMIC_disableChannel for CFG_us915 2016-08-09 22:07:20 +02:00
Frank Leon Rose
05da3c3bbf Remove trailing space 2016-08-09 22:01:56 +02:00
Frank Leon Rose
6cc4e21bf5 Added functions to enable/disable/select sub-bands 2016-08-09 22:01:52 +02:00
Matthijs Kooijman
e253f917da Merge pull request #29 from things-nyc/make-regional-code-conditional
Conditionally compile regional code in examples
2016-08-09 21:47:20 +02:00
Matthijs Kooijman
99da8f468c Merge pull request #28 from robertoostenveld/master
ENH - removed extra break from switch statement
2016-08-09 21:44:27 +02:00
Frank Leon Rose
d74f8cd660 Conditionally compile regional code in examples 2016-06-27 23:29:08 -04:00
Robert Oostenveld
c01dba99c7 ENH - removed extra break from switch statement 2016-06-26 17:47:16 +02:00
Matthijs Kooijman
f19beb4bab Merge pull request #14 from Oliv4945/master
Correction of DevStatusAns
2016-04-16 21:00:16 +02:00
Oliv
194b5659b1 Correction of DevStatusAns
Battery level and margin was exchanged, see LoraWAN specification chapter 5.5
2016-04-13 22:49:27 +02:00
Matthijs Kooijman
a5c12967d7 Correct power pin documentations
This previously referred to SX1272 pins that are used as regulator
outputs, so powering those would actually be harmful. This resulted from
the fact that the SX1272 evaluation board has multiple power pins, but
it turns out these do not correspond to the SX1272 pins as I had
previously assumed.

The documentation now explicitely mentions the evaluation board pin
names, which should be more clear.
2016-03-10 13:30:41 +01:00
Matthijs Kooijman
d02e260ad8 Bump version to 1.5.0+arduino1 2016-02-23 21:50:49 +01:00
Matthijs Kooijman
1e5e572b72 Clarify when a pin is optional in the README 2016-02-23 21:46:02 +01:00
Matthijs Kooijman
4b8280d4e6 Disable printf support by default
The current implementation only works on AVR and it is no longer
actually used by the library itself, so better to disable it by default.
2016-02-23 21:44:15 +01:00
Matthijs Kooijman
c584ac5eb6 Separate failure printing from printf support
Before, enabling printf was needed for assertion failures to be printed.
However, printf support has more overhead than simply printing failures,
and the current implementation only works on AVR. Separating these
allows disabling printf support by default (in the next commit), without
also disabling failure printing.
2016-02-23 21:44:15 +01:00
Matthijs Kooijman
d72d7449d0 Uncomment DISABLE_INVERT_IQ_ON_RX
This should only be set for specific usecases, it was accidentally
defined by default, breaking downlink packets from gateways.
2016-02-20 14:31:16 +01:00
Matthijs Kooijman
c72012d967 Document config.h in README 2016-02-20 13:22:15 +01:00
Matthijs Kooijman
0df84037f4 Bump the version number to 1.5.0+arduino-0
The upstream version is 1.5, the .0 is added to comply with Arduino
semantic versioning requirements. And additional +arduino-0 version
number is added, which will be used to track changes in the
arduino-specific part of this library.
2016-02-20 12:31:28 +01:00