With class B now being available the device class test moved to the LoRaMac class which then queries the Class B interface for support.
The Class B interface is not available here because the unit test stack class instantiates a LoRaMac stub class .
- Documented LoRaWANInterface beacon acquisition, and ping slot APIs
- Existing GPS time set/get documentation was only in LoRaWANStack.h, so I copied their docs to LoRaWANInterface and lightly modified them
to be a higher level description like the other documentation in this file.
- Updated set_utc_time to handle millisecond precision gps time.
Use close_rx_window callback to disable active class b window. This change protects against disabling the radio during class A transmit
Move class B resume notification to one location in LoRaMac::set_tx_ongoing()
- Added a bool return status to LoRaPHY::compute_*_win_params(...) methods. Currently, failed status returned if the rx slot type is invalid or rf frequency is invalid
- Updated Class B implementation to check return status
The Rx done/timeout event handler now checks if the radio is currently
transmitting before putting the radio to sleep. This test returns true in
class A rx window event handlers, so the radio is not not put to sleep.
Now to accurately test if transmitting, a mod ongoing flag is set true on send
and false on tx done/timeout.
Make class function names lower case. Previously, class b's public interface was part of the class and to avoid function name conflicts the static API was being distinguished from instance methods by upper-casing the first letter.
Fixed by moving the public interface to new LoRaMacClassBInterface
- 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
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.
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.
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.
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.
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'.
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.
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.