Files
espurna/code/espurna/utils.h
Maxim Prokhorov f92116341e system: refactor build configurations
Namespace build configurations of modules, make more things into constexpr
(not fully finished though)

Unify code using ...Count() to parse IDs

Avoid using unsigned char aka uint8_t as index, prefer size_t
as most code already uses it anyway. Making sure we never accidentally
truncate the value or try to read it as 32bit-wide. Also, simplify
access to built in containers, since those use the wide type as well.

Renames led and button types, more consistent initialization and field access.
2021-03-31 09:41:04 +03:00

58 lines
1.5 KiB
C

/*
UTILS MODULE
Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
*/
#pragma once
#include <Arduino.h>
#include "system.h"
#define INLINE inline __attribute__((always_inline))
extern "C" uint32_t _SPIFFS_start;
extern "C" uint32_t _SPIFFS_end;
void setDefaultHostname();
void setBoardName();
const String& getDevice();
const String& getManufacturer();
const String& getCoreVersion();
const String& getCoreRevision();
const String& getVersion();
String getAdminPass();
String getBoardName();
String buildTime();
bool haveRelaysOrSensors();
String getUptime();
void infoHeapStats(const char* name, const HeapStats& stats);
void infoHeapStats(bool show_frag_stats = false);
void infoMemory(const char* name, unsigned int total_memory, unsigned int free_memory);
void info(bool first = false);
bool sslCheckFingerPrint(const char * fingerprint);
bool sslFingerPrintArray(const char * fingerprint, unsigned char * bytearray);
bool sslFingerPrintChar(const char * fingerprint, char * destination);
char* ltrim(char* s);
char* strnstr(const char* buffer, const char* token, size_t n);
bool isNumber(const String&);
void nice_delay(unsigned long ms);
double roundTo(double num, unsigned char positions);
size_t hexEncode(const uint8_t* in, size_t in_size, char* out, size_t out_size);
size_t hexDecode(const char* in, size_t in_size, uint8_t* out, size_t out_size);
using TryParseIdFunc = size_t(*)();
bool tryParseId(const char* ptr, TryParseIdFunc limit, size_t& out);