Files
led-driver/managed_components/espressif__mdns/mdns_mem_caps.c
T
jimmyandClaude Haiku 5.5 4cd3bc7973 feat: DDP frame sync over UDP broadcast, DDP acks, DDP enable setting
- Driver acks each completed DDP frame; the test waits for the acks before broadcasting the sync.
- Sync listener on UDP 4049: a frame is held until the next sync, then shown.
- DDP pixels are shown at full brightness, ignoring the device brightness settings.
- "DDP and sync receive on" setting (NVS, network API, web UI); off ignores DDP and sync packets.
- ddp_test.py: finds devices on the subnet, drives them in lockstep at a fixed rate, runs animations.
- /api/ddp reports sync counters for diagnosis.
- Includes in-progress WebSocket, multi-driver web UI and Wi-Fi work from the same tree.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-11 14:10:55 +13:00

97 lines
2.4 KiB
C

/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include "sdkconfig.h"
#include "mdns_private.h"
#include "mdns_mem_caps.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#if CONFIG_MDNS_MEMORY_CUSTOM_IMPL
#define ALLOW_WEAK __attribute__((weak))
#else
#define ALLOW_WEAK
#endif
#if CONFIG_MDNS_TASK_CREATE_FROM_SPIRAM
#define MDNS_TASK_MEMORY_CAPS (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
#define MDNS_TASK_MEMORY_LOG "SPIRAM"
#endif
#if CONFIG_MDNS_TASK_CREATE_FROM_INTERNAL
#define MDNS_TASK_MEMORY_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#define MDNS_TASK_MEMORY_LOG "internal RAM"
#endif
#if CONFIG_MDNS_MEMORY_ALLOC_SPIRAM
#define MDNS_MEMORY_CAPS (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
#endif
#if CONFIG_MDNS_MEMORY_ALLOC_INTERNAL
#define MDNS_MEMORY_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#endif
// Allocate memory from internal heap as default.
#ifndef MDNS_MEMORY_CAPS
#warning "No memory allocation method defined, using internal memory"
#define MDNS_MEMORY_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#endif
#ifndef MDNS_TASK_MEMORY_CAPS
#define MDNS_TASK_MEMORY_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#define MDNS_TASK_MEMORY_LOG "internal RAM"
#endif
void ALLOW_WEAK *mdns_mem_malloc(size_t size)
{
return heap_caps_malloc(size, MDNS_MEMORY_CAPS);
}
void ALLOW_WEAK *mdns_mem_calloc(size_t num, size_t size)
{
return heap_caps_calloc(num, size, MDNS_MEMORY_CAPS);
}
void ALLOW_WEAK mdns_mem_free(void *ptr)
{
heap_caps_free(ptr);
}
char ALLOW_WEAK *mdns_mem_strdup(const char *s)
{
if (!s) {
return NULL;
}
size_t len = strlen(s) + 1;
char *copy = (char *)heap_caps_malloc(len, MDNS_MEMORY_CAPS);
if (copy) {
memcpy(copy, s, len);
}
return copy;
}
char ALLOW_WEAK *mdns_mem_strndup(const char *s, size_t n)
{
if (!s) {
return NULL;
}
size_t len = strnlen(s, n);
char *copy = (char *)heap_caps_malloc(len + 1, MDNS_MEMORY_CAPS);
if (copy) {
memcpy(copy, s, len);
copy[len] = '\0';
}
return copy;
}
void ALLOW_WEAK *mdns_mem_task_malloc(size_t size)
{
ESP_LOGI("mdns_mem", "mDNS task will be created from %s", MDNS_TASK_MEMORY_LOG);
return heap_caps_malloc(size, MDNS_TASK_MEMORY_CAPS);
}
void ALLOW_WEAK mdns_mem_task_free(void *ptr)
{
heap_caps_free(ptr);
}