Commit Graph

98 Commits (dc702c2df9d7d57613c1c4371fb50a1eeb71762e)

Author SHA1 Message Date
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
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 bd9066431f LoRaWANStack unit tested 2018-09-27 11:30:52 +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
Hasnain Virk c9d6741212 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-09-21 15:55:30 +03:00
Hasnain Virk 94eb4c0bc0 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-09-21 15:55:30 +03:00
Hasnain Virk 5bfa7c03ba 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-09-21 15:55:30 +03:00
Hasnain Virk e110856941 LoRaWAN: Refactoring compliance test code
While performing compliance tests with an industry tester, we realized
that there was no need for any extra handling code for the compliance
tests. The tests would run fine, if we only have a handling application.
However, in normal operation we wouldn't like the network to send us any
traffic on compliance testing port. To mitigate that, on the reception
path we filter out any traffic on compliance testing port if compliance
testing is not underway. User should define LORAWAN_COMPLIANCE_TEST macro
in mbed_app.json to enable traffic on compliance test port.
2018-09-11 11:26:31 +03:00
Kimmo Vaisanen 6dc83dd737 Lora: Remove duplicate LinkCheckReq MAC command
When application requests link check request with add_link_check_request()
it was added to MAC command buffer. Again when actual TX was started,
stack cherry-picked the request into MAC buffer again resulting in a duplicate
entry in the buffer.

Functionality is changed now so that add_link_check_request() does not add
the request into MAC command buffer but it is cherry-picked into the buffer when
TX is issued.
2018-08-27 13:45:21 +03:00
Martin Kojtal 81f5decf8f
Merge pull request #7785 from kivaisan/fix_join_accept_failure_handling
Lora: Fix join-response failure handling
2018-08-22 14:05:24 +02:00
Cruz Monrreal 36ee9b98d6
Merge pull request #7767 from kivaisan/fix_tx_error_if_corrupter_msg_received
Lora: Fix TX_ERROR event if corrupted msg is received for CONFIRMED request
2018-08-21 10:20:23 -05:00
Cruz Monrreal 4ce0d9066e
Merge pull request #7719 from kivaisan/document_lorawan_return_values
Lora: Document all possible error codes for LoRaWANBase methods
2018-08-16 09:04:39 -05:00
Kimmo Vaisanen aa0c61b2b2 Lora: send and receive methods return LORAWAN_STATUS_NOT_INITIALIZED if not initialized
In order have a consistent return value for all methods in case of system is uninitialized
now also send and receive methods can return LORAWAN_STATUS_NOT_INITIALIZED.
2018-08-14 10:03:11 +03:00
Kimmo Vaisanen efeeb095c5 Lora: Fix join-response failure handling
Thix commit fixes a bug where stack was resending join-accept already
after RX1 if received join-response was invalid.

Stack should wait for RX2 before resending the join-accept.
2018-08-13 16:11:33 +03:00
Kimmo Vaisanen 07f4ca83f7 Lora: Fix TX_ERROR event if corrupted msg is received for CONFIRMED request
When node sends a CONFIRMED message and gateway sends ACK in RX1 window but the
message gets corrupted during the transmission (e.g. MIC fails), currently
our stack already checks for retransmission after RX1 and if retries attemps are
exhausted, TX_ERROR event is sent to application. This is wrong as MAC layer
will still attempt reception in RX2 window.

