Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
0e3b0bd1dThis file is pinned to the selected release. Download the original to open it in your design tool.
//
// Serial Protocol Header
// JSON-based bidirectional communication over UART 0
//
#ifndef SERIAL_PROTOCOL_H
#define SERIAL_PROTOCOL_H
#include <stdint.h>
#include <stdbool.h>
// Initialize serial protocol
void serial_protocol_init(void);
// Send sensor data as JSON.
// aqi - canonical AirCube VOC Level (TVOC-derived, 0-500)
// aqi_s - deprecated; always 0 (kept for serial JSON compat)
// aqi_uba - ENS161 UBA hygienic rating (1-5)
// model - "base" or "pro" (detected hardware variant)
// co2_ppm - true CO2 from SCD41 (Pro only; 0 on Base)
// lux - ambient light from VCNL4040 (Pro only; 0 on Base)
void serial_send_sensor_data(uint8_t ens210_status, float temperature_c, float humidity,
const char* ens16x_status_str, int etvoc, int eco2,
int aqi, int aqi_s, int aqi_uba,
const char* model, int co2_ppm, float lux);
// Process incoming commands (call periodically)
void serial_process_commands(void);
// Send history info as JSON
void serial_send_history_info(void);
// Send a page of history data as JSON
void serial_send_history_page(uint16_t start, uint16_t count);
// Clear history and send confirmation
void serial_send_history_clear(void);
#endif // SERIAL_PROTOCOL_H