SDK Modules
The SDK is organized into focused modules. Include only the headers you need to keep your binary lean.Initialization
Core system setup, logging, delays, and device info via
anx/anx.h.GPIO
Digital I/O, pull resistors, and interrupt handlers via
anx/gpio.h.Communication
Serial protocols — UART, I2C, and SPI — via
anx/uart.h, anx/i2c.h, and anx/spi.h.ADC
Analog-to-digital conversion and channel sampling via
anx/adc.h.PWM
Pulse-width modulation output and duty-cycle control via
anx/pwm.h.Wi-Fi
Station and access-point mode, network scanning, and connection management via
anx/wifi.h.MQTT
Publish, subscribe, and broker connection management via
anx/mqtt.h.OTA
Over-the-air firmware updates and rollback support via
anx/ota.h.Including the SDK
Always includeanx/anx.h as the first header in your application. It initializes the ANX OS integration layer and pulls in the common types — including anx_err_t — that every other module depends on.
main.c
ANX OS calls
app_main() automatically after the hardware and config.json finish loading. You do not need to write a main() function yourself.SDK Versioning
Callanx_sdk_version() at runtime to retrieve the SDK version string (for example, "1.2.0"). The SDK version must be compatible with the firmware version running on the device — compatibility requires that the MAJOR and MINOR components match exactly. A mismatch will cause anx_sdk_version() to log a warning on boot and may result in undefined behavior from certain API calls.
version_check.c
Error Handling
Every ANX SDK function returns ananx_err_t value. Check the return value after every call — silent failures in embedded systems are difficult to diagnose in the field. Use anx_err_to_str() to convert an error code into a human-readable string for logging.
Use the pattern below as a template for every SDK call in your application:
error_handling.c