Commit Graph

66 Commits (b63c98e1038bbb4f2e89eef1b6b294d4e4772671)

Author SHA1 Message Date
Antti Kauppila b63c98e103 LoRa: LoRaPHY dependency removed from LoRaMacStack
- This is internal change, no functionality has been changed
- LoRaWanInterface cleaned up and code moved to LoRaMacStack
- Compliance code in LoRaMacStack moved to EOF
- Green tea tests have been run manually
- Doxygen updated accordingly

LoRA: reorder class members
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen fe225a8430 Remove redundant event from timer callbacks
Since our timers are now already using events, we no longer need to
defer timer callback calls.
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen c6eee4fd98 Simplify check for pending bit 2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 32075b91b5 Fix reception of class C messages
- Do not put radio into sleep when message is received in class c mode
- Experimental feature for acknowledging confirmed downlink messages
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen a26fca8bf5 Add set_device_class API to change active device class
This API can be used to runtime change device class.

Please note that only class A and C are supported at the moment.
Trying to set class B will return LORAWAN_STATUS_UNSUPPORTED.

Fix set_device_class documentation

fix documentation
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 4aba3434f4 Change minimum required channels from 6 to 2 (US915Hybrid)
https://github.com/Lora-net/LoRaMac-node/issues/362
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 65b2dbc7dc Update DevStatusAnd format
In the DevStatusAns format, the protocol requires RFU(7:6) value = 0
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen e1fff2e738 Update handling for functions OnRadioRxError and OnRadioRxTimout.
This is especially important for class c devices.
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 6c165e0f19 Changed mcps confirmation ul_frequency to channel 2018-03-21 08:54:42 +02:00
Kimmo Vaisanen e097429b69 Remove unused is_fPort_allowed method 2018-03-21 08:54:42 +02:00
Kimmo Vaisanen a9e1076572 Bug fix in RX timeout and RX error handling for class c nodes.
1. Do not stop the 2nd window timer, as it is not running.
2. Wait for the OnAckTimeout event, before setting MacDone
3. Process for class c also the 2nd window timeout part, as we do
   not have a 2nd window timer.
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 591bc7da1f Add the possibility to set the default antenna gain. 2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 256a3a5842 Fix calculation of the aggregated time-off.
Perform only an assignment.

https://github.com/Lora-net/LoRaMac-node/issues/282
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen c1ea418ac4 Fix rx slot handling
Store the rx slot temporarily. When in class C, this variable will be changed
in function OpenContinuousRx2Window.
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen fc1696b74f Do only set the MacDone if the MAC is not in class c 2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 6114f2b3d5 Fix an issue with sequence calls.
This issue is only present for a device in class c mode, which
has perform unconfirmed uplinks.