This commit fixes the behaviour so that TX_ERROR is not sent until RX2 window
has been closed.
2018-08-10 13:38:57 +03:00
Cruz Monrreal 40ff622711
Merge pull request #7601 from hasnainvirk/abp_auto_fix
LoRaWAN: Reduced priority for automatic uplinks & higher data rate usage for connection establishment
2018-08-07 09:13:45 -05:00
Cruz Monrreal 952930c23f
Merge pull request #7495 from hasnainvirk/scheduling_failure_report
LoRaWAN: Reporting scheduling failures
2018-08-02 10:10:47 -05:00
Cruz Monrreal 35fb35a3b2
Merge pull request #7661 from EnsilicaEdd/fix_lorawan_incomplete_connect
Clear CONN_IN_PROGRESS flag after incomplete connect()
2018-08-01 21:36:59 -05:00
Hasnain Virk b07c3e791f Reporting scheduling failures
It is quite possible that the user request for scheduling an uplink is deferred because of backoff or if it was a CONFIRMED message, a retry may take place on a different datarate and different channel.
We didn't have a hook for such deferred scheduling, telling the user whether the async rescheduling worked or not. This commit adds that capability and now we can tell the application if a scheduling failure took place after the original schedule request was accepted.
2018-08-01 16:28:00 +03:00
Edd Inglis 88b2858af4 An incomplete connect (either abandoned with a disconnect() or just
failed of its own accord) would prevent futher connect()'s  due to the
CONN_IN_PROGRESS_FLAG remaining set.  This change clears that flag in
the two cases described.
2018-07-31 17:01:54 +01:00
Hasnain Virk c7f3585e28 Clear distinction b/w class A & C data paths 2018-07-30 15:25:37 +03:00
Hasnain Virk 36a4c557b7 [IOTCELL-1182] User TX priority over automatic uplinks
In the case when an automatic uplink was queued and the user do have something send,
we should give priority to user data instead od automatic uplink message.
2018-07-27 15:04:31 +03:00
Kimmo Vaisanen 668c6ab6fa Lora: Fix cancel_sending
This commit fixes some bugs from cancel_sending() method:
-  System crashed if method was called before initialization.
   Now LORAWAN_STATUS_NOT_INITIALIZED will be returned.
-  Method returned LORAWAN_STATUS_BUSY error when no send request was pending.
   LORAWAN_STATUS_OK should be returned in this case.
-  LORAWAN_STATUS_BUSY is now returned if backoff timer is just about to be
   dispatched (time_left returns 0).
2018-07-27 13:30:27 +03:00
Cruz Monrreal c5ba97fbe0
Merge pull request #7445 from hasnainvirk/issue_7230
LoRaWAN: Remedy for issue #7230
2018-07-13 11:48:13 -05:00
Hasnain Virk f0844b4cfc Streamlining connect() API with posix like retcodes
For ABP: First call to connect() or connect(params) will return LORAWAN_STATUS_OK
         and a CONNECTED event will be sent. Any subsequent call will return
         LORAWAN_STATUS_ALREADY_CONNECTED (posix EISCONN) and no event is generated.

FOR OTAA: First call to connect() or connect(params) will return LORAWAN_STATUS_CONNECT_IN_PROGRESS
          and a CONNECTED event will be sent whenever the JoinAccept is received. If the application
          calls connect again before receiving the CONNECTED event, LORAWAN_STATUS_BUSY will be returned.
          After the CONNECTED event is dispatched, any subsequent call to connect() or connect(params) API
          will be returned with LORWAN_STATUS_ALREADY_CONNECTED.

No new parameters are accepted after the first call. The application must disconnect before making
a connect() call with new parameters.
2018-07-10 13:31:50 +03:00
Hasnain Virk 51f92b0efd LoRaWAN: Handling re-joining when already Joined
This is a remedy for the issue #7230.
While the device is joining, LORAWAN_STATUS_CONNECT_IN_PROGRESS is returned.
However, if the device is already joined, we will return LORAWAN_STATUS_ALREADY_CONNECTED.
2018-07-09 12:59:54 +03:00
Kimmo Vaisanen 0397b0b292 Lora: Support user provided LoRaPHY object
To support custom PHY object, a new LoRaWANInterface constructor was
added.
2018-07-06 15:11:10 +03:00
Hasnain Virk 7ce434b274 LoRaWAN: Fixing transport of fatal TX timeout event
This commit fixes the issue reported in #7285.
If the radio is unable to transmit, its a fatal error and can happen
both while joining or sending a normal packet. In the case of such
a catastrophy we ought to tell the application that this happened.

A fix for the radio driver will also be patched.
2018-06-27 11:41:30 +03:00
Hasnain Virk d335f82440 Remaining style fixes 2018-06-14 14:52:46 +03:00
Hasnain Virk ffb0698ce7 Adding port in trace & streamlining continuous RX2 2018-06-14 14:52:45 +03:00
Hasnain Virk eab2bad593 Queuing the automatic uplink
If the automatic uplink is sent directly the call-stack becomes larger than 1K
which may cause serious problems in debug builds. Just to have a respite between
RX and TX we queue an event for the automatic uplink rather than directly undergoing
an automatic uplink.
2018-06-14 14:52:38 +03:00
Hasnain Virk 828815c7e3 Adding precise timing for receive delays
RX1 and 2 delays needed to be more precise and aggregate tx time was
drifiting because of timing difference between actual tx interrupt and
our processing of that interrupt ever so slightly.

