L2A interface functions#
Lab.SCHC FullSDK provides a reference implementation of the L2A layer based on LoRaWAN technology.
The targets of the L2A reference implementation is currently the ST NUCLEO-L476RG microcontroller board, with either the SX1276MB1MAS or SX1272MB2xAS LoRaWAN shields and running the Semtech LoRa stack, in classes A or C. Class B is not supported.
The header file for the L2A interface is fullsdkl2a.h
.
The layer-two adaptation interface (also called L2A) is required to bind the lab.SCHC FullSDK with the L2 stack (LoRa, etc).
Integration#
The L2A layer is usually provided by the integrator who has to implement the
list of functions available in the fullsdkl2a.h
header file.
Note that these functions are only called by the lab.SCHC FullSDK and must not be called directly from the application code.
Initialization#
When the application calls the mgt_initialize()
function (initialization by
the Management interface), the l2a_initialize()
function is implicitly called
by lab.SCHC FullSDK.
This function can be used by the integrator to initialize the L2 stack and to store the callback functions provided as parameters:
l2a_processing_required
: To be called by the integrator to inform the lab.SCHC FullSDK when an asynchronous task needs to be handled by the layer. Seel2a_process()
function below for more details.l2a_transmission_result
: To be called by the integrator to inform the lab.SCHC FullSDK when the uplink packet has been transmitted (with or without success) by the L2 stack.l2a_data_received
: To be called by the integrator to inform the lab.SCHC FullSDK when a downlink packet is received from the L2 stack.l2a_connectivity_lost
: To be called by the integrator to inform the lab.SCHC FullSDK when the L2 connectivity is lost.l2a_connectivity_available
: To be called by the integrator to inform the lab.SCHC FullSDK when the L2 connectivity is available. For example, in LoRa, it corresponds to the Join Accept reception.
l2a_initialize()
returns a status code indicating whether the initialization
is successful or not.
L2 Technology#
Lab.SCHC FullSDK calls the l2a_get_technology()
function to get information on
the L2 stack used by the integrator.
The following technology profiles are supported:
Technology Profile | Description |
---|---|
L2A_DEFAULT |
Recommended technology profile for LoRa with class C |
L2A_DEFAULT_CLASS_A |
Recommended technology profile for LoRa with class A |
L2A_LORA |
Technology profile described in RFC 9011 |
L2A_SIGFOX |
Technology profile for Sigfox |
Transmission#
Lab.SCHC FullSDK calls the l2a_send_data()
function to transmit a packet to
the L2 stack. This function requires two parameters:
- The buffer containing the packet to be transmitted
- The size of the packet
The integrator should handle the transmission of the packet to the L2 stack. When the size of the packet is set to 1 and the value is 0x00 in hexadecimal, the integrator must send an empty frame (see Polling in the Management interface functions).
MTU Size#
Lab.SCHC FullSDK calls the l2a_get_mtu()
function to get information on the
maximum packet size (in bytes) that can be transmitted by the L2 stack.
Lab.SCHC FullSDK calls this function from time to time because the MTU may change. For example, with a LoRa L2 stack, the MTU may change when ADR is enabled according to the radio conditions. It is up to the integrator to retrieve this value from the L2 stack.
Device IID#
Lab.SCHC FullSDK calls the l2a_get_dev_iid()
function when the IPv6 address of
the device is derived from L2 stack information.
It is used for LoRaWAN technology and can be implemented according to the formula referenced in RFC 9011 (section 5.3).
For other technologies, it must be returned false.
Next Transmission Delay#
Lab.SCHC FullSDK calls the l2a_get_next_tx_delay()
function to get information
on the next uplink transmission slot (in ms) according to the L2 stack type and
its configuration.
The next uplink packet transmitted by Lab.SCHC FullSDK using l2a_send_data()
(see above) will be based on this delay.
For example, with a LoRa L2 stack, there is duty cycle limitation to follow before emitting over the radio.
L2 Processing#
Lab.SCHC FullSDK calls the l2a_process()
function every time
l2a_processing_required
callback (see above) is called by the integrator.
This function is used to handle asynchronous events received from the L2 stack.
Call the following callbacks inside l2a_process()
:
| Direction | Callback | Description | | Uplink | l2a_transmission_result
|
When the event corresponding to the end of the transmission of an uplink packet
is received from the L2 stack. | | Downlink | l2a_data_received
| When the
event corresponding to the reception of a downlink packet is received from the
L2 stack. |
Handle in the same way any other asynchronous event (timer, etc.) that might need to be implemented by the integrator and can be processed here.