Skip to content

Compilation errors and deprecation warnings with ESP32, ArduinoJson, and LEDC API (PlatformIO, Arduino core 2.x.x+) #6

@printryde

Description

@printryde

Hello!
I am facing several compilation errors and deprecation warnings when building my project for ESP32 using PlatformIO and the latest Arduino/ESP32/ArduinoJson libraries. Here are the details:

  1. ArduinoJson Deprecation Warnings
    I get warnings like:
    warning: 'DynamicJsonDocument' is deprecated: use JsonDocument instead [-Wdeprecated-declarations] DynamicJsonDocument wifiDoc(256);
    and
    warning: 'StaticJsonDocument' is deprecated: use JsonDocument instead [-Wdeprecated-declarations] StaticJsonDocument<256> jsonCmdReceive;
    But when I try to use JsonDocument directly, I get an error:
    no instance of constructor "ArduinoJson::V741PB22::JsonDocument::JsonDocument" matches the argument list
    So, it is unclear how to migrate to the new API without breaking the code.
  2. LEDC API Errors
    I get errors like:
    'ledcAttach' was not declared in this scope
    and
    'suggested alternative: ledcAttachPin'
    when using:
    ledcAttach(PWMA, freq, ANALOG_WRITE_BITS);.
    It seems that the LEDC API has changed between Arduino ESP32 core 2.x.x and 3.x.x, and the documentation is not always clear which version supports which function.
  3. ESP-NOW API Error
    I get this error:
    'esp_now_recv_info_t' does not name a type; did you mean 'esp_now_peer_info_t'? void OnDataRecv(const esp_now_recv_info_t *info, const unsigned char* incomingData, int len)
    It looks like the type esp_now_recv_info_t does not exist in the current ESP32 Arduino core.
  4. General Deprecation Warnings
    I also see warnings like:
    'bool ArduinoJson::V741PB22::JsonDocument::containsKey(TChar*) const' is deprecated: use doc["key"].is<T>() instead.
    and
    control reaches end of non-void function [-Wreturn-type]
    Environment:
    PlatformIO (latest)
    ESP32 Arduino core 2.x.x
    ArduinoJson 7.x.x
    Windows 10
    Questions:
    What is the correct way to migrate to the new JsonDocument API for both static and dynamic documents?
    What is the recommended way to write cross-version compatible code for LEDC (PWM) initialization?
    What is the correct function signature for ESP-NOW receive callback in the latest ESP32 Arduino core?
    Are there any migration guides or best practices for handling these deprecations and API changes?
    Thank you for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions