Commit Graph

6450 Commits (75dcacd33a15e009ca62adb15a43f68ad9aa0bd7)

Author SHA1 Message Date
Unknown 75dcacd33a Add back PHY computed ping slot window offset
Removed unintentionally in last commit
2020-02-06 18:38:36 +02:00
Unknown 0dfd7d54bd Remove extra beacon debug setting
Was only used to print bad beacon frames
2020-02-06 18:38:36 +02:00
Unknown bf7b6be032 Fix LoRaWAN interface gps time type
Switched to  high precision gps time
2020-02-06 18:38:36 +02:00
Unknown 002f7fc306 Moved Beacon GPS time set
Moved from stack to class b beacon handler
2020-02-06 18:38:36 +02:00
Unknown 7656e91630 Fix PingSlotInfoReq parsing
PingSlotInfoReq 1 byte payload
2020-02-06 18:38:36 +02:00
Unknown 75b588412a Reorder class b slot types by priority 2020-02-06 18:38:36 +02:00
Unknown a28d6ec615 Fix class b disable timers
Stop beacon acquisition timer
2020-02-06 18:38:36 +02:00
Unknown 78b55c3ffc Stack Class B support
- Switched to millisecond gps time
- Updated process rx/rx_timeout events for  class B windows
- Added beacon event callback
2020-02-06 18:38:36 +02:00
Unknown 61cd2d7a05 LoRaRadio on air time computation
Instead of implementing this in each derived radio class, let's do it once here.
2020-02-06 18:38:36 +02:00
Unknown e6ea8309b3 Add core Class B implementation
Here it is - the main Class B functionaiity
2020-02-06 18:38:36 +02:00
Unknown bb878fea8a PHY Class B configuration
- Initialize Class B configuration
- Implement class B receiver configuration
- For regions such as US915 with derived rx_config(),  changes to the base class implementation makes the derivation unnecessary , so these region specific versions have been removed
2020-02-06 18:38:36 +02:00
Unknown bf6f45a05b PHY Class B handling
Support class b beacon and ping slot rx configuration
2020-02-06 18:38:36 +02:00
Unknown 0a30aeeec2 PHY Class B beacon and ping slot configuration
- Add PHY beacon and ping slot configuration
2020-02-06 18:38:36 +02:00
Unknown 62bcb061e5 Class B json configuration
Added Class B configuration
2020-02-06 18:38:36 +02:00
Unknown 792269305f LoRaWAN Interface Class B APIs
Added:
-  enable beacon acquisition
-  add/remove PingSlotInfoReq MAC  command
-  get last received beacon
2020-02-06 18:38:36 +02:00
Unknown ff16ddd8c3 Add Class B related MAC Commands
-  PingSlotInfoReq & PingSlotInfoAns 
-  PingSlotChannelReq & PingSlotChannelAns
-  BeaconFreqReq & BeaconFreqAns

Switch to millisecond computation for  device time handling
2020-02-06 18:38:36 +02:00
Unknown 88c44480c4 Add Crypto ping slot random offset computation
Implement ping slot pseudo-random offset computation
2020-02-06 18:38:36 +02:00
Unknown 42ddb617d9 Switch to millisecond resolution gps time
The existing gps time  resolution is seconds, while class b beacon and ping slot scheduling requires millisecond resolution.
This set of changes switches gps time to  millisecond resolution.
2020-02-06 18:38:36 +02:00
Hasnain Virk d7a57fb0f3 Fixing DevTimeAns handling
As per discussion with Nicolas Sornin, any device time synchronization
value must be handled as is (monotonically increasing GPS epoch time guaranteed to be monotonic with granularity 1 second).

