Commit Graph

195 Commits (ce28c91405309648c936f2ccc01a64f6083c6c72)

Author SHA1 Message Date
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