#ifndef LORAMODULEINTERFACE_H
#define LORAMODULEINTERFACE_H

#include <QByteArray>
#include <QObject>
#include <QSerialPort>
#include "NetworkProtocol.h"
#include "AbstractNetworkInterface.h"
#include "NetworkDevice.h"
#include <QTimer>
#include <QSerialPort>
#include <QByteArrayList>
#include "NetworkCommIFSurrogate.h"
#include "LoraModuleInterfaceData.h"


class CLoraModuleInterface : public QObject, public CNetworkProtocol, public CAbstractNetworkCommIF
{
    Q_OBJECT

public:
    CLoraModuleInterface();
    virtual ~CLoraModuleInterface();

    int SetLoraModuleInterfaceParameters(QString ComPort,qint32 BaudRate);
    int SetLoraDestinationAddress(quint16 Address, quint8 Channel);
    CLoraModuleInterfaceStatus GetModuleIFStatus() {return mLoraModuleStatus;}

    QTimer *mLoraModuleIFStatusTimer;
    QSerialPort mLoraModuleIFSerialPort;
    QString mLoraModuleIFComPortName;
    qint32 mLoraModuleIFComPortBaudRate;
    CNetworkCommIFSurrogate *mLoraDeviceCommSurrogate;
    unsigned short mDestLoraAddress;
    unsigned char mDestLoraChannel;
    QByteArray mLoraPreamble;

    CLoraModuleInterfaceStatus mLoraModuleStatus;



    //NetworkProtocol implementation
  virtual int NewFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);

  //NetworkCommIF implementation
  virtual int SendNetworkMessage(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray *Data);

public slots:
    void LoraModuleStatusTimerExpired();
    void NewLoraModuleIFDataReady();

    void LoraRemoteDeviceDataReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);
    void LoraRemoteDeviceReceiveError(CNetworkProtocol::ProtocolRetValues RetID);
};

#endif // LORAMODULEINTERFACE_H
