Files
nfc-pn532-warlord/firmware/main/main.c
drjones 2da1515f8d feat: resilient boot + full polish pass
Firmware:
- nfc_engine: add nfc_engine_try_init() (non-fatal, sets s_pn532_ready),
  nfc_engine_try_reattach() (soft re-init, skips bus re-init),
  nfc_engine_is_ready() accessor
- main: replace ESP_ERROR_CHECK(nfc_engine_init) with nfc_engine_try_init;
  device boots and serves web UI even with no PN532 connected
- app_net: add reconnect_task — every 5s retries nfc_engine_try_reattach()
  and broadcasts {"channel":"pn532","payload":{"connected":true}} over WS
- app_net: scan_loop_task skips polling when !nfc_engine_is_ready()
- app_net/api_status: always emit pn532Connected bool; null-guard pn532 fw object
- find_sector_hit / program_classic_snapshot_locked: null-guard cJSON array items
- session_capture: abort if xSemaphoreCreateMutex() returns NULL

Web:
- NfcWsContext: track pn532Connected state from WS pn532 channel + status fetch on connect
- App.tsx: live HeaderBadge (LIVE/NO RF/WAIT) replacing static text
- Dashboard: READY/SEARCHING pill with fw version when available
- api.ts: add pn532Connected to Status type
- toast.tsx: fix ID collision (Date.now + Math.random)
- Capture: surface status fetch errors
- ReadAnalyze: add error feedback for readUl when no data returned
- WriteClone: busy state on both write buttons
- RawConsole: toast when frame returns error not response
- Emulate: validate hex before send (non-empty, even length, hex chars only)
- Brute: warn and skip invalid custom key lines

Made-with: Cursor
2026-04-09 15:49:18 -07:00

24 lines
765 B
C

#include "esp_log.h"
#include "esp_ota_ops.h"
#include "board_rgb_off.h"
#include "nfc_engine/nfc_engine.h"
#include "nfc_engine/session_capture.h"
#include "net_service/app_net.h"
static const char *TAG = "main";
void app_main(void)
{
(void)esp_ota_mark_app_valid_cancel_rollback();
board_rgb_led_quiet();
ESP_LOGI(TAG, "PN532 NFC Toolkit starting");
nfc_engine_try_init(); /* non-fatal: logs warning if PN532 absent, AP starts regardless */
session_capture_init();
ESP_ERROR_CHECK(app_net_init());
if (nfc_engine_is_ready()) {
ESP_LOGI(TAG, "PN532 ready · AP SSID PN532-Toolkit → http://192.168.4.1");
} else {
ESP_LOGW(TAG, "PN532 not found at boot — AP running, retrying · http://192.168.4.1");
}
}