Fixes for V6+ client on V5- server

This commit is contained in:
Adam Honse
2026-07-01 14:06:39 -05:00
parent 3a0b93c774
commit 1a62db7246
5 changed files with 141 additions and 17 deletions

View File

@@ -341,11 +341,6 @@ unsigned int RGBController::GetZoneLEDsCount(unsigned int zone)
if(zone < zones.size())
{
leds_count = zones[zone].leds_count;
if((zones[zone].flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY) && (leds_count > 1))
{
leds_count = 1;
}
}
else
{
@@ -1909,6 +1904,8 @@ void RGBController::UpdateZoneLEDs(int zone)
AccessMutex.lock_shared();
DeviceUpdateZoneLEDs(zone);
AccessMutex.unlock_shared();
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATELEDS);
}
void RGBController::UpdateSingleLED(int led)
@@ -1916,6 +1913,8 @@ void RGBController::UpdateSingleLED(int led)
AccessMutex.lock_shared();
DeviceUpdateSingleLED(led);
AccessMutex.unlock_shared();
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATELEDS);
}
void RGBController::UpdateMode()
@@ -1930,6 +1929,8 @@ void RGBController::UpdateZoneMode(int zone)
AccessMutex.lock_shared();
DeviceUpdateZoneMode(zone);
AccessMutex.unlock_shared();
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATEMODE);
}
void RGBController::SaveMode()
@@ -3770,6 +3771,23 @@ unsigned char* RGBController::SetZoneDescription(unsigned char* data_ptr, unsign
COPY_DATA_FIELD(data_ptr, data_start, zone->flags);
}
/*-----------------------------------------------------*\
| Set the manually configurable flag if older protocol |
| and the LED minimum and maximum differ |
\*-----------------------------------------------------*/
if(protocol_version < 6)
{
if((zone->leds_min != zone->leds_max) && !(zone->flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY))
{
zone->flags |= ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE;
}
if(zone->leds_count > 0)
{
zone->flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SIZE;
}
}
/*-----------------------------------------------------*\
| Copy in zone modes |
\*-----------------------------------------------------*/

View File

