Skip to content

tiny_measurement.h Overview

tiny_measurement.h is the unified include for:

  • tiny_measurement_config.h
  • online_sensing.h
  • offline_sensing.h
  • sensing_command.h
  • tiny_measurement_app.h
  • real-time-process-arch.h
  • ftsp.h — WSN time synchronization (FTSP over ESP-NOW)

It is intended as the single middleware-facing include for measurement features.

WSN Module

The WSN time-sync module is included via ftsp.h, which aggregates:

Header Purpose
ftsp_config.h Compile-time tuning (beacon interval, table size, min pairs)
ftsp_types.h Beacon packet layout (16 B basic / 26 B extended with NTP world time)
ftsp_gateway.h Gateway: periodic beacon broadcast via ESP-NOW
ftsp_leafnode.h Leaf: beacon sniffer + linear regression clock correction
ftsp_ntp.h NTP sync recording and world-time anchor (µs precision)
ftsp_precision.h Clock drift estimation and compensation (ppm)
ftsp_sync_viz.h RGB LED sync status visualization (marquee color cycling)

Quick Start

Gateway node (requires NTP via Enterprise WiFi):

node_espnow_config_t espnow_cfg;
node_espnow_default_config(&espnow_cfg);
espnow_cfg.create_sta_netif = true;  // DHCP for NTP
node_espnow_init(&espnow_cfg, NULL);

// NTP sync (blocking, ~30s timeout)
sync_time_with_timezone(NTP_TIMEZONE);

// Start FTSP beacon broadcast
ftsp_gateway_start();

// Sync visualization (WHITE → GREEN → MARQUEE)
ftsp_sync_viz_init();

Leaf node (no WiFi needed):

node_espnow_config_t espnow_cfg;
node_espnow_default_config(&espnow_cfg);
node_espnow_init(&espnow_cfg, NULL);

// Start FTSP receiver
ftsp_leafnode_start();

// Sync visualization
ftsp_sync_viz_init();

// After ftsp_is_synced() → get world time
uint64_t world_us;
ftsp_get_world_time_us(&world_us);