Skip to content

Conversation

@HadyBazzi
Copy link

ArduinoJson v7 Migration & Developer Experience Improvements

Summary

This PR modernizes the library with ArduinoJson v7 compatibility, adds SSL/TLS support for production security, and significantly improves the developer experience by enabling configuration overrides without editing library source files.

Changes

New Features

  • Configuration overrides — Users can now configure the library via #define statements before including the library (Arduino IDE) or via build_flags (PlatformIO), eliminating the need to edit ESP32_AI_Connect_config.h
  • SSL/TLS support — New setRootCA() and getRootCA() methods allow enabling secure connections with certificate verification (disabled by default for backwards compatibility and ease of use)

Refactoring

  • ArduinoJson v7 migration — Updated all deprecated JSON handling to use v7 API:
    • DynamicJsonDocument / StaticJsonDocumentJsonDocument
    • containsKey()!field.isNull()
    • createNestedArray() / createNestedObject().to<JsonArray>() / .to<JsonObject>()

Documentation

  • Updated all examples and user guides to reflect the new configuration pattern
  • Added SSL documentation to README and User Guides along with example code
  • Updated keywords.txt with new methods

New Configuration Pattern

// Arduino IDE - define BEFORE including the library
#define DISABLE_AI_API_GEMINI
#define AI_API_REQ_JSON_DOC_SIZE 8192
#include <ESP32_AI_Connect.h>
# PlatformIO - add to platformio.ini
build_flags =
    -DDISABLE_AI_API_GEMINI
    -DAI_API_REQ_JSON_DOC_SIZE=8192

New SSL/TLS Feature

Enable secure connections with certificate verification for production deployments:

const char* root_ca = R"(
-----BEGIN CERTIFICATE-----
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
-----END CERTIFICATE-----
)";

// Enable secure mode
aiClient.setRootCA(root_ca);

// Check security status
if (aiClient.getRootCA() != nullptr) {
    Serial.println("Secure mode enabled");
}

// Disable secure mode (back to insecure)
aiClient.setRootCA(nullptr);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant