Commit Graph

270 Commits (4950178db5d692e26d2db844000371f2f7f90df7)

Author SHA1 Message Date
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 76814d4847 Style correction
LinkADRReq parameters and certain parameters used camel case
which is not the recommended style.
2018-09-21 15:55:30 +03:00
Martin Kojtal 0c8aa2823d
Merge pull request #8096 from kivaisan/fix_mac_command_retransmission
Lora: Fix sticky MAC command retransmissions
2018-09-21 09:47:47 +02:00
Cruz Monrreal 9346a7e781
Merge pull request #7935 from kivaisan/fix_invalid_mac_command_case
LoRa: Stop processing MAC commands if command id is unknown
2018-09-20 10:14:59 -05:00
Martin Kojtal f3af8267c5
Merge pull request #8074 from hasnainvirk/compliance_testing
LoRaWAN: Refactoring compliance test code
2018-09-20 13:10:47 +02:00
Kimmo Vaisanen 19d90bd25e Lora: Fix sticky MAC command retransmission
This commit fixes the bug where sticky MAC commands were duplicated in
send buffer everytime send() was called.
2018-09-20 12:20:17 +03:00
Martin Kojtal d8ec21a99a
Merge pull request #8054 from kivaisan/fix_ADRAckReq
Lora: Fix ADRAckReq
2018-09-19 16:59:08 +02:00
Martin Kojtal aca7740f00
Merge pull request #7982 from hasnainvirk/mem_overrun
LoRaWAN: Memory overrun correction
2018-09-17 14:43:13 +02: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 782e470306 Lora: Fix ADRAckReq
This commit fixes two bugs related to ADRAckReq:
- adr_ack_counter must be incremented for all uplink messages (not just confirmed)
- When ADR_ACK_LIMIT + ADR_ACK_DELAY has been reached, stack decreased used
  datarate twice.
2018-09-10 13:39:47 +03:00
Edd Inglis 4a07adbac5 Changed the reported SNR from unsigned to signed.
Internally and logically it is a signed value.
2018-09-07 10:19:01 +01:00
Cruz Monrreal 6165386d34
Merge pull request #7893 from kivaisan/improve_callback_descriptions
Lora: Improve description of callback methods
2018-09-04 09:26:44 -05:00
Hasnain Virk 7b7d5ebc77 LoRaWAN: Memory overrun correction
A typo in LoRaPHYCN470 is causing memory overrun.
We were supposed to fill-in default channel mask and iterate over CN470_CHANNEL_MASK_SIZE times.
2018-09-04 15:21:40 +03:00
Anna Bridge 4fb3aec84a
Merge pull request #7895 from kivaisan/remove_duplicate_linkcheckreq
Lora: Remove duplicate LinkCheckReq MAC command
2018-09-03 16:43:02 +01:00
Anna Bridge c2fdc0d972
Merge pull request #7423 from mprse/mutex_lock_assert
Fix issue #6872 - Mutex lock has possibility to fail at runtime (returning status flag)
2018-09-03 14:14:24 +01:00
Kimmo Vaisanen f24623af97 LoRa: Stop processing MAC commands if command id is unknown
The length of a MAC command is not explicitly given and must be
implicitly known by the MAC implementation. Therefore unknown MAC
commands cannot be skipped and the first unknown MAC command
terminates the processing of the MAC command sequence.

This commit fixes the bug where MAC command processing was not
terminated when unknown MAC command was received.
2018-08-30 15:43:54 +03:00
Amanda Butler a779e6f3c2
Copy edit FSB_Usage.txt
Copy edit for active voice, consistent tense and precise language.
2018-08-27 10:06:21 -05:00
Amanda Butler e4c4e7cc8d
Copy edit lorawan_types.h
Copy edit for minor grammar nits and consistent tense across docs.
2018-08-27 09:51:27 -05: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
Hasnain Virk 5cca2f2e76 Adding override for TX ch. selection in CN470 PHY
set_next_channel() is the base function provided by LoRaPHY class and should be overridden
by the PHYs who behave differently as compared to EU868 like PHY layers.
CN470 PHY had been missing such an override.
In addition to that we have provided a parameter "fsb-mask-china" that can be used to
enforce a custom frequency sub-band of operation as most of the base stations in the market
may not support all 96 channels. Such a strategy will help in rapid network acquisition.
2018-08-27 12:50:09 +03:00
Kimmo Vaisanen fdff9f0f5d Lora: Improve description of callback methods
Users often use "show declaration" (or similar) in their IDE to see descriptions of callback
methods so the function descriptions should be placed close to function declaration itself.
2018-08-27 12:37:29 +03:00
Przemyslaw Stekiel e7b8e303ef Fix usage of `Mutex::unlock()` function - ignore returned value. 2018-08-27 08:50:00 +02:00
Przemyslaw Stekiel 8482cdc70f Fix usage of `Mutex::lock()` function - ignore returned value. 2018-08-27 08:48:58 +02:00
Hasnain Virk 9b2507d71a Adding helpers for Channel mask manipulation
A few protected member functions are introduced in LoRaPHY class
that help manipulate channel masks in various ways.
2018-08-24 15:32:13 +03:00
Hasnain Virk 8f0bb07390 Removing US915Hybrid PHY
This phy implementation was just to support a single sub-band in US region.
As we have decided to make FSBs configurable, we do not need this class anymore.
2018-08-24 15:32:12 +03:00
Hasnain Virk dc56a06646 Enabling FSB support in AU915 PHY
Just like US915 PHY, user can define a custom FSB mask for AU915 PHY.
This helps deployments where base stations do not portray full feature
channel sets and choose to stick with sub-bands.
2018-08-24 15:31:53 +03:00
Hasnain Virk 207ae2dedf Adding FSB selection feature for US915 PHY
User can now define a custom frequency sub-band for the US915 PHY.
FSB_Usage.txt defines how this parameter will be configured.
2018-08-24 15:31:53 +03:00
Martin Kojtal 781573a0b2
Merge pull request #7839 from kivaisan/change_loramac_internal_methods_as_private
Lora: Change visibility of LoRaMac internal methods as private
2018-08-24 13:04:56 +02:00
Cruz Monrreal f7a731544c
Merge pull request #7816 from kivaisan/option_to_disabled_join_duty_cycle
Lora: Refactor duty-cycle configuration and introduce config for JOIN request
2018-08-23 10:05:44 -05: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 7c22dca302
Merge pull request #7831 from hasnainvirk/rx2_dr_default
LoRaWAN: Restoring default RX2 data rate
2018-08-21 09:59:21 -05:00
Cruz Monrreal bf26cbf330
Merge pull request #7807 from hasnainvirk/warning_fix
Compiler warning: unused variable in LoRaMac.h
2018-08-21 09:53:26 -05:00
Cruz Monrreal 08afaf2f85
Merge pull request #7770 from kivaisan/fix_rejoin_with_parameters
LoRa: Fix MAC initialization for connection with parameters
2018-08-21 09:42:16 -05:00
Kimmo Vaisanen 223e6a27d8 Lora: Change visibility of LoRaMac internal methods as private
Some LoRaMac methods were defined as public even though there were used only
internally.

Also removed definition of some methods which were not even implemented nor used.
2018-08-21 12:08:12 +03:00
Kimmo Vaisanen 2f15dae400 Lora: Refactor duty-cycle configuration and introduce config for JOIN request
- Duty cycle can be now only disabled with duty-cycle-on flag if region supports duty-cycle.
  If region does not support duty-cycle, this flag has no effect and duty cycle is always
  disabled.

- Also introduced a new flag (duty-cycle-on-join) to disable duty cycle for JOIN requests.
  This flag can be used for testing only and is used to speed up JOIN request testing as
  backoff times for JOIN request are really long (easily several minutes per attempt).
  This flag works in conjunction with main duty cycle setting. Disabling duty-cycle-on-join
  works only if duty-cycle-on is disabled (or region settings have duty cycle disabled).
2018-08-20 15:30:15 +03:00
Hasnain Virk 928c68cd7f Restoring default RX2 data rate
In #b0b0261 we changed the RX2 data rate to start from the highest data rate
available for the PHY rather than standard defined DR.
This introduced a regression, i.e., even when somebody changed the default RX2 data
rate to something usable for their environment, it didn't take any effect. As in
reset_mac_params() we override the data rate with max value possible for that PHY.
This commit restores the original behaviour and we always use standard defined
values.
2018-08-20 14:35:40 +03:00
Hasnain Virk a7cb32f83f unused variable warning in LoRaMac.h for release build
In release builds where MBED_ASSERT macro is syphoned off, we were hitting
an unused variable warning. To mitigate that we could direct the variable
used in MBED_ASSERT to void.
2018-08-17 11:19:34 +03: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 76d01f5c71 LoRa: Fix MAC initialization for connection with parameters
LoRaMAC was not initialized properly if application called
connect(const lorawan_connect_t &connect);

This causes problems for example in case where application
first disconnects and then reconnects as counter values are not
initialized.
2018-08-13 12:41:01 +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
Amanda Butler 9e74fa5072
Copy edit LoRaWANBase.h
Copy edit file for minor grammar nits.
2018-08-09 15:51:11 -05:00
Kimmo Vaisanen 57f89a2576 Lora: Reformate LoRaWANBase documentation
- Modified "user" to "you"
- Modified line length to ~100 characters.
2018-08-09 14:38:07 +03:00
Amanda Butler 71341ec44e
Copy edit LoraWANBase.h
Copy edit file, mostly for consistent U.S. spelling and precise language.
2018-08-08 15:30:18 -05: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
Kimmo Vaisanen 17d02d949f Lora: Document all possible error codes for LoRaWANBase methods
Also duplicate documentation is removed from LoRaWANInterface which
inherits LoRaWANBase class.
2018-08-07 15:25:44 +03: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
Martin Kojtal 03ad9d63ec
Merge pull request #7620 from kivaisan/fix_cancel_sending
Lora: Fix cancel_sending
2018-08-01 15:00:04 +02: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 d76f6c07e9 Making recv timing error and preamble length configurable
We had a bug especially in the reception path. Our recv window opening
delays were being calculated on the premise that the radio has to capture
5 preamble symbols out of 8 transmitted by the base station. However, in PHY
layer while setting radio rc settings, we were setting preamble length to be 8.
Preamble length register needs to be configured differently for Uplink and Downlink.
For uplink, we wish to transmit 8 preamble symbols whereas in the reception path we need
to receive 5 preamble symbols at least out of 8.
Alongwith that the maximum range of timing error may vary from platform to platform as it
is based upon the crystal in the chip. We have now made these parameters configurable and
have loaded them with the most optimal defaults.
2018-07-30 15:25:36 +03:00
Hasnain Virk 24c5c58d4f Mark an error in post processing if ack not recvd
If an ack is not received after maximum retries, we need to mark an error
which was missing from the post processing sequence.
2018-07-30 15:25:18 +03:00
Hasnain Virk 31aaea6749 [IOTCELL-1181] Fixing incorrect NetID causing ABP Failures
The issue rose up when using ARMC6. A test case didn't initialize NetID
parameter for ABP while using connect(params) API. NetID is the first 7 bits
of the Device Address. It makes sense to actually remove the net-id parameter
from ABP settings as the stack can deduce it from device address. However, the ABP
structure is exposed in public APIs, so we can't really do that at the moment.
Simpler fix is to move the mask that helps us to extract first 7 bits of the device address
is exposed in lorawan_types.h and the user can use it to deduce correct net-id.
2018-07-30 15:02:35 +03:00
Hasnain Virk 465fb447e5 AS923: Using LoRa modulation comatible DR as default
DR7 is used for FSK in AS932 region. As a default max DR, we should use a LoRa modulation
compatible data rate. Ofcourse if a device wishes to use FSK, it can set DR7 using set_data_rate() API
and turning off ADR, or an NS can configure a new channel for the device utilizing DR7.
2018-07-27 15:04:31 +03:00
Hasnain Virk b0b026126c [IOTCELL-1181] Using higher data rates to connect
The stack was trying to connect with default data rates which happened to be
the lowest data rates in a specific region. In the beginning device and NS do
not have agreed upon tx rx parameters and there can be synchronization issues.
When we use lower datarates, we may end up having a minute and a half long
transmissions that hnot only blocks the channel for a long time but also reduce
the chance of proper synch between device and NS. That's why we have decided to
begin with higher data rates and gradually decrease datarate if we do not hear
from the network server.
2018-07-27 15:04:31 +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
Hasnain Virk 4a4f8de6f2 LoRaWAN: Wrong return code for JoinRequest retry
51f92b0efd introduced
handling for connection attempts while a connection was already underway or have been
completed. Unfortunately a similar check slipped through and the stack was not able to continue
sending join requests if an error happened.
2018-07-16 16:28:52 +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 ed9048f79c Correcting unit for timeout
timeout unit should be ms not micro second.
2018-07-12 13:28:21 +03:00
Hasnain Virk 9a77b5d05f FRMPayload size validity
It was pointed out in #7432 and #7232 that the stack was comparing frame payload size
with the allowed payload size in a wrong manner in shcedule_tx().
We must strip the overhead from the frame before comparison.

