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);
153 inline std::string to_hex(
int value)
159 unsigned int uvalue{
static_cast<unsigned int>(value)}, pos{8};
163 unsigned int nibble{uvalue & 0xf};
164 buffer[--pos] = (nibble < 10) ? (
'0' + nibble) : (
'a' + (nibble - 10));
168 return std::string(buffer + pos, 8 - pos);
181 template <
typename _In,
typename _Out>
182 bool from_chars(
const _In& input, _Out& out)
184 const auto& result{std::from_chars(input.data(), input.data() + input.size(), out)};
185 return result.ec == std::errc();
196 std::string getDeviceUuidHex();
206 extern EOTAType::Type getOtaBootType();
215 extern void saveOtaBootIndicator(EOTAType::Type type = EOTAType::OTA_GENERIC);
228 template<
class _Type1,
class _Type2>
229 inline bool starts_with(
const _Type1& input,
const _Type2& match)
231 return input.size() >= match.size() && std::equal(match.begin(), match.end(), input.begin());
237 extern const std::string getResetReason();
244 extern const std::string getUptimeFromSeconds(uint32_t seconds);
250 extern const std::string getUptimeString();
257 extern void loadCredentials(std::string& ssid, std::string& password);
264 extern void saveCredentials(std::string ssid, std::string password);