Skip to content

Commit

Permalink
Corrected SendGeneralSwitch code
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmocuz committed May 30, 2018
1 parent 0f03172 commit 85dc65a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions hardware/DomoticzHardware.cpp
Expand Up @@ -865,13 +865,15 @@ void CDomoticzHardwareBase::SendAlertSensor(const int NodeID, const int BatteryL
sDecodeRXMessage(this, (const unsigned char *)&gDevice, defaultname.c_str(), BatteryLevel);
}

void CDomoticzHardwareBase::SendGeneralSwitchSensor(const int NodeID, const int BatteryLevel, const int switchState, const char* defaultname, const int unitCode)
void CDomoticzHardwareBase::SendGeneralSwitch(const int NodeID, const int ChildID, const int BatteryLevel, const int SwitchState, const int Level, const std::string &defaultname, const int RssiLevel)
{
_tGeneralSwitch gSwitch;
gSwitch.id = NodeID;
gSwitch.unitcode = unitCode;
gSwitch.cmnd = switchState;
sDecodeRXMessage(this, (const unsigned char *)&gSwitch, defaultname, BatteryLevel);
gSwitch.unitcode = ChildID;
gSwitch.cmnd = SwitchState;
gSwitch.level = Level;
gSwitch.rssi = RssiLevel;
sDecodeRXMessage(this, (const unsigned char *)&gSwitch, defaultname.c_str(), BatteryLevel);
}

void CDomoticzHardwareBase::SendMoistureSensor(const int NodeID, const int BatteryLevel, const int mLevel, const std::string &defaultname)
Expand Down
2 changes: 1 addition & 1 deletion hardware/DomoticzHardware.h
Expand Up @@ -68,6 +68,7 @@ class CDomoticzHardwareBase
void SendSwitch(const int NodeID, const int ChildID, const int BatteryLevel, const bool bOn, const double Level, const std::string &defaultname, const int RssiLevel = 12);
void SendSwitchIfNotExists(const int NodeID, const int ChildID, const int BatteryLevel, const bool bOn, const double Level, const std::string &defaultname);
void SendRGBWSwitch(const int NodeID, const int ChildID, const int BatteryLevel, const int Level, const bool bIsRGBW, const std::string &defaultname);
void SendGeneralSwitch(const int NodeID, const int ChildID, const int BatteryLevel, const int SwitchState, const int Level, const std::string &defaultname, const int RssiLevel = 12);
void SendVoltageSensor(const int NodeID, const int ChildID, const int BatteryLevel, const float Volt, const std::string &defaultname);
void SendCurrentSensor(const int NodeID, const int BatteryLevel, const float Current1, const float Current2, const float Current3, const std::string &defaultname, const int RssiLevel = 12);
void SendPercentageSensor(const int NodeID, const int ChildID, const int BatteryLevel, const float Percentage, const std::string &defaultname);
Expand All @@ -84,7 +85,6 @@ class CDomoticzHardwareBase
void SendBlindSensor(const int NodeID, const int ChildID, const int BatteryLevel, const int Command, const std::string &defaultname, const int RssiLevel = 12);
void SendSoundSensor(const int NodeID, const int BatteryLevel, const int sLevel, const std::string &defaultname);
void SendAlertSensor(const int NodeID, const int BatteryLevel, const int alertLevel, const std::string &message, const std::string &defaultname);
void SendGeneralSwitchSensor(const int NodeID, const int BatteryLevel, const int switchState, const char* defaultname, const int unitCode);
void SendMoistureSensor(const int NodeID, const int BatteryLevel, const int mLevel, const std::string &defaultname);
void SendTextSensor(const int NodeID, const int ChildID, const int BatteryLevel, const std::string &textMessage, const std::string &defaultname);
std::string GetTextSensorText(const int NodeID, const int ChildID, bool &bExists);
Expand Down
8 changes: 4 additions & 4 deletions hardware/MultiFun.cpp
Expand Up @@ -448,12 +448,12 @@ void MultiFun::GetRegisters(bool firstTime)
{
if (((*it).first & value) && !((*it).first & m_LastDevices))
{
SendGeneralSwitchSensor(2, 255, true, (*it).second.c_str(), (*it).first);
SendGeneralSwitch(2, (*it).first, 255, true, 0, (*it).second.c_str());
}
else
if (!((*it).first & value) && ((*it).first & m_LastDevices))
{
SendGeneralSwitchSensor(2, 255, false, (*it).second.c_str(), (*it).first);
SendGeneralSwitch(2, (*it).first, 255, false, 0, (*it).second.c_str());
}
}
m_LastDevices = value;
Expand Down Expand Up @@ -531,12 +531,12 @@ void MultiFun::GetRegisters(bool firstTime)
{
if (((*it).first & value) && !((*it).first & m_LastQuickAccess))
{
SendGeneralSwitchSensor(0x21, 255, true, (*it).second.c_str(), (*it).first);
SendGeneralSwitch(0x21, (*it).first, 255, true, 0, (*it).second.c_str());
}
else
if ((!((*it).first & value) && ((*it).first & m_LastQuickAccess)) || firstTime)
{
SendGeneralSwitchSensor(0x21, 255, false, (*it).second.c_str(), (*it).first);
SendGeneralSwitch(0x21, (*it).first, 255, false, 0, (*it).second.c_str());
}
}
m_LastQuickAccess = value;
Expand Down
4 changes: 2 additions & 2 deletions hardware/SatelIntegra.cpp
Expand Up @@ -780,7 +780,7 @@ void SatelIntegra::ReportOutputState(const int Idx, const bool state)

if ((Idx > 1024) || m_isOutputSwitch[Idx - 1])
{
SendGeneralSwitchSensor(Idx, 255, state ? gswitch_sOn : gswitch_sOff, NULL, 1);
SendGeneralSwitch(Idx, 1, 255, state ? gswitch_sOn : gswitch_sOff, 0, NULL);
}
else
{
Expand All @@ -796,7 +796,7 @@ void SatelIntegra::ReportArmState(const int Idx, const bool isArm)
{
m_armLastState[Idx-1] = isArm;

SendGeneralSwitchSensor(Idx, 255, isArm ? gswitch_sOn : gswitch_sOff, NULL, 2);
SendGeneralSwitch(Idx, 2, 255, isArm ? gswitch_sOn : gswitch_sOff, 0, NULL);
}

void SatelIntegra::ReportAlarm(const bool isAlarm)
Expand Down

3 comments on commit 85dc65a

@tomaszszczukobls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gizmocuz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting, i think it was not allowed to send NULL, we needed to send ""
Fixed, and a new beta is available (9550)
Sorry for the inconvenience, but change was needed to be more compliant

@tomaszszczukobls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I know.

Please sign in to comment.