18#define KSF_ONE_SEC_MS 1000UL
25#define KSF_SEC_TO_MS(seconds) (seconds*1000UL)
27#ifndef KSF_MQTT_RECONNECT_DELAY_MS
29#define KSF_MQTT_RECONNECT_DELAY_MS 10000UL
32#ifndef KSF_DOMAIN_QUERY_INTERVAL_MS
34#define KSF_DOMAIN_QUERY_INTERVAL_MS 3000UL
37#ifndef KSF_DOMAIN_QUERY_DNS_SERVER
39#define KSF_DOMAIN_QUERY_DNS_SERVER IPAddress(8, 8, 8, 8)
42#ifndef KSF_MQTT_TIMEOUT_MS
44#define KSF_MQTT_TIMEOUT_MS 4000UL
47#ifndef KSF_WIFI_TIMEOUT_MS
49#define KSF_WIFI_TIMEOUT_MS 120000UL
52#ifndef KSF_WIFI_RECONNECT_TIME_MS
54#define KSF_WIFI_RECONNECT_TIME_MS 5000UL
57#ifndef KSF_WATCHDOG_TIMEOUT_SECS
59#define KSF_WATCHDOG_TIMEOUT_SECS 10UL
63#define KSF_FRAMEWORK_INIT() ksf::initializeFramework();
66#define KSF_LIBRARY_VERSION "1.0.54"
87 extern const char* getNvsDirectory();
92 extern void initializeFramework();
99 extern bool removeDirectory(
const char* path);
105 extern bool eraseConfigData();
110 extern void updateDeviceUptime();
116 extern uint64_t millis64();
126 extern std::string to_string(
double value,
const int base);
137 extern std::string to_string(
float value,
const int base);
147 template <
typename _Type>
148 inline std::string to_string(
const _Type& input)
150 return std::to_string(input);
160 inline std::string to_hex(
int value)
166 unsigned int uvalue{
static_cast<unsigned int>(value)}, pos{8};
170 unsigned int nibble{uvalue & 0xf};
171 buffer[--pos] = (nibble < 10) ? (
'0' + nibble) : (
'a' + (nibble - 10));
175 return std::string(buffer + pos, 8 - pos);
188 template <
typename _In,
typename _Out>
189 bool from_chars(
const _In& input, _Out& out)
191 const auto& result{std::from_chars(input.data(), input.data() + input.size(), out)};
192 return result.ec == std::errc();
203 std::string getDeviceUuidHex();
212 extern void saveOtaBootIndicator(EOTAType::Type type = EOTAType::OTA_GENERIC);
225 template<
class _Type1,
class _Type2>
226 inline bool starts_with(
const _Type1& input,
const _Type2& match)
228 return input.size() >= match.size() && std::equal(match.begin(), match.end(), input.begin());
240 extern std::string json_escape(
const std::string& input);
246 extern const std::string getResetReason();
253 extern const std::string getUptimeFromSeconds(uint32_t seconds);
259 extern const std::string getUptimeString();
266 extern void loadCredentials(std::string& ssid, std::string& password);
273 extern void saveCredentials(std::string ssid, std::string password);