@@ -32,7 +32,14 @@ unsigned int RGBController_Network::GetID()
void RGBController_Network::SetHidden(bool hidden)
{
client->SendRequest_RGBController_SetHidden(dev_id, hidden);
if(client->GetProtocolVersion() < 6)
{
RGBController::SetHidden(hidden);
}
else
{
client->SendRequest_RGBController_SetHidden(dev_id, hidden);
}
}
void RGBController_Network::ClearSegments(int zone)
@@ -395,20 +402,67 @@ void RGBController_Network::SetDeviceSpecificZoneConfiguration(int zone, nlohman
client->WaitOnControllerData();
}
/*-----------------------------------------------------*\
| This function overrides RGBController::UpdateLEDs()! |
| Normally, UpdateLEDs() sets a flag for the updater |
| thread to update the device asynchronously, which |
| prevents delays updating local devices. This causes |
| instability and flickering with network devices though|
| so for the network implementation, process all updates|
| synchronously. |
\*-----------------------------------------------------*/
/*---------------------------------------------------------*\
| This function overrides RGBController::UpdateLEDs()! |
| Normally, UpdateLEDs() sets a flag for the updater |
| thread to update the device asynchronously, which |
| prevents delays updating local devices. This causes |
| instability and flickering with network devices though |
| so for the network implementation, process all updates |
| synchronously. |
\*---------------------------------------------------------*/
void RGBController_Network::UpdateLEDs()
{
AccessMutex.lock_shared();
DeviceUpdateLEDs();
AccessMutex.unlock_shared();
/*-----------------------------------------------------*\
| On protocol 6+, the server sends SignalUpdate packets |
| back to the client, but on earlier protocols we need |
| to signal the update internally and assume it was |
| successfully updated on the server. |
\*-----------------------------------------------------*/
if(client->GetProtocolVersion() < 6)
{
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATELEDS);
}
}
void RGBController_Network::UpdateZoneLEDs(int zone)
{
AccessMutex.lock_shared();
DeviceUpdateZoneLEDs(zone);
AccessMutex.unlock_shared();
/*-----------------------------------------------------*\
| On protocol 6+, the server sends SignalUpdate packets |
| back to the client, but on earlier protocols we need |
| to signal the update internally and assume it was |
| successfully updated on the server. |
\*-----------------------------------------------------*/
if(client->GetProtocolVersion() < 6)
{
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATELEDS);
}
}
void RGBController_Network::UpdateSingleLED(int led)
{
AccessMutex.lock_shared();
DeviceUpdateSingleLED(led);
AccessMutex.unlock_shared();
/*-----------------------------------------------------*\
| On protocol 6+, the server sends SignalUpdate packets |
| back to the client, but on earlier protocols we need |
| to signal the update internally and assume it was |
| successfully updated on the server. |
\*-----------------------------------------------------*/
if(client->GetProtocolVersion() < 6)
{
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATELEDS);
}
}
void RGBController_Network::UpdateMode()
@@ -416,6 +470,53 @@ void RGBController_Network::UpdateMode()
AccessMutex.lock_shared();
DeviceUpdateMode();
AccessMutex.unlock_shared();
/*-----------------------------------------------------*\
| On protocol 6+, the server sends SignalUpdate packets |
| back to the client, but on earlier protocols we need |
| to signal the update internally and assume it was |
| successfully updated on the server. |
\*-----------------------------------------------------*/
if(client->GetProtocolVersion() < 6)
{
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATEMODE);
}
}
void RGBController_Network::UpdateZoneMode(int zone)
{
AccessMutex.lock_shared();
DeviceUpdateZoneMode(zone);
AccessMutex.unlock_shared();
/*-----------------------------------------------------*\
| On protocol 6+, the server sends SignalUpdate packets |
| back to the client, but on earlier protocols we need |
| to signal the update internally and assume it was |
| successfully updated on the server. |
\*-----------------------------------------------------*/
if(client->GetProtocolVersion() < 6)
{
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_UPDATEMODE);
}
}
void RGBController_Network::SaveMode()
{
AccessMutex.lock_shared();
DeviceSaveMode();
AccessMutex.unlock_shared();
/*-----------------------------------------------------*\
| On protocol 6+, the server sends SignalUpdate packets |
| back to the client, but on earlier protocols we need |
| to signal the update internally and assume it was |
| successfully updated on the server. |
\*-----------------------------------------------------*/
if(client->GetProtocolVersion() < 6)
{
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_SAVEMODE);
}
}
unsigned char * RGBController_Network::CreateUpdateLEDsPacket(unsigned int protocol_version)

View File

@@ -43,7 +43,12 @@ public:
void SetDeviceSpecificZoneConfiguration(int zone, nlohmann::json configuration_json);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void UpdateMode();
void UpdateZoneMode(int zone);
void SaveMode();
void DeviceUpdateMode();
void DeviceUpdateZoneMode(int zone);

View File

@@ -1207,7 +1207,7 @@ void ApplyOptions(DeviceOptions& options, std::vector<RGBController *>& rgb_cont
else
{
start_from = (std::size_t)device->GetZoneStartIndex(options.zone);
led_count = (std::size_t)device->GetZoneLEDsCount(options.zone);
led_count = (std::size_t)device->GetLEDsInZone(options.zone);
}
for(std::size_t led_idx = 0; led_idx < led_count; led_idx++)

View File

@@ -155,7 +155,7 @@ void OpenRGBZoneInitializationDialog::CreateZoneWidget(RGBController* controller
| Spin box: controls the zone size |
\*---------------------------------------------------------*/
QSpinBox* spin_box = new QSpinBox(this);
spin_box->setValue(0);
spin_box->setValue(controller->GetZoneLEDsCount(zone_index));
spin_box->setMinimum(controller->GetZoneLEDsMin(zone_index));
spin_box->setMaximum(controller->GetZoneLEDsMax(zone_index));