Skip to content

Commit b7b32cb

Browse files
committed
Ensure configuration is saved to file. Any property that uses saveConfig should have an equivelant Property.save(fp) in saveConfigItems
1 parent 6f1ba6d commit b7b32cb

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

drivers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@
11011101
</device>
11021102
<device label="Pegasus PPBA" manufacturer="Pegasus Astro">
11031103
<driver name="Pegasus PPBA">indi_pegasus_ppba</driver>
1104-
<version>1.3</version>
1104+
<version>1.4</version>
11051105
</device>
11061106
<device label="Pegasus PPBM" manufacturer="Pegasus Astro">
11071107
<driver name="Pegasus PPBM">indi_pegasus_ppba</driver>

drivers/power/pegasus_ppb.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bool PegasusPPB::ISNewSwitch(const char * dev, const char * name, ISState * stat
219219
PowerOnBootSP.update(states, names, n);
220220
PowerOnBootSP.setState(setPowerOnBoot() ? IPS_OK : IPS_ALERT);
221221
PowerOnBootSP.apply();
222-
saveConfig(true, PowerOnBootSP.getName());
222+
saveConfig(PowerOnBootSP);
223223
return true;
224224
}
225225

@@ -351,6 +351,9 @@ bool PegasusPPB::setDewPWM(uint8_t id, uint8_t value)
351351
bool PegasusPPB::saveConfigItems(FILE * fp)
352352
{
353353
INDI::DefaultDevice::saveConfigItems(fp);
354+
355+
PowerOnBootSP.save(fp);
356+
354357
WI::saveConfigItems(fp);
355358
PI::saveConfigItems(fp);
356359

@@ -405,7 +408,7 @@ bool PegasusPPB::getSensorData()
405408
PI::PowerSensorsNP[PI::SENSOR_CURRENT].setValue(std::stod(result[PA_CURRENT]) / 65.0);
406409
PI::PowerSensorsNP.setState(IPS_OK);
407410
if (lastSensorData.size() > PA_CURRENT &&
408-
(lastSensorData[PA_VOLTAGE] != result[PA_VOLTAGE] || lastSensorData[PA_CURRENT] != result[PA_CURRENT]))
411+
(lastSensorData[PA_VOLTAGE] != result[PA_VOLTAGE] || lastSensorData[PA_CURRENT] != result[PA_CURRENT]))
409412
PI::PowerSensorsNP.apply();
410413
}
411414

@@ -416,9 +419,9 @@ bool PegasusPPB::getSensorData()
416419
setParameterValue("WEATHER_HUMIDITY", std::stod(result[PA_HUMIDITY]));
417420
setParameterValue("WEATHER_DEWPOINT", std::stod(result[PA_DEW_POINT]));
418421
if (lastSensorData.size() > PA_DEW_POINT &&
419-
(lastSensorData[PA_TEMPERATURE] != result[PA_TEMPERATURE] ||
420-
lastSensorData[PA_HUMIDITY] != result[PA_HUMIDITY] ||
421-
lastSensorData[PA_DEW_POINT] != result[PA_DEW_POINT]))
422+
(lastSensorData[PA_TEMPERATURE] != result[PA_TEMPERATURE] ||
423+
lastSensorData[PA_HUMIDITY] != result[PA_HUMIDITY] ||
424+
lastSensorData[PA_DEW_POINT] != result[PA_DEW_POINT]))
422425
{
423426
if (WI::syncCriticalParameters())
424427
critialParametersLP.apply();
@@ -458,7 +461,7 @@ bool PegasusPPB::getSensorData()
458461
if (PI::DewChannelDutyCycleNP.size() >= 2)
459462
PI::DewChannelDutyCycleNP[1].setValue(std::stod(result[PA_DEW_2]) / 255.0 * 100.0);
460463
if (lastSensorData.size() > PA_DEW_2 &&
461-
(lastSensorData[PA_DEW_1] != result[PA_DEW_1] || lastSensorData[PA_DEW_2] != result[PA_DEW_2]))
464+
(lastSensorData[PA_DEW_1] != result[PA_DEW_1] || lastSensorData[PA_DEW_2] != result[PA_DEW_2]))
462465
PI::DewChannelDutyCycleNP.apply();
463466
}
464467

drivers/power/pegasus_ppba.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static std::unique_ptr<PegasusPPBA> ppba(new PegasusPPBA());
3636

3737
PegasusPPBA::PegasusPPBA() : INDI::DefaultDevice(), FI(this), WI(this), PI(this)
3838
{
39-
setVersion(1, 3);
39+
setVersion(1, 4);
4040
lastSensorData.reserve(PA_N);
4141
lastConsumptionData.reserve(PS_N);
4242
lastMetricsData.reserve(PC_N);
@@ -407,7 +407,7 @@ bool PegasusPPBA::ISNewSwitch(const char * dev, const char * name, ISState * sta
407407
PowerOnBootSP.update(states, names, n);
408408
PowerOnBootSP.setState(setPowerOnBoot() ? IPS_OK : IPS_ALERT);
409409
PowerOnBootSP.apply();
410-
saveConfig(true, PowerOnBootSP.getName());
410+
saveConfig(PowerOnBootSP);
411411
return true;
412412
}
413413

@@ -630,15 +630,21 @@ bool PegasusPPBA::setDewPWM(uint8_t id, uint8_t value)
630630
bool PegasusPPBA::saveConfigItems(FILE * fp)
631631
{
632632
INDI::DefaultDevice::saveConfigItems(fp);
633+
634+
AdjOutVoltSP.save(fp);
635+
PowerOnBootSP.save(fp);
636+
AutoDewSettingsNP.save(fp);
637+
633638
if (m_HasExternalMotor)
634639
{
635640
FI::saveConfigItems(fp);
636641
FocuserSettingsNP.save(fp);
637642
FocuserDriveSP.save(fp);
638643
}
644+
639645
WI::saveConfigItems(fp);
640-
PI::saveConfigItems(fp); // Save power properties
641-
AutoDewSettingsNP.save(fp); // This is a custom property, not part of INDI::PowerInterface
646+
PI::saveConfigItems(fp);
647+
642648
return true;
643649
}
644650

drivers/power/pegasus_upb.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ bool PegasusUPB::saveConfigItems(FILE * fp)
816816
AutoDewAggNP.save(fp);
817817
}
818818
FocuserSettingsNP.save(fp);
819+
PowerOnBootSP.save(fp);
819820
return true;
820821
}
821822

0 commit comments

Comments
 (0)