diff --git a/code/espurna/alexa.cpp b/code/espurna/alexa.cpp index ce700a7a..5eadd53d 100644 --- a/code/espurna/alexa.cpp +++ b/code/espurna/alexa.cpp @@ -240,9 +240,9 @@ void alexaSetup() { // Register main callbacks #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE - lightSetReportListener(_alexaUpdateLights); + lightOnReport(_alexaUpdateLights); #elif RELAY_SUPPORT - relaySetStatusChange(_alexaUpdateRelay); + relayOnStatusChange(_alexaUpdateRelay); #endif espurnaRegisterReload(_alexaConfigure); diff --git a/code/espurna/button.cpp b/code/espurna/button.cpp index dea0265d..427d10a8 100644 --- a/code/espurna/button.cpp +++ b/code/espurna/button.cpp @@ -361,7 +361,7 @@ void buttonSetCustomAction(ButtonEventHandler handler) { std::forward_list _button_notify_event; -void buttonSetEventNotify(ButtonEventHandler handler) { +void buttonOnEvent(ButtonEventHandler handler) { _button_notify_event.push_front(handler); } diff --git a/code/espurna/button.h b/code/espurna/button.h index 6e9050ce..e95acd3c 100644 --- a/code/espurna/button.h +++ b/code/espurna/button.h @@ -97,10 +97,10 @@ struct button_t { using ButtonEventHandler = void(*)(size_t id, ButtonEvent event); void buttonSetCustomAction(ButtonEventHandler); -void buttonSetNotifyAction(ButtonEventHandler); ButtonAction buttonAction(size_t id, const ButtonEvent event); void buttonEvent(size_t id, ButtonEvent event); +void buttonOnEvent(ButtonEventHandler); bool buttonAdd(); diff --git a/code/espurna/domoticz.cpp b/code/espurna/domoticz.cpp index 4f2c548c..0bb1906c 100644 --- a/code/espurna/domoticz.cpp +++ b/code/espurna/domoticz.cpp @@ -313,7 +313,7 @@ void domoticzSetup() { #endif #if RELAY_SUPPORT - relaySetStatusChange(_domoticzRelayCallback); + relayOnStatusChange(_domoticzRelayCallback); #endif // Callbacks diff --git a/code/espurna/homeassistant.cpp b/code/espurna/homeassistant.cpp index 5b6612bb..5320548d 100644 --- a/code/espurna/homeassistant.cpp +++ b/code/espurna/homeassistant.cpp @@ -26,6 +26,7 @@ Copyright (C) 2019-2021 by Maxim Prokhorov namespace homeassistant { +namespace { // Output is supposed to be used as both part of the MQTT config topic and the `uniq_id` field // TODO: manage UTF8 strings? in case we somehow receive `desc`, like it was done originally @@ -952,6 +953,7 @@ bool onKeyCheck(const char* key, JsonVariant& value) { #endif } // namespace web +} // namespace } // namespace homeassistant // This module no longer implements .yaml generation, since we can't: @@ -969,15 +971,14 @@ void haSetup() { #endif #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE - lightSetReportListener(homeassistant::publishLightJson); + lightOnReport(homeassistant::publishLightJson); mqttHeartbeat(homeassistant::heartbeat); #endif mqttRegister(homeassistant::mqttCallback); #if TERMINAL_SUPPORT terminalRegisterCommand(F("HA.SEND"), [](const terminal::CommandContext& ctx) { - using namespace homeassistant::internal; - state = State::Pending; + homeassistant::internal::state = homeassistant::internal::State::Pending; homeassistant::publishDiscovery(); terminalOK(ctx); }); diff --git a/code/espurna/influxdb.cpp b/code/espurna/influxdb.cpp index 004d1e11..ebcc95a0 100644 --- a/code/espurna/influxdb.cpp +++ b/code/espurna/influxdb.cpp @@ -293,11 +293,11 @@ void idbSetup() { #endif #if RELAY_SUPPORT - relaySetStatusChange(_idbSendStatus); + relayOnStatusChange(_idbSendStatus); #endif #if SENSOR_SUPPORT - sensorSetMagnitudeReport(_idbSendSensor); + sensorOnMagnitudeReport(_idbSendSensor); #endif espurnaRegisterReload(_idbConfigure); diff --git a/code/espurna/led.cpp b/code/espurna/led.cpp index ee796825..9932fde7 100644 --- a/code/espurna/led.cpp +++ b/code/espurna/led.cpp @@ -581,7 +581,7 @@ void ledSetup() { // TODO: grab a specific LED from the relay module itself? // either for global status, or a specific relay _led_relays.resize(leds, RelaysMax); - relaySetStatusChange([](size_t, bool) { + relayOnStatusChange([](size_t, bool) { _led_update = true; }); #endif diff --git a/code/espurna/light.cpp b/code/espurna/light.cpp index fbcb0008..28c3378a 100644 --- a/code/espurna/light.cpp +++ b/code/espurna/light.cpp @@ -2014,7 +2014,7 @@ void lightHs(long hue, long saturation) { // ----------------------------------------------------------------------------- -void lightSetReportListener(LightReportListener func) { +void lightOnReport(LightReportListener func) { _light_report.push_front(func); } diff --git a/code/espurna/light.h b/code/espurna/light.h index c4b54ccd..f3cdc48b 100644 --- a/code/espurna/light.h +++ b/code/espurna/light.h @@ -246,9 +246,8 @@ bool lightUseRGB(); bool lightUseCCT(); void lightMQTT(); +void lightOnReport(LightReportListener); -void lightSetReportListener(LightReportListener); -void lightSetStateListener(LightStateListener); void lightSetProvider(std::unique_ptr&&); bool lightAdd(); diff --git a/code/espurna/mqtt.h b/code/espurna/mqtt.h index 6fd6f7d9..102f168f 100644 --- a/code/espurna/mqtt.h +++ b/code/espurna/mqtt.h @@ -101,9 +101,6 @@ const String& mqttPayloadOnline(); const String& mqttPayloadOffline(); const char* mqttPayloadStatus(bool status); -void mqttSetBroker(IPAddress ip, uint16_t port); -void mqttSetBrokerIfNone(IPAddress ip, uint16_t port); - void mqttEnabled(bool status); bool mqttEnabled(); diff --git a/code/espurna/relay.cpp b/code/espurna/relay.cpp index 2944f59b..41765765 100644 --- a/code/espurna/relay.cpp +++ b/code/espurna/relay.cpp @@ -310,11 +310,11 @@ void RelayProviderBase::notify(bool) { // Direct status notifications -void relaySetStatusNotify(RelayStatusCallback callback) { +void relayOnStatusNotify(RelayStatusCallback callback) { _relay_status_notify.push_front(callback); } -void relaySetStatusChange(RelayStatusCallback callback) { +void relayOnStatusChange(RelayStatusCallback callback) { _relay_status_change.push_front(callback); } diff --git a/code/espurna/relay.h b/code/espurna/relay.h index 71ef5aee..ee7cce8a 100644 --- a/code/espurna/relay.h +++ b/code/espurna/relay.h @@ -98,8 +98,8 @@ using RelayStatusCallback = void(*)(size_t id, bool status); using RelayProviderBasePtr = std::unique_ptr; bool relayAdd(RelayProviderBasePtr&& provider); -void relaySetStatusNotify(RelayStatusCallback); -void relaySetStatusChange(RelayStatusCallback); +void relayOnStatusNotify(RelayStatusCallback); +void relayOnStatusChange(RelayStatusCallback); void relaySetupDummy(size_t size, bool reconfigure = false); void relaySetup(); diff --git a/code/espurna/rfbridge.cpp b/code/espurna/rfbridge.cpp index 5c6efd2d..f7d8cfe0 100644 --- a/code/espurna/rfbridge.cpp +++ b/code/espurna/rfbridge.cpp @@ -1291,8 +1291,8 @@ void rfbSetup() { #endif #if RELAY_SUPPORT - relaySetStatusNotify(rfbStatus); - relaySetStatusChange(rfbStatus); + relayOnStatusNotify(rfbStatus); + relayOnStatusChange(rfbStatus); #endif #if MQTT_SUPPORT diff --git a/code/espurna/rpnrules.cpp b/code/espurna/rpnrules.cpp index c7950f26..4145d8b6 100644 --- a/code/espurna/rpnrules.cpp +++ b/code/espurna/rpnrules.cpp @@ -1131,11 +1131,11 @@ void rpnSetup() { #endif #if RELAY_SUPPORT - relaySetStatusChange(_rpnRelayStatus); + relayOnStatusChange(_rpnRelayStatus); #endif #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE - lightSetReportListener(_rpnLightStatus); + lightOnReport(_rpnLightStatus); #endif #if RFB_SUPPORT @@ -1143,7 +1143,7 @@ void rpnSetup() { #endif #if SENSOR_SUPPORT - sensorSetMagnitudeRead(_rpnSensorMagnitudeRead); + sensorOnMagnitudeRead(_rpnSensorMagnitudeRead); #endif espurnaRegisterReload(_rpnConfigure); diff --git a/code/espurna/sensor.cpp b/code/espurna/sensor.cpp index f0bb5bb8..81d179a8 100644 --- a/code/espurna/sensor.cpp +++ b/code/espurna/sensor.cpp @@ -550,13 +550,13 @@ using MagnitudeReadHandlers = std::forward_list; MagnitudeReadHandlers _magnitude_read_handlers; -void sensorSetMagnitudeRead(MagnitudeReadHandler handler) { +void sensorOnMagnitudeRead(MagnitudeReadHandler handler) { _magnitude_read_handlers.push_front(handler); } MagnitudeReadHandlers _magnitude_report_handlers; -void sensorSetMagnitudeReport(MagnitudeReadHandler handler) { +void sensorOnMagnitudeReport(MagnitudeReadHandler handler) { _magnitude_report_handlers.push_front(handler); } diff --git a/code/espurna/sensor.h b/code/espurna/sensor.h index 4f83ff67..711c7d80 100644 --- a/code/espurna/sensor.h +++ b/code/espurna/sensor.h @@ -135,8 +135,8 @@ struct Value { } using MagnitudeReadHandler = void(*)(const String&, unsigned char, double, const char*); -void sensorSetMagnitudeRead(MagnitudeReadHandler handler); -void sensorSetMagnitudeReport(MagnitudeReadHandler handler); +void sensorOnMagnitudeRead(MagnitudeReadHandler handler); +void sensorOnMagnitudeReport(MagnitudeReadHandler handler); String magnitudeUnits(unsigned char index); String magnitudeDescription(unsigned char index); diff --git a/code/espurna/thingspeak.cpp b/code/espurna/thingspeak.cpp index d27fa3a8..5308f226 100644 --- a/code/espurna/thingspeak.cpp +++ b/code/espurna/thingspeak.cpp @@ -457,7 +457,7 @@ void tspkSetup() { #endif #if RELAY_SUPPORT - relaySetStatusChange(_tspkRelayStatus); + relayOnStatusChange(_tspkRelayStatus); #endif DEBUG_MSG_P(PSTR("[THINGSPEAK] Async %s, SSL %s\n"),