Skip to content

Host API reference

This page documents the host API contract that the firmware exposes to plugins. It is built directly from the canonical header components/plugin_manager/include/plugin_manager/host_api.h and the WAMR symbol table in components/plugin_manager/src/WamrImports.cpp.

Every function listed here is both declared in host_api.h and registered in the symbol table: the two sets match exactly (213 functions each, a clean bijection), so there are no declared-but-unimplemented stubs. For the full signatures, parameters and return semantics, generate and read the Doxygen reference.

For the plugin model, manifest schema and lifecycle, see the Plugin SDK & manifest page.

The API level constants are defined in host_api.h:

ConstantValueSource
HOST_API_LEVEL_MAJOR0host_api.h:28
HOST_API_LEVEL_MINOR7host_api.h:29
HOST_API_LEVEL_STR"0.7"host_api.h:30
HOST_API_LEVEL_PACKED(major << 16) | minorhost_api.h:31

A plugin declares host_api_level_min in its manifest. At load the firmware requires the plugin major to equal the firmware major and the plugin minor to be less than or equal to the firmware minor; otherwise the plugin is rejected with an API-level mismatch (CapabilityChecker.cpp:44-49).

All fallible host functions return an int status. The codes are (host_api.h:37-46):

CodeValueMeaning
HOST_OK0Success
HOST_ERR_GENERIC-1Unspecified failure
HOST_ERR_INVALID_ARG-2Bad argument (includes failed pointer validation)
HOST_ERR_NO_CAPABILITY-3Required manifest capability not declared
HOST_ERR_NOT_FOUND-4Resource or key not found
HOST_ERR_TIMEOUT-5Operation timed out
HOST_ERR_NO_MEMORY-6Allocation failed
HOST_ERR_BUSY-7Resource in use / conflicting claim
HOST_ERR_NOT_SUPPORTED-8Operation not supported
HOST_ERR_RMEM_FULL-9Retained-memory pool exhausted

Functions that return a count or handle return a non-negative value on success and a negative HOST_ERR_* on failure; handle-returning functions (HTTP, socket) return a handle greater than zero.

The whole host API speaks UTF-8. Text passed to UI, canvas and display functions is converted to the display codepage internally, and text read back (host_ui_consume_input_text, host_view_canvas_get_text) is returned as UTF-8 (host_api.h:1414-1424). Plugins normally never convert anything themselves.

For message transfer, payload bytes are opaque and not converted; for text MIME types they are UTF-8 (host_api.h:1336-1339). Two optional helpers, host_str_to_display and host_str_to_utf8, exist for advanced cases such as pre-rendering to a specific codepage; do not feed their output back into the auto-converting UI functions (host_api.h:1428-1454).

Each family is a Doxygen \defgroup in host_api.h with a matching host_api_<family>.cpp implementation. The table below lists the family, the manifest capability it requires (if any), and a few representative functions. It is not exhaustive; consult host_api.h or the Doxygen reference for the complete set.

The “Capability” column reflects what is enforced at the host-call boundary (HOST_ERR_NO_CAPABILITY), not just what is documented.

FamilyCapabilityRepresentative functions
Loggingnonehost_log, host_log_hex
Time / RTCnonehost_uptime_ms, host_unix_time, host_local_time, host_is_time_set
Powernonehost_battery_pct, host_power_source, host_charge_status, host_set_sleep_inhibit
Cryptononehost_random, host_sha256, host_hmac_sha256, host_aes_gcm_encrypt, host_base64_encode
SecureElement / TROPIC01rmem, ecc (named slots)host_rmem_read_named, host_rmem_write_named, host_ecc_generate, host_ecdsa_sign, host_eddsa_sign
HTTPhttp (manifest only, see note)host_http_open, host_http_set_header, host_http_perform, host_http_read_chunk, host_http_close
Socketsockethost_socket_open, host_socket_write, host_socket_read, host_socket_close
WiFiwifi (manifest only, see note)host_wifi_request, host_wifi_is_connected, host_wifi_start_scan, host_wifi_scan_results
BLEblehost_ble_register_service, host_ble_send_notification, host_ble_scan_start, host_ble_connect, host_ble_subscribe
NVS (plugin-namespaced)nonehost_nvs_get_blob, host_nvs_set_blob, host_nvs_get_u32, host_nvs_erase_all
vFAT (sandboxed files)vfathost_fs_write, host_fs_read, host_fs_remove, host_fs_list, host_fs_view
UI - Viewsnonehost_ui_push_toast, host_ui_push_list, host_ui_push_t9_input, host_ui_push_confirm, host_ui_pop
UI - Canvasnonehost_view_canvas_push, host_view_canvas_draw_text, host_view_canvas_add_slider, host_view_canvas_commit
UI - Low-level GFXdisplay_lowlevelhost_display_width, host_display_draw_line, host_display_fill_rect, host_display_flush
I18nnonehost_i18n_tr_key, host_i18n_tr_core, host_i18n_tr_meta, host_i18n_current_language
EventBusnonehost_event_subscribe, host_event_unsubscribe, host_event_publish
Keypadnonehost_key_pressed, host_key_consume_next
USB CDCusb_cdchost_usb_cdc_write
System Infononehost_get_firmware_version, host_get_build_profile, host_feature_enabled, host_cpu_load
Command channelnonehost_cmd_consume
Message transferble + message_typeshost_msg_register_handler, host_msg_consume, host_msg_send_interactive, host_msg_send
Stringsnonehost_str_to_display, host_str_to_utf8
GPIO / PWM / ADC / I2C / SAOgpio_pins / pwm_pins / adc_pins (per pin)host_gpio_write, host_gpio_read, host_gpio_pwm_start, host_adc_read, host_i2c_write_read, host_sao_eeprom_read
Pixel strippixel_striphost_pixel_strip_init, host_pixel_strip_set, host_pixel_strip_fill, host_pixel_strip_refresh
Lockscreen quick-actionnone (requires an active plugin)host_lockscreen_register_action, host_lockscreen_alert

This page is a map, not a complete signature list. For every function’s exact prototype, parameters and return contract, build and open the generated Doxygen reference, which is rendered from the Doxygen comments in host_api.h.