Commit Graph

14042 Commits (6ea541c0540222b7282bea53a609a7efd1e70135)

Author SHA1 Message Date
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
Hasnain Virk b634ca49dd Architecture rework, bug fixing & missing features
MAC layer is now a class rather than being a blob.
In addition to that Mac commands are now being handled in
a seperate subsystem (a class of its own). In future we
will do the same with othe sublayers of MAC like MLME, MCPS etc.

The drive behind this exercise is to make MAC and supporting layers
into an object oriented system.

Major bug fixes include:

- last join time inclusion in band parameters
- disabling rx2 window if we missed the slot already
- MLME uplink schdule hook
- nbRep according to spec
- maintaining datarate after successful joining
- suppressing MLME requests if MAC is in TX_DELAYED state
- Uplink dwell time verification

Some missing features are implemented. Details are as follows.

Support for LinkCheckRequet:

An application API is added, add_link_check_request() to delegate a
request for Link Check Request MAC command.

* Application provides a callback function that needs to be called on reception of
  link check response.

* Mac command is piggybacked with data frames.

This API makes the sticky MAC command stick with the application payloads until/unless
the application un-sticks the said mac command using remove_link_check_request() API.

Handling fPending bit:

If in the Downlink, we get the fPending bit set in fctrl octet,
we attempt to send an empty message back to Network Server to
open additional Receive windows. This operation is independent
of the application. An RX_DONE event is queued bedore generating
the said empty message. Specification does not mention what can be the
type of that empty message. We have decided it to be of CONFIRMED
type as it gives us an added benefit of retries if the corresponding
RX slots are missed.

Radio event callbacks as Mbed callbacks:

radio_events_t structure has been carrying C-style callbacks which was
inherited from the legacy code. These callbacks has now been changed to
Mbed Callbacks that makes sure that we can be object oriented from now
on.
2018-02-11 00:31:47 +02:00
Kimmo Vaisanen 1eedadd52d Change region configuration help format
New mbed os configuration parser no longer seems to allow multiline help description.
2018-02-11 00:31:47 +02:00
Hasnain Virk 5e8d8e1c08 Bug fix in setting data rate
Setting up user defined data rate was found broken maybe because of
some rebase issue. Code has been setting always the default data rate
and ignoring used defined values.
2018-02-09 11:00:56 -06:00
Hasnain Virk f7c0ce6221 Making static objects SingletonPtr
We had a lot of static objects which would get constructed and hence
pull in some of the LoRaWAN code into the builds for other technologies.
Such objects have been now lazily initialized using utility class
SingletonPtr.
2018-02-09 11:00:56 -06:00
Kimmo Vaisanen 7872b6a29c Use EventQueue for elapsed time
Current implementation uses high resolution timers to calculate elapsed time.
This prevents for example deep sleep completely and causes unnecessary timer
events.

This commit changes implamentation to use EventQueue::tick() to get elapsed time.
2018-02-09 11:00:56 -06:00
Kimmo Vaisanen b0889f7d21 Move all compliance test code inside compilation flag
All compliance test related codes are now inside LORAWAN_COMPLIANCE_TEST
build flag. This will reduce memory usage in when compliance test codes
are not needed.
2018-02-09 11:00:56 -06:00
Hasnain Virk 97f1680586 [IOTCELL-270] Detaching TxNextPacketTimer
TxNextPacketTimer callback was being used for testing only (compliance testing to be precise).
Now there are independent methods and direct calls to automatic timers for the
compliance testing so there is no particular need for this timer anymore.
2018-02-09 11:00:56 -06:00
Hasnain Virk 05e2d29238 Reworking callback API
Application should be able to add some optional callbacks if it needs to.
Ofcourse there is a penalty of 8-12 bytes per callback, but there can be
certain needs of the application that needs to be met for example setting
up a link check request etc.

We have introduced a structure that contains callbacks for the application use.

 - 'events' callback is mandatory, user must assign it. Because this callback brings
   state changes for the application. We cannot segregate this into individual handlers
   because of RAM penalty.
- Other calbacks (none of them are implemented yet are optional).

Example of using the API is provided with doxygen
2018-02-09 11:00:56 -06:00
Hasnain Virk e60227cf4d Receive API typo fix
Receive API should return the length of data written to the user buffer
as the Posix APIs suggest rather than sending the pending length of data
back.
That has actually been a typo mistake which actually wnt in even with doicumentation :)
2018-02-09 11:00:56 -06:00
Hasnain Virk 6281073d8b [IOTCELL-279] Using Application provided EventQueue
The EventQueue thread in LoRaMac.cpp is disbanded and the LoRaWAN
protocol is redesigned to store a pointer for an application
provided EventQueue. It means that now the stack runs in the
same thread as application. Application provided EventQueue is used
to defer ISRs from radio driver and timer callbacks as well as the
application events are queued to the same event loop.
2018-02-09 11:00:56 -06:00
Hasnain Virk 29353a8380 Adding license text and BSD-Clause 3 2018-02-09 11:00:56 -06:00
Hasnain Virk f33ef6528b Adding LoRaWANInterface - implementing, LoRaWANBase
This class is the doorway for the user application into the
Mbed-OS implementation of LoRaWAN protocol. It implements LoRaWANBase
and hence would work with any stack implementation underneath, ensuring
seemless portability for applications.

It takes a pre-constructed object of LoRaRadio and delegates it in the
downward direction. Before calling connect() user must call initialize() function
in order to initialize stack and mac layers.

connect() APIs can be used to either provide relevent keys and connection method at
runtime or compile time (using Mbed config system).

enable_adaptive_datarate() and disable_adaptive_datarate() are used to turn on/off
automatic rate control. Otherwisem set_datarate() could be used to set a particular
data rate on the current channel.

set_confirmed_msg_retries() is valid only for CONFIRMED messages. It means that the stack will
retry for a given number of times before timing out.

set_channel_plan() and get_channel_plan() are used to set or get a particular channel plan.
These APIs are particularly useful in case of ABP (activation by personalization). Because
in case of OTAA(over the air activation), by default the stack takes in a CF List (carrier frequency list)
sent by the base station in conjunction with Network server. This list overwrites all user configured
channels or channel plan. set_channel_plan() can be used to set a single channel as well by setting the
parameter for number of channels to 1.

remove_channel_plan() or remove_channel() are used to remove a currently active channel plan or a specific
channel.

send() and receive() APIs follow posix design except the socket descriptor is replaced with port number here.

lora_event_callback() API is used to set a callback function from the application side which is used by the stack
to inform user of particular events like CONNECTED, DISCONNECTED, CRYPTO_FAILURE, TX_TIMEOUT etc.
2018-02-09 11:00:56 -06:00
Hasnain Virk 2f860d2be5 Adding LoRaWANStack class to control MAC and PHY
LoRaWANStack class is our controller layer on top of our
current MAC and PHY layer. It provides services to an implementation
of LoRaWANBase class.

It is a singleton class owing to the fact that the mac layer underneath
is not a class object. Instead, it uses the MAC via setting mib, mlme, mcps
requests and getting responses back from the mac layer using confirmations and
indications.

In essense this class is a special handle for
mac layer underneath which is predominantly reference design based.
In future we may refactor the LoRaMac.cpp code to make it object oriented
and cleaner.

At one end, it binds the application selected radio driver with the PHY layer
and at the other end it provides services to upper layers handling the mac via
well defined APIs.

For proper selection of a PHY layer, user must use Mbed config system.
For this purpose an mbed_lib.json is provided which can be overriden by the
user defined mbed_app.json. By default the EU868 band is selected as a PHY layer.
User must set relevant keys for the selected connection mechanism.
2018-02-09 11:00:56 -06:00
Hasnain Virk 5734b57c0a Adding MAC layer for LoRaWAN implementation
The actual mac algorithms are being used as it is in the reference
implementation.

We introduce an internal class that starts a thread and constructs an event queue
to handle deffered calls from interrupt context for RTOS. The code base is
compatible with Mbed-OS 2 as well.

GetPhyEventHandlers() API provides mac callback funtions for PHY layer,
which are in turn delegated to radio driver from the PHY layer.

LoRaMacInitialization() is augmented with LoRaPHY parameter which let's
the MAC layer know which particular PHY layer is in use.

LoRaMacSetTxTimer() and LoRaMacStopTxTimer() are used when duty cycle is
off for testing purpose or to support custom application timers.

If the duty cycle is off, mac and phy layer work togather to figure
out the next possible transmission time.

LoRaMacCrypto APIs are provided which provide seemless integration of
mbedTLS into mac layer for cryptography. User application is supposed to
provide proper mbedTLS configuration file.

All other APIs are retained as it is.
2018-02-09 11:00:56 -06:00
Hasnain Virk c861c321be Adding PHY layer for LoRaWAN
LoRaPHY is the abstract class for the LoRa PHY layer which governs
the LoRaRadio and provides some common functionality to all regional
implementations.
We support 10 regions and every region comes loaded with default parameters.
These parameters can be changed by the Mac layer or explicitely by the stack
controller layer using APIs provided. This layer in essence detaches Mac completely
from PHY and provides more modular approach to the entire system.
Apart from class structure, the internal functionality is directly deduced from
semtech reference implementation that's why most of the internal data structures are
used on 'as is' basis.
In addition to that, the PHY layer provides APIs to control the LoRaRadio layer, i.e.,
the lora radio driver, ensuring that the radio is accessed from a single entry point.
A seperate data structure file is added which is common to PHY layers only.
2018-02-09 11:00:56 -06:00
Hasnain Virk c9804bd167 Adding base class for LoRaWAN interfaces
All network interfaces for LoRaWAN protocol must implement this
class. In order to be compatible with Mbed-OS applications, any
implementation of this class must use the data structures and
Mbed-OS timers provided.

lorawan_data_structures may look repetitive but this is essential
as we have a plan to use a reference implementation for LoRaWAN mac
layer from Semtech. Some of the data structures provide seemless
transition from semtech implementation (as MAC layer) to the Mbed-OS
control layers above.

