Commit Graph

270 Commits (4950178db5d692e26d2db844000371f2f7f90df7)

Author SHA1 Message Date
Hasnain Virk 8fd791db49 Adding TOA and Channel info in RX metadata
We provide now downlink channel frequency and time on air for the
received frame in the RX metadata.
Previously the channel information in both TX and RX metada contained
the index number of the channel. That information wasn't very useful
except the index numbers of default channels. To make more sense of the
meta data, we now store the channel frequency in the channel parameter
rather than the index number of the channel.

RX time on air is collected from the radio driver and it is assumed that
the downlink frame had 8 downlink preamble symbols (plus 4.25 of the
preambles added by the chip) for LoRa modulation.

This commit also include a bit of tidying of RX frequency storage in rx
configuration parameters storage. Previously we were missing filling in
the RX1 frequency correctly.
2019-03-27 10:23:43 +02:00
Cruz Monrreal a0a265ad84
Merge pull request #10196 from hasnainvirk/premature_rx2_fix
LoRaWAN: Fixing premature RX2 closure
2019-03-27 00:26:12 -05:00
Hasnain Virk 2691b83c4e Fixing premature RX2 abort
A bug while setting up RX start timers would result in premature closusre
of RX2 window. The 'ack_Timeout_timer' would be invoked prematurely and
at that time RX2 window may be being demodulating. This resulted in
massive instability with any test that relied on Confirmed traffic or
lower data rates.

To fix the issue, we must know the length of the RX window in
milliseconds and for this purpose we have extended the
'get_rx_window_params(...)' API. The length of the time the window
may remain open must be accounted for while setting up
'ack_timeout_timer'.
2019-03-22 15:15:51 +02:00
Hasnain Virk 2618813c70 Ack timeout must be at least 2 seconds
While calculating ack timeout, we were ending up getting a random value
which may become less than 2 seconds. This is not allowed as per v1.0.2
specification.

To fix the issue we now take the random number from 0 to 2000 ms and
then add that to the fixed 2000 ms ack timeout value, guaranteeing a
value at least equal to 2000 ms.
2019-03-22 15:15:51 +02:00
itziar 4c1fedd72a Applied suggested astyle fix(es) 2019-03-19 10:11:15 +01:00
itziar 5beef7405c Bug related to downlink sequence counter rollover 2019-03-19 10:11:14 +01:00
Martin Kojtal d030c04a60
Merge pull request #9219 from hasnainvirk/lorawanbase_migration
LoRaWAN: Retiring LoRaWANBase class
2019-02-21 13:55:11 +01:00
Ron Eldor c94b5861e4 Add mbedtls platform setup and teardown to modules
Add calls to `mbedtls_platform_setup()`
and `mbedtls_platform_teardown()` to all modules and tests using Mbed TLS.
2019-02-18 11:43:32 +02:00
Hasnain Virk 726eff9305 Proper size checking for link ADR commands
In a specific branch path 'adr_settings' in link_adr_request() API, the
structure adr_settings of type link_adr_params_t will be rendered
uninitialized. To prevent this we initialize the construct as zero.
In addition to that, to handle the case properly we should check for the
command identifier and the command payload length anticipating contiguous
blocks of adr commands. If we find a discrepency in size, we should
abort.
2019-02-14 17:15:42 +02:00
Martin Kojtal 51a8c39088
Merge pull request #9245 from kjbracey-arm/lorawan_atomic_flag
LoRAWAN: volatile bool -> atomic_flag
2019-01-16 09:31:29 +01:00
Kevin Bracey 6f757a5824 LoRAWAN: volatile bool -> atomic_flag
Now we have a proper atomic flag API, use it rather than a volatile
cheat.
2019-01-14 11:59:25 +02:00
Cruz Monrreal fd04d25e52 Fixed single space that astyle caught 2019-01-11 11:31:42 +02:00
Mel W 701bb055a2 Writer review
Grammatical changes, passive -> active in some places, and future -> present.
2019-01-11 11:31:22 +02:00
Hasnain Virk 8ed521e7ed Doxygen update for LoRaRadio class
Added more documentation to the data structures and corrected the
inclusion of this class to the correct class hierarchy.
2019-01-11 11:29:57 +02:00
Hasnain Virk 5fb383c27a Doxygen corrections
Adding group identidier so that LoRaWANInterface class goes to the class
hierarchy section rather than data-structures.

Adding missing documentation for a couple of public functions.

Adding \code and \endcode modifiers for the example code in the
documentation.

Adding compile time NO_DOXYGEN flag for the implementations of the
LoRaPHY Class.

Adding documentation for some of the private structures.
2019-01-10 16:14:19 +02:00
Hasnain Virk 2b95fd3e3a Removing virtual modifier from LoRaWANInterface
Doing away with virtual modifier from LoRaWANInterface, gets rid of
vtable for LoRaWANInterface.
2019-01-10 16:14:19 +02:00
Hasnain Virk ef1baa3c8b Deprecation notice for LoRaWANBase
A deprecation notice has been added for any users of LoRaWANBase and any
existing reference is redirected to LoRaWANInterface.
2019-01-10 16:14:18 +02:00
Hasnain Virk b9b414a690 Retiring LoRaWANBase class
It was decided within the team to retire LoRaWANBase class which served
as a pure virtual interface class from which LoRaWAN network stack
implementations would get inherited. However, the current view is that
we may be the only user of it so we could retire LoRaWANBase.
2019-01-10 16:14:18 +02:00
Hasnain Virk c07ae669ff Randomizing backoff for Join process
Randomizing backoff by 200ms to 1000ms for Join Requests in a dense
network will add robustness and better chances of reception by the base
station especially in cases of catastrophic network outage and
reconnection.
2019-01-04 02:10:50 +02:00
Hasnain Virk e1e48b492b Final cleanup and ASCII art for algorithm v2
Final code cleanup and adding ascii art for the version 2 of the
algorithm.
2018-12-10 08:53:30 +02:00
Hasnain Virk 5170daa00a RX window calculation algorithm version 2
In this version we try to mitigate a situation when we start listening
right in the middle of a preamble sequence (e.g., in high SF case).
2018-12-10 08:53:30 +02:00
Hasnain Virk 3ec643f06a Style alignment
Minor style alignment.
2018-12-10 08:53:30 +02:00
Hasnain Virk 88490fb145 Mitigating reception problems with lower data rates
A new algorithm has been taken in use to calculate the receive window
length and the timing offset involved in opening of the said receive
window. This algorithm performs better than the stock algorthm and
consumes less power.
2018-12-10 08:53:30 +02:00
Hasnain Virk f4077af5b1 UL FCnt increment in case of retry exhaustion
Previously we had been incrementing UL frame counter for a CONFIRMED
message only when the transmission was deemed successful i.e., we would
have received an ack before all the retries would have exhausted.
Now we have opted to increment the frame counter if all the retries are
exhausted considering the fact that we essentially treat the next
message after retry exhaustion as a new packet so we should also
increment the frame counter.
2018-12-10 08:53:30 +02:00
Antti Kauppila cf53494f2e Compliance test errors fixed 2018-11-14 09:46:38 +02:00
Martin Kojtal 884a7748b2 lorawan: fix astyle coding style 2018-11-07 08:56:36 +00:00
Martin Kojtal 5c79ba5189 lorawan: fix coding style 2018-11-07 08:56:32 +00:00
Antti Kauppila f0864be1c5 Fixed lorawan unittests valgrind issues 2018-10-17 15:25:53 +03:00
Hasnain Virk 0a9417299b Fixing coverity findings
A couple of the coverity analysis findings are being treated here. For
the rest there will be a separate PR.
2018-10-16 12:23:21 +03:00
Hasnain Virk 7818733728 Proper handling of RX1 frequency in rx_config
Previously, we weren't filling in RX1 frequecny in rx_window1_config
structure. However, everything worked as in LoRaPHY::rx_config() API
there was a check which filled in correct RX1 frequency.
Now we are filling in RX1 freq. properly while we are computing
parameters for RX1 window.
2018-10-16 12:23:21 +03:00
Hasnain Virk 9e4487c850 TX post-process for CONFIRMED UL in no-reception case
The idea behind the method post_process_no_reception() is to post
process any outgoing TX but we shouldn't do that if a CONFIRMED message
is outgoing and there are still some retries left.
2018-10-16 12:23:21 +03:00
Hasnain Virk 8d4cda11f7 Making sure that RX slots open after state change
After transmission we should change the state before invoking opening of
slots as we may start receiving in the rx slots and the state would
suddenly change from SENDING to RECEIVING without going through the
ACK_WAIT state (in case of CONFIRMED messages). Tests show that after
this slight adjustment, our number of ack retries have significantly
reduced.
2018-10-16 12:23:21 +03:00
Hasnain Virk d5ce0cc96f Adding QOS handling and fixing bugs for Class C
LinkADRReq mac command can be used by the network server to set a
certain level of QOS using NbTrans field which is applicable to
Unconfirmed traffic only for 1.0.2 spec.
This commit introduces mechanisms to facilitate this QOS. It means to
repeat an outgoing unconfirmed message NbTrans times without changing
its frame counter.

