Skip to content

Commit

Permalink
configuration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PBrunot committed Jan 14, 2024
1 parent 90d617d commit 10cd9b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
22 changes: 14 additions & 8 deletions src/BoardLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,19 +456,25 @@ namespace fablabbg

void BoardLogic::beep_ok() const
{
ledcWriteTone(conf::buzzer::LEDC_PWM_CHANNEL, conf::buzzer::BEEP_HZ);
delay(duration_cast<milliseconds>(conf::buzzer::STANDARD_BEEP_DURATION).count());
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 0UL);
if (auto ms = duration_cast<milliseconds>(conf::buzzer::STANDARD_BEEP_DURATION).count(); ms > 0)
{
ledcWriteTone(conf::buzzer::LEDC_PWM_CHANNEL, conf::buzzer::BEEP_HZ);
delay(ms);
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 0UL);
}
}

void BoardLogic::beep_failed() const
{
for (auto i = 0; i < conf::buzzer::NB_BEEPS; i++)
if (auto ms = duration_cast<milliseconds>(conf::buzzer::STANDARD_BEEP_DURATION).count(); ms > 0)
{
ledcWriteTone(conf::buzzer::LEDC_PWM_CHANNEL, conf::buzzer::BEEP_HZ);
delay(duration_cast<milliseconds>(conf::buzzer::STANDARD_BEEP_DURATION).count());
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 0UL);
delay(duration_cast<milliseconds>(conf::buzzer::STANDARD_BEEP_DURATION).count());
for (auto i = 0; i < conf::buzzer::NB_BEEPS; i++)
{
ledcWriteTone(conf::buzzer::LEDC_PWM_CHANNEL, conf::buzzer::BEEP_HZ);
delay(ms);
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 0UL);
delay(ms);
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/Machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,17 @@ namespace fablabbg
String payload = value ? act_config.mqtt_config.on_message.data() : act_config.mqtt_config.off_message.data();

auto retries = 0;
constexpr auto MAX_TRIES = 3;
constexpr auto DELAY_MS = duration_cast<milliseconds>(conf::mqtt::MAX_RETRY_DURATION).count() / MAX_TRIES;
constexpr auto DELAY_MS = duration_cast<milliseconds>(conf::mqtt::TIMEOUT_REPLY_SERVER).count();
while (!mqtt_server.publish(topic, payload))
{
ESP_LOGE(TAG, "Error while publishing %s to %s", payload.c_str(), topic.c_str());

mqtt_server.connect();
delay(DELAY_MS);
retries++;
if (retries > MAX_TRIES)
if (retries > conf::mqtt::MAX_TRIES)
{
ESP_LOGW(TAG, "Unable to publish to MQTT (%d/%d)", retries, MAX_TRIES);
ESP_LOGW(TAG, "Unable to publish to MQTT (%d/%d)", retries, conf::mqtt::MAX_TRIES);
return;
}
}
Expand Down

0 comments on commit 10cd9b4

Please sign in to comment.