#ifdef ESP_PLATFORM #include #include #include #include "esp_event.h" #include "esp_netif.h" constexpr auto* TAG = "Tactility"; #include #include namespace tt { static void* cjson_psram_malloc(size_t size) { return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); } static void cjson_psram_free(void* ptr) { heap_caps_free(ptr); } static void initNetwork() { LOG_I(TAG, "Init network"); ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); } void initEsp() { cJSON_Hooks hooks = { .malloc_fn = cjson_psram_malloc, .free_fn = cjson_psram_free }; cJSON_InitHooks(&hooks); LOG_I(TAG, "cJSON hooks initialized to use PSRAM"); check(initPartitionsEsp(), "Failed to init partitions"); initNetwork(); } } // namespace #endif