Commit Graph

158 Commits (e7cd6ae2a98d7b24cf30072eef07b66740aa85bc)

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