Added udp cloud options and ledstrip fixes
This commit is contained in:
@@ -123,6 +123,8 @@ struct CanReceiveRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_
|
|||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
struct CloudCollectRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.cloudCollectRate; } };
|
struct CloudCollectRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.cloudCollectRate; } };
|
||||||
struct CloudSendRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.cloudSendRate; } };
|
struct CloudSendRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.cloudSendRate; } };
|
||||||
|
struct UdpCloudSendIntervalAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.udpSendRateMs; } };
|
||||||
|
struct UdpCloudEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.cloudSettings.udpCloudEnabled; } };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct DefaultModeModelModeAccessor : public RefAccessorSaveSettings<UnifiedModelMode> { UnifiedModelMode &getRef() const override { return settings.defaultMode.modelMode; } };
|
struct DefaultModeModelModeAccessor : public RefAccessorSaveSettings<UnifiedModelMode> { UnifiedModelMode &getRef() const override { return settings.defaultMode.modelMode; } };
|
||||||
@@ -171,7 +173,7 @@ struct LedsStVOFrontLengthAccessor : public RefAccessorSaveSettings<int16_t> { i
|
|||||||
struct EnableLedstripStVOFrontlight : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.stvoFrontEnable; } };
|
struct EnableLedstripStVOFrontlight : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.stvoFrontEnable; } };
|
||||||
struct AnimationMultiplierAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.animationMultiplier; } };
|
struct AnimationMultiplierAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.animationMultiplier; } };
|
||||||
struct LedstripBrightnessAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.ledstrip.brightness; } };
|
struct LedstripBrightnessAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.ledstrip.brightness; } };
|
||||||
struct LedstripEnableBlinkAnimation : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableAnimBlink; } };
|
struct LedstripEnableBlinkAnimationAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableAnimBlink; } };
|
||||||
struct LedstripOtaAnimationAccessor : public RefAccessorSaveSettings<OtaAnimationModes> { OtaAnimationModes &getRef() const override { return settings.ledstrip.otaMode; } };
|
struct LedstripOtaAnimationAccessor : public RefAccessorSaveSettings<OtaAnimationModes> { OtaAnimationModes &getRef() const override { return settings.ledstrip.otaMode; } };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -50,6 +50,14 @@ using CloudSendRateChangeDisplay = espgui::makeComponent<
|
|||||||
espgui::BackActionInterface<espgui::SwitchScreenAction<CloudSettingsMenu>>,
|
espgui::BackActionInterface<espgui::SwitchScreenAction<CloudSettingsMenu>>,
|
||||||
espgui::SwitchScreenAction<CloudSettingsMenu>
|
espgui::SwitchScreenAction<CloudSettingsMenu>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
using UdpCloudSendRateChangeDisplay = espgui::makeComponent<
|
||||||
|
espgui::ChangeValueDisplay<int16_t>,
|
||||||
|
espgui::StaticText<TEXT_UDPSENDRATE>,
|
||||||
|
UdpCloudSendIntervalAccessor,
|
||||||
|
espgui::BackActionInterface<espgui::SwitchScreenAction<CloudSettingsMenu>>,
|
||||||
|
espgui::SwitchScreenAction<CloudSettingsMenu>
|
||||||
|
>;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
using namespace espgui;
|
using namespace espgui;
|
||||||
@@ -57,6 +65,7 @@ using namespace espgui;
|
|||||||
CloudSettingsMenu::CloudSettingsMenu()
|
CloudSettingsMenu::CloudSettingsMenu()
|
||||||
{
|
{
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDENABLED>, ToggleBoolAction, CheckboxIcon, CloudEnabledAccessor>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDENABLED>, ToggleBoolAction, CheckboxIcon, CloudEnabledAccessor>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UDPCLOUDENABLED>, ToggleBoolAction, CheckboxIcon, UdpCloudEnabledAccessor>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDTRANSMITTIMEOUT>, SwitchScreenAction<CloudTransmitTimeoutChangeScreen>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDTRANSMITTIMEOUT>, SwitchScreenAction<CloudTransmitTimeoutChangeScreen>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, CloudCreatedText, DisabledColor, DummyAction>>();
|
constructMenuItem<makeComponent<MenuItem, CloudCreatedText, DisabledColor, DummyAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, CloudStartedText, DisabledColor, DummyAction>>();
|
constructMenuItem<makeComponent<MenuItem, CloudStartedText, DisabledColor, DummyAction>>();
|
||||||
@@ -64,6 +73,7 @@ CloudSettingsMenu::CloudSettingsMenu()
|
|||||||
constructMenuItem<makeComponent<MenuItem, CloudBufferLengthText, DisabledColor, DummyAction>>();
|
constructMenuItem<makeComponent<MenuItem, CloudBufferLengthText, DisabledColor, DummyAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDCOLLECTRATE>, SwitchScreenAction<CloudCollectRateChangeDisplay>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDCOLLECTRATE>, SwitchScreenAction<CloudCollectRateChangeDisplay>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDSENDRATE>, SwitchScreenAction<CloudSendRateChangeDisplay>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDSENDRATE>, SwitchScreenAction<CloudSendRateChangeDisplay>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UDPSENDRATE>, SwitchScreenAction<UdpCloudSendRateChangeDisplay>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ namespace {
|
|||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKLEFT>, LedstripAnimationBlinkLeftAction>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKLEFT>, LedstripAnimationBlinkLeftAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKRIGHT>, LedstripAnimationBlinkRightAction>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKRIGHT>, LedstripAnimationBlinkRightAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKBOTH>, LedstripAnimationBlinkBothAction>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKBOTH>, LedstripAnimationBlinkBothAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_EN_BLINK_ANIM>, ToggleBoolAction, CheckboxIcon, LedstripEnableBlinkAnimation>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_EN_BLINK_ANIM>, ToggleBoolAction, CheckboxIcon, LedstripEnableBlinkAnimationAccessor>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -213,7 +213,7 @@ void updateLedStrip()
|
|||||||
|
|
||||||
void showAnimation()
|
void showAnimation()
|
||||||
{
|
{
|
||||||
if (settings.ledstrip.enableLedAnimation && !simplified && (!asyncOtaTaskStarted || settings.ledstrip.otaMode != OtaAnimationModes::None))
|
if (settings.ledstrip.enableLedAnimation && !simplified && !(asyncOtaTaskStarted && settings.ledstrip.otaMode != OtaAnimationModes::None))
|
||||||
{
|
{
|
||||||
if (animation_type == LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW) showDefaultLedstrip();
|
if (animation_type == LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW) showDefaultLedstrip();
|
||||||
else if (animation_type == LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW) showBetterRainbow();
|
else if (animation_type == LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW) showBetterRainbow();
|
||||||
|
@@ -449,6 +449,7 @@ extern "C" void app_main()
|
|||||||
#endif
|
#endif
|
||||||
calculateStatistics();
|
calculateStatistics();
|
||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
|
if (settings.cloudSettings.udpCloudEnabled)
|
||||||
sendUdpCloudPacket();
|
sendUdpCloudPacket();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -147,6 +147,7 @@ constexpr Settings::BoardcomputerHardware::TimersSettings defaultTimersSettings
|
|||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
.cloudCollectRate = 100,
|
.cloudCollectRate = 100,
|
||||||
.cloudSendRate = 1,
|
.cloudSendRate = 1,
|
||||||
|
.udpSendRateMs = 65,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,6 +176,7 @@ constexpr Settings::CloudSettings defaultCloudSettings {
|
|||||||
.cloudEnabled = false,
|
.cloudEnabled = false,
|
||||||
.cloudTransmitTimeout = 10,
|
.cloudTransmitTimeout = 10,
|
||||||
.udpUid = 0,
|
.udpUid = 0,
|
||||||
|
.udpCloudEnabled = false,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -113,6 +113,7 @@ struct Settings
|
|||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
int16_t cloudCollectRate;
|
int16_t cloudCollectRate;
|
||||||
int16_t cloudSendRate;
|
int16_t cloudSendRate;
|
||||||
|
int16_t udpSendRateMs;
|
||||||
#endif
|
#endif
|
||||||
} timersSettings;
|
} timersSettings;
|
||||||
} boardcomputerHardware;
|
} boardcomputerHardware;
|
||||||
@@ -122,6 +123,7 @@ struct Settings
|
|||||||
bool cloudEnabled;
|
bool cloudEnabled;
|
||||||
int16_t cloudTransmitTimeout; // in ms
|
int16_t cloudTransmitTimeout; // in ms
|
||||||
uint32_t udpUid;
|
uint32_t udpUid;
|
||||||
|
bool udpCloudEnabled;
|
||||||
} cloudSettings;
|
} cloudSettings;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -282,12 +284,14 @@ void Settings::executeForEveryCommonSetting(T &&callable)
|
|||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
callable("cloudCollectRat", boardcomputerHardware.timersSettings.cloudCollectRate);
|
callable("cloudCollectRat", boardcomputerHardware.timersSettings.cloudCollectRate);
|
||||||
callable("cloudSendRate", boardcomputerHardware.timersSettings.cloudSendRate);
|
callable("cloudSendRate", boardcomputerHardware.timersSettings.cloudSendRate);
|
||||||
|
callable("udpSendRate", boardcomputerHardware.timersSettings.udpSendRateMs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
callable("cloudEnabled", cloudSettings.cloudEnabled);
|
callable("cloudEnabled", cloudSettings.cloudEnabled);
|
||||||
callable("clodTransmTmout", cloudSettings.cloudTransmitTimeout);
|
callable("clodTransmTmout", cloudSettings.cloudTransmitTimeout);
|
||||||
callable("cloudUDPUid", cloudSettings.udpUid);
|
callable("cloudUDPUid", cloudSettings.udpUid);
|
||||||
|
callable("enUdpCloud", cloudSettings.udpCloudEnabled);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEATURE_LEDSTRIP
|
#ifdef FEATURE_LEDSTRIP
|
||||||
|
@@ -48,10 +48,12 @@ constexpr char TEXT_BLEENABLED[] = "BLE enabled";
|
|||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
//CloudSettingsMenu
|
//CloudSettingsMenu
|
||||||
constexpr char TEXT_CLOUDSETTINGS[] = "Cloud settings";
|
constexpr char TEXT_CLOUDSETTINGS[] = "Cloud settings";
|
||||||
constexpr char TEXT_CLOUDENABLED[] = "Cloud enabled";
|
constexpr char TEXT_CLOUDENABLED[] = "Tcp Cloud enabled";
|
||||||
|
constexpr char TEXT_UDPCLOUDENABLED[] = "Udp Cloud enabled";
|
||||||
constexpr char TEXT_CLOUDTRANSMITTIMEOUT[] = "Transmit timeout";
|
constexpr char TEXT_CLOUDTRANSMITTIMEOUT[] = "Transmit timeout";
|
||||||
constexpr char TEXT_CLOUDCOLLECTRATE[] = "Cloud collect rate";
|
constexpr char TEXT_CLOUDCOLLECTRATE[] = "Cloud collect rate";
|
||||||
constexpr char TEXT_CLOUDSENDRATE[] = "Cloud send rate";
|
constexpr char TEXT_CLOUDSENDRATE[] = "Cloud send rate";
|
||||||
|
constexpr char TEXT_UDPSENDRATE[] = "Udp send rate";
|
||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -4,6 +4,11 @@ constexpr const char * const TAG = "bobbycloud";
|
|||||||
// 3rd party includes
|
// 3rd party includes
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
|
#ifdef FEATURE_OTA
|
||||||
|
#include <espcppmacros.h>
|
||||||
|
#include <espstrutils.h>
|
||||||
|
#include <esp_ota_ops.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "udpcloud.h"
|
#include "udpcloud.h"
|
||||||
@@ -19,6 +24,8 @@ constexpr const char * const TAG = "bobbycloud";
|
|||||||
#include "drivingstatistics.h"
|
#include "drivingstatistics.h"
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
// Little "flash" on statusdisplay when udp stuff is happening
|
||||||
|
bool visualSendUdpPacket;
|
||||||
|
|
||||||
espchrono::millis_clock::time_point timestampLastFailed;
|
espchrono::millis_clock::time_point timestampLastFailed;
|
||||||
|
|
||||||
@@ -115,6 +122,14 @@ std::string buildUdpCloudJson()
|
|||||||
doc["wN"] = drivingStatistics.wh_used;
|
doc["wN"] = drivingStatistics.wh_used;
|
||||||
doc["wL"] = getRemainingWattHours();
|
doc["wL"] = getRemainingWattHours();
|
||||||
doc["kmL"] = getRemainingWattHours() / settings.battery.watthoursPerKilometer;
|
doc["kmL"] = getRemainingWattHours() / settings.battery.watthoursPerKilometer;
|
||||||
|
//#ifdef FEATURE_OTA
|
||||||
|
// if (const esp_app_desc_t *app_desc = esp_ota_get_app_description())
|
||||||
|
// {
|
||||||
|
// doc["ver"] = espcpputils::toHexString({app_desc->app_elf_sha256, 8});
|
||||||
|
// }
|
||||||
|
//#else
|
||||||
|
// doc["ver"] = "-";
|
||||||
|
//#endif
|
||||||
|
|
||||||
serializeJson(doc, buf);
|
serializeJson(doc, buf);
|
||||||
return buf;
|
return buf;
|
||||||
@@ -122,17 +137,22 @@ std::string buildUdpCloudJson()
|
|||||||
|
|
||||||
void sendUdpCloudPacket()
|
void sendUdpCloudPacket()
|
||||||
{
|
{
|
||||||
EVERY_N_MILLIS(30) {
|
EVERY_N_MILLIS(settings.boardcomputerHardware.timersSettings.udpSendRateMs) {
|
||||||
if (espchrono::ago(timestampLastFailed) < 3s)
|
if (espchrono::ago(timestampLastFailed) < 3s)
|
||||||
|
{
|
||||||
|
visualSendUdpPacket = false;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (stringSettings.udpCloudUrl.empty())
|
if (stringSettings.udpCloudUrl.empty())
|
||||||
{
|
{
|
||||||
|
visualSendUdpPacket = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
|
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
|
||||||
{
|
{
|
||||||
|
visualSendUdpPacket = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,12 +169,14 @@ void sendUdpCloudPacket()
|
|||||||
ESP_LOGE(TAG, "dns_gethostbyname() failed because: %i", res);
|
ESP_LOGE(TAG, "dns_gethostbyname() failed because: %i", res);
|
||||||
}
|
}
|
||||||
timestampLastFailed = espchrono::millis_clock::now();
|
timestampLastFailed = espchrono::millis_clock::now();
|
||||||
|
visualSendUdpPacket = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (udpCloudIp.type != IPADDR_TYPE_V4)
|
if (udpCloudIp.type != IPADDR_TYPE_V4)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "unsupported ip type: %hhu", udpCloudIp.type);
|
ESP_LOGE(TAG, "unsupported ip type: %hhu", udpCloudIp.type);
|
||||||
|
visualSendUdpPacket = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +195,7 @@ void sendUdpCloudPacket()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "now: %s", buf.c_str());
|
ESP_LOGD(TAG, "now: %s", buf.c_str());
|
||||||
|
visualSendUdpPacket = !visualSendUdpPacket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// Little "flash" on statusdisplay when udp stuff is happening
|
||||||
|
extern bool visualSendUdpPacket;
|
||||||
|
|
||||||
void spamUdpBroadcast();
|
void spamUdpBroadcast();
|
||||||
std::string buildUdpCloudJson();
|
std::string buildUdpCloudJson();
|
||||||
void sendUdpCloudPacket();
|
void sendUdpCloudPacket();
|
||||||
|
Reference in New Issue
Block a user