![]() |
|
Uniot Core
|
| 0.9.0 |
Common utilities and macros for the Uniot Core. More...
Classes | |
| struct | FourCC< a, b, c, d > |
| Creates a four-character code (FourCC) value from template parameters. More... | |
Macros | |
| #define | UNIOT_SEMVER_TO_INT(major, minor, patch) |
| Packs a semantic version into one integer. | |
| #define | UNIOT_CORE_VERSION UNIOT_SEMVER_TO_INT(0, 9, 0) |
| Version of Uniot Core, reported in the device's status packet. | |
| #define | UNIOT_MQTT_HOST "mqtt.uniot.io" |
| Hostname of the MQTT broker the device connects to. | |
| #define | UNIOT_MQTT_PORT 1883 |
| TCP port of the MQTT broker. | |
| #define | UNIOT_WIFI_AP_PREFIX "UNIOT" |
| Prefix for the generated configuration AP SSID. | |
| #define | UNIOT_WIFI_AP_PASSWORD "" |
| WPA2 password for the configuration AP. | |
| #define | UNIOT_WIFI_REBOOT_RESET_COUNT 5 |
| Consecutive reboots that reset the stored network configuration. | |
| #define | UNIOT_WIFI_REBOOT_WINDOW_MS 10000 |
| How long after boot a reboot still counts towards the reset, in ms. | |
| #define | UNIOT_LISP_HEAP 24576 |
| Bytes of heap the Lisp interpreter is given at startup. | |
| #define | UNIOT_LISP_MAX_EVAL_STACK 1280 |
| Bytes of C stack an evaluation may spend before a script is abandoned. | |
| #define | UNIOT_WIFI_NO_SLEEP 0 |
| Keep the WiFi radio awake between beacon intervals (ESP32 only). | |
| #define | COUNT_OF(arr) |
| Calculates the number of elements in a statically allocated array. | |
| #define | ARRAY_ELEMENT_SAFE(arr, index) |
| Provides safe array access with bounds checking. | |
| #define | FOURCC(name) |
| Creates a FourCC constant from a string literal. | |
| #define | ALIAS_IMPLICIT_FUNCTION(high, low) |
| Creates an alias for a function that forwards all arguments implicitly. | |
| #define | ALIAS_EXPLICIT_FUNCTION(high, low) |
| Creates an alias for a template function that forwards all arguments explicitly. | |
Functions | |
| template<typename... Args> | |
| void | UNUSED (Args &&...args) |
| Utility function to mark function parameters as intentionally unused. | |
| uint32_t | CRC32 (const void *data, size_t length, uint32_t crc=0) |
| Calculates CRC32-C (Castagnoli) checksum for data integrity verification. | |
| template<typename T> | |
| using | uniot::UniquePointer = std::unique_ptr<T> |
| Type alias for std::unique_ptr with cleaner syntax. | |
| template<typename T> | |
| using | uniot::SharedPointer = std::shared_ptr<T> |
| Type alias for std::shared_ptr with cleaner syntax. | |
| template<typename T_First, typename T_Second> | |
| using | uniot::Pair = std::pair<T_First, T_Second> |
| Type alias for std::pair with cleaner syntax. | |
| template<typename T, typename... Args> | |
| auto | uniot::MakeShared (Args &&...args) -> decltype(std::make_shared< T >(std::forward< Args >(args)...)) |
| Creates a shared pointer instance, alias for std::make_shared. | |
| template<typename T, typename... Args> | |
| auto | uniot::MakeUnique (Args &&...args) -> decltype(std::make_unique< T >(std::forward< Args >(args)...)) |
| Creates a unique pointer instance, alias for std::make_unique. | |
| template<typename... Args> | |
| auto | uniot::MakePair (Args &&...args) -> decltype(std::make_pair(std::forward< Args >(args)...)) |
| Creates a pair instance, alias for std::make_pair. | |
Common utilities and macros for the Uniot Core.
| #define ALIAS_EXPLICIT_FUNCTION | ( | high, | |
| low ) |
Creates an alias for a template function that forwards all arguments explicitly.
Similar to ALIAS_IMPLICIT_FUNCTION but maintains the explicit template parameter.
| high | New function name |
| low | Original function being aliased |
| #define ALIAS_IMPLICIT_FUNCTION | ( | high, | |
| low ) |
Creates an alias for a function that forwards all arguments implicitly.
Used to expose standard library functions through a custom namespace with the same parameter forwarding behavior.
| high | New function name |
| low | Original function being aliased |
| #define ARRAY_ELEMENT_SAFE | ( | arr, | |
| index ) |
Provides safe array access with bounds checking.
Returns the element at the specified index if within bounds, otherwise returns the last element.
| #define COUNT_OF | ( | arr | ) |
Calculates the number of elements in a statically allocated array.
| #define FOURCC | ( | name | ) |
Creates a FourCC constant from a string literal.
Uses up to the first four characters of the string to create a unique identifier. If the string has fewer than 4 characters, the remaining positions will be filled with the last character.
| #define UNIOT_CORE_VERSION UNIOT_SEMVER_TO_INT(0, 9, 0) |
Version of Uniot Core, reported in the device's status packet.
Neither this nor UNIOT_SEMVER_TO_INT is guarded, so a sketch cannot redefine them: they describe the core that is running, not something a sketch chooses. Keep this in step with the version in library.json.
| #define UNIOT_LISP_HEAP 24576 |
Bytes of heap the Lisp interpreter is given at startup.
Allocated once in lisp_create() and never grown, so it is a fixed claim on system heap for the life of the machine. Creating a machine costs ~3150 bytes before a script runs, so what a script actually has is this value less that. The library refuses anything above 65535.
| #define UNIOT_LISP_MAX_EVAL_STACK 1280 |
Bytes of C stack an evaluation may spend before a script is abandoned.
Interpreter recursion runs on the C stack, and overrunning it resets the device rather than raising an error. The budget is in bytes, not levels of nesting, since a level that prints costs several times what a bare call costs.
It is not simply the stack that is free. The guard measures from where lisp_eval() was entered and stops seeing anything once a primitive or the error path takes over, so the true peak is the budget plus roughly 600 bytes paid afterwards, during unwinding. Each value below is measured on target against the full firmware, not the standalone tool, with the probe in src/main.cpp; measure a budget before changing it rather than scaling it from another part.
Keep the ESP32 branches separate: defined(ESP32) is true for the C3, so collapsing them means a retune of one silently retunes the other.
| #define UNIOT_MQTT_HOST "mqtt.uniot.io" |
Hostname of the MQTT broker the device connects to.
| #define UNIOT_MQTT_PORT 1883 |
TCP port of the MQTT broker.
| #define UNIOT_SEMVER_TO_INT | ( | major, | |
| minor, | |||
| patch ) |
Packs a semantic version into one integer.
Uses the same formula as uniot-lisp's SEMVER_TO_INT, so a core version and an interpreter version are comparable and read the same way. It carries its own name so that including both headers cannot make one definition silently stand for the other.
| #define UNIOT_WIFI_AP_PASSWORD "" |
WPA2 password for the configuration AP.
An empty string creates an open network. WPA2 requires at least 8 characters; a shorter non-empty password makes softAP() fail and no configuration AP is started.
| #define UNIOT_WIFI_AP_PREFIX "UNIOT" |
Prefix for the generated configuration AP SSID.
The full SSID is "PREFIX-DEVICEID", upper-cased.
| #define UNIOT_WIFI_NO_SLEEP 0 |
Keep the WiFi radio awake between beacon intervals (ESP32 only).
Set to 1 to disable modem sleep once the station associates. This avoids association drops caused by missed DTIM beacons on a marginal link, at the cost of a significantly higher idle current. Leave at 0 on battery devices.
| #define UNIOT_WIFI_REBOOT_RESET_COUNT 5 |
Consecutive reboots that reset the stored network configuration.
Each reboot within UNIOT_WIFI_REBOOT_WINDOW_MS of the last one increments a counter held in ctrl.cbor; reaching this many clears the credentials. It is the only reset path on a device with no button, so it is a deliberate gesture – power-cycling this many times in quick succession – and the count trades ease of use against wiping a device by accident on flaky power.
This is the count used once the mechanism is switched on, not whether it is on. UniotCore leaves reboot-reset disabled until configWiFiResetOnReboot() asks for it, precisely because of that accidental-wipe risk; this value is what that call uses when given no count of its own.
| #define UNIOT_WIFI_REBOOT_WINDOW_MS 10000 |
How long after boot a reboot still counts towards the reset, in ms.
Staying up longer than this clears the counter, so ordinary restarts do not accumulate towards a reset. Ignored when the count is UINT8_MAX.
| using uniot::Pair = std::pair<T_First, T_Second> |
| using uniot::SharedPointer = std::shared_ptr<T> |
| using uniot::UniquePointer = std::unique_ptr<T> |
|
inline |
Calculates CRC32-C (Castagnoli) checksum for data integrity verification.
This function implements the CRC-32C polynomial used in iSCSI standard.
| data | Pointer to data buffer |
| length | Size of data buffer in bytes |
| crc | Initial CRC value (defaults to 0) |
| uint32_t | CRC32 checksum value |
|
inline |
Creates a pair instance, alias for std::make_pair.
|
inline |
Creates a shared pointer instance, alias for std::make_shared.
|
inline |
Creates a unique pointer instance, alias for std::make_unique.
|
inline |
Utility function to mark function parameters as intentionally unused.
Prevents compiler warnings about unused parameters by explicitly consuming them.
| Args | Variadic template parameter types |
| args | Parameters to mark as used |