Ajout interface LoraModuleInterface
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include "ChaletGui.h"
|
||||
#include "ui_ChaletGui.h"
|
||||
#include "CChalet.h"
|
||||
#include "LoraModuleInterface.h"
|
||||
#include <QWidget>
|
||||
#include <QDate>
|
||||
#include "LoraModuleInterfaceData.h"
|
||||
|
||||
CChaletGui::CChaletGui(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -277,6 +279,23 @@ int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChaletGui::UpdateLoraModuleStatus(CLoraModuleInterfaceStatus Status)
|
||||
{
|
||||
if(ui->mLoraModuleCommActivityLbl->isEnabled())
|
||||
{
|
||||
ui->mLoraModuleCommActivityLbl->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mLoraModuleCommActivityLbl->setEnabled(true);
|
||||
}
|
||||
|
||||
QString ModuleStatusTxt = QString("Ambient RSSI: %1 [%3dBm]\nLast Rx RSSI: %2 [%4dBm]").arg(Status.mModuleAmbientRSSI).arg(Status.mModuleLastRxRSSI).arg(-1*(255-Status.mModuleAmbientRSSI)).arg(-1*(255-Status.mModuleLastRxRSSI));
|
||||
ui->mLoraIFModuleStatus->setText(ModuleStatusTxt);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChaletGui::UpdateChaletLogPlot(QByteArray *Log)
|
||||
{
|
||||
int NbRecords;
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <QHostAddress>
|
||||
|
||||
class CChalet;
|
||||
class CLoraModuleInterface;
|
||||
class CLoraModuleInterfaceStatus;
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class CChaletGui;
|
||||
@@ -21,9 +24,11 @@ public:
|
||||
~CChaletGui();
|
||||
|
||||
CChalet *mProgramHandle;
|
||||
CLoraModuleInterface *mLoraModuleIFProgramHandle;
|
||||
QCustomPlot *mBatteryPlotWidget;
|
||||
|
||||
int UpdateChaletStatus(CChaletMainStatus Status);
|
||||
int UpdateLoraModuleStatus(CLoraModuleInterfaceStatus Status);
|
||||
int UpdateChaletLogPlot(QByteArray* Log);
|
||||
int ChaletCommActivity();
|
||||
QTimer *mGetWifiParamsButtonColorTimer, *mGetFimwVersionButtonColorTimer;
|
||||
|
||||
@@ -691,13 +691,13 @@ Chalet --> Master: ??</string>
|
||||
<property name="title">
|
||||
<string>Lora module Interface</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mLoraIFModuleType">
|
||||
<widget class="QLabel" name="mLoraIFModuleStatus">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>131</width>
|
||||
<height>61</height>
|
||||
<width>231</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -757,6 +757,19 @@ Module state: ??</string>
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mLoraModuleCommActivityLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>390</x>
|
||||
<y>80</y>
|
||||
<width>47</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Activity!!!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<zorder>groupBox_2</zorder>
|
||||
<zorder>groupBox</zorder>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "LoraModuleIFMasterCtrlInterface.h"
|
||||
#include "LoraModuleInterface.h"
|
||||
#include "LoraModuleInterfaceData.h"
|
||||
|
||||
CLoraModuleIFMasterCtrlInterface::CLoraModuleIFMasterCtrlInterface(CLoraModuleInterface *ProgramHandle)
|
||||
{
|
||||
mMyDeviceID = ID_LORA_INTERFACE_INTERFACE;
|
||||
mNetworkPort = 2182;
|
||||
mMasterCtrlIPAddress = "127.0.0.1";
|
||||
mNetworkCommSocket = 0;
|
||||
mDeviceAddress = 1;
|
||||
|
||||
mProgramHandle = ProgramHandle;
|
||||
}
|
||||
|
||||
int CLoraModuleIFMasterCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data)
|
||||
{
|
||||
Q_UNUSED(DataSize)
|
||||
Q_UNUSED(SenderID)
|
||||
Q_UNUSED(SenderAddress)
|
||||
|
||||
|
||||
if(TargetDeviceID == mMyDeviceID && (TargetDeviceAddress == BROADCAST_VALUE || TargetDeviceAddress == mDeviceAddress))
|
||||
{
|
||||
switch(MessageID)
|
||||
{
|
||||
case LORA_MODULE_IF_INTERFACE_ACK:
|
||||
{
|
||||
qDebug("Chalet Interface ACK received");
|
||||
break;
|
||||
}
|
||||
case LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_RESPONSE:
|
||||
{
|
||||
// qDebug("Rx Lora Module IF status");
|
||||
CLoraModuleInterfaceStatus Status;
|
||||
QDataStream Strm(Data);
|
||||
Strm >> Status;
|
||||
mProgramHandle->NewLoraModuleStatusData(Status);
|
||||
break;
|
||||
}
|
||||
case LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_REQUEST:
|
||||
default:
|
||||
{
|
||||
qDebug("CLoraModuleIFMasterCtrlInterface: invalid command received");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
int CLoraModuleIFMasterCtrlInterface::DeviceConnectedToMaster(bool Connected)
|
||||
{
|
||||
if(Connected)
|
||||
{
|
||||
qDebug("LoraModuleIF Interface connected to Master.");
|
||||
mProgramHandle->ConnectedToMaster(Connected);
|
||||
|
||||
}
|
||||
else
|
||||
return RET_ERROR;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef LORAMODULEIFMASTERCTRLINTERFACE_H
|
||||
#define LORAMODULEIFMASTERCTRLINTERFACE_H
|
||||
|
||||
#include "MasterCtrlInterface.h"
|
||||
class CLoraModuleInterface;
|
||||
|
||||
class CLoraModuleIFMasterCtrlInterface: public CMasterCtrlInterface
|
||||
{
|
||||
public:
|
||||
CLoraModuleIFMasterCtrlInterface(CLoraModuleInterface *ProgramHandle);
|
||||
|
||||
int DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
|
||||
int DeviceConnectedToMaster(bool Connected = true);
|
||||
|
||||
private:
|
||||
CLoraModuleInterface *mProgramHandle;
|
||||
};
|
||||
|
||||
#endif // LORAMODULEIFMASTERCTRLINTERFACE_H
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "LoraModuleInterface.h"
|
||||
#include "LoraModuleIFMasterCtrlInterface.h"
|
||||
|
||||
CLoraModuleInterface::CLoraModuleInterface(CChaletGui *ChaletGuiPtr)
|
||||
{
|
||||
mChaletGui = ChaletGuiPtr;
|
||||
mChaletGui->mLoraModuleIFProgramHandle = this;
|
||||
mNetworkInterface = new CLoraModuleIFMasterCtrlInterface(this);
|
||||
|
||||
|
||||
mLoraModulePollTimer = new QTimer();
|
||||
mLoraModulePollTimer->setInterval(1000);
|
||||
mLoraModulePollTimer->setSingleShot(false);
|
||||
connect(mLoraModulePollTimer,&QTimer::timeout,this,&CLoraModuleInterface::LoraModulePollTimerExpired);
|
||||
}
|
||||
|
||||
int CLoraModuleInterface::ConnectedToMaster(bool connected)
|
||||
{
|
||||
if(connected)
|
||||
{
|
||||
mLoraModulePollTimer->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
mLoraModulePollTimer->stop();
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CLoraModuleInterface::Start()
|
||||
{
|
||||
mNetworkInterface->ConnectToMasterCtrl();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CLoraModuleInterface::LoraModulePollTimerExpired()
|
||||
{
|
||||
mNetworkInterface->SendMasterCtrlCommand(LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CLoraModuleInterface::NewLoraModuleStatusData(CLoraModuleInterfaceStatus Data)
|
||||
{
|
||||
mChaletGui->UpdateLoraModuleStatus(Data);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef LORAMODULEINTERFACE_H
|
||||
#define LORAMODULEINTERFACE_H
|
||||
|
||||
#include "ChaletGui.h"
|
||||
#include <QTimer>
|
||||
#include "LoraModuleInterfaceData.h"
|
||||
|
||||
|
||||
class CLoraModuleIFMasterCtrlInterface;
|
||||
|
||||
class CLoraModuleInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CLoraModuleInterface(CChaletGui *ChaletGuiPtr);
|
||||
int Start();
|
||||
|
||||
int ConnectedToMaster(bool connected);
|
||||
int NewLoraModuleStatusData(CLoraModuleInterfaceStatus Data);
|
||||
|
||||
CLoraModuleIFMasterCtrlInterface *mNetworkInterface;
|
||||
CChaletGui *mChaletGui;
|
||||
QTimer *mLoraModulePollTimer;
|
||||
|
||||
public slots:
|
||||
void LoraModulePollTimerExpired();
|
||||
};
|
||||
|
||||
#endif // LORAMODULEINTERFACE_H
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "LoraModuleInterfaceData.h"
|
||||
|
||||
CLoraModuleInterfaceStatus::CLoraModuleInterfaceStatus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CLoraModuleInterfaceStatus& CLoraModuleInterfaceStatus::operator = (const CLoraModuleInterfaceStatus &rhs)
|
||||
{
|
||||
if(this == &rhs)
|
||||
return *this;
|
||||
|
||||
mModuleModel = rhs.mModuleModel;
|
||||
mModuleInternalAddress = rhs.mModuleInternalAddress;
|
||||
mModuleUARTParity = rhs.mModuleUARTParity;
|
||||
mModuleUARTRate = rhs.mModuleUARTRate;
|
||||
mModuleAirRate = rhs.mModuleAirRate;
|
||||
mModuleSubPacket = rhs.mModuleSubPacket;
|
||||
mModuleRSSIEnabled = rhs.mModuleRSSIEnabled;
|
||||
mModuleTxPower = rhs.mModuleTxPower;
|
||||
mModuleInternalChannel = rhs.mModuleInternalChannel;
|
||||
mModuleRSSIByteEnabled = rhs.mModuleRSSIByteEnabled;
|
||||
mModuleTxMethod = rhs.mModuleTxMethod;
|
||||
mModuleLBTEnabled = rhs.mModuleLBTEnabled;
|
||||
mModuleWORCycle = rhs.mModuleWORCycle;
|
||||
mModuleAmbientRSSI = rhs.mModuleAmbientRSSI;
|
||||
mModuleLastRxRSSI = rhs.mModuleLastRxRSSI;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CLoraModuleInterfaceStatus &source)
|
||||
{
|
||||
out << source.mModuleModel
|
||||
<< source.mModuleInternalAddress
|
||||
<< source.mModuleUARTParity
|
||||
<< source.mModuleUARTRate
|
||||
<< source.mModuleAirRate
|
||||
<< source.mModuleSubPacket
|
||||
<< source.mModuleRSSIEnabled
|
||||
<< source.mModuleTxPower
|
||||
<< source.mModuleInternalChannel
|
||||
<< source.mModuleRSSIByteEnabled
|
||||
<< source.mModuleTxMethod
|
||||
<< source.mModuleLBTEnabled
|
||||
<< source.mModuleWORCycle
|
||||
<< source.mModuleAmbientRSSI
|
||||
<< source.mModuleLastRxRSSI;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CLoraModuleInterfaceStatus &dest)
|
||||
{
|
||||
in >> dest.mModuleModel
|
||||
>> dest.mModuleInternalAddress
|
||||
>> dest.mModuleUARTParity
|
||||
>> dest.mModuleUARTRate
|
||||
>> dest.mModuleAirRate
|
||||
>> dest.mModuleSubPacket
|
||||
>> dest.mModuleRSSIEnabled
|
||||
>> dest.mModuleTxPower
|
||||
>> dest.mModuleInternalChannel
|
||||
>> dest.mModuleRSSIByteEnabled
|
||||
>> dest.mModuleTxMethod
|
||||
>> dest.mModuleLBTEnabled
|
||||
>> dest.mModuleWORCycle
|
||||
>> dest.mModuleAmbientRSSI
|
||||
>> dest.mModuleLastRxRSSI;
|
||||
|
||||
|
||||
return in;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
#ifndef LORAMODULEINTERFACEDATA_H
|
||||
#define LORAMODULEINTERFACEDATA_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDataStream>
|
||||
|
||||
class CLoraModuleInterfaceStatus
|
||||
{
|
||||
public:
|
||||
|
||||
enum eE220UartRates
|
||||
{
|
||||
E220_UART_1200 = 0,
|
||||
E220_UART_2400,
|
||||
E220_UART_4800,
|
||||
E220_UART_9600,
|
||||
E220_UART_19200,
|
||||
E220_UART_38400,
|
||||
E220_UART_57600,
|
||||
E220_UART_115200
|
||||
|
||||
};
|
||||
|
||||
|
||||
enum eE220ParityBit
|
||||
{
|
||||
E220_UART_8N1=0,
|
||||
E220_UART_8O1,
|
||||
E220_UART_8E1,
|
||||
E220_UART_8N1_bis
|
||||
};
|
||||
|
||||
|
||||
enum e220AirDataRates
|
||||
{
|
||||
E220_AIR_RATE_24K = 0,
|
||||
E220_AIR_RATE_24K_1,
|
||||
E220_AIR_RATE_24K_2,
|
||||
E220_AIR_RATE_48K,
|
||||
E220_AIR_RATE_96K,
|
||||
E220_AIR_RATE_192K,
|
||||
E220_AIR_RATE_384K,
|
||||
E220_AIR_RATE_625K
|
||||
};
|
||||
|
||||
|
||||
enum e220PacketSizes
|
||||
{
|
||||
E220_PACKET_200,
|
||||
E220_PACKET_128,
|
||||
E220_PACKET_64,
|
||||
E220_PACKET_32
|
||||
};
|
||||
|
||||
|
||||
enum e220TransmitPower
|
||||
{
|
||||
E220_TX_PWR_30,
|
||||
E220_TX_PWR_27,
|
||||
E220_TX_PWR_24,
|
||||
E220_TX_PWR_21
|
||||
};
|
||||
|
||||
|
||||
enum e220WORCycles
|
||||
{
|
||||
E220_WOR_500MS,
|
||||
E220_WOR_1000MS,
|
||||
E220_WOR_1500MS,
|
||||
E220_WOR_2000MS,
|
||||
E220_WOR_2500MS,
|
||||
E220_WOR_3000MS,
|
||||
E220_WOR_3500MS,
|
||||
E220_WOR_4000MS
|
||||
};
|
||||
|
||||
|
||||
|
||||
CLoraModuleInterfaceStatus();
|
||||
|
||||
quint8 mModuleModel;
|
||||
quint16 mModuleInternalAddress;
|
||||
quint8 mModuleUARTParity;
|
||||
quint8 mModuleUARTRate;
|
||||
quint8 mModuleAirRate;
|
||||
quint8 mModuleSubPacket;
|
||||
quint8 mModuleRSSIEnabled;
|
||||
quint8 mModuleTxPower;
|
||||
quint8 mModuleInternalChannel;
|
||||
quint8 mModuleRSSIByteEnabled;
|
||||
quint8 mModuleTxMethod;
|
||||
quint8 mModuleLBTEnabled;
|
||||
quint8 mModuleWORCycle;
|
||||
|
||||
quint8 mModuleAmbientRSSI;
|
||||
quint8 mModuleLastRxRSSI;
|
||||
|
||||
CLoraModuleInterfaceStatus& operator=(const CLoraModuleInterfaceStatus &rhs);
|
||||
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CLoraModuleInterfaceStatus &source);
|
||||
QDataStream &operator>>(QDataStream &in, CLoraModuleInterfaceStatus &dest);
|
||||
|
||||
#endif // LORAMODULEINTERFACEDATA_H
|
||||
@@ -62,7 +62,7 @@ int CMasterCtrlInterface::NewFrameReceived(int TargetDeviceID, int TargetDeviceA
|
||||
}
|
||||
case ETH_NETWK_CONNECTION_REFUSED:
|
||||
{
|
||||
qDebug("MasterCtrl connection refused");
|
||||
qDebug("MasterCtrl connection refused for device ID: %d, address: %d",TargetDeviceID,TargetDeviceAddress);
|
||||
mNetworkCommSocket->close();
|
||||
delete mNetworkCommSocket;
|
||||
mNetworkCommSocket = 0;
|
||||
|
||||
+17
-1
@@ -61,9 +61,12 @@ enum DEVICES_IDS
|
||||
ID_CHALET_INTERFACE,
|
||||
ID_CHALET_DEVICE,
|
||||
ID_ISPINDEL_INTERFACE,
|
||||
ID_LORA_INTERFACE_DEVICE,
|
||||
ID_LORA_INTERFACE_INTERFACE,
|
||||
ID_NB_DEVICE_ID
|
||||
|
||||
};
|
||||
|
||||
// Commands definitions
|
||||
|
||||
enum MASTER_CMD
|
||||
@@ -288,6 +291,7 @@ enum CHALET_INTERFACE_CMDS
|
||||
CHALET_INTERFACE_GET_WIFI_STATUS_RESPONSE,
|
||||
|
||||
|
||||
|
||||
MAX_CHALET_INTERFACE_CMD
|
||||
};
|
||||
|
||||
@@ -314,8 +318,10 @@ enum CHALET_CMDS
|
||||
CHALET_REBOOT_CPU_RESPONSE,
|
||||
CHALET_GET_STORED_WIFI_SETTINGS_REQUEST, //14
|
||||
CHALET_GET_STORED_WIFI_SETTINGS_RESPONSE,
|
||||
CHALET_SET_STORED_WIFI_SETTINGS_REQUEST,
|
||||
CHALET_SET_STORED_WIFI_SETTINGS_REQUEST, //
|
||||
CHALET_SET_STORED_WIFI_SETTINGS_RESPONSE,
|
||||
CHALET_GET_FIRMWARE_VERSION_REQUEST,
|
||||
CHALET_GET_FIRMWARE_VERSION_RESPONSE,
|
||||
CHALET_CLEAR_COMMS_STATISTICS_REQUEST,
|
||||
CHALET_CLEAR_COMMS_STATISTICS_RESPONSE,
|
||||
|
||||
@@ -388,4 +394,14 @@ enum LORA_INTERFACE_CMDS
|
||||
MAX_LORA_IF_CMD
|
||||
};
|
||||
|
||||
enum LORA_MODULE_IF_INTERFACE_CMDS
|
||||
{
|
||||
LORA_MODULE_IF_INTERFACE_ACK = 1,
|
||||
LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_REQUEST,
|
||||
LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_RESPONSE,
|
||||
|
||||
|
||||
MAX_LORA_MODULE_IF_INTERFACE_CMD
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,11 +11,14 @@ CSystemGui::CSystemGui(QObject *parent) : QObject(parent)
|
||||
mChalet = new CChalet(mGui->mChaletGui);
|
||||
mPICUploader = new CPICUploader(mGui->mPICUploaderGui);
|
||||
mIspindel = new CIspindel(mGui->mIspindelGui);
|
||||
mLoraModuleIF = new CLoraModuleInterface(mGui->mChaletGui);
|
||||
|
||||
mSysTrayMgr = new CSystemTrayManager();
|
||||
mSysTrayMgr->mProgramHandle=this;
|
||||
mSMSClient->mTrayIconMgr = mSysTrayMgr;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
CSystemGui::~CSystemGui()
|
||||
@@ -28,6 +31,7 @@ CSystemGui::~CSystemGui()
|
||||
delete mChalet;
|
||||
delete mPICUploader;
|
||||
delete mIspindel;
|
||||
delete mLoraModuleIF;
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +44,7 @@ void CSystemGui::Start()
|
||||
mChalet->Start();
|
||||
mPICUploader->Start();
|
||||
mIspindel->Start();
|
||||
mLoraModuleIF->Start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "CChalet.h"
|
||||
#include "PICUploader.h"
|
||||
#include "Ispindel.h"
|
||||
#include "LoraModuleInterface.h"
|
||||
|
||||
|
||||
class CSystemGui : public QObject
|
||||
@@ -39,6 +40,7 @@ private:
|
||||
CChalet *mChalet;
|
||||
CPICUploader *mPICUploader;
|
||||
CIspindel *mIspindel;
|
||||
CLoraModuleInterface *mLoraModuleIF;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user