17#include <stdlib_noniso.h>
20#define KSF_ONE_SEC_MS 1000UL
27#define KSF_SEC_TO_MS(seconds) (seconds*1000UL)
29#ifndef KSF_MQTT_RECONNECT_DELAY_MS
31#define KSF_MQTT_RECONNECT_DELAY_MS 10000UL
34#ifndef KSF_DOMAIN_QUERY_INTERVAL_MS
36#define KSF_DOMAIN_QUERY_INTERVAL_MS 3000UL
39#ifndef KSF_DOMAIN_QUERY_DNS_SERVER
41#define KSF_DOMAIN_QUERY_DNS_SERVER IPAddress(8, 8, 8, 8)
44#ifndef KSF_MQTT_TIMEOUT_MS
46#define KSF_MQTT_TIMEOUT_MS 4000UL
49#ifndef KSF_WIFI_TIMEOUT_MS
51#define KSF_WIFI_TIMEOUT_MS 120000UL
54#ifndef KSF_WIFI_RECONNECT_TIME_MS
56#define KSF_WIFI_RECONNECT_TIME_MS 5000UL
59#ifndef KSF_WATCHDOG_TIMEOUT_SECS
61#define KSF_WATCHDOG_TIMEOUT_SECS 10UL
65#define KSF_FRAMEWORK_INIT() ksf::initializeFramework();
68#define KSF_LIBRARY_VERSION "1.0.49"
92 extern const char* getNvsDirectory();
97 extern void initializeFramework();
104 extern bool removeDirectory(
const char* path);
110 extern bool eraseConfigData();
115 extern void updateDeviceUptime();
121 extern uint64_t millis64();
131 extern std::string to_string(
double value,
const int base);
142 extern std::string to_string(
float value,
const int base);
152 template <
typename _Type>
153 inline std::string to_string(
const _Type& input)
155 return std::to_string(input);
165 inline std::string to_hex(
int value)
171 unsigned int uvalue{
static_cast<unsigned int>(value)}, pos{8};
175 unsigned int nibble{uvalue & 0xf};
176 buffer[--pos] = (nibble < 10) ? (
'0' + nibble) : (
'a' + (nibble - 10));
180 return std::string(buffer + pos, 8 - pos);
193 template <
typename _In,
typename _Out>
194 bool from_chars(
const _In& input, _Out& out)
196 const auto& result{std::from_chars(input.data(), input.data() + input.size(), out)};
197 return result.ec == std::errc();
208 std::string getDeviceUuidHex();
218 extern EOTAType::Type getOtaBootType();
227 extern void saveOtaBootIndicator(EOTAType::Type type = EOTAType::OTA_GENERIC);
240 template<
class _Type1,
class _Type2>
241 inline bool starts_with(
const _Type1& input,
const _Type2& match)
243 return input.size() >= match.size() && std::equal(match.begin(), match.end(), input.begin());
255 extern std::string json_escape(
const std::string& input);
261 extern const std::string getResetReason();
268 extern const std::string getUptimeFromSeconds(uint32_t seconds);
274 extern const std::string getUptimeString();
281 extern void loadCredentials(std::string& ssid, std::string& password);
288 extern void saveCredentials(std::string ssid, std::string password);