// Lets the sources that have no hardware dependency compile on a host (pio test -e native), where the // program-memory helpers of the Arduino cores do not exist: there a PROGMEM object is an ordinary constant and a // pointer to one an ordinary pointer. On a board this is Arduino.h and the random source of the hardware. #ifndef ALEXA_COMPAT_H #define ALEXA_COMPAT_H #if defined(ARDUINO) #include #else #include #include #include #define PROGMEM #define PGM_P const char * #define PSTR(text) (text) #define F(text) (text) #define FPSTR(text) (text) #define pgm_read_byte(address) (*reinterpret_cast(address)) #define pgm_read_ptr(address) (*reinterpret_cast(address)) #define strcmp_P strcmp #define strncpy_P strncpy #endif // 32 bits that cannot be predicted and differ after every reset inline uint32_t alexaRandom32() { #if defined(ESP8266) return RANDOM_REG32; // fed by the noise of the radio #elif defined(ESP32) return esp_random(); // ESP32: untested #else static std::random_device source; return source(); #endif } #endif // ALEXA_COMPAT_H