https://github.com/Lora-net/LoRaMac-node/issues/327
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen e206c1ee54 Changed RegionNextChannel function in order to return LoRaMacStatus_t instead of a boolean
Removed the while loop checking the return value from set_next_channel
(GitHub Issue https://github.com/Lora-net/LoRaMac-node/issues/357)

The new return values are:

LORAWAN_STATUS_OK                    : A channel has been found.
LORAWAN_STATUS_NO_FREE_CHANNEL_FOUND : No free channel has been found (AS923 and KR920 regions)
LORAWAN_STATUS_DUTYCYCLE_RESTRICTED  : No channel found due to the duty-cycle or JoinReq back-off restrictions. Trial must be delayed.
LORAWAN_STATUS_NO_CHANNEL_FOUND      : No channel has been found. Re-enabled the default channels.
2018-03-21 08:54:42 +02:00
Kimmo Vaisanen 339306ed1b Ensure DR_6 cannot be selected for IN865 region 2018-03-21 08:54:42 +02:00
Antti Kauppila a294aa028d LoRa: LoRaWANInterface refactored.
- Only internal changes, no functionality changes
- Some minor improvements to LoRaWanStack
2018-03-21 08:54:42 +02:00
Antti Kauppila 32257858d0 Added missing mac_cmd_buf_idx_to_repeat to LoRaMacCommand class
- Reordered LoRaWANStack internal variables for more compact code
2018-03-16 18:00:02 +02:00
Antti Kauppila 488cf03d1e LoRA: Code cleanup + doxygen updates
- Internal changes only
- reset function is created to LoRaPHY to reset LoRaMAC parameters with default values
- Doxygen updates for newly created functions
2018-03-16 18:00:02 +02:00
Antti Kauppila 2ac73a6cac LoRa: LoRaMacMcps refactored to remove dependency to LoRaMac.
- This is internal logic only and there are no functionality changes
- Some compliance test stuff have been moved to end of files
- Some internal data structures removed as useless after refactor
2018-03-16 18:00:02 +02:00
Antti Kauppila 37371df968 LoRa: reset_mac_parameters put to correct place 2018-03-16 18:00:02 +02:00
Antti Kauppila d232d3bb52 LoRa: Removed LoRaMac dependency from MIB and MLME classes
- Internal refactoring only, no functional changes
2018-03-16 18:00:02 +02:00
Antti Kauppila d1cdd77290 LoRa: get_phy_params() refactored
- get_phy_params function was very heavy weight and needed to be refactored.
- switch-case clauses have been refactored to be functions now and the complexity of the usage has been improved a lot.
- There are no functional changes, this is internal only change
2018-03-16 18:00:02 +02:00
Antti Kauppila 3c7bd1b794 LoRa: LoRaMac need removed from LoRaMacCommand class
- LoRaMacCommand does not have any external dependencies anymore
- Also LoRaMacMlme is not using LoRaMacCommand anymore
2018-03-16 17:58:44 +02:00
Kimmo Vaisanen 5bfe056370 Fix verification of RX2 datarate
Datarate verification passed only if given datarate was a minimum
possible value. Instead datarate should be checked that it is less
than maximum value.
2018-03-08 14:02:40 +02:00
Kimmo Vaisanen 3bd0f97914 Fix initialization of phy_params.payloads_with_repeater.size 2018-03-08 12:46:54 +02:00
Hasnain Virk b163057da7 Verifying datarate bug fix
A patch was missed from the feature PR.
verify_channel_DR() in LoRaPHY class had a loop with uninitialized
loop counter.
2018-02-20 15:08:04 +02:00
Kevin Bracey d5dc655a6d Correct LoRaWAN license header 2018-02-15 15:40:18 +02:00
Hasnain Virk d7c22a6b09 A few Cosmetics & methods for mask manipulation
LoRaMacChannelPlan class provides APIs which are not usable for
PHY layer implementations who do not support custom channel plans.
So we had some code in APIs which was explicitely using magic numbers
for the channel mask. Although it turned out to be not a bug as a layer
down we were checking for custom channel support. However, we now
check for custom channel support before going deep into PHY layer that will
make the code run faster and we have done some cosmetics to the code for
readability.

Channel mask is manipulated with inline methods
2018-02-13 15:09:58 +02:00
Kimmo Vaisanen 90c02f2843 Check correct return value
mib_get_request() returns lorawan_status_t value so comparing
return value to boolean is incorrect.
2018-02-12 12:09:16 +02:00
Hasnain Virk 7224fbae1c Style Changes in MAC layer
Style changed according to Mbed-OS guidelines.
2018-02-11 00:31:47 +02:00
Hasnain Virk 20bce2f21c Style changes for LoRaWANTimer & a warning fix
Method naming, doxygen style etc are made to follow Mbed-OS guidelines.
A warning fix in LoRaWANstack.
2018-02-11 00:31:47 +02:00
Hasnain Virk f0fe1229cf Moving LoRaRadio and LoRaWANBAse to lorawan
LoRaRadio and LoRaWANBase use to exist under netsocket/.
However, their logical location should be where the actual stack exists.
2018-02-11 00:31:47 +02:00
Hasnain Virk 4432ad9ae7 Major PHY layer modifications
The PHY layer had a lot of duplicated code in various geographic regions.
In this commit we have tried to concentrate all common functionaliy into
one single class which LoRaPHY that provides three kind of methods:

i) Non virtual base methods which are there for upper layer use, e.g.,
   providing access to driver or generic PHY layer functionality which
   needs to be exposed to upper layers.