Once we receive a response to DevTimeReq (i.e., DevTimeAns is received)
we immediately set our local gps time stamp and take a snapshot of our
local monotonic (ticker or equivalent) clock. This is achieved by
calling 'set_gps_time(...)' API in the LoRaWANTimer module.
After that an event is generated to let the application know that a
device time has been synched.
2020-02-06 18:38:36 +02:00
Hasnain Virk 6654a595d6 Exposing GPS/UTC time APIs
Provides hooks for the internal APIs handling GPS time base for device
synchronization.
In addition to that 'set_system_time_utc(...)' API is added which have no
roots in the stack. Its just a helper for the application developer to
acquire UTC time base given the difference between TAI and UTC time
bases.
2020-02-06 18:38:36 +02:00
Hasnain Virk ef6bc1d0a4 Adding network assisted GPS time acquisition
LoRaWANTimer class is responsible for providing time base for the
LoRaWAN stack in Mbed OS. It derives its core monotonic clock from the
EventQueue which is essentially a millisecond ticker or equivalent (in
tickless mode). LoRaWAN network can assist the device for device level
time synchronization using ClockSynchronization protocol (for v1.0.2) or
by replying to DevTimeReq MAC command (for v1.0.3 and above). The time
base used for device synchronization using above methods is purely
based on GPS epoch and needs no conversion to UTC or TAI etc (no
adjustment for leap seconds either).
Therefore we have extended the LoRaWANTimer APIs to account for GPS time
base if assisted by the network.
get_gps_time() is the API to use to acquire GPS time base from the
stack. If the network never assisted the device with a time stamp, a
value of zero is returned which means GPS time base is not available.
set_gps_time(time) API is used to set a given GPS time-stamp when the
network sends it.
These APIs are hooked via LoRaMAC to LoRaWANInterface which exposes the
access to the application.
2020-02-06 18:38:36 +02:00
Antti Kauppila de9e292bf9 fixed include problem 2020-02-06 18:38:36 +02:00
Antti Kauppila e76a55681f astyle fixes 2020-02-06 18:38:15 +02:00
Hasnain Virk 623436d726 Hooking up DeviceTimeReq generation for application
The application can use add_device_time_request() API to attach
DeviceTimeRequest mac command for the next outgoing packet.
It is a non-stick mac command, so if there is no response, the app can
retry. The API indicates if the mac command was queued successfully or
not. The actual indication of successful time and date update will come
through an event 'DEVICE_TIME_SYNCHED'.
2020-02-06 18:38:15 +02:00
Hasnain Virk 6f42adf8e5 Handling DevTimeAns mac cmd properly
DevTimeAns mac command will carry number of seconds since the GPS epoch
in the first four bytes and the fifth byte is the fractional part.
After extracting the time from the command fields, we need to adjust
this time according to the unix time, so we add the Unix to GPS time
diff to it. After that we account for leap seconds and set the time
using standard set_time() call.

We have removed the method time_received() fom LoRaPHY as it is not
important nor required. It doesn't fit into the LoRaPHY context.

Stubs are therefore updated to reflect the change.

mbed_lib.json now contains the configurable parameters for TAI to UTC
and GPS TAI to UTC differences in seconds needed for leap second
correction. They are loaded with values as of 2018.
2020-02-06 18:37:24 +02:00
Hasnain Virk 72c25df1e3 _rx_ready flag is now atomic since #9245
_rx_ready boolean is not used anymore. We set/unset it using core util
atomic flag set test.
2020-02-06 18:37:24 +02:00
Hasnain Virk 7fb75500e3 Removing multiple attachment of LinkCheckRequest
A rebase error perhaps. We need to attach Link Check request only once
to the outgoing message.
2020-02-06 18:37:24 +02:00
Hasnain Virk 86eb300c35 Fixing multiple UL Fcnt increment
While post processing a transmission in case of no reception, we already
take care of frame counters. We must not kick post processing step once
again.
2020-02-06 18:37:24 +02:00
Antti Kauppila af04a7a638 astyle fixes 2020-02-06 18:37:24 +02:00
Antti Kauppila 4fadc1e773 Increment app DL counter correctly 2020-02-06 18:37:24 +02:00
Antti Kauppila 45aec0c900 Pre-cert fixes 2020-02-06 18:37:24 +02:00
Antti Kauppila 0c7f5684bb LoRaWAN: Moved keys to LoRaMacCrypto class
- Unittests updated to reflect LoRaWAN 1.1 changes
2020-02-06 18:37:24 +02:00
Antti Kauppila 27f26f2327 Auto merge problem fixed 2020-02-06 18:37:24 +02:00
Hasnain Virk 80f3b842d7 Bug fixing for Rejoins
* While starting timer for rejoin request type 0, we should multiply max
time with 1000 as the timer APIs take ms values as parameters.

* RJCountX are incremented every time a Rejoin request is sent. For MIC
calculation we need to take the previous RJCnt value in account.

* Rejoin process should start against an event otherwise it will meddle
with state machine and any ongoing traffic.

* If a Type 1 rejoin is ongoing, we should not trigger a Type 0 rejoin.

* Some bug fixes after Triage with Antti.
2020-02-06 18:37:24 +02:00
Hasnain Virk d8f7011c58 Changing precision in RX window calculation
Double precision may introduce unwanted results and it's impact is
massive on microcontrollers. So we change the precision from double to
float.
This change doesn't seem to enhance performance yet.
2020-02-06 18:37:24 +02:00
Hasnain Virk 341b5e1566 Managing Confirmed traffic based on NbTrans
In 1.1, NbTrans governs both unconfirmed and confirmed traffic.
We cannot set number of retries ourselves. Based upon NbTrans received
in linkADRReq command, we will retry. If NbTrans is 1, we will send only
one message and if ack is not received we will generate TX error event.
Its the NS now which controls how many retransmission a device can do
without incrementing Frame counter. When we fail with TX error after not
receiving an ack, we increment the frame counter. This is necessary as
the NS will drop anything with the  previous counter and it can happen
that the NS may have sent an ack but we didn't receive it.
2020-02-06 18:37:24 +02:00
Hasnain Virk 749b3d459c Adding resets in lieu to Section 6.2.3 of Spec 1.1
Rejoin requests and presence/absence of CFlist demand different
handling.
If a Rejoin request was sent we shall use RJCountX (0,1) instead of dev
nonce for key derivation.
If a Rejoin request is not of type 2, we reset mac, phy parameters
alongwith frame counters. However, if it is type 2, we reset frame
counters only.

If cflist i present, we shall always apply it as it is.
If it's not and rejoin type is not type 2, we restore default channels.
Otherwise the local channels do not change.
2020-02-06 18:37:24 +02:00
Hasnain Virk 475fe0b47f Implementing CR-FcntDwn-usage-in-FOpts-encryption
LoRaWAN specification 1.1.0 is incorrect in handling of FOpts encrytpion.
A CR was made by STMicroelectronics which correctly addresses the issue.
We have taken that CR and implemented in our code base.
2020-02-06 18:37:24 +02:00
Hasnain Virk ed93d7e026 Stopping multiple RX slot opening
Yet another rebase issue. RX processing was supposed to happen after
state setup and only once not twice.
2020-02-06 18:37:24 +02:00
Hasnain Virk 2dbbc84da4 RekeyInd mac command handling
RekeyInd Mac command was being handled incorrectly.
parse_mac_commnad_to_repeat() was missing handling for RekeyInd mac
command. Plus it is a sticky mac command as the spec says that it needs
to persist until we receive a RekeyConf mac command.
2020-02-06 18:37:24 +02:00
Hasnain Virk ce6733edc0 Removing incorrect context free
After deriving JSEncKey we were wrongly clearing the AES context.
We shouldn't clear the context until the function is done doing its job.
That was why JSINtKey derivation was wrong which would result in MIC
failures.
2020-02-06 18:37:24 +02:00
Hasnain Virk e490fbf991 Adding handling of packets with no fport field
Although we always add a port field for Uplink traffic, the spec allows
for fport field to be excluded. So there can be network server instances
which would exclude fport field from downlinks. We are now adding
handling for such situations.
2020-02-06 18:37:24 +02:00
Antti Kauppila 78a04ec77c 1.0.3 flag added and add_device_time_req updated to not support 1.0.2 2020-02-06 18:37:24 +02:00
Antti Kauppila cba835bbad set_tx_continuous_wave removed 2020-02-06 18:37:24 +02:00
Antti Kauppila 1fbeb58b85 Auto merge problems solved 2020-02-06 18:37:24 +02:00
Kimmo Vaisanen 09f3259d94 Enable RekeyInd again 2020-02-06 18:37:24 +02:00
Kimmo Vaisanen a8dbad926c Fix MIC calculation 2020-02-06 18:37:24 +02:00
Kimmo Vaisanen 6e60f2e161 MAC commands wip 2020-02-06 18:37:24 +02:00
Kimmo Vaisanen 88781d067c Fix uplink 2020-02-06 18:37:24 +02:00
Kimmo Vaisanen d48aae3692 Uplink (unstable) 2020-02-06 18:37:24 +02:00