Commit suite au Fuck-Up de Windows
This commit is contained in:
@@ -18,6 +18,7 @@ CLoraSettingsGui::SetSettings(CSettings *settings)
|
||||
{
|
||||
ui->mLoraAddressSpinBx->setValue(settings->mChaletLoraAddress);
|
||||
ui->mComportComboBox->setCurrentText(settings->mChaletComPort);
|
||||
ui->mUseLoraIFCheckBx->setChecked(settings->mChaletUseLoraIF);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -36,3 +37,8 @@ QString CLoraSettingsGui::GetChaletLoraComPort()
|
||||
{
|
||||
return ui->mComportComboBox->currentText();
|
||||
}
|
||||
|
||||
bool CLoraSettingsGui::GetChaletUseLoraIF()
|
||||
{
|
||||
return ui->mUseLoraIFCheckBx->isChecked();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
QString GetChaletLoraComPort();
|
||||
quint8 GetChaletLoraChannel();
|
||||
quint16 GetChaletLoraAddress();
|
||||
bool GetChaletUseLoraIF();
|
||||
|
||||
private:
|
||||
Ui::CLoraSettingsGui *ui;
|
||||
|
||||
@@ -188,6 +188,19 @@
|
||||
Chaloupe = 8</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mUseLoraIFCheckBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>160</y>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use LoraInterface (restart needed)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -235,6 +235,7 @@ void CSettingsWindow::DoneButtonClicked(bool checked)
|
||||
Settings->mChaletComPort = mLoraSettingsPage->GetChaletLoraComPort();
|
||||
Settings->mChaletLoraAddress = mLoraSettingsPage->GetChaletLoraAddress();
|
||||
Settings->mChaletLoraChannel = mLoraSettingsPage->GetChaletLoraChannel();
|
||||
Settings->mChaletUseLoraIF = mLoraSettingsPage->GetChaletUseLoraIF();
|
||||
|
||||
mProgramHandle->SaveSettings(Settings);
|
||||
mProgramHandle->SettingsWindowClosed();
|
||||
|
||||
@@ -21,12 +21,71 @@ CLoraModuleInterface::~CLoraModuleInterface()
|
||||
//This the handling of the Microcontroller (LoraModuleInterface)
|
||||
int CLoraModuleInterface::NewFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data)
|
||||
{
|
||||
switch(MessageID)
|
||||
{
|
||||
case LORA_IF_GET_STATUS_RESPONSE:
|
||||
{
|
||||
unsigned char model = Data.at(0);
|
||||
qDebug("LoraModuleInterface status received : %d",model);
|
||||
break;
|
||||
}
|
||||
case LORA_IF_SEND_FRAME_RESPONSE:
|
||||
{
|
||||
qDebug("LoraModuleInterface sent frame to end Lora device");
|
||||
break;
|
||||
}
|
||||
case LORA_IF_NEW_FRAME_RESPONSE: //LoraInterface received a message from the Lora end point (chalet for example). Let's decode it and send it to the destination device
|
||||
{
|
||||
CNetworkProtocol *mTempProtocol = new CNetworkProtocol; //Let's instanciate a temp protocol class to avoid messing with our own derived class...
|
||||
int FwdDeviceID;
|
||||
int FwdDeviceAddress;
|
||||
int FwdMessageID;
|
||||
int FwdDataSize;
|
||||
QByteArray FwdData;
|
||||
if(mTempProtocol->ProtocolAnalyseBufferStatically(Data,FwdDeviceID,FwdDeviceAddress,FwdMessageID,FwdDataSize,FwdData) == PROTOCOL_RET_OK_PACKET_COMPLETE)
|
||||
{
|
||||
mDevicePtr->NewDeviceFrameReceived(FwdDeviceID,FwdDeviceAddress,FwdMessageID,FwdDataSize,FwdData);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("LoraModuleInterface received an invalid packet from end Lora device in NewFrameReceived");
|
||||
}
|
||||
|
||||
delete mTempProtocol;
|
||||
break;
|
||||
}
|
||||
case LORA_IF_GET_MODULE_CONFIG_RESPONSE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORA_IF_GET_RSSI_RESPONSE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORA_IF_SET_MODULE_CONFIG_RESPONSE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORA_IF_GET_STATUS_REQUEST:
|
||||
case LORA_IF_SEND_FRAME_REQUEST:
|
||||
case LORA_IF_GET_MODULE_CONFIG_REQUEST:
|
||||
case LORA_IF_GET_RSSI_REQUEST:
|
||||
case LORA_IF_SET_MODULE_CONFIG_REQUEST:
|
||||
default:
|
||||
{
|
||||
qDebug("CLoraModuleInterface: Received invalid response from LoraModule: %d",MessageID);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
//This is to answer to CChaletDevice requests
|
||||
//This is the CAbstractNetworkCommIF class implementation (to answer to CChaletDevice requests).
|
||||
int CLoraModuleInterface::SendNetworkMessage(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray *Data)
|
||||
{
|
||||
qDebug("LoraInterfce: New frame received from MasterCtrl class");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -34,7 +93,9 @@ int CLoraModuleInterface::SendNetworkMessage(int DeviceID, int DeviceAddress, in
|
||||
|
||||
void CLoraModuleInterface::LoraModuleStatusTimerExpired()
|
||||
{
|
||||
|
||||
QByteArray Packet = GetTxPacket(LORA_IF_GET_STATUS_REQUEST,0,0,0,1,ID_LORA_INTERFACE);
|
||||
mLoraModuleIFSerialPort.write(Packet);
|
||||
mLoraModuleIFSerialPort.waitForBytesWritten(500);
|
||||
}
|
||||
|
||||
int CLoraModuleInterface::SetLoraModuleInterfaceParameters(QString ComPort, qint32 BaudRate)
|
||||
@@ -61,7 +122,7 @@ int CLoraModuleInterface::SetLoraModuleInterfaceParameters(QString ComPort, qint
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
qDebug("Lora serial port opened");
|
||||
qDebug("LoraModuleInterface serial port opened");
|
||||
return RET_OK;
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "NetworkDevice.h"
|
||||
#include <QTimer>
|
||||
#include <QSerialPort>
|
||||
#include <QByteArrayList>
|
||||
|
||||
class CLoraModuleInterface : public QObject, public CNetworkProtocol, public CAbstractNetworkCommIF
|
||||
{
|
||||
@@ -16,7 +17,7 @@ class CLoraModuleInterface : public QObject, public CNetworkProtocol, public CAb
|
||||
|
||||
public:
|
||||
CLoraModuleInterface();
|
||||
~CLoraModuleInterface();
|
||||
virtual ~CLoraModuleInterface();
|
||||
|
||||
int SetLoraModuleInterfaceParameters(QString ComPort,qint32 BaudRate);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int CLoraNetworkCommIF::SendLoraFrame(unsigned short DestAddress, unsigned char
|
||||
{
|
||||
|
||||
mLoraDeviceSerialPort.write(GetLoraFrame(DestAddress,DestChannel,Payload));
|
||||
mLoraDeviceSerialPort.write(Payload);
|
||||
// mLoraDeviceSerialPort.write(Payload);
|
||||
mLoraDeviceSerialPort.waitForBytesWritten(500);
|
||||
return RET_OK;
|
||||
|
||||
@@ -77,7 +77,7 @@ void CLoraNetworkCommIF::LoraDeviceNewDataReady()
|
||||
{
|
||||
QByteArray NewData = mLoraDeviceSerialPort.readAll();
|
||||
|
||||
// QString Printf = "New Lora Data: ";
|
||||
// QString Printf = "New Lora Data: ";
|
||||
|
||||
AnalyzeRxBuffer(NewData);
|
||||
|
||||
|
||||
+50
-15
@@ -7,6 +7,10 @@
|
||||
CMasterCtrl::CMasterCtrl()
|
||||
{
|
||||
qDebug("Creation...");
|
||||
|
||||
mChaletLoraModuleInterface = 0;
|
||||
mChaletLoraNetworkCommInterface = 0;
|
||||
|
||||
// mDeadBoltDevice = new CDeadboltDevice(1);
|
||||
mAVReceiverDevice = new CAVReceiverDevice();
|
||||
mVoipMsSMSClient = new CVoipMsSMSClient;
|
||||
@@ -15,12 +19,24 @@ CMasterCtrl::CMasterCtrl()
|
||||
mSettingsWindow = new CSettingsWindow();
|
||||
mSettingsWindow->mProgramHandle = this;
|
||||
|
||||
mSettingsManager.LoadSettings(&mMasterCtrlSettings);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(mMasterCtrlSettings.mChaletUseLoraIF == true)
|
||||
{
|
||||
mChaletLoraModuleInterface = new CLoraModuleInterface(); //JFM LoraInterface Dev
|
||||
mChaletLoraDevice = new CChaletLoraDevice(1,mChaletLoraModuleInterface); //JFM LoraInterface Dev
|
||||
}
|
||||
else
|
||||
{
|
||||
mChaletLoraNetworkCommInterface = new CLoraNetworkCommIF();//JFM LoraInterface Dev
|
||||
mChaletLoraDevice = new CChaletLoraDevice(1,mChaletLoraNetworkCommInterface);//JFM LoraInterface Dev
|
||||
}
|
||||
|
||||
// mChaletLoraNetworkCommInterface = new CLoraNetworkCommIF();//JFM LoraInterface Dev
|
||||
mChaletLoraModuleInterface = new CLoraModuleInterface();
|
||||
|
||||
// mChaletLoraDevice = new CChaletLoraDevice(1,mChaletLoraNetworkCommInterface);//JFM LoraInterface Dev
|
||||
mChaletLoraDevice = new CChaletLoraDevice(1,mChaletLoraModuleInterface);
|
||||
// mChaletLoraInterface = new CChaletLoraInterface(mRooftopTowerLoraDevice);
|
||||
|
||||
|
||||
@@ -45,8 +61,10 @@ CMasterCtrl::~CMasterCtrl()
|
||||
delete mEthernetNetworkServer;
|
||||
delete mContactsRepository;
|
||||
delete mSprinklerManager;
|
||||
//delete mChaletLoraNetworkCommInterface; //JFM LoraInterface Dev
|
||||
delete mChaletLoraModuleInterface;
|
||||
if(mChaletLoraNetworkCommInterface != 0)
|
||||
delete mChaletLoraNetworkCommInterface; //JFM LoraInterface Dev
|
||||
if(mChaletLoraModuleInterface != 0)
|
||||
delete mChaletLoraModuleInterface;
|
||||
delete mChaletLoraDevice;
|
||||
delete mIspindelDevice;
|
||||
// delete mMasterCtrlSettings;
|
||||
@@ -89,7 +107,7 @@ void CMasterCtrl::Start()
|
||||
connect(mVoipMsSMSClient,SIGNAL(DIDSFetched(QStringList)),mSettingsWindow,SLOT(DIDsListFetched(QStringList)));
|
||||
|
||||
|
||||
mSettingsManager.LoadSettings(&mMasterCtrlSettings);
|
||||
|
||||
mSettingsWindow->SetSettingsData(&mMasterCtrlSettings);
|
||||
mVoipMsSMSClient->SetVOIPMsSettings(&mMasterCtrlSettings.mVoipMSSettings);
|
||||
mVoipMsSMSClient->DownloadSMSFromServer();
|
||||
@@ -99,12 +117,21 @@ void CMasterCtrl::Start()
|
||||
|
||||
mAVReceiverDevice->Start();
|
||||
|
||||
/* //JFM LoraInterface Dev
|
||||
mChaletLoraNetworkCommInterface->mMyLoraAddress = 5;
|
||||
mChaletLoraNetworkCommInterface->mMyLoraChannel = 4;
|
||||
mChaletLoraNetworkCommInterface->SetLoraDestinationAddress(mMasterCtrlSettings.mChaletLoraAddress,mMasterCtrlSettings.mChaletLoraChannel);
|
||||
mChaletLoraNetworkCommInterface->SetLoraSerialPortSettings(mMasterCtrlSettings.mChaletComPort,QSerialPort::Baud9600);
|
||||
*/ //JFM LoraInterface Dev
|
||||
//JFM LoraInterface Dev
|
||||
if(mMasterCtrlSettings.mChaletUseLoraIF)
|
||||
{
|
||||
mChaletLoraModuleInterface->SetLoraModuleInterfaceParameters(mMasterCtrlSettings.mChaletComPort,QSerialPort::Baud9600);
|
||||
}
|
||||
else
|
||||
{
|
||||
mChaletLoraNetworkCommInterface->mMyLoraAddress = 5;
|
||||
mChaletLoraNetworkCommInterface->mMyLoraChannel = 4;
|
||||
mChaletLoraNetworkCommInterface->SetLoraDestinationAddress(mMasterCtrlSettings.mChaletLoraAddress,mMasterCtrlSettings.mChaletLoraChannel);
|
||||
mChaletLoraNetworkCommInterface->SetLoraSerialPortSettings(mMasterCtrlSettings.mChaletComPort,QSerialPort::Baud9600);
|
||||
}
|
||||
//JFM LoraInterface Dev
|
||||
|
||||
|
||||
|
||||
// mChaletLoraNetworkCommInterface->SetLoraSerialPortSettings("COM5",QSerialPort::Baud9600);
|
||||
mChaletLoraDevice->Start();
|
||||
@@ -152,8 +179,16 @@ unsigned int CMasterCtrl::SettingsWindowClosed()
|
||||
{
|
||||
mVoipMsSMSClient->SetVOIPMsSettings(&mMasterCtrlSettings.mVoipMSSettings);
|
||||
mVoipMsSMSClient->DownloadSMSFromServer();
|
||||
//mChaletLoraNetworkCommInterface->SetLoraDestinationAddress(mMasterCtrlSettings.mChaletLoraAddress,mMasterCtrlSettings.mChaletLoraChannel); //JFM LoraInterface Dev
|
||||
//mChaletLoraNetworkCommInterface->SetLoraSerialPortSettings(mMasterCtrlSettings.mChaletComPort,QSerialPort::Baud9600); //JFM LoraInterface Dev
|
||||
|
||||
if(mChaletLoraModuleInterface != 0)
|
||||
{
|
||||
mChaletLoraModuleInterface->SetLoraModuleInterfaceParameters(mMasterCtrlSettings.mChaletComPort,QSerialPort::Baud9600);
|
||||
}
|
||||
if(mChaletLoraNetworkCommInterface != 0)
|
||||
{
|
||||
mChaletLoraNetworkCommInterface->SetLoraDestinationAddress(mMasterCtrlSettings.mChaletLoraAddress,mMasterCtrlSettings.mChaletLoraChannel); //JFM LoraInterface Dev
|
||||
mChaletLoraNetworkCommInterface->SetLoraSerialPortSettings(mMasterCtrlSettings.mChaletComPort,QSerialPort::Baud9600); //JFM LoraInterface Dev
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
CChaletLoraDevice *mChaletLoraDevice;
|
||||
// CChaletLoraInterface *mChaletLoraInterface;
|
||||
// CLoraNetworkCommIF *mChaletLoraNetworkCommInterface;
|
||||
CLoraNetworkCommIF *mChaletLoraNetworkCommInterface;
|
||||
CLoraModuleInterface *mChaletLoraModuleInterface;
|
||||
// CAppIconWidget mAppWidget;
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ QByteArray CNetworkProtocol::GetTxPacket(unsigned char MessageID, unsigned char
|
||||
// }
|
||||
//}
|
||||
|
||||
int CNetworkProtocol::RxStateMachine(unsigned char Data)
|
||||
int CNetworkProtocol::RxStateMachine(unsigned char Data, bool DoStaticAnalysis)
|
||||
{
|
||||
int ret = PROTOCOL_RET_OK_PACKET_INCOMPLETE;
|
||||
|
||||
@@ -310,11 +310,14 @@ int CNetworkProtocol::RxStateMachine(unsigned char Data)
|
||||
}
|
||||
|
||||
// mDataBuffer = QByteArray(&mRxData[DATA_START],RxSize);
|
||||
NewFrameReceived(SenderID,SenderAddress,RxCmd,RxSize,mDataBuffer);
|
||||
ret = PROTOCOL_RET_OK_PACKET_COMPLETE;
|
||||
if(mIsResetManual == false)
|
||||
if(DoStaticAnalysis == false)
|
||||
{
|
||||
ResetRxStateMachine();
|
||||
NewFrameReceived(SenderID,SenderAddress,RxCmd,RxSize,mDataBuffer);
|
||||
if(mIsResetManual == false)
|
||||
{
|
||||
ResetRxStateMachine();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -360,7 +363,7 @@ int CNetworkProtocol::AnalyzeRxBuffer(QByteArray Buffer)
|
||||
{
|
||||
if(ret == PROTOCOL_RET_OK_BAD_HEADER)
|
||||
{
|
||||
qDebug("Protocol Bad header");
|
||||
// qDebug("Protocol Bad header");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -376,3 +379,47 @@ void CNetworkProtocol::SetManualPacketReset(bool Manual)
|
||||
{
|
||||
mIsResetManual = Manual;
|
||||
}
|
||||
|
||||
int CNetworkProtocol::ProtocolAnalyseBufferStatically(QByteArray InputBuffer, int &BufDeviceID, int &BufDeviceAddress, int &BufMessageID, int &BufDataSize, QByteArray &BufData)
|
||||
{
|
||||
int ret = PROTOCOL_RET_ERROR_EMPTY_BUFFER;
|
||||
for(int i = 0; i < InputBuffer.size(); i++)
|
||||
{
|
||||
ret = RxStateMachine(InputBuffer.at(i));
|
||||
if(ret != PROTOCOL_RET_OK_PACKET_INCOMPLETE)
|
||||
{
|
||||
if(ret == PROTOCOL_RET_OK_BAD_HEADER)
|
||||
{
|
||||
qDebug("Protocol Bad header");
|
||||
}
|
||||
if(ret == PROTOCOL_RET_OK_PACKET_COMPLETE)
|
||||
{
|
||||
BufDeviceID = SenderID;
|
||||
BufDeviceAddress = SenderAddress;
|
||||
BufMessageID = RxCmd;
|
||||
BufDataSize = RxSize;
|
||||
BufData = mDataBuffer;
|
||||
}
|
||||
|
||||
ResetRxStateMachine();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
ResetRxStateMachine();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CNetworkProtocol::ProtocolIsBusyReceiving()
|
||||
{
|
||||
if(RxState == RxHeader)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CNetworkProtocol::NewFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data)
|
||||
{
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void PrepareForNewPacket();
|
||||
void SetManualPacketReset(bool Manual);
|
||||
|
||||
virtual int NewFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data) = 0;
|
||||
virtual int NewFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);// = 0;
|
||||
|
||||
enum ProtocolRetValues
|
||||
{
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
int ProtocolGetCmd(){return RxCmd;}
|
||||
int ProtocolGetDataSize(){return RxSize;}
|
||||
QByteArray ProtocolGetData(){return mDataBuffer;}
|
||||
int ProtocolAnalyseBufferStatically(QByteArray InputBuffer, int &BufDeviceID, int &BufDeviceAddress, int &BufMessageID, int &BufDataSize, QByteArray &BufData);
|
||||
bool ProtocolIsBusyReceiving();
|
||||
|
||||
|
||||
private:
|
||||
@@ -44,7 +46,7 @@ private:
|
||||
unsigned char CalcCRC(char *Buffer, int Size);
|
||||
// int TxData(unsigned char MessageID,unsigned char Flags,unsigned char *Data,int Size, unsigned char Address,unsigned char ID);
|
||||
|
||||
int RxStateMachine(unsigned char Data);
|
||||
int RxStateMachine(unsigned char Data, bool DoStaticAnalysis = false);
|
||||
|
||||
//State Machine states
|
||||
enum States
|
||||
|
||||
@@ -54,6 +54,7 @@ void CProgramSettings::LoadDefaultSettings(CSettings *Settings)
|
||||
Settings->mChaletComPort = "COM3";
|
||||
Settings->mChaletLoraAddress = 6;
|
||||
Settings->mChaletLoraChannel = 4;
|
||||
Settings->mChaletUseLoraIF = true;
|
||||
}
|
||||
|
||||
unsigned int CProgramSettings::SaveSettings(CSettings *SettingsData)
|
||||
@@ -95,6 +96,7 @@ QDataStream &operator<<(QDataStream &out, const CSettings &source)
|
||||
out << source.mChaletComPort;
|
||||
out << source.mChaletLoraAddress;
|
||||
out << source.mChaletLoraChannel;
|
||||
out << source.mChaletUseLoraIF;
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -105,6 +107,7 @@ QDataStream &operator>>(QDataStream &in, CSettings &dest)
|
||||
in >> dest.mChaletComPort;
|
||||
in >> dest.mChaletLoraAddress;
|
||||
in >> dest.mChaletLoraChannel;
|
||||
in >> dest.mChaletUseLoraIF;
|
||||
|
||||
return in;
|
||||
}
|
||||
@@ -154,5 +157,6 @@ CSettings& CSettings::operator =(const CSettings &source)
|
||||
this->mChaletComPort = source.mChaletComPort;
|
||||
this->mChaletLoraAddress = source.mChaletLoraAddress;
|
||||
this->mChaletLoraChannel = source.mChaletLoraChannel;
|
||||
this->mChaletUseLoraIF = source.mChaletUseLoraIF;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
QString mChaletComPort;
|
||||
quint16 mChaletLoraAddress;
|
||||
quint8 mChaletLoraChannel;
|
||||
bool mChaletUseLoraIF;
|
||||
|
||||
|
||||
CSettings &operator=(const CSettings &source);
|
||||
|
||||
Reference in New Issue
Block a user