1.2 Host Interface Modem App

The Host Interface Modem App is an application example intended to be used when the Meters And More Stack is to be run in a separate device from the rest of the applications that run in another external device. This example includes a Serial Connection, so the Modem can be controlled from such external device.

The following table shows the available Host Interface Modem App projects:

Table 1-2. Host Interface Modem App projects
Bare-Metal / FreeRTOSPathBoards
Bare-Metalsmartenergy_metersandmore_apps\apps\modem_app\metersandmore_modem_hi\pic32cx_mtg_ek_pl460.XPIC32CXMTG-EK + PL460-EK
FreeRTOSsmartenergy_metersandmore_apps\apps\modem_app\metersandmore_modem_hi\pic32cx_mtg_ek_pl460_freertos.XPIC32CXMTG-EK + PL460-EK
Bare-Metalsmartenergy_metersandmore_apps\apps\modem_app\metersandmore_modem_hi\sam_d20_xpro_pl460.X SAMD20-XPRO+ PL460-EK
FreeRTOSsmartenergy_metersandmore_apps\apps\modem_app\metersandmore_modem_hi\sam_d20_xpro_pl460_freertos.X SAMD20-XPRO+ PL460-EK

The Host Interface Modem application offers a Serial Interface providing the modem with the capability to send and receive commands.

The chosen Serial Interface protocol has been taken from the one defined for Certification purposes in the Meters And More Alliance Certification Documents.

This protocol definition, which is named after Meters And More Host Interface, can be found in its own component documentation: onlinedocs.microchip.com/v2/keyword-lookup?keyword=MM_HostInterface_Description&redirect=true

The Host Interface Modem Application interfaces also with the AL component, which is the Meters And More Stack API to interact with the PLC protocol.

Documentation of AL component can be found here: onlinedocs.microchip.com/v2/keyword-lookup?keyword=MM_AL_Description&redirect=true

Application Functionality

The Host Interface Modem App functionality is very simple as almost all the duties are carried out by the Host Interface Component.

The MODEM_APP_Initialize function initializes the application’s State Machine and sets its role as Master or Slave:
void MODEM_APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    modem_appData.state = MODEM_APP_STATE_INIT;

#ifdef MASTER_NODE
    modem_appData.master = true;
#else
    modem_appData.master = false;
#endif
}
The MASTER_NODE macro is defined or commented in the modem_app.h file:
/* Define Modem App to act as Master Node or not (Slave) */
#define MASTER_NODE
After Initialization, the State Machine is in charge of setting the corresponding callbacks to AL and Host Interface layers:
MMHI_MacDataCallbackRegister(lMODEM_APP_MacDataReqCallback);
AL_DataIndicationCallbackRegister(lMODEM_APP_AL_DataIndication_callback);
AL_DataConfirmCallbackRegister(lMODEM_APP_AL_DataConfirm_callback);
AL_EventIndicationCallbackRegister(lMODEM_APP_AL_EventIndication_callback);
Then wait for AL to be ready:
if (AL_GetStatus() == SYS_STATUS_READY)
{
    modem_appData.state = MODEM_APP_STATE_WAITING;
}
And finally just wait for callbacks from AL or Host Interface layers.