spaxel/firmware/main/ble.h
jedarden f178496c83 feat(firmware): ESP32-S3 firmware skeleton with CSI/BLE/WebSocket
- State machine: 7-state lifecycle (BOOT→WIFI→DISCOVERY→CONNECTED,
  degraded modes WIFI_LOST/MOTHERSHIP_UNAVAILABLE/CAPTIVE_PORTAL)
- WiFi: STA connection with exponential backoff, mDNS discovery with
  cached IP fallback, captive portal AP for provisioning
- WebSocket: bidirectional comms, binary CSI frames (24B header + I/Q),
  JSON hello/health/ble/ota_status upstream, role/config/ota/reboot
  downstream, OTA task with progress reporting
- CSI: promiscuous mode capture, queue-based processing, passive BSSID
  filter, on-device variance tracking (Welford's) for motion hints
- BLE: passive scanning on Core 0, 60-device cache, 5s reporting
- NVS: 15-key schema with versioning, role/rate persistence

Complete: ESP32 firmware skeleton, passive radar, BLE scanning
Remaining: Dashboard skeleton, Docker packaging (Phase 1 items 5-6)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 07:20:55 -04:00

52 lines
902 B
C

#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
/**
* Initialize BLE scanning subsystem.
* Runs on Core 0 concurrent with WiFi.
*/
esp_err_t ble_init(void);
/**
* Start BLE scanning.
*/
esp_err_t ble_start_scan(void);
/**
* Stop BLE scanning.
*/
esp_err_t ble_stop_scan(void);
/**
* Get discovered devices as JSON string.
* Caller must free returned string.
*
* @return JSON array of discovered devices, or NULL on error
*/
char *ble_get_devices_json(void);
/**
* BLE device info structure.
*/
typedef struct {
uint8_t addr[6];
uint8_t addr_type; // 0=public, 1=random
int8_t rssi;
char name[32];
uint16_t mfr_id;
uint8_t mfr_data[32];
uint8_t mfr_data_len;
} ble_device_t;
/**
* Get number of discovered devices.
*/
int ble_get_device_count(void);
/**
* Clear discovered devices cache.
*/
void ble_clear_devices(void);