Browse Source

Fix superfluous whitespaces and line endings

resolve #2310
mcspr-patch-1
Maxim Prokhorov 4 years ago
parent
commit
63b6f46752
27 changed files with 176 additions and 184 deletions
  1. +1
    -1
      code/espurna/DebounceEvent.cpp
  2. +1
    -1
      code/espurna/broker.h
  3. +3
    -4
      code/espurna/button.cpp
  4. +1
    -1
      code/espurna/button.h
  5. +96
    -96
      code/espurna/config/custom.h.example
  6. +2
    -2
      code/espurna/config/hardware.h
  7. +19
    -23
      code/espurna/curtain_kingart.cpp
  8. +0
    -2
      code/espurna/libs/AsyncClientHelpers.h
  9. +1
    -1
      code/espurna/libs/DebounceEvent.h
  10. +4
    -4
      code/espurna/libs/Encoder.h
  11. +1
    -1
      code/espurna/mqtt.cpp
  12. +2
    -2
      code/espurna/ntp.cpp
  13. +3
    -3
      code/espurna/ntp_timelib.h
  14. +1
    -1
      code/espurna/sensors/AnalogSensor.h
  15. +5
    -5
      code/espurna/sensors/BMP180Sensor.h
  16. +1
    -1
      code/espurna/sensors/BaseEmonSensor.h
  17. +17
    -17
      code/espurna/sensors/DallasSensor.h
  18. +5
    -5
      code/espurna/sensors/PZEM004TV30Sensor.h
  19. +4
    -4
      code/espurna/sensors/SI1145Sensor.h
  20. +1
    -1
      code/espurna/settings.cpp
  21. +0
    -1
      code/espurna/settings_embedis.h
  22. +1
    -1
      code/espurna/terminal.cpp
  23. +1
    -1
      code/espurna/thingspeak.cpp
  24. +1
    -1
      code/espurna/tuya_protocol.h
  25. +2
    -2
      code/espurna/tuya_transport.h
  26. +2
    -2
      code/espurna/utils.cpp
  27. +1
    -1
      code/test/unit/terminal/terminal.cpp

+ 1
- 1
code/espurna/DebounceEvent.cpp View File