ii) Virtual methods (no hard limit on implementation) that can be overriden
    in derived classes. Some PHY implementations will need that as they may
    come with very peculiar channel schemes, e.g., dynamic channel schemes
    in US bands.

iii) Protected methods which are only available for the derived PHYs

We have adopted a mechanism for the dervied PHYs to announce their differenmtiating
parameters in their constructors by filling up a data structure known as lora_phy_params_t
which exists at base level. Access modifier for this data structure is protected so it can only be
used by the base or derived classes, i.e., no exposure to upper layers.

For extra functionality and differentiating controls, a derived PHY can override any virual method as necessary.

In addition to that we have adopted the Mbed-OS style guide and have changed data structures and code to reflect that.
Some data structures are removed.

* Algorithm to get alternate DR is modified. Current scheme, works as multiples of 6 as EU and EU like PHYs
provide 6 datarates. We make sure that we try a datarate at least once. If nuber of join retries is a multiple
of 6, we may try multiple times on each data rate.

* Most of the PHYs with dynamic channel plans, always override the above mentioned algorithm as the rules governing
  this algorithm do not hild in their case.

* band_t data structure is enhanced with lower band frequency and higher band frequency. That enables us to validate
  frequency based upon the band and hence we can have a single function for all PHYs to validate frequency.

* In some PHYs, there were some extra channel masks were defined which were not being used. Hence removed.

* EIRP table corrected in some PHYs based upon spec.

* PHY functions in response to Mac commands are renamed to reflect what they exactly do.
  for example accept_rx_param_setup_req() because that's what they do. they can either accept
  the mac command or reject it.# Please enter the commit message for your changes.
2018-02-11 00:31:47 +02:00
Kimmo Vaisanen 5d98839092 Improve error handling & robustness
This commit also introduces API change for disconnect(). disconnect() will
now return LORAWAN_STATUS_DEVICE_OFF for successfull disconnect.

 * LoRaWANStack::handle_tx() can be called with NULL buffer when length is 0.
   This commit fixes the case where user has provided NULL buffer and length
   is > max_possible_size.

handle_tx() now always returns LORAWAN_STATUS_PARAMETER_INVALID if given
buffer is NULL pointer and length > 0.

General error checking is added and some asserts are added for events.
2018-02-11 00:31:47 +02:00
Kimmo Vaisanen 35045f19cc Implement LoRaMac::disconnect
In order to reset LoRaMac's state in disconnect, we need to implement
an API which can be used to cancel all outstanding requests and reset
LoRaMac's internal state to idle.

This commit introduces LoRaMac::disconnect() which can be used for
this purpose.
2018-02-11 00:31:47 +02:00
Kimmo Vaisanen 44bca596c5 Use EventQueue for timers
Instead of initiating own timer objects we can use EventQueue::call_in() method
as we already have handle to EventQueue object.

Also setting timeout and starting timer has been combined to TimerStart method.
2018-02-11 00:31:47 +02:00
Hasnain Virk 7369cbd649 [IOTCELL-346] Removing default value storage
We now save roughly 500 bytes by removing storage of default
parameters in the loramac_params_t data structure. We use Mib to
get default values from PHY whenever needed instead.

loramac_sys_arams_t now contains only the runtime values set during operation
whenever defaults are needed we directly query the PHY layer or via Mib as the
need maybe.
2018-02-11 00:31:47 +02:00
Hasnain Virk c02774343a [IOTCELL-282] Code cleanup/simplification and rules
Baseline is changed to use a single set of data structures that simplifies the
code in the LoRaWANStack and Mac layer. We are now following certian rules for naming
data structures.

- All structures visible outside their domain are prefixed as 'lorawan_'
- All mac structures are prefixed as 'loramac_'
- All subsystem or module strucutures carry their name in prefix, like 'mcps_'

PHY layer still have legacy camel case data structures which will be entertained
later while we will be simplifying PHY layer.
Test cases are also updated with the new data structure naming conventions.