We now take a timestamp of the tx interrupt and take a time diff while
instantiating delay timers. The timestamp is then used to update the aggregate
tx time.

Two new methods are introduced in the LoRaMac class which provide current
timing and current receive slot. These functions are used by LoRaWANStack
for its processing.
2018-06-12 12:32:13 +03:00
Hasnain Virk 9ac7f21140 Style changes only
Travis astyle check pointed out some of the style mismatches in the code.
Not all of them are worth changing as they make the code unreadable and
some of them are semantically wrong.

So in this commit, we have attempted to pick the most important style
mismatches and rectify.
2018-06-01 12:41:09 +03:00
Kimmo Vaisanen d3327c3f5a Lora: All API methods should check if stack has been initialized 2018-06-01 12:29:25 +03:00
Hasnain Virk 9973eb3e79 Stability improvements & CRYPTO_ERROR addition
General stability improvements are performed.
A flag is added if a Class C RX2 window is open.
We shouldn't open it again if its already opened.

TX_CRYPTO_ERROR is renamed to CRYPTO_ERROR.
Keeping TX_CRYPTO_ERROR for backwards compatibility.
2018-05-24 15:59:07 +03:00
Hasnain Virk 0feb0efb89 Adding checks for stack initialization
Metadata APIs should return an error if the stack is not initialized yet.
2018-05-24 15:54:32 +03:00
Hasnain Virk 3020d658bf Travis astyle corrections
The scope of style corrections is local to this PR only.
2018-05-24 15:54:32 +03:00
Hasnain Virk 2bc8e4e847 Adding ack expiry handling for class C
In Class C, rx timeout does not take place for RX2 windows, so if we have
not received anything, we would be retrying but if the no. of retries are
maxed out, and we have not recieved anything yet, we need a mechanism to
tell the upper layer that this has happened.
2018-05-24 15:54:32 +03:00
Hasnain Virk b0ce443f5b Doing away with rx_abort()
rx_abort() was sort of dead code as it was doing essentially nothing.
It might have actually meddled with the state machine if it was hit by
invoking on_ack_timeout_timer_event().

State machine and corresponding processors now take care of the ack timeout,
retries and all other bits, so we don't need abort_rx().
2018-05-24 15:54:32 +03:00
Hasnain Virk 375e1b711d Adding useful trace and setting no. of retries
MCPS confirmation should be filled with the current number of retries
if the ack is not recieved for a CONFIRMED message.

Ack retry number needs to be incremented after the retry is made not before
that.

A few traces are added at the crucial junctions of the code just to tally with
the conceptual flow for debug purposes.
2018-05-24 15:54:32 +03:00
Hasnain Virk 26b28f78af Adding ability to cancel outgoing transmission
Application can use cancel_sending() API to stop any outstanding, outgoing
transmission (a TX which is not already queued for transmission). This can
potentially enable use cases where the application could cancel a transmission
and go to sleep if the backoff period is long enough rather than waiting for
the transmission to happen.
2018-05-24 15:54:32 +03:00
Hasnain Virk 8363311c7a Adding acquisition of backoff time value
This API enables the application to get hold of remaining time after which
the transmission will take place. User can query the backoff time whenever
there is a packet in the TX pipe. If the event for the backoff expiry is
already queued, the stack does not provide backoff metadata.
2018-05-24 15:54:32 +03:00
Hasnain Virk 387f56c738 Adding acquisition of RX meta data
User can now inquire about any RX meta data available after a
successful reception.
2018-05-24 15:54:32 +03:00
Hasnain Virk 555d945a42 Adding acquisition of TX Meta-data
An API is added to fetch any meta-data available after a succesful
transmission. The stack will make the meta data available after the
TX interrupt is processed. User can get the tx meta data after receiving
TX_DONE event.
2018-05-24 15:54:32 +03:00
Cruz Monrreal 863259e48b
Merge pull request #6960 from hasnainvirk/msg_flags
LoRaWAN: Message flags correction
2018-05-23 22:22:53 -05:00
Hasnain Virk 71348f7d65 Message flags correction
Uplink multicast is not allowed. Proprietary messages cannot be
of type unconfirmed and unconfirmed.
2018-05-21 16:16:58 +03:00