Phase 5: Wi-Fi manager w/ reconnect, Scryfall HTTPS client + cJSON caching to /spiffs on net_task (Core 0)
This commit is contained in:
56
main/scryfall_client.h
Normal file
56
main/scryfall_client.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* MTG RFID Companion - Scryfall API client (Core 0)
|
||||
*
|
||||
* Phase 5: HTTPS card lookups with cJSON parsing and LittleFS caching of
|
||||
* metadata + card art. Runs on the dedicated net_task.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SCRYFALL_API "https://api.scryfall.com"
|
||||
#define SCRYFALL_CARD_ARTS_URL "/cards/named?exact="
|
||||
|
||||
/**
|
||||
* @brief Start the net_task (waits for Wi-Fi, prefetches mapping cache,
|
||||
* then serves fetch requests). Must be called after wifi start.
|
||||
*/
|
||||
esp_err_t scryfall_client_start(void);
|
||||
|
||||
/**
|
||||
* @brief Queue an async fetch by exact card name (net_task performs it).
|
||||
* @param card_name Exact card name, e.g. "Sol Ring"
|
||||
* @param uid Uppercase hex UID used for cache filenames
|
||||
*/
|
||||
esp_err_t scryfall_fetch_request(const char *card_name, const char *uid);
|
||||
|
||||
/**
|
||||
* @brief Synchronously ensure the card cache exists for uid; fetch if missing.
|
||||
* Safe to call from net_task only.
|
||||
*/
|
||||
esp_err_t scryfall_ensure_cached(const char *card_name, const char *uid);
|
||||
|
||||
/**
|
||||
* @brief True if net_task finished caching a card since last consumption.
|
||||
*/
|
||||
bool scryfall_has_pending_result(void);
|
||||
|
||||
/**
|
||||
* @brief UID of the most recently cached card.
|
||||
*/
|
||||
const char *scryfall_last_result_uid(void);
|
||||
|
||||
/**
|
||||
* @brief Clear the pending-result flag.
|
||||
*/
|
||||
void scryfall_consume_result(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user