Ajouté console audio + chalet dev LTE

This commit is contained in:
2025-07-10 18:11:27 -04:00
parent bf31303763
commit b56ee96941
16 changed files with 577 additions and 16 deletions
+74
View File
@@ -400,6 +400,24 @@ QByteArray CAVReceiverDevice::GetReceiverStatus()
return StatusArray;
}
QByteArray CAVReceiverDevice::GetReceiverStatusForConsole()
{
QByteArray StatusArray;
StatusArray = mReceiverStatus.ToConsoleStatusByteArray();
StatusArray.append(mZone2Status.ToConsoleStatusByteArray());
if(mReceiverStatus.mSyncZonesVolumes == true &&
( (mReceiverStatus.mMainVolume != mLastMainZoneVolume) ||
(mReceiverStatus.mMainVolume != mZone2Status.mMainVolume)))
{
SetZone2Volume(mReceiverStatus.mMainVolume);
}
mLastMainZoneVolume = mReceiverStatus.mMainVolume;
return StatusArray;
}
int CAVReceiverDevice::SelectScene(char Zone, char Scene)
{
QString Cmd;
@@ -469,4 +487,60 @@ int CAVReceiverDevice::SetSyncZ2withZ1(bool Sync)
SetZone2Volume(mReceiverStatus.mMainVolume);
}
// qDebug("Sync Z2 with Z1: %d",Sync);
return RET_OK;
}
int CAVReceiverDevice::IncrementMainVolume(bool Increment)
{
float NewVolume = mReceiverStatus.mMainVolume;
if(Increment)
{
if(NewVolume >= RECEIVER_MAXIMUM_VOLUME)
{
return RET_OK;
}
NewVolume += RECEIVER_VOLUME_INCREMENT_STEP;
SetMainVolume(NewVolume);
}
else
{
if((NewVolume - RECEIVER_VOLUME_INCREMENT_STEP) < RECEIVER_MINIMUM_VOLUME)
{
return RET_OK;
}
NewVolume -= RECEIVER_VOLUME_INCREMENT_STEP;
SetMainVolume(NewVolume);
}
mReceiverStatus.mMainVolume = NewVolume;
return RET_OK;
}
int CAVReceiverDevice::IncrementZ2Volume(bool Increment)
{
float NewVolume = mZone2Status.mMainVolume;
if(Increment)
{
if(NewVolume >= RECEIVER_MAXIMUM_VOLUME)
{
return RET_OK;
}
NewVolume += RECEIVER_VOLUME_INCREMENT_STEP;
SetZone2Volume(NewVolume);
}
else
{
if((NewVolume - RECEIVER_VOLUME_INCREMENT_STEP) < RECEIVER_MINIMUM_VOLUME)
{
return RET_OK;
}
NewVolume -= RECEIVER_VOLUME_INCREMENT_STEP;
SetZone2Volume(NewVolume);
}
mZone2Status.mMainVolume = NewVolume;
return RET_OK;
}
+6
View File
@@ -11,6 +11,9 @@
#define RECEIVER_PORT 50000
#define RECEIVER_IP_ADDRESS "192.168.50.101"
#define RECEIVER_STATE_UPDATE_TIMEOUT 3000
#define RECEIVER_MINIMUM_VOLUME -80.5
#define RECEIVER_MAXIMUM_VOLUME 16.5
#define RECEIVER_VOLUME_INCREMENT_STEP 0.5
enum eReceiverSpkStatus
{
@@ -89,7 +92,10 @@ public:
int SetZone2Volume(float Volume);
int SetZone2Input(QString InputString);
int SetSyncZ2withZ1(bool Sync);
int IncrementMainVolume(bool Increment);
int IncrementZ2Volume(bool Increment);
QByteArray GetReceiverStatus();
QByteArray GetReceiverStatusForConsole();
private:
QTcpSocket *mReceiverSocket;
@@ -0,0 +1,132 @@
#include "AvReceiverConsoleInterface.h"
#include "ProtocolDefs.h"
#include "AVReceiverDevice.h"
#include <QDataStream>
CAvReceiverConsoleInterface::CAvReceiverConsoleInterface(int Address, CAbstractNetworkCommIF *NetworkInterface , CAVReceiverDevice *DevicePtr):
CNetworkDevice(ID_AVRECEIVER_INTERFACE,Address,NetworkInterface)
{
mAvReceiverDevice = DevicePtr;
}
int CAvReceiverConsoleInterface::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 AV_RECEIVER_INTERFACE_ACK:
{
break;
}
case AV_RECEIVER_INTERFACE_GENERAL_STATUS_REQUEST:
{
QByteArray data = mAvReceiverDevice->GetReceiverStatusForConsole();
mNetworkInterfacePtr->SendNetworkMessage(ID_AVRECEIVER_CONSOLE_INTERFACE,mDeviceAddress,AV_RECEIVER_INTERFACE_GENERAL_STATUS_RESPONSE,data.size(),&data);
break;
}
case AV_RECEIVER_INTERFACE_SET_MAIN_POWER_REQUEST:
{
bool SpkStatus = (bool)Data[0];
mAvReceiverDevice->SetMainZone(SpkStatus);
break;
}
case AV_RECEIVER_INTERFACE_SET_ZONE2_REQUEST:
{
bool SpkStatus = (bool)Data[0];
mAvReceiverDevice->SetZone2(SpkStatus);
break;
}
case AV_RECEIVER_INTERFACE_SET_MAIN_ZONE_REQUEST:
{
bool SpkStatus = (bool)Data[0];
mAvReceiverDevice->SetMainZone(SpkStatus);
break;
}
case AV_RECEIVER_INTERFACE_SET_SPEAKERS_REQUEST:
{
break;
}
case AV_RECEIVER_INTERFACE_SEND_DIRECT_CMD_REQUEST:
{
break;
}
case AV_RECEIVER_INTERFACE_SELECT_SCENE_REQUEST:
{
mAvReceiverDevice->SelectScene(Data[0],Data[1]);
break;
}
case AV_RECEIVER_INTERFACE_SET_MAIN_VOLUME_REQUEST:
{
char VolumeData;
VolumeData = Data[0];
float Volume = (VolumeData/2) - 80.5;
mAvReceiverDevice->SetMainVolume(Volume);
break;
}
case AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_REQUEST:
{
char VolumeData;
VolumeData = Data[0];
float Volume = (VolumeData/2) - 80.5;
qDebug("Volume 2 %d, %f",VolumeData, Volume);
mAvReceiverDevice->SetZone2Volume(Volume);
break;
}
case AV_RECEIVER_INTERFACE_SET_ZONE2_INPUT_REQUEST:
{
QString Source(Data);
mAvReceiverDevice->SetZone2Input(Source);
break;
}
case AV_RECEIVER_INTERFACE_SET_SYNC_Z2_WITH_Z1_REQUEST:
{
bool Sync = (bool)Data[0];
mAvReceiverDevice->SetSyncZ2withZ1(Sync);
break;
}
case AV_RECEIVER_INTERFACE_INCREMENT_MAIN_VOLUME_REQUEST:
{
bool Increment = (bool)Data[0];
mAvReceiverDevice->IncrementMainVolume(Increment);
break;
}
case AV_RECEIVER_INTERFACE_INCREMENT_Z2_VOLUME_REQUEST:
{
bool Increment = (bool)Data[0];
mAvReceiverDevice->IncrementZ2Volume(Increment);
break;
}
case AV_RECEIVER_INTERFACE_GENERAL_STATUS_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_MAIN_POWER_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_ZONE2_RESPONSE:
case AV_RECEIVER_INTERFACE_SEND_DIRECT_CMD_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_SPEAKERS_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_MAIN_ZONE_RESPONSE:
case AV_RECEIVER_INTERFACE_SELECT_SCENE_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_MAIN_VOLUME_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_ZONE2_INPUT_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_SYNC_Z2_WITH_Z1_RESPONSE:
default:
{
qDebug("Received invalid msg from Sprinkler Interface");
break;
}
}
return 0;
}
@@ -0,0 +1,19 @@
#ifndef AVRECEIVERCONSOLEINTERFACE_H
#define AVRECEIVERCONSOLEINTERFACE_H
#include "NetworkDevice.h"
class CAVReceiverDevice;
class CAvReceiverConsoleInterface: public QObject, public CNetworkDevice
{
Q_OBJECT
public:
CAvReceiverConsoleInterface(int Address, CAbstractNetworkCommIF *NetworkInterface, CAVReceiverDevice *DevicePtr );
virtual int NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);
private:
CAVReceiverDevice *mAvReceiverDevice;
};
#endif // AVRECEIVERCONSOLEINTERFACE_H
+117 -11
View File
@@ -13,21 +13,67 @@ QByteArray CAvReceiverMainStatus::ToByteArray()
QByteArray Output;
Output.clear();
QDataStream Strm(&Output,QIODevice::WriteOnly);
// QDataStream Strm(&Output,QIODevice::WriteOnly);
Strm << mMainPwrStatus;
Strm << mMainSleepStatus;
Strm << mMainVolume;
Strm << mIsMute;
Strm << mInput;
Strm << mProgram;
//// Strm << mMainPwrStatus;
//// Strm << mMainSleepStatus;
//// Strm << mMainVolume;
//// Strm << mIsMute;
//// Strm << mInput;
//// Strm << mProgram;
Strm << mDataValid;
Strm << mReceiverOnline;
Strm << mSyncZonesVolumes;
//// Strm << mDataValid;
//// Strm << mReceiverOnline;
//// Strm << mSyncZonesVolumes;
}
QByteArray CAvReceiverMainStatus::ToConsoleStatusByteArray()
{
QByteArray Output;
if(mMainPwrStatus == true) //0
Output.append(0x01);
else
Output.append((char)0x00);
if(mMainSleepStatus == true) //1
Output.append(0x01);
else
Output.append((char)0x00);
// int Volume = ((mMainVolume + 80.5) * 2);
// char VolArray[4];
// memcpy(VolArray,&Volume,4); //2-5
// Output.append(VolArray,4);
char Volume = ((mMainVolume + 80.5) * 2); //2
Output.append(Volume);
if(mIsMute == true) //3
Output.append(0x01);
else
Output.append((char)0x00);
if(mDataValid == true) //4
Output.append(0x01);
else
Output.append((char)0x00);
if(mReceiverOnline == true) //5
Output.append(0x01);
else
Output.append((char)0x00);
if(mSyncZonesVolumes == true) //6
Output.append(0x01);
else
Output.append((char)0x00);
return Output;
}
int CAvReceiverMainStatus::FromByteArray(QByteArray Data)
@@ -46,9 +92,69 @@ int CAvReceiverMainStatus::FromByteArray(QByteArray Data)
Strm >> mReceiverOnline;
Strm >> mSyncZonesVolumes;
return RET_OK;
}
int CAvReceiverMainStatus::FromConsoleStatusByteArray(QByteArray Data)
{
if(Data.at(0) == 1)
mMainPwrStatus = true;
else
mMainPwrStatus = false;
if(Data.at(1) == 1)
mMainSleepStatus = true;
else
mMainSleepStatus = false;
char VolArray[4];
VolArray[0] = Data[2];
VolArray[1] = Data[3];
VolArray[2] = Data[4];
VolArray[3] = Data[5];
memcpy(&mMainVolume,VolArray,4);
if(Data.at(6) == 1)
mIsMute = true;
else
mIsMute = false;
// char String[50];
// for(int i= 0; i < 50; i++)
// {
// String[i] = Data[i+7];
// }
// mInput.clear();
// mInput.append(String);
// for(int i= 0; i < 50; i++)
// {
// String[i] = Data[i+57];
// }
// mProgram.clear();
// mProgram.append(String);
if(Data.at(7) == 1)
mDataValid = true;
else
mDataValid = false;
if(Data.at(8) == 1)
mReceiverOnline = true;
else
mReceiverOnline = false;
if(Data.at(9) == 1)
mSyncZonesVolumes = true;
else
mSyncZonesVolumes = false;
return RET_OK;
}
QDataStream &operator<<(QDataStream &out, const CAvReceiverMainStatus &source)
{
out << source.mMainPwrStatus
+2
View File
@@ -16,7 +16,9 @@ class CAvReceiverMainStatus
public:
QByteArray ToByteArray();
QByteArray ToConsoleStatusByteArray();
int FromByteArray(QByteArray Data);
int FromConsoleStatusByteArray(QByteArray Data);
CAvReceiverMainStatus();