We did have a similar check in prepare_ongoing_tx() API which would correctly analyse
the situation but a check was needed in schedule_tx() as well. The reason is that the
schedule_tx() API can be called automatically by the stack if the user intiated requested
was not promptly entertained because of duty cycle restriction. Now, the datarate can change
here (for CONFIRMED messages if the ack was not received after retries max out). That's why
a test for validity was needed.

We now perform a comparison using _ongoing_tx_message structure which contains the actual
FRMPayload size.

For proprietary type of messages only MHDR and Port field is used so we shouldn't add MAC commands
and other overhead into them.

In order to have consistent frame overhead, we have opted to always include Port field in the
frame.
2018-07-12 13:28:15 +03: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 24db1c81ec Updating docs
API documentation is updated to clear how the connection related return codes will
work from now on.
2018-07-09 13:00:01 +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
Kimmo Vaisanen 50004ca89a Lora: Add initialize() method to set LoRaWANTimeHandler class for phy
Instead of giving LoRaWANTimeHandler object as parameter for constructor,
object is now given via own initialize() method.

This change is needed for future refactoring where application can give own
PHY object for LoRa stack.
2018-07-06 10:04:44 +03:00
Hasnain Virk bf78e264c8 Bug fix for receive windows
In rx_config(params) API we shouldn't check for radio state as radio may never get
idle for a class C device. That check made sense only for class A. As the PHY layer
have no conecpt of receive windows which is a MAC layer construct, we should remove the
state check.
The API will be changed later to void rx_config(params).

In addition to that another bug is fixed in the open_rx2_windows() API. We should set the rx slot
first before instantiating a test based on its value.
2018-07-02 18:42:21 +03:00
Martin Kojtal 3ee8f3214f
Merge pull request #7348 from hasnainvirk/doc_fix
LoRaWAN: Correcting doxygen
2018-07-02 17:24:52 +02:00
Amanda Butler aa53ee6204
Copy edit LoRaWANBase.h
Copy edit for precise language and comma use.
2018-06-29 14:28:44 -05:00
Amanda Butler 563d742872
Copy edit LoRaWANinterface.h
Copy edit for precise language and comma use.
2018-06-29 14:27:45 -05:00
Cruz Monrreal d06826b2a4
Merge pull request #7335 from hasnainvirk/recieve_api_change
LoRaWAN: Refactoring LoRaRadio::receive(uint32_t) API
2018-06-28 19:41:39 -05:00
Hasnain Virk ce1e210e4a Correcting doxygen
Use of MSG_FLAGS was updated in previous PRs but the doc was not updated
accordingly.
2018-06-27 15:25:22 +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 10c3019e06 Refactoring LoRaRadio::receive(uint32_t) API
receive(uint32_t) API in the LoRaRadio class (base class for the radio drivers) should
not take any argument as we decided to take hardware timers for RX timeout interrupts
instead of software timers. It is being refactored to receive(void).
This is an API change, but as it is not an application interface, we will not put a
deprecation notice. Only user of this API is our stack (LoRaPHY layer) which has been updated
accordingly.
Actual driver comes out of the tree and a PR is open there to update the drivers:
https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers/pull/22

In addition to this an internal API belonging to LoRaPHY class is refactored.
set_rx_window(parameters) is refactored to handle_receive(void) which is more consistent with
handle_send().
2018-06-26 15:47:51 +03:00
Hasnain Virk d335f82440 Remaining style fixes 2018-06-14 14:52:46 +03:00
Hasnain Virk 27290bb12f Adding valid frequency check for RXParamSetup cmd
We must check for a valid value of a frequency being sent
by the network server.
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
Kimmo Vaisanen 0f0b3be7e9 Lora: Check for valid ABP params
Check that ABP dev_addr and nwk_id is non-zero and keys are not null.
2018-06-01 12:41:16 +03:00
Hasnain Virk 493ae2bd91 dr_range bitfield should be unsigned integer
If the value is an integer, the 4th bit is used for sign, so you can store
values upto 7 only whereas the datarate values could go upto 15. That's why
we need to turn this to an unsigned integer so that the last bit can also be used.
2018-06-01 12:41:15 +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
Hasnain Virk e438846c2d Moving missing public data structures
A few of the structures were missing from the storage space which is
visible topublic APIs. Suc structures are now being added.
2018-06-01 12:30:07 +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