#include "LoraModuleInterfaceInterface.h"


CLoraModuleInterfaceInterface::CLoraModuleInterfaceInterface(int Address, CAbstractNetworkCommIF *NetworkInterface, CLoraModuleInterface *DevicePtr):
    CNetworkDevice(ID_LORA_INTERFACE_INTERFACE,Address,NetworkInterface)
{
    mLoraModuleIFPtr = DevicePtr;
}

int CLoraModuleInterfaceInterface::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data)
{
    Q_UNUSED(DeviceID)
    Q_UNUSED(DeviceAddress)
    Q_UNUSED(DataSize)
    Q_UNUSED(Data)

    switch(MessageID)
    {
        case LORA_MODULE_IF_INTERFACE_ACK:
        {
            break;
        }
        case LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_REQUEST:
        {
            QByteArray StatusData;
            QDataStream Strm(&StatusData,QIODevice::WriteOnly);
            Strm << mLoraModuleIFPtr->GetModuleIFStatus();
            mNetworkInterfacePtr->SendNetworkMessage(ID_LORA_INTERFACE_INTERFACE,mDeviceAddress,LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_RESPONSE,StatusData.size(),&StatusData);
            break;
        }
        case LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_RESPONSE:
        {
            qDebug("CLoraModuleInterfaceInterface : Received an invalid command from remote");
            break;
        }

    }
    return RET_OK;
}
