#ifndef CLORANETWORKCOMMIF_H
#define CLORANETWORKCOMMIF_H
#include <QByteArray>
#include <QObject>
#include <QSerialPort>
#include "NetworkProtocol.h"
#include "AbstractNetworkInterface.h"
#include "NetworkDevice.h"
#define LORA_MAGIC_WORD 0xBAADCAFE


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

public:
    CLoraNetworkCommIF();

    QString mLoraSerialPortName;
    qint32 mLoraSerialPortBaudRate;


    unsigned short mMyLoraAddress;
    unsigned char mMyLoraChannel;
    unsigned short mDestLoraAddress;
    unsigned char mDestLoraChannel;
    QSerialPort mLoraDeviceSerialPort;

    int SendLoraFrame(unsigned short DestAddress,unsigned char DestChannel,QByteArray Payload);
    int SetLoraSerialPortSettings(QString PortName, qint32 BaudRate);
    int SetLoraDestinationAddress(quint16 Address, quint8 Channel);

    //NetworkProtocol implementation
  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);

private:
    QByteArray GetLoraFrame(unsigned short DestAddress,unsigned char DestChannel,QByteArray Payload);
    qint32 mRxLoraTestMsgBuf;
    QByteArray mLoraMagicResponse;

public slots:
    void LoraDeviceNewDataReady();
};

#endif // CLORADEVICE_H
