16#include "stdlib_noniso.h"
21#define KSF_ONE_SEC_MS 1000UL
28#define KSF_SEC_TO_MS(seconds) (seconds*1000UL)
30#ifndef KSF_MQTT_RECONNECT_DELAY_MS
32#define KSF_MQTT_RECONNECT_DELAY_MS 10000UL
35#ifndef KSF_MQTT_TIMEOUT_MS
37#define KSF_MQTT_TIMEOUT_MS 4000UL
40#ifndef KSF_WIFI_TIMEOUT_MS
42#define KSF_WIFI_TIMEOUT_MS 120000UL
45#ifndef KSF_WIFI_RECONNECT_TIME_MS
47#define KSF_WIFI_RECONNECT_TIME_MS 5000UL
50#ifndef KSF_WATCHDOG_TIMEOUT_SECS
52#define KSF_WATCHDOG_TIMEOUT_SECS 10UL
56#define KSF_FRAMEWORK_INIT() ksf::initializeFramework();
80 extern const char* getNvsDirectory();
85 extern void initializeFramework();
92 extern bool removeDirectory(
const char* path);
98 extern bool eraseConfigData();
103 extern void updateDeviceUptime();
109 extern uint64_t millis64();
119 extern std::string to_string(
double value,
const int base);
130 extern std::string to_string(
float value,
const int base);
140 template <
typename _Type>
141 inline std::string to_string(
const _Type& input)
143 return std::to_string(input);
156 template <
typename _In,
typename _Out>
157 bool from_chars(
const _In& input, _Out& out)
159 const auto& result{std::from_chars(input.data(), input.data() + input.size(), out)};
160 return result.ec == std::errc();
171 extern EOTAType::Type getOtaBootType();
180 extern void saveOtaBootIndicator(EOTAType::Type type = EOTAType::OTA_GENERIC);
193 template<
class _Type1,
class _Type2>
194 inline bool starts_with(
const _Type1& input,
const _Type2& match)
196 return input.size() >= match.size() && std::equal(match.begin(), match.end(), input.begin());
202 extern const std::string getResetReason();
209 extern const std::string getUptimeFromSeconds(uint32_t seconds);
215 extern const std::string getUptimeString();
222 extern void loadCredentials(std::string& ssid, std::string& password);
229 extern void saveCredentials(std::string ssid, std::string password);