/** * @file app_info.h * @brief Device information query over the BLE frame protocol * (BLE_FRAME_INFO_QUERY / BLE_FRAME_INFO_RSP), plus the data sources * behind it (chip temperature, VDD, fan rpm, uptime, heap). * * See docs/ble_protocol.md section 5 for the item ids and the TLV encoding. */ #ifndef __APP_INFO_H__ #define __APP_INFO_H__ #ifdef __cplusplus extern "C" { #endif #include /* Info item ids */ #define BLE_INFO_FW_VERSION 0x01 /* u32, e.g. 0x00010001 = V1.00.01 */ #define BLE_INFO_CHIP_TEMP 0x02 /* i16, 0.1 degC (ADC internal sensor) */ #define BLE_INFO_FAN_RPM 0x03 /* u16 rpm, 0xFFFF = not present */ #define BLE_INFO_VDD_MV 0x04 /* u16, mV (ADC CH6) */ #define BLE_INFO_UPTIME_S 0x05 /* u32, seconds */ #define BLE_INFO_FREE_HEAP 0x06 /* u32, bytes */ #define APP_FAN_RPM_INVALID 0xFFFFu /** * @brief Handle one INFO_QUERY frame: payload = item id list (empty or a * single 0xFF queries all items). Answers with one INFO_RSP frame. * BLE schedule task context only. */ void app_info_handle_query(uint8_t seq, const uint8_t* ids, uint16_t n); /** * @brief TLV snapshot of ALL info items (identical content to an * INFO_RSP(all) frame), served as the read value of the read-only * device info characteristic. Returns a static buffer. */ const uint8_t* app_info_tlv_snapshot(uint16_t* out_len); /* Data sources (also usable from the CLI) */ /** Chip temperature in 0.1 degC; 0x7FFF when the ADC read timed out. */ int16_t app_info_chip_temp_c10(void); /** Last raw TS ADC reading (debug; 0xFFFF = timeout). */ uint16_t app_info_last_temp_raw(void); /** VDD voltage in mV; 0 when the ADC read timed out. */ uint16_t app_info_vdd_mv(void); /** * @brief Fan speed in rpm. Weak default returns APP_FAN_RPM_INVALID; * product code overrides this once the fan tachometer is hooked up. */ uint16_t app_fan_get_rpm(void); #ifdef __cplusplus } #endif #endif /* __APP_INFO_H__ */