1.2.2 How the Data Link Layer Module Works
Description
The Data Link Layer is the access point to the Meters And More Stack, if AL (App Layer) is not used.
- Module initialization
- Transmitting and Receiving frames
- Accessing Information Base (IB) to get/set configuration parameters
- State Machine maintenance
Module Initialization
First of all, module has to be initialized at System level by calling DLL_Initialize Function to get an object identifier of the DLL instance. As stated, this function is called at System level, and user does not need to take care of it.
The first step a user has to take when using DLL is to set the callback functions to receive events from DLL module, this is done be means of DLL_DataIndicationCallbackRegister Function, DLL_DataConfirmCallbackRegister Function and DLL_EventIndicationCallbackRegister Function, which take pointers to such callback handlers as parameter.
Before using the DLL module for data exchange, user has to ensure DLL is ready (i.e. has finished its initialization duties). This is done by means of DLL_GetStatus Function, which returns the internal Status of DLL module. When Status is equal to DLL_STATUS_READY, module is ready to be used.
Transmitting and Receiving frames
Data Transmission on Meters And More Network is done by means of the DLL_DataRequest Function, which expects its parameters in form of a structure defined in DLL_DATA_REQUEST_PARAMS Struct.
The result of requested transmission, is provided to upper layer by invoking DLL_DATA_CONFIRM_CALLBACK Typedef. Parameters include the result of transmission, and others explained on DLL_DATA_CONFIRM_PARAMS Struct.
Received frames are reported to upper layer by invoking DLL_DATA_IND_CALLBACK Typedef, along with reception parameters contained in DLL_DATA_IND_PARAMS Struct.
In case a frame cannot be delivered to final destination, due to a problem in the repetition path, the DLL_EVENT_IND_CALLBACK Typedef is invoked by the DLL, indicating the Address of the repeater in which the frame was lost (a timeout expired).
If the frame is not delivered to the next repeater (or destination if no repetition required), no event is generated, and it is application layer which has to set a timeout to detect such situation. As the DLL module has all the necessary data to calculate this timeout value, DLL offers the DLL_GetTxTimeout Function, which can be called by application after Data Request is called, to get the correct timeout value, so application does not need to perform calculations.
The application layer must set and manage these callbacks in order to receive frames and to capture the result of transmitted ones.
Accessing Information Base
Parameter Information Base (IB) is a set of parameters that can be accessed for reading and/or writing. They serve mainly 2 purposes: DLL layer configuration through IB writing, and information retrieval through IB reading.
The reading and writing of parameters are made by means of DLL_GetRequest Function and DLL_SetRequest Function primitives respectively.
These functions are synchronous, in the sense that they return the result of the Get/Set operation, and the read value (in case of Get operation) in one of the function parameters itself.
A list of available parameters and their description is provided on DLL_IB_ATTRIBUTE Enum definition.
State Machine maintenance
DLL State Machine is called periodically by System though the DLL_Tasks Function. As it is called at System level, user does not need to take care of maintaining DLL State Machine.
Every DLL process is done inside this state machine (except for IB access which is synchronous). Request Primitives trigger State Machine changes, and then internal processes trigger in turn the callbacks to report different events to DLL user.
