54 lines
1.6 KiB
C
54 lines
1.6 KiB
C
/**
|
|
* @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 <stdint.h>
|
|
|
|
/* 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);
|
|
|
|
/* 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);
|
|
|
|
/** 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__ */
|