One major difference from the previous baseline is the removal of static buffer
from mcps indication. And we do not copy data from stack buffer to rx_msg buffer.
This saves at least 512 bytes.

It may look like now that if we have received something but the user have not read
from the buffer, then the buffer will be overwritten and we will lose previous frame.
Yes, we will. But the same will happen even if we would have copied the buffer into rx_msg
because then the rx_msg gets overwritten. So we decide to abandon copying the buffer at
multiple locations. We inform the user about reception, if the user doesn't read and
the data gets overwritten, then so be it.
2018-02-11 00:31:47 +02:00
Hasnain Virk 6ea541c054 [IOTCELL-286] Adding Channel Plan subsystem
Channel planning was distributed over LoRaWANStack and LoRaMac previously.
We now centralize it by allocating the service to its own class.

Thus making the workflow consistent, i.e.,

Request for channel plan = Application->Interface->stack->Mac->ChannelPlan

Major change apart from adding the channel plan subsystem are the API changes
in LoRaMac class.
2018-02-11 00:31:47 +02:00
Kimmo Vaisanen 34c034dfff Remove duplicate configuration flags
This commit changes code to use directly mbed os configuration system generated
compilation flags.
2018-02-11 00:31:47 +02:00
Hasnain Virk b47c59ce2a [IOTCELL-288] Adding MIB subsystem
As a part of MAC layer breakdown into independent subsystems, we have
introduced a class for MIB service.

Major changes from the baseline are:

- making OpenRxWindow() public in LoRaMac.cpp
- Moving various data structures to central protocol data structure
2018-02-11 00:31:47 +02:00
Hasnain Virk 49885d2bba Changing MLME data access methods to inline
As indicated in one of the reveiws, it makes more sense
to change the data access methods to inline as they are
just one liners.
2018-02-11 00:31:47 +02:00
Hasnain Virk 255bd30a48 [IOTCELL-290] Adding MCPS subsystem
Like MLME, MCPS has also been alloted its own class. This is the
2nd stage of breaking down the MAC services into subsystems.
2018-02-11 00:31:47 +02:00
Hasnain Virk a100ab0226 [IOTCELL-289] Adding Mlme class handle
MAC layer will services will be broken down into independent
subsystems. This is the first of those efforts. We have introduced
LoRaMacMlme class that handles everything related to MLME subsystem or
subservice. To accomodate subsystems we have grouped all protocol level
variables into one big data structure. A pointer to that data structure
will be passed around the subsystems in order to regulate the entire
system.

LoRaMac::Send() and LoRaMac::SetTxContWave*() APIs are made public as
they are needed to be accessed by the subsystems.
2018-02-11 00:31:47 +02:00
Hasnain Virk a3106d2fe6 Timer SingletonPtr & mac protocol data structure
Ticker objects embeded in TimerEvent_t data structure were getting constructed
even for the non LORAWAN builds. And that's what was bloating the builds.
We now lazy initialize them using Mbed-OS utility clas SingletonPtr.

A central data structure has been created that carries all the protocol level
variables for the Mac layer. This is important as we are going to break down
MAC services into subsystems and we will pass around common data using that data structure.
2018-02-11 00:31:47 +02:00
Hasnain Virk f62253ca0e Changing Timer callback to Mbed Callback
Time handler class had a c style callback attached to it which
had been hampering us to be fully object oriented.
That particular callback is changed to Mbed Callback which is attatched
to a specific object hence allowing us to be fully object oriented.
2018-02-11 00:31:47 +02:00
Kimmo Vaisanen e18d76aa7e Change LoRaWANTimer to a C++ class
LoRaWANTimer is now called as LoRaWANTimeHandler class as this class handles both
current time and timer functionalities.

Some refactoring on how LoRa objects are created was needed:
- LoRaWANTimeHandler object is created by LoRaWANStack and shares with LoRaMac and PHY.
- LoRaPHY object is now member of LoRaWANStack class instead of static variable in source file.
2018-02-11 00:31:47 +02:00