@ -1,5 +1,5 @@
/* /*
Original code: Original code:
Debounce buttons and trigger events Debounce buttons and trigger events


+ 1
- 1
code/espurna/broker.h View File

@ -64,7 +64,7 @@ struct TBroker<R(Args...)> {
// TODO: since 1.14.0 we intoduced static syntax for Brokers, ::Register & ::Publish. // TODO: since 1.14.0 we intoduced static syntax for Brokers, ::Register & ::Publish.
// Preserve it (up to a point) when creating module-level objects. // Preserve it (up to a point) when creating module-level objects.
// Provide a helper namespace with Register & Publish, instance and
// Provide a helper namespace with Register & Publish, instance and
// To help out VS Code with argument discovery, put TArgs as the first template parameter. // To help out VS Code with argument discovery, put TArgs as the first template parameter.
#define BrokerDeclare(Name, Signature) \ #define BrokerDeclare(Name, Signature) \


+ 3
- 4
code/espurna/button.cpp View File

@ -129,11 +129,11 @@ constexpr const debounce_event::types::Config _buttonDecodeConfigBitmask(const u
((bitmask & ButtonMask::Pushbutton) ((bitmask & ButtonMask::Pushbutton)
? debounce_event::types::Mode::Pushbutton ? debounce_event::types::Mode::Pushbutton
: debounce_event::types::Mode::Switch), : debounce_event::types::Mode::Switch),
((bitmask & ButtonMask::DefaultHigh)
((bitmask & ButtonMask::DefaultHigh)
? debounce_event::types::PinValue::High ? debounce_event::types::PinValue::High
: debounce_event::types::PinValue::Low), : debounce_event::types::PinValue::Low),
((bitmask & ButtonMask::SetPullup) ? debounce_event::types::PinMode::InputPullup
: (bitmask & ButtonMask::SetPulldown) ? debounce_event::types::PinMode::InputPulldown
((bitmask & ButtonMask::SetPullup) ? debounce_event::types::PinMode::InputPullup
: (bitmask & ButtonMask::SetPulldown) ? debounce_event::types::PinMode::InputPulldown
: debounce_event::types::PinMode::Input) : debounce_event::types::PinMode::Input)
}; };
} }
@ -841,7 +841,6 @@ void buttonSetup() {
actions, actions,
delays delays
); );
} }
} }
#endif // BUTTON_PROVIDER_ITEAD_SONOFF_DUAL_SUPPORT || BUTTON_PROVIDER_FOXEL_LIGHTFOX_DUAL #endif // BUTTON_PROVIDER_ITEAD_SONOFF_DUAL_SUPPORT || BUTTON_PROVIDER_FOXEL_LIGHTFOX_DUAL


+ 1
- 1
code/espurna/button.h View File

@ -54,7 +54,7 @@ struct button_event_delays_t {
struct button_t { struct button_t {
button_t(unsigned char relayID, const button_actions_t& actions, const button_event_delays_t& delays); button_t(unsigned char relayID, const button_actions_t& actions, const button_event_delays_t& delays);
button_t(std::shared_ptr<BasePin> pin, const debounce_event::types::Config& config,
button_t(std::shared_ptr<BasePin> pin, const debounce_event::types::Config& config,
unsigned char relayID, const button_actions_t& actions, const button_event_delays_t& delays); unsigned char relayID, const button_actions_t& actions, const button_event_delays_t& delays);
bool state(); bool state();


+ 96
- 96
code/espurna/config/custom.h.example View File

@ -1,96 +1,96 @@
// ------------------------------------------------------------------------------
// Example file for custom.h
// Either copy and paste this file then rename removing the .example or create your
// own file: 'custom.h'
// This file allows users to create their own configurations.
// See 'code/espurna/config/general.h' for default settings.
//
// See: https://github.com/xoseperez/espurna/wiki/Software-features#enabling-features
// and 'code/platformio_override.ini.example' for more details.
// ------------------------------------------------------------------------------
// Example of a Sonoff Basic board with some options disabled to reduce firmware size.
#if defined(MY_SONOFF_BUILD01) // This section will be used when src_build_flags contains
// -DMY_SONOFF_BUILD01 in 'platformio_override.ini'
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_BASIC_BUILD01"
// Disable these
#define DEBUG_SERIAL_SUPPORT 0
#define ALEXA_SUPPORT 0
#define DOMOTICZ_SUPPORT 0
#define HOMEASSISTANT_SUPPORT 0
#define THINGSPEAK_SUPPORT 0
// Buttons
#define BUTTON1_PIN 0
#define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
// Relays
#define RELAY1_PIN 12
#define RELAY1_TYPE RELAY_TYPE_NORMAL
// LEDs
#define LED1_PIN 13
#define LED1_PIN_INVERSE 1
// Example of the Sonoff Basic board above but with two buttons on different GPIOs.
// The two buttons both toggle the one RELAY but ALL button events send MQTT values.
// An MQTT based system can then carry out differnt functions depending on
// the 'DOUBLE CLICK, LONG CLICK OR LONG-LONG CLICK' trigger. A BMX280 environment
// sensor is also connected using I2C on GPIO 1 and 3.
#elif defined(MY_SONOFF_BUILD02) // This section will be used when src_build_flags contains
// -DMY_SONOFF_BUILD02 in 'platformio_override.ini
// Info - Custom Basic with BMX280 I2C on GPIO 1 and 3
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_BASIC_BMX280" // You can use your own name here
// Disable these
#define DEBUG_SERIAL_SUPPORT 0
#define ALEXA_SUPPORT 0
#define DOMOTICZ_SUPPORT 0
#define HOMEASSISTANT_SUPPORT 0
#define THINGSPEAK_SUPPORT 0
// Buttons
#define BUTTON_MQTT_SEND_ALL_EVENTS 1
#define BUTTON1_PIN 0 // Built in button.
#define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
#define BUTTON1_PRESS BUTTON_MODE_NONE
#define BUTTON1_CLICK BUTTON_MODE_TOGGLE
#define BUTTON1_DBLCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGCLICK BUTTON_MODE_OFF
#define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE
#define BUTTON2_PIN 2 // External push button connected between IO2 and GND.
#define BUTTON2_CONFIG BUTTON_PUSHBUTTON | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH
#define BUTTON2_RELAY 1
#define BUTTON2_PRESS BUTTON_MODE_NONE
#define BUTTON2_CLICK BUTTON_MODE_TOGGLE
#define BUTTON2_DBLCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
// Relays
#define RELAY1_PIN 12
#define RELAY1_TYPE RELAY_TYPE_NORMAL
// LEDs
#define LED1_PIN 13
#define LED1_PIN_INVERSE 1
// Extras
#define BMX280_SUPPORT 1
#define BMX280_ADDRESS 0x76
#define I2C_SDA_PIN 1 //TX PIN **DISABLE DEBUG_SERIAL_SUPPORT**
#define I2C_SCL_PIN 3 //RX PIN **DISABLE DEBUG_SERIAL_SUPPORT**
#endif
// ------------------------------------------------------------------------------
// Example file for custom.h
// Either copy and paste this file then rename removing the .example or create your
// own file: 'custom.h'
// This file allows users to create their own configurations.
// See 'code/espurna/config/general.h' for default settings.
//
// See: https://github.com/xoseperez/espurna/wiki/Software-features#enabling-features
// and 'code/platformio_override.ini.example' for more details.
// ------------------------------------------------------------------------------
// Example of a Sonoff Basic board with some options disabled to reduce firmware size.
#if defined(MY_SONOFF_BUILD01) // This section will be used when src_build_flags contains
// -DMY_SONOFF_BUILD01 in 'platformio_override.ini'
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_BASIC_BUILD01"
// Disable these
#define DEBUG_SERIAL_SUPPORT 0
#define ALEXA_SUPPORT 0
#define DOMOTICZ_SUPPORT 0
#define HOMEASSISTANT_SUPPORT 0
#define THINGSPEAK_SUPPORT 0
// Buttons
#define BUTTON1_PIN 0
#define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
// Relays
#define RELAY1_PIN 12
#define RELAY1_TYPE RELAY_TYPE_NORMAL
// LEDs
#define LED1_PIN 13
#define LED1_PIN_INVERSE 1
// Example of the Sonoff Basic board above but with two buttons on different GPIOs.
// The two buttons both toggle the one RELAY but ALL button events send MQTT values.
// An MQTT based system can then carry out differnt functions depending on
// the 'DOUBLE CLICK, LONG CLICK OR LONG-LONG CLICK' trigger. A BMX280 environment
// sensor is also connected using I2C on GPIO 1 and 3.
#elif defined(MY_SONOFF_BUILD02) // This section will be used when src_build_flags contains
// -DMY_SONOFF_BUILD02 in 'platformio_override.ini
// Info - Custom Basic with BMX280 I2C on GPIO 1 and 3
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_BASIC_BMX280" // You can use your own name here
// Disable these
#define DEBUG_SERIAL_SUPPORT 0
#define ALEXA_SUPPORT 0
#define DOMOTICZ_SUPPORT 0
#define HOMEASSISTANT_SUPPORT 0
#define THINGSPEAK_SUPPORT 0
// Buttons
#define BUTTON_MQTT_SEND_ALL_EVENTS 1
#define BUTTON1_PIN 0 // Built in button.
#define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
#define BUTTON1_PRESS BUTTON_MODE_NONE
#define BUTTON1_CLICK BUTTON_MODE_TOGGLE
#define BUTTON1_DBLCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGCLICK BUTTON_MODE_OFF
#define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE
#define BUTTON2_PIN 2 // External push button connected between IO2 and GND.
#define BUTTON2_CONFIG BUTTON_PUSHBUTTON | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH
#define BUTTON2_RELAY 1
#define BUTTON2_PRESS BUTTON_MODE_NONE
#define BUTTON2_CLICK BUTTON_MODE_TOGGLE
#define BUTTON2_DBLCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
// Relays
#define RELAY1_PIN 12
#define RELAY1_TYPE RELAY_TYPE_NORMAL
// LEDs
#define LED1_PIN 13
#define LED1_PIN_INVERSE 1
// Extras
#define BMX280_SUPPORT 1
#define BMX280_ADDRESS 0x76
#define I2C_SDA_PIN 1 //TX PIN **DISABLE DEBUG_SERIAL_SUPPORT**
#define I2C_SCL_PIN 3 //RX PIN **DISABLE DEBUG_SERIAL_SUPPORT**
#endif

+ 2
- 2
code/espurna/config/hardware.h View File

@ -3422,10 +3422,10 @@
#define DEBUG_SERIAL_SUPPORT 0 #define DEBUG_SERIAL_SUPPORT 0
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// Power socket 16A similar to BLITZWOLF_BWSHPX but button pin differs
// Power socket 16A similar to BLITZWOLF_BWSHPX but button pin differs
// IMPORTANT, This template is for hardware version SP111_A_Wifi_Ver1.1 (as printed on the PCB) // IMPORTANT, This template is for hardware version SP111_A_Wifi_Ver1.1 (as printed on the PCB)
// hhttps://www.amazon.de/-/en/Smallest-Consumption-Measuring-Function-Compatible/dp/B07PSMF47W // hhttps://www.amazon.de/-/en/Smallest-Consumption-Measuring-Function-Compatible/dp/B07PSMF47W
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
#elif defined(GOSUND_SP111) #elif defined(GOSUND_SP111)


+ 19
- 23
code/espurna/curtain_kingart.cpp View File

@ -49,7 +49,7 @@ Copyright (C) 2020 - Eric Chauvet
char _KACurtainBuffer[KINGART_CURTAIN_BUFFER_SIZE]; char _KACurtainBuffer[KINGART_CURTAIN_BUFFER_SIZE];
bool _KACurtainNewData = false; bool _KACurtainNewData = false;
// Status vars - for curtain move detection :
// Status vars - for curtain move detection :
int _curtain_position = CURTAIN_POSITION_UNKNOWN; int _curtain_position = CURTAIN_POSITION_UNKNOWN;
int _curtain_last_position = CURTAIN_POSITION_UNKNOWN; int _curtain_last_position = CURTAIN_POSITION_UNKNOWN;
int _curtain_button = CURTAIN_BUTTON_UNKNOWN; int _curtain_button = CURTAIN_BUTTON_UNKNOWN;
@ -90,7 +90,7 @@ int setButtonFromSwitchText(String & text) {
else else
return CURTAIN_BUTTON_UNKNOWN; return CURTAIN_BUTTON_UNKNOWN;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Private // Private
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -98,9 +98,9 @@ int setButtonFromSwitchText(String & text) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//This check that wa got latest and new stats from the AT+RESULT message //This check that wa got latest and new stats from the AT+RESULT message
bool _KAValidStatus() { bool _KAValidStatus() {
return _curtain_button != CURTAIN_BUTTON_UNKNOWN &&
_curtain_last_button != CURTAIN_BUTTON_UNKNOWN &&
_curtain_position != CURTAIN_POSITION_UNKNOWN &&
return _curtain_button != CURTAIN_BUTTON_UNKNOWN &&
_curtain_last_button != CURTAIN_BUTTON_UNKNOWN &&
_curtain_position != CURTAIN_POSITION_UNKNOWN &&
_curtain_last_position != CURTAIN_POSITION_UNKNOWN; _curtain_last_position != CURTAIN_POSITION_UNKNOWN;
} }
@ -166,7 +166,7 @@ void _KAStopMoving() {
else if( _curtain_last_position != CURTAIN_POSITION_UNKNOWN) else if( _curtain_last_position != CURTAIN_POSITION_UNKNOWN)
_curtain_position_set = _curtain_last_position; _curtain_position_set = _curtain_last_position;
if (!_curtain_initial_position_set) { //The curtain stopped moving for the first time, set the position back to
if (!_curtain_initial_position_set) { //The curtain stopped moving for the first time, set the position back to
int init_position = getSetting("curtainBoot", 0); int init_position = getSetting("curtainBoot", 0);
KINGART_DEBUG_MSG_P(PSTR("[KA] curtainBoot : %d, curtainBootPos : %d\n"), init_position, getSetting("curtainBootPos", 100)); KINGART_DEBUG_MSG_P(PSTR("[KA] curtainBoot : %d, curtainBootPos : %d\n"), init_position, getSetting("curtainBootPos", 100));
if (init_position == CURTAIN_INIT_CLOSE) { if (init_position == CURTAIN_INIT_CLOSE) {
@ -226,7 +226,7 @@ The device will determine the direction all by itself.
# Set the Cover / Shutter / Blind / Curtain run time # Set the Cover / Shutter / Blind / Curtain run time
The factory default Open and Close run time for the switch is 50 seconds, and it must be set to
The factory default Open and Close run time for the switch is 50 seconds, and it must be set to
an accurate run time for smooth working. Some motors do not have the resistance stop function, an accurate run time for smooth working. Some motors do not have the resistance stop function,
so when the Cover/Shutter/Blind/Curtain track open or close to the maximum length, but the motor keeps on running. so when the Cover/Shutter/Blind/Curtain track open or close to the maximum length, but the motor keeps on running.
This might cause damage on the motor and the switch, it also wastes a lot of energy. In order This might cause damage on the motor and the switch, it also wastes a lot of energy. In order
@ -255,8 +255,8 @@ void _KACurtainResult() {
const String buffer(_KACurtainBuffer); const String buffer(_KACurtainBuffer);
_curtain_button = CURTAIN_BUTTON_UNKNOWN; _curtain_button = CURTAIN_BUTTON_UNKNOWN;
_curtain_position = CURTAIN_POSITION_UNKNOWN; _curtain_position = CURTAIN_POSITION_UNKNOWN;
if(buffer.indexOf("AT+RESULT") == 0) { //AT+RESULT is an acquitment of our command (MQTT or GUI) if(buffer.indexOf("AT+RESULT") == 0) { //AT+RESULT is an acquitment of our command (MQTT or GUI)
//Set the status on what we kown //Set the status on what we kown
if( ( _curtain_last_button == CURTAIN_BUTTON_OPEN && _curtain_last_position == 0 ) || if( ( _curtain_last_button == CURTAIN_BUTTON_OPEN && _curtain_last_position == 0 ) ||
@ -265,11 +265,11 @@ void _KACurtainResult() {
_KAStopMoving(); _KAStopMoving();
} else { //Else it is probably moving } else { //Else it is probably moving
_KASetMoving(); _KASetMoving();
/*
/*
(*1) ATTENTION THERE : (*1) ATTENTION THERE :
Send immediatly a AT+START - we need to purge the first response.
It will return us the right direction of the switch but the position
we set instead of the real on. We take care of the switch response but
Send immediatly a AT+START - we need to purge the first response.
It will return us the right direction of the switch but the position
we set instead of the real on. We take care of the switch response but
we ignore the position. we ignore the position.
*/ */
_KACurtainSend("AT+START"); _KACurtainSend("AT+START");
@ -289,8 +289,7 @@ void _KACurtainResult() {
switch_text = switch_text.substring(0, leftovers); switch_text = switch_text.substring(0, leftovers);
_curtain_button = setButtonFromSwitchText(switch_text); _curtain_button = setButtonFromSwitchText(switch_text);
} }
}
}
// Get position from MCU // Get position from MCU
int setclose_idx = buffer.indexOf("setclose"); int setclose_idx = buffer.indexOf("setclose");
if (setclose_idx > 0) { if (setclose_idx > 0) {
@ -299,7 +298,7 @@ void _KACurtainResult() {
if (leftovers > 0) { // Not found if finishing by setclose if (leftovers > 0) { // Not found if finishing by setclose
position = position.substring(0, leftovers); position = position.substring(0, leftovers);
} }
if(_curtain_ignore_next_position) { // (*1)
if(_curtain_ignore_next_position) { // (*1)
_curtain_ignore_next_position = false; _curtain_ignore_next_position = false;
} else { } else {
_curtain_position = position.toInt(); _curtain_position = position.toInt();
@ -314,7 +313,7 @@ void _KACurtainResult() {
_KAStopMoving(); _KAStopMoving();
} else if(_curtain_moving ) { } else if(_curtain_moving ) {
if(_KAValidStatus()) { if(_KAValidStatus()) {
if(_curtain_last_button != _curtain_button) //Direction change? Reset the timer to know
if(_curtain_last_button != _curtain_button) //Direction change? Reset the timer to know
_KASetMoving(); _KASetMoving();
else if(_curtain_last_position == _curtain_position) //Same direction, same position - curtain is not moving anymore else if(_curtain_last_position == _curtain_position) //Same direction, same position - curtain is not moving anymore
_KAStopMoving(); _KAStopMoving();
@ -339,7 +338,7 @@ void _KACurtainResult() {
} else if (_curtain_button != CURTAIN_BUTTON_UNKNOWN) { } else if (_curtain_button != CURTAIN_BUTTON_UNKNOWN) {
_curtain_last_button = _curtain_button; _curtain_last_button = _curtain_button;
} }
// Handle configuration button presses // Handle configuration button presses
if (buffer.indexOf("enterESPTOUCH") > 0) { if (buffer.indexOf("enterESPTOUCH") > 0) {
wifiStartAP(); wifiStartAP();
@ -373,7 +372,6 @@ void _curtainMQTTCallback(unsigned int type, const char * topic, char * payload)
} else { } else {
_curtain_position_set = String(payload).toInt(); _curtain_position_set = String(payload).toInt();
_KACurtainSet(CURTAIN_BUTTON_UNKNOWN, _curtain_position_set); _KACurtainSet(CURTAIN_BUTTON_UNKNOWN, _curtain_position_set);
} }
} }
} }
@ -420,7 +418,7 @@ void _curtainWebSocketStatus(JsonObject& root) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void _curtainWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& data) { void _curtainWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& data) {
if (strcmp(action, "curtainAction") == 0) { if (strcmp(action, "curtainAction") == 0) {
if (data.containsKey("position")) { if (data.containsKey("position")) {
_curtain_position_set = data["position"].as<int>(); _curtain_position_set = data["position"].as<int>();
@ -473,13 +471,12 @@ void kingartCurtainSetup() {
// Init port to receive and send messages // Init port to receive and send messages
KINGART_CURTAIN_PORT.begin(KINGART_CURTAIN_BAUDRATE); KINGART_CURTAIN_PORT.begin(KINGART_CURTAIN_BAUDRATE);
#if MQTT_SUPPORT #if MQTT_SUPPORT
// Register MQTT callback only when supported // Register MQTT callback only when supported
mqttRegister(_curtainMQTTCallback); mqttRegister(_curtainMQTTCallback);
#endif // MQTT_SUPPORT #endif // MQTT_SUPPORT
#if WEB_SUPPORT #if WEB_SUPPORT
// Websockets // Websockets
wsRegister() wsRegister()
@ -505,5 +502,4 @@ unsigned char curtainCount() {
return 1; return 1;
} }
#endif // KINGART_CURTAIN_SUPPORT #endif // KINGART_CURTAIN_SUPPORT

+ 0
- 2
code/espurna/libs/AsyncClientHelpers.h View File

@ -10,5 +10,3 @@ enum class AsyncClientState {
Connected, Connected,
Disconnecting Disconnecting
}; };

+ 1
- 1
code/espurna/libs/DebounceEvent.h View File

@ -1,5 +1,5 @@
/* /*
Original code: Original code:
Debounce buttons and trigger events Debounce buttons and trigger events


+ 4
- 4
code/espurna/libs/Encoder.h View File

@ -7,17 +7,17 @@
* Version 1.2 - fix -2 bug in C-only code * Version 1.2 - fix -2 bug in C-only code
* Version 1.1 - expand to support boards with up to 60 interrupts * Version 1.1 - expand to support boards with up to 60 interrupts
* Version 1.0 - initial release * Version 1.0 - initial release
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -38,7 +38,7 @@
#pragma once #pragma once
// _______ _______
// _______ _______
// Pin1 ______| |_______| |______ Pin1 // Pin1 ______| |_______| |______ Pin1
// negative <--- _______ _______ __ --> positive // negative <--- _______ _______ __ --> positive
// Pin2 __| |_______| |_______| Pin2 // Pin2 __| |_______| |_______| Pin2


+ 1
- 1
code/espurna/mqtt.cpp View File

@ -315,7 +315,7 @@ void _mqttConfigure() {
const auto qos = getSetting("mqttQoS", MQTT_QOS); const auto qos = getSetting("mqttQoS", MQTT_QOS);
const bool retain = getSetting("mqttRetain", 1 == MQTT_RETAIN); const bool retain = getSetting("mqttRetain", 1 == MQTT_RETAIN);
// Note: MQTT spec defines this as 2 bytes // Note: MQTT spec defines this as 2 bytes
const auto keepalive = constrain( const auto keepalive = constrain(
getSetting("mqttKeep", MQTT_KEEPALIVE), getSetting("mqttKeep", MQTT_KEEPALIVE),


+ 2
- 2
code/espurna/ntp.cpp View File

@ -181,7 +181,7 @@ String _ntpGetServer() {
void _ntpReport() { void _ntpReport() {
if (!ntpSynced()) { if (!ntpSynced()) {
DEBUG_MSG_P(PSTR("[NTP] Not synced\n"));
DEBUG_MSG_P(PSTR("[NTP] Not synced\n"));
return; return;
} }
@ -214,7 +214,7 @@ void _ntpConfigure() {
setenv("TZ", cfg_tz.c_str(), 1); setenv("TZ", cfg_tz.c_str(), 1);
tzset(); tzset();
} }
const auto cfg_server = getSetting("ntpServer", F(NTP_SERVER)); const auto cfg_server = getSetting("ntpServer", F(NTP_SERVER));
const auto active_server = _ntpGetServer(); const auto active_server = _ntpGetServer();
if (cfg_tz != active_tz) { if (cfg_tz != active_tz) {


+ 3
- 3
code/espurna/ntp_timelib.h View File

@ -25,7 +25,7 @@ constexpr time_t secondsY2K = 946684800; // the time at the start of y2k
template <typename T> template <typename T>
constexpr const T numberOfSeconds(T ts) { constexpr const T numberOfSeconds(T ts) {
return (ts % (T)secondsPerMinute); return (ts % (T)secondsPerMinute);
}
}
template <typename T> template <typename T>
constexpr const T numberOfMinutes(T ts) { constexpr const T numberOfMinutes(T ts) {
@ -47,7 +47,7 @@ constexpr const int elapsedDays(uint32_t ts) {
return (ts / secondsPerDay); return (ts / secondsPerDay);
} }
// the number of seconds since last midnight
// the number of seconds since last midnight
constexpr const uint32_t elapsedSecsToday(uint32_t ts) { constexpr const uint32_t elapsedSecsToday(uint32_t ts) {
return (ts % (uint32_t)secondsPerDay); return (ts % (uint32_t)secondsPerDay);
} }
@ -65,7 +65,7 @@ constexpr const time_t previousMidnight(time_t ts) {
return ((ts / secondsPerDay) * secondsPerDay); return ((ts / secondsPerDay) * secondsPerDay);
} }
// time at the end of the given day
// time at the end of the given day
constexpr const time_t nextMidnight(time_t ts) { constexpr const time_t nextMidnight(time_t ts) {
return previousMidnight(ts) + secondsPerDay; return previousMidnight(ts) + secondsPerDay;
} }


+ 1
- 1
code/espurna/sensors/AnalogSensor.h View File

@ -68,7 +68,7 @@ class AnalogSensor : public BaseAnalogSensor {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Initialization method, must be idempotent // Initialization method, must be idempotent
void begin() {
void begin() {
_ready = true; _ready = true;
} }


+ 5
- 5
code/espurna/sensors/BMP180Sensor.h View File

@ -145,7 +145,7 @@ class BMP180Sensor : public I2CSensor<> {
_bmp180_calib.ac1 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC1); _bmp180_calib.ac1 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC1);
_bmp180_calib.ac2 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC2); _bmp180_calib.ac2 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC2);
_bmp180_calib.ac3 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC3); _bmp180_calib.ac3 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC3);
_bmp180_calib.ac4 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC4); _bmp180_calib.ac4 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC4);
_bmp180_calib.ac5 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC5); _bmp180_calib.ac5 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC5);
_bmp180_calib.ac6 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC6); _bmp180_calib.ac6 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC6);
@ -157,9 +157,9 @@ class BMP180Sensor : public I2CSensor<> {
_bmp180_calib.md = i2c_read_int16(_address, BMP180_REGISTER_CAL_MD); _bmp180_calib.md = i2c_read_int16(_address, BMP180_REGISTER_CAL_MD);
} }
// Compute B5 coefficient used in temperature & pressure calcs. // Compute B5 coefficient used in temperature & pressure calcs.
// Based on Adafruit_BMP085_Unified library
// Based on Adafruit_BMP085_Unified library
long _computeB5(unsigned long t) { long _computeB5(unsigned long t) {
long X1 = (t - (long)_bmp180_calib.ac6) * ((long)_bmp180_calib.ac5) >> 15; long X1 = (t - (long)_bmp180_calib.ac6) * ((long)_bmp180_calib.ac5) >> 15;
long X2 = ((long)_bmp180_calib.mc << 11) / (X1+(long)_bmp180_calib.md); long X2 = ((long)_bmp180_calib.mc << 11) / (X1+(long)_bmp180_calib.md);
@ -234,11 +234,11 @@ class BMP180Sensor : public I2CSensor<> {
int16_t b1; int16_t b1;
int16_t b2; int16_t b2;
int16_t mb; int16_t mb;
int16_t mc; int16_t mc;
int16_t md; int16_t md;
} bmp180_calib_t; } bmp180_calib_t;
bmp180_calib_t _bmp180_calib; bmp180_calib_t _bmp180_calib;


+ 1
- 1
code/espurna/sensors/BaseEmonSensor.h View File

@ -71,7 +71,7 @@ class BaseEmonSensor : public BaseSensor {
virtual double defaultVoltage() { virtual double defaultVoltage() {
return 0.0; return 0.0;
} }
// when sensor needs explicit mains voltage value // when sensor needs explicit mains voltage value
virtual void setVoltage(double) {} virtual void setVoltage(double) {}
virtual void setVoltage(unsigned char index, double value) { virtual void setVoltage(unsigned char index, double value) {


+ 17
- 17
code/espurna/sensors/DallasSensor.h View File

@ -33,31 +33,31 @@
#define DS2406_CHANNEL_ACCESS 0xF5; #define DS2406_CHANNEL_ACCESS 0xF5;
// CHANNEL CONTROL BYTE // CHANNEL CONTROL BYTE
// 7 6 5 4 3 2 1 0
// 7 6 5 4 3 2 1 0
// ALR IM TOG IC CHS1 CHS0 CRC1 CRC0 // ALR IM TOG IC CHS1 CHS0 CRC1 CRC0
// 0 1 0 0 0 1 0 1 0x45 // 0 1 0 0 0 1 0 1 0x45
// CHS1 CHS0 Description
// 0 0 (not allowed)
// 0 1 channel A only
// 1 0 channel B only
// 1 1 both channels interleaved
// CHS1 CHS0 Description
// 0 0 (not allowed)
// 0 1 channel A only
// 1 0 channel B only
// 1 1 both channels interleaved
// TOG IM CHANNELS EFFECT // TOG IM CHANNELS EFFECT
// 0 0 one channel Write all bits to the selected channel
// 0 1 one channel Read all bits from the selected channel
// 1 0 one channel Write 8 bits, read 8 bits, write, read, etc. to/from the selected channel
// 1 1 one channel Read 8 bits, write 8 bits, read, write, etc. from/to the selected channel
// 0 0 two channels Repeat: four times (write A, write B)
// 0 1 two channels Repeat: four times (read A, read B)
// 1 0 two channels Four times: (write A, write B), four times: (readA, read B), write, read, etc.
// 0 0 one channel Write all bits to the selected channel
// 0 1 one channel Read all bits from the selected channel
// 1 0 one channel Write 8 bits, read 8 bits, write, read, etc. to/from the selected channel
// 1 1 one channel Read 8 bits, write 8 bits, read, write, etc. from/to the selected channel
// 0 0 two channels Repeat: four times (write A, write B)
// 0 1 two channels Repeat: four times (read A, read B)
// 1 0 two channels Four times: (write A, write B), four times: (readA, read B), write, read, etc.
// 1 1 two channels Four times: (read A, read B), four times: (write A, write B), read, write, etc. // 1 1 two channels Four times: (read A, read B), four times: (write A, write B), read, write, etc.
// CRC1 CRC0 Description // CRC1 CRC0 Description
// 0 0 CRC disabled (no CRC at all) // 0 0 CRC disabled (no CRC at all)
// 0 1 CRC after every byte // 0 1 CRC after every byte
// 1 0 CRC after 8 bytes // 1 0 CRC after 8 bytes
// 1 1 CRC after 32 bytes
// 1 1 CRC after 32 bytes
#define DS2406_CHANNEL_CONTROL_BYTE 0x45; #define DS2406_CHANNEL_CONTROL_BYTE 0x45;
#define DS2406_STATE_BUF_LEN 7 #define DS2406_STATE_BUF_LEN 7
@ -165,7 +165,7 @@ class DallasSensor : public BaseSensor {
_devices[index].data[0] = _devices[index].data[0] + 1; _devices[index].data[0] = _devices[index].data[0] + 1;
return; return;
} }
_wire->select(_devices[index].address); _wire->select(_devices[index].address);
data[0] = DS2406_CHANNEL_ACCESS; data[0] = DS2406_CHANNEL_ACCESS;
@ -261,8 +261,8 @@ class DallasSensor : public BaseSensor {
return MAGNITUDE_DIGITAL; return MAGNITUDE_DIGITAL;
} else { } else {
return MAGNITUDE_TEMPERATURE; return MAGNITUDE_TEMPERATURE;
}
}
}
}
return MAGNITUDE_NONE; return MAGNITUDE_NONE;
} }


+ 5
- 5
code/espurna/sensors/PZEM004TV30Sensor.h View File

@ -342,11 +342,11 @@ class PZEM004TV30Sensor : public BaseEmonSensor {
// Quoting the README.md of the original library repo and datasheet, we have: // Quoting the README.md of the original library repo and datasheet, we have:
// (name, measuring range, resolution, accuracy) // (name, measuring range, resolution, accuracy)
// 1. Voltage 80~260V 0.1V 0.5%
// 2. Current 0~10A or 0~100A* 0.01A or 0.02A* 0.5%
// 3. Active power 0~2.3kW or 0~23kW* 0.1W 0.5%
// 4. Active energy 0~9999.99kWh 1Wh 0.5%
// 5. Frequency 45~65Hz 0.1Hz 0.5%
// 1. Voltage 80~260V 0.1V 0.5%
// 2. Current 0~10A or 0~100A* 0.01A or 0.02A* 0.5%
// 3. Active power 0~2.3kW or 0~23kW* 0.1W 0.5%
// 4. Active energy 0~9999.99kWh 1Wh 0.5%
// 5. Frequency 45~65Hz 0.1Hz 0.5%
// 6. Power factor 0.00~1.00 0.01 1% // 6. Power factor 0.00~1.00 0.01 1%
void parseMeasurements(buffer_type&& buffer, size_t size) { void parseMeasurements(buffer_type&& buffer, size_t size) {
if (25 != size) { if (25 != size) {


+ 4
- 4
code/espurna/sensors/SI1145Sensor.h View File

@ -23,7 +23,7 @@ class SI1145Sensor : public I2CSensor<> {
_si1145 = new Adafruit_SI1145(); _si1145 = new Adafruit_SI1145();
} }
void begin() {
void begin() {
static unsigned char addresses[1] = { SI1145_ADDRESS }; static unsigned char addresses[1] = { SI1145_ADDRESS };
_address = _begin_i2c(_address, sizeof(addresses), addresses); _address = _begin_i2c(_address, sizeof(addresses), addresses);
if (_address == 0) return; if (_address == 0) return;
@ -68,13 +68,13 @@ class SI1145Sensor : public I2CSensor<> {
// Current value for slot # index // Current value for slot # index
double value(unsigned char index) { double value(unsigned char index) {
if (index == 0) return _uvi;
if (index == 0) return _uvi;
return 0.0; return 0.0;
} }
protected:
protected:
Adafruit_SI1145 * _si1145 = nullptr; Adafruit_SI1145 * _si1145 = nullptr;
double _uvi = 0.0; double _uvi = 0.0;
}; };
#endif // SENSOR_SUPPORT && SI1145_SUPPORT #endif // SENSOR_SUPPORT && SI1145_SUPPORT

+ 1
- 1
code/espurna/settings.cpp View File

@ -162,7 +162,7 @@ struct SettingsKeys {
} }
bool operator !=(iterator& const other) const { bool operator !=(iterator& const other) const {
return !(*this == other);
return !(*this == other);
} }
using difference_type = size_t; using difference_type = size_t;


+ 0
- 1
code/espurna/settings_embedis.h View File

@ -523,7 +523,6 @@ class KeyValueStore {
// implementation quirk is that `Cursor::operator=` won't work because of the `RawStorageBase&` member // implementation quirk is that `Cursor::operator=` won't work because of the `RawStorageBase&` member
// right now, just construct in place and assume that compiler will inline things // right now, just construct in place and assume that compiler will inline things
// on one hand, we can implement it. but, we can't specifically
KeyValueResult _read_kv() { KeyValueResult _read_kv() {
auto key = _raw_read(); auto key = _raw_read();
if (!key || !key.length) { if (!key || !key.length) {


+ 1
- 1
code/espurna/terminal.cpp View File

@ -651,5 +651,5 @@ void terminalSetup() {
} }
#endif // TERMINAL_SUPPORT
#endif // TERMINAL_SUPPORT

+ 1
- 1
code/espurna/thingspeak.cpp View File

@ -363,7 +363,7 @@ void _tspkPost(const String& address) {
auto client = std::make_unique<WiFiClient>(); auto client = std::make_unique<WiFiClient>();
_tspkPost(*client.get(), url, false); _tspkPost(*client.get(), url, false);
return; return;
}
}
} }


+ 1
- 1
code/espurna/tuya_protocol.h View File

@ -99,7 +99,7 @@ namespace Tuya {
template <> template <>
std::vector<uint8_t> DataProtocol<bool>::serialize() { std::vector<uint8_t> DataProtocol<bool>::serialize() {
return std::vector<uint8_t> { return std::vector<uint8_t> {
_id, static_cast<uint8_t>(Type::BOOL), 0x00, 0x01,
_id, static_cast<uint8_t>(Type::BOOL), 0x00, 0x01,
static_cast<uint8_t>(_value) static_cast<uint8_t>(_value)
}; };
} }


+ 2
- 2
code/espurna/tuya_transport.h View File

@ -72,10 +72,10 @@ namespace Tuya {
Output(Stream& stream) : Output(Stream& stream) :
StreamWrapper(stream)
StreamWrapper(stream)
{} {}
Output(StreamString& stream, size_t length) :
Output(StreamString& stream, size_t length) :
Output(stream) Output(stream)
{ {
stream.reserve((length * 2) + 1); stream.reserve((length * 2) + 1);


+ 2
- 2
code/espurna/utils.cpp View File

@ -220,7 +220,7 @@ unsigned int getInitialFreeHeap() {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
namespace Heartbeat { namespace Heartbeat {
enum Report : uint32_t {
enum Report : uint32_t {
Status = 1 << 1, Status = 1 << 1,
Ssid = 1 << 2, Ssid = 1 << 2,
Ip = 1 << 3, Ip = 1 << 3,
@ -434,7 +434,7 @@ void heartbeat() {
if ((hb_cfg & Heartbeat::Vcc) && (ADC_MODE_VALUE == ADC_VCC)) if ((hb_cfg & Heartbeat::Vcc) && (ADC_MODE_VALUE == ADC_VCC))
idbSend(MQTT_TOPIC_VCC, String(ESP.getVcc()).c_str()); idbSend(MQTT_TOPIC_VCC, String(ESP.getVcc()).c_str());
if (hb_cfg & Heartbeat::Loadavg) if (hb_cfg & Heartbeat::Loadavg)
idbSend(MQTT_TOPIC_LOADAVG, String(systemLoadAverage()).c_str()); idbSend(MQTT_TOPIC_LOADAVG, String(systemLoadAverage()).c_str());


+ 1
- 1
code/test/unit/terminal/terminal.cpp View File

@ -228,7 +228,7 @@ void test_case_insensitive() {
str.out += String("TeSt.lOwErCaSe1\r\n"); str.out += String("TeSt.lOwErCaSe1\r\n");
TEST_ASSERT_EQUAL(terminal::Terminal::Result::Command, handler.processLine()); TEST_ASSERT_EQUAL(terminal::Terminal::Result::Command, handler.processLine());
} }
// We can use command ctx.output to send something back into the stream // We can use command ctx.output to send something back into the stream


Loading…
Cancel
Save