LoRaMAC
4.5.2
Documentation of the API
|
This quick start guide provides a short introduction into important operations of the LoRaMAC layer. Full examples for the different device classes are available in the example section.
The initialization function of the LoRaMAC layer is LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks, LoRaMacRegion_t region ). The function has three parameters, LoRaMacPrimitives_t, LoRaMacCallback_t and LoRaMacRegion_t. The LoRaMAC layer utilizes primitives and callbacks, which must be provided by the upper layer. The data structure LoRaMacPrimitives_t contains function pointers to the Confirm and Indication primitives. The LoRaMAC layer will call the primitives to provide operation status information to the upper layers. The data structure LoRaMacCallback_t contains function pointers to procedures that should provide information for the LoRaMAC layer. E.g. the battery level of the device. The data type LoRaMacRegion_t specifies on which region the LoRaMAC layer shall operate.
The following code snippet provides an example for the initialization:
The LoRaMAC layer provides a MLME-Request to perform the over-the-air activation (LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest )). The LoRaMAC layer creates the join-request message and reports the status of the operation with the MacMlmeConfirm primitive. Please note that the credentials are stored in the file se-identity.h for the related secure element.
The following code snippet provides an example:
The activation by personalization procedure requires to store important information on the LoRaMAC node:
The application must configure those parameters to perform a personalized activation. In addition, the application has to enable the LoRaWAN network itself. Please note that the credentials are stored in the file se-identity.h for the related secure element.
The following code snippet provides an example:
The LoRaMAC Stack supports different regional setups. In general, it is possible to specify multiple regions such that it is possible to switch between them during runtime. A specific region can be enabled by defining the related symbol in the preprocessor options. E.g. to enable the EU868 region, please define REGION_EU868. If the LoRaMAC layer shall support more than one region at once, please define the corresponding symbol in addition.
The following symbols are supported:
When multiple regions are selected during the build of the LoRaWAN Stack, it is possible to switch the region during runtime. To perform a region switch it is necessary to initialize the LoRaWAN Stack with the function LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks, LoRaMacRegion_t region ) again. When the node performs a switch of the region, the LoRaWAN Stack will restore all default values.