features/lorawan/lorastack is the placeholder for future items like mac and
phy layers. system/ will contain all the common bits.
2018-02-09 11:00:56 -06:00
Hasnain Virk 69664c5394 Adding base class for all LoRa radio drivers
All Mbed-OS drivers for LoRa radio devices must implement
this pure virtual class in order to be compliant with Mbed-OS
applications.

This class comes loaded with all necessary data structures.
The implementations of this class can come out of tree.
2018-02-09 11:00:56 -06:00
Martin Kojtal 04f0f2b1aa
Merge pull request #5604 from betzw/betzw_tests_netsocket_wb
TESTS/NETSOCKET: Refinement of `netsocket` tests
2018-02-08 15:25:45 +00:00
Martin Kojtal 9f6eb14ae2
Merge pull request #5996 from ashok-rao/br-BL600
Adding LAIRD_BL600 MTB
2018-02-08 15:23:07 +00:00
Martin Kojtal 65e751bafb
Merge pull request #6025 from karsev/thread_api_adds
Mesh-api setters for eui64 and pskd
2018-02-08 15:22:02 +00:00
Martin Kojtal e8efe11c0e
Merge pull request #6031 from OpenNuvoton/nuvoton_m2351_cthunk
M23: Fix CThunk error on Cortex-M23
2018-02-08 15:21:24 +00:00
Martin Kojtal b7908a64c4
Merge pull request #6033 from anttiylitokola/master
Update mbed-coap to version 4.2.0
2018-02-08 15:20:37 +00:00
Martin Kojtal 8e8b3d3bbd
Merge pull request #6036 from bcostm/dev_move_DISCO_L072CZ
DISCO_L072CZ_LRWAN1: move target folder
2018-02-08 15:19:08 +00:00
Cruz Monrreal 0978062dae
Merge pull request #5971 from maciejbocianski/ticker_tests_fix
Ticker tests fix
2018-02-07 20:17:39 -06:00
Cruz Monrreal 02eeb7af41
Merge pull request #6030 from deepikabhavnani/correct_arch
M33: -march not required if -mcpu is set
2018-02-07 20:07:11 -06:00
Cruz Monrreal 1c5c1c79d0
Merge pull request #6027 from ithinuel/fix-target-names-for-murata-abz-and-adv-wise-1510
rename MURATA type ABZ & WISE 1510 to their expected name
2018-02-07 20:06:50 -06:00
Cruz Monrreal f8cc42689c
Merge pull request #5970 from TomoYamanaka/master
RZ_A1LU: Fix TRNG function
2018-02-07 20:06:17 -06:00
Cruz Monrreal 1ac115d794
Merge pull request #6013 from kivaisan/add-wise-1570
Add MTB_ADV_WISE_1570 target
2018-02-07 20:05:38 -06:00
Jimmy Brisson 7b5d48df38
Merge pull request #5571 from kjbracey-arm/retarget_fh
Complete mbed_retarget FileHandle rework
2018-02-07 17:21:09 -06:00
Cruz Monrreal 40d1c02e25
Merge pull request #5914 from mprse/Transaction_tests
Add Transaction class unit test.
2018-02-07 15:56:59 -06:00
Cruz Monrreal e9fddb6eee
Merge pull request #6017 from theotherjimmy/bl-nonzero-rom
Correct auto-sizing last region of bl
2018-02-07 15:56:43 -06:00
Cruz Monrreal c679dee286
Merge pull request #5848 from theotherjimmy/compile-py3
Python2+3: mbed compile, mbed test --compile,  python unit tests
2018-02-07 15:48:18 -06:00
Cruz Monrreal 3b1438b9ba
Merge pull request #6015 from davidsaada/david_k82f_flash
Add missing flash device feature to the K82F board
2018-02-07 15:03:22 -06:00
Cruz Monrreal ebb39244f4
Merge pull request #6001 from ubirch/mbed-os-5985
Corrects intermittent CLion exporter issue with cmake build directory
2018-02-07 14:56:18 -06:00
Cruz Monrreal 63201db875
Merge pull request #6004 from bcostm/fix_l476-486_sram_iar
STM32L476/486: Improve SRAM usage for IAR
2018-02-07 14:51:30 -06:00
Cruz Monrreal 671cf409c8
Merge pull request #6007 from theotherjimmy/bl-heed-outputext
Take OUTPUT_EXT into account in managed bl
2018-02-07 14:51:11 -06:00
Cruz Monrreal 779ee843ea
Merge pull request #5797 from hosse005/master
ARMC5+6: Specify CPU for ARM scatter file preprocessor
2018-02-07 14:50:44 -06:00
bcostm 7630874b9c Move TARGET_DISCO_L072CZ_LRWAN1 folder 2018-02-07 16:23:09 +01:00
Kari Severinkangas f63dbf56db Mesh-api setters for eui64 and pskd 2018-02-07 16:45:39 +02:00
Wolfgang Betz d6cb3853df Enlarge event queue in `test_socket_attach()` 2018-02-07 13:40:50 +01:00
Martin Kojtal 1d759d0b9c
Merge pull request #5895 from maciejbocianski/fileHandle_tests
Add FileHandle tests
2018-02-07 11:53:04 +00:00