WhirlingBits ESP-IDF Components

website·Indexed 30 days ago

https://docs.whirlingbits.de

A collection of production-ready components for ESP-IDF, including wb-idf-core for I2C master drivers, WLAN, and SNTP synchronization; wb-idf-lwm2m for OMA LWM2M 1.0/1.1 client implementation with TLV encoding and CoRE Link-Format; and wb-idf-coap-client for event-driven CoAP client functionality.

Tokens
14.5K
Snippets
103
Records
118
Agent score
49%

What's inside WhirlingBits ESP-IDF Components

  1. Overview of WhirlingBits ESP-IDF Components

    WhirlingBits provides a suite of professional, open-source ESP-IDF components designed for production IoT projects. These components are built with best practices, featuring comprehensive error handling, robust implementations, and fully documented APIs with integration guides.
  2. Overview of LWM2M TLV Binary Content-Format

    The module implements the OMA LWM2M TLV (Type-Length-Value) binary content-format as specified in OMA-TS-LightweightM2M_Core §6.4.3. This format is used for Read responses and Write requests in LWM2M 1.0. The associated CoAP Content-Format is application/vnd.oma.lwm2m+tlv (ID: 11542).
  3. Available components in wb-idf-core

    The wb-idf-core package includes the following production-ready components:

    • I2C Master Driver: Advanced I2C functionality including device probing and 16-bit operations.
    • WLAN Driver: Advanced WLAN functionality for ESP-IDF.
    • SNTP Client: Simple SNTP Time Synchronization for ESP-IDF.
  4. Synchronize time using the SNTP Client module

    The SNTP Client module is a high-level wrapper for the ESP-IDF SNTP component. It simplifies the process of initializing the SNTP service, waiting for synchronization to complete, and configuring timezones using POSIX strings. It is designed for reliability by providing blocking logic to ensure time is valid before use.
  5. Verify wb-idf-coap-client system requirements

    The wb-idf-coap-client requires the following environment:

    • ESP-IDF Version: 5.0 or higher
    • Dependencies: espressif/coap version 4.3.4 or higher
    • Supported SoCs: ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6
    • Network: IP connectivity via WiFi or Ethernet
  6. Analyze wb-idf-coap-client memory requirements

    The approximate RAM usage for the CoAP client components is as follows:

    • Client handle + internal state: ~512 bytes
    • Processing task stack: 8192 bytes (configurable)
    • Request queue (8 entries): ~256 bytes
    • DTLS session (if security is enabled): ~10-20 KB
  7. Understand wb-idf-coap-client threading and concurrency constraints

    When using the wb-idf-coap-client, adhere to the following threading rules:

    • Request functions (get, post, put, delete, observe) are thread-safe and can be called from any FreeRTOS task.
    • The event handler callback is executed within the internal CoAP task; do not perform blocking operations inside this callback.
    • wb_coap_client_is_connected() is safe to call from any context.
    • Lifecycle functions wb_coap_client_start(), stop(), and destroy() must not be called concurrently from multiple tasks.
  8. WiFi Status and Configuration Constants

    The driver uses the following bits and configuration macros for status monitoring and setup:
    // Status Bits
    #define WIFI_CONNECTED_BIT BIT0
    #define WIFI_FAIL_BIT      BIT1
    
    // Kconfig / Macros
    // CONFIG_STATION_ESP_MAXIMUM_RETRY: Maximum retries for station mode
    // CONFIG_AP_ESP_WIFI_CHANNEL: WiFi channel for Access Point
    // CONFIG_AP_ESP_MAX_STA_CONN: Maximum number of stations allowed to connect to AP
  9. Manage LWM2M client runtime and telemetry

    Once the client is started, you can check the registration status and push telemetry updates using wb_lwm2m_notify. To shut down, stop the client and destroy the handle and associated standard objects.
    // Periodically push telemetry
    while (1) {
        vTaskDelay(pdMS_TO_TICKS(30000));
        if (wb_lwm2m_is_registered(lwm2m)) {
            wb_lwm2m_notify(lwm2m, WB_LWM2M_OBJ_DEVICE, 0, WB_LWM2M_RES_DEVICE_MEMORY_FREE);
        }
    }
    
    // Clean shutdown
    wb_lwm2m_stop(lwm2m);
    wb_lwm2m_destroy(lwm2m);
    wb_lwm2m_destroy_std_object(security_obj);
    wb_lwm2m_destroy_std_object(server_obj);
    wb_lwm2m_destroy_std_object(device_obj);
  10. Register LWM2M objects with the client

    Use wb_lwm2m_add_object() to register an LWM2M object definition. This must be called BEFORE calling wb_lwm2m_start(). Note that the object definition is referenced by the client, not copied, so the definition must remain valid in memory for the duration of the client's lifecycle.
    esp_err_t err = wb_lwm2m_add_object(client, &my_object_def);
  11. Initialize and start the LWM2M client

    To start an LWM2M client, first call wb_lwm2m_init() to allocate resources and create the underlying CoAP client. Then, call wb_lwm2m_start() to establish the CoAP connection and send the LWM2M Registration request. Registration updates are handled automatically based on the configured lifetime.
    // 1. Initialize the client
    wb_lwm2m_client_handle_t client = wb_lwm2m_init(&config);
    
    // 2. Start the client (connects and registers)
    esp_err_t err = wb_lwm2m_start(client);