Skip to content

Commit

Permalink
stop updating during ota
Browse files Browse the repository at this point in the history
  • Loading branch information
markirb committed Jun 15, 2024
1 parent f58ed70 commit 3182eb3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DHT/shelly_dht_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ void DHTSensor::StartUpdating(int interval) {
meas_timer_.Reset(interval, MGOS_TIMER_REPEAT | MGOS_TIMER_RUN_NOW);
}

void DHTSensor::StopUpdating() {
meas_timer_.Clear();
}

StatusOr<float> DHTSensor::GetTemperature() {
return result_;
}
Expand Down
1 change: 1 addition & 0 deletions src/DHT/shelly_dht_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DHTSensor : public HumidityTempSensor {
StatusOr<float> GetHumidity() override;

virtual void StartUpdating(int interval) override;
virtual void StopUpdating() override;

private:
uint8_t pin_in_;
Expand Down
5 changes: 5 additions & 0 deletions src/DS18XXX/shelly_temp_sensor_ow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ void TempSensorDS18XXX::StartUpdating(int interval) {
meas_timer_.Reset(interval, MGOS_TIMER_REPEAT | MGOS_TIMER_RUN_NOW);
}

void TempSensorDS18XXX::StopUpdating() {
read_timer_.Clear(); // Clear eventually pending read
meas_timer_.Clear();
}

StatusOr<float> TempSensorDS18XXX::GetTemperature() {
return result_;
}
Expand Down
1 change: 1 addition & 0 deletions src/DS18XXX/shelly_temp_sensor_ow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class TempSensorDS18XXX : public TempSensor {

static bool SupportsFamily(uint8_t family);
virtual void StartUpdating(int interval) override;
virtual void StopUpdating() override;

private:
struct __attribute__((__packed__)) Scratchpad {
Expand Down
1 change: 1 addition & 0 deletions src/shelly_hap_humidity_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ HumiditySensor::HumiditySensor(int id, HumidityTempSensor *sensor,
}

HumiditySensor::~HumiditySensor() {
hum_sensor_->StopUpdating();
hum_sensor_->SetNotifier(nullptr);
}

Expand Down
1 change: 1 addition & 0 deletions src/shelly_hap_temperature_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ TemperatureSensor::TemperatureSensor(int id, TempSensor *sensor,
}

TemperatureSensor::~TemperatureSensor() {
temp_sensor_->StopUpdating();
temp_sensor_->SetNotifier(nullptr);
}

Expand Down
3 changes: 3 additions & 0 deletions src/shelly_temp_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class TempSensor {
virtual void StartUpdating(int interval UNUSED_ARG) {
}

virtual void StopUpdating() {
}

virtual TempType getType() {
return TS;
}
Expand Down

0 comments on commit 3182eb3

Please sign in to comment.