feat(lvgl+mdns): complete canvas API + fix GB blank render + mDNS browse API

lvgl-module/symbols.c:
- canvas: full LVGL9 docs API (get_buf, get_image, get_px, get_draw_buf,
  set_palette, copy_buf, init_layer, finish_layer, buf_size) – was only 5 symbols
- draw_buf: create/destroy/init/dup/copy/goto/clear/width_to_stride/align/palette/from_image/to_image
- cache: lv_draw_buf_invalidate_cache, flush_cache, lv_image_cache_drop – critical bugfix for
  GameBoy (and any direct framebuffer) where raw buf mutated but image cache stale -> FPS but no image.
- draw layer helpers, image scale/rotation/pivot/offset, transform scales for GB 2x/3x integer scaling

Reason blank screen: lv_canvas in LVGL9 is lv_image backed by draw_buf. Mutating raw pointer
without lv_image_cache_drop + invalidate_cache leaves stale texture. Timer was calling
lv_obj_invalidate only. Now exports needed symbols and app fixed to drop cache each frame.

mDNS (preserve from local WIP, sits on top of 60764979 'kidsOS-XXXX' mdns init):
- Tactility/network/Mdns.h/cpp: C++ browse + resolveHostname wrappers around esp-idf mdns 1.3.2
  (PTR query, txt records, address extraction, POSIX stub)
- TactilityC/tt_mdns.h/cpp: C copy-based API for ELF apps (TT_MDNS_MAX_RESULTS 32,
  capped addresses/txt, hostname->IP resolve)
- TactilityC/tt_init.cpp: export tt_mdns_is_available / browse / resolve_hostname symbols

Test plan:
- firmware build for es3c28p --dev
- release-sdk-current.py
- GameBoy app build against new SDK (0 missing symbols expected)
- push both branches to personal gitea
This commit is contained in:
Adolfo Reyna
2026-07-20 12:32:00 -04:00
parent ff3eeacaf7
commit 75178652e2
6 changed files with 424 additions and 3 deletions
@@ -0,0 +1,72 @@
#pragma once
#include <cstdint>
#include <map>
#include <string>
#include <vector>
namespace tt::network::mdns {
/**
* A discovered mDNS service instance.
* Example: instanceName="kidsOS-AB12", serviceType="_http", proto="_tcp",
* hostname="kidsOS-AB12", port=80, addresses=["192.168.1.42"]
*/
struct Service {
std::string instanceName; ///< Instance name (e.g. "ESP32-WebServer")
std::string serviceType; ///< Service type (e.g. "_http", "_tactility")
std::string proto; ///< Protocol (e.g. "_tcp", "_udp")
std::string hostname; ///< Hostname without .local (e.g. "kidsOS-AB12")
uint16_t port = 0; ///< Service port
std::vector<std::string> addresses; ///< All resolved IP addresses (v4 and v6)
std::string primaryAddress; ///< First IPv4 address, or first address if no v4
uint32_t ttl = 0; ///< Time to live
std::map<std::string, std::string> txtRecords; ///< TXT key-value pairs
};
/**
* @return true if mDNS subsystem is initialized and ready for queries.
* On simulator/POSIX it returns false until a platform implementation is present.
*/
bool isAvailable();
/**
* Browse for mDNS services.
*
* This wraps `mdns_query_ptr(serviceType, proto, timeout, maxResults, ...)`.
* It blocks for up to timeoutMs while collecting results.
*
* @param serviceType e.g. "_http", "_tactility", "_arduino"
* @param proto e.g. "_tcp", "_udp" (include leading underscore)
* @param timeoutMs how long to wait for answers (e.g. 3000)
* @param maxResults maximum number of results to collect (e.g. 20)
* @param outResults filled with discovered services
* @return true on success (may still be 0 results), false if mDNS not running or error
*/
bool browse(const std::string& serviceType, const std::string& proto, uint32_t timeoutMs, size_t maxResults, std::vector<Service>& outResults);
/**
* Browse with sensible defaults: 3s timeout, 20 max results.
*/
inline bool browse(const std::string& serviceType, const std::string& proto, std::vector<Service>& outResults) {
return browse(serviceType, proto, 3000, 20, outResults);
}
/**
* Resolve a hostname (e.g. "kidsOS-AB12" or "kidsOS-AB12.local") to an IPv4 address string.
*
* @param hostname hostname to resolve, ".local" suffix is optional and stripped
* @param timeoutMs time to wait
* @param outIp resolved IP (e.g. "192.168.1.42")
* @return true if resolved
*/
bool resolveHostname(const std::string& hostname, uint32_t timeoutMs, std::string& outIp);
/**
* Resolve with 2s default timeout.
*/
inline bool resolveHostname(const std::string& hostname, std::string& outIp) {
return resolveHostname(hostname, 2000, outIp);
}
} // namespace tt::network::mdns