For class C, we have retired the ack_expiry_timer_for_class_c and have
replaced it with another timer which mimics the RX2 closure as in Class
A but doesn't actually close RX2 window. It's just a mechanism by which
the state machine is informed that the you can proceed forward, we have
not received anything in RX2 window either. This is needed as RX2
doesn't timeout in class C (i.e., the radio remains in continuous mode).
In addition to that we need to close any pending timers for Receive
windows after the MIC has passed and the Duplicate counter check has
also been passed.
2018-10-16 12:23:21 +03:00
Hasnain Virk dc702c2df9 Adding check for ongoing automatic-uplink
Before going after an automatic uplink, we should check if there was an
automatic uplink already ongoing, i.e., the ack for the previous
automatic uplink cycle has not been received.
If there is we shouldn't queue the new automatic uplink and wait for
the previous Ack cycle to complete.
2018-10-16 12:23:21 +03:00
Hasnain Virk 1fa2589c1e Style correction
LinkADRReq parameters and certain parameters used camel case
which is not the recommended style.
2018-10-16 12:23:21 +03:00
Cruz Monrreal b666cd68dc
Merge pull request #8299 from hasnainvirk/issue_8285
Making cancel_sending() API robust
2018-10-15 10:12:27 -05:00
Cruz Monrreal II dd8e9bb954 Revert "Merge pull request #8183 from hasnainvirk/QOS_impl"
This reverts commit 5c675d3688, reversing
changes made to 2b04a02eb2.
2018-10-11 16:51:46 -05:00
Cruz Monrreal 5c675d3688
Merge pull request #8183 from hasnainvirk/QOS_impl
Adding QOS in response to LinkADRReq and fixing class C bugs
2018-10-11 10:09:37 -05:00
Hasnain Virk 603ee28098 Making cancel_sending() API robust
If the packet is already handed over to the PHY layer, we shouldn't be
able to cancel that particular transmission. In addition to that if the
backoff timer is either not applied or has been deactivated, should end
up in no-op rather than having normal termination. A new error code has
been introduced to cover no-op cases. This error code replaces the
compliance test related error code which is no longer relevant.
clear_tx_pipe() does nothing if:
	- The stack cannot cancel TX (already handed over to PHY)
        - The backoff timer is not active at all
        - The event is disaptched to schedule

stop_sending() will only post process ongoin TX if the pipe was
definitely cleared.
2018-10-02 14:07:52 +03:00
Antti Kauppila a54c271814 cmake Paths corrected 2018-09-27 11:30:52 +03:00
Antti Kauppila f6ecb319d0 LoRaMac unittested 2018-09-27 11:30:52 +03:00
Antti Kauppila bd9066431f LoRaWANStack unit tested 2018-09-27 11:30:52 +03:00
Antti Kauppila e07940d5e7 LoRaMacCrypto unittested 2018-09-27 10:49:07 +03:00
Antti Kauppila f3d402f70e LoRaPHY unittested, small fixed done during tests 2018-09-27 10:49:07 +03:00
Antti Kauppila 0f8cfd8631 LoRa regions unittested, stubs licences revisited 2018-09-27 10:49:07 +03:00
Antti Kauppila 0f83f08043 More lorawan unit tests added 2018-09-27 10:49:07 +03:00
Martin Kojtal a999289365
Merge pull request #8034 from EnsilicaEdd/snr_unsigned_signed
Changed the reported SNR from unsigned to signed.
2018-09-25 13:23:14 +02:00
Hasnain Virk bc976c6545 Fixing coverity findings
A couple of the coverity analysis findings are being treated here. For
the rest there will be a separate PR.
2018-09-21 15:55:30 +03:00
Hasnain Virk 0d3ec26b4a Proper handling of RX1 frequency in rx_config
Previously, we weren't filling in RX1 frequecny in rx_window1_config
structure. However, everything worked as in LoRaPHY::rx_config() API
there was a check which filled in correct RX1 frequency.
Now we are filling in RX1 freq. properly while we are computing
parameters for RX1 window.
2018-09-21 15:55:30 +03:00
Hasnain Virk 19e87ceab9 TX post-process for CONFIRMED UL in no-reception case
The idea behind the method post_process_no_reception() is to post
process any outgoing TX but we shouldn't do that if a CONFIRMED message
is outgoing and there are still some retries left.
2018-09-21 15:55:30 +03:00