2025-04-12 18:24:59 +08:00
|
|
|
#ifndef _APP_TEMPERATURE_H_
|
|
|
|
#define _APP_TEMPERATURE_H_
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <finsh.h>
|
|
|
|
#include "common.h"
|
|
|
|
#include "param_config.h"
|
|
|
|
#include "ble_pub.h"
|
|
|
|
#include "drv_oled.h"
|
|
|
|
|
|
|
|
#include "belon_ble.h"
|
|
|
|
|
|
|
|
#if (CFG_BLE_VERSION == BLE_VERSION_5_2)
|
|
|
|
#include "app_ble.h"
|
|
|
|
#include "app_sdp.h"
|
|
|
|
#include "app_ble_init.h"
|
|
|
|
#endif
|
|
|
|
#if (BLE_APP_SEC)
|
|
|
|
#include "app_sec.h"
|
|
|
|
#endif
|
|
|
|
#include "kernel_mem.h"
|
|
|
|
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 腋温计iT12
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_DEVICE_IT12 "iT12"
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 耳温计iT19
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_DEVICE_IT19 "iT19"
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 温度定时更新间隔时间
|
|
|
|
*/
|
2025-04-26 23:37:31 +08:00
|
|
|
#define BLE_TEMPERATURE_DETECT_INTERVAL 5000
|
2025-04-12 18:24:59 +08:00
|
|
|
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 显示温度最小值 低于该值显示LOW
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_LIMIT_MIN 3200
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 显示温度最大值 高于该值显示HIGH
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_LIMIT_MAX 4200
|
|
|
|
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 霍尔按键检测GPIO
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_HALL_DETECT_PIN 38
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 盒子电源控制GPIO
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_BOX_POWER_CTR 39
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 检测到充电仓关闭后延迟多长时间关机
|
|
|
|
*/
|
|
|
|
#define BLE_TEMPERATURE_POWEROFF_TIMEOUT 3000 //ms
|
|
|
|
/**
|
|
|
|
* 进入绑定模式 等待多长时间进行BLE 设备扫描
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_BIND_MODE_TIMEOUT 8000 //ms
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 霍尔按键检测时间间隔
|
|
|
|
*/
|
|
|
|
#define BLE_TEMPERATURE_HALL_DETECT_INTERVAL 50 //ms
|
2025-04-12 18:24:59 +08:00
|
|
|
/**
|
|
|
|
* 超时10s 都没有收到温度广播数据 回到等待测温页面
|
|
|
|
*/
|
|
|
|
#define BLE_TEMPERATURE_IDLE_MODE_TIMEOUT 10000 //ms
|
|
|
|
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 配置文件easyflah KEY
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
#define BLE_TEMPERATURE_FLASH_CONFIG_KEY "dev_cfg"
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 测温记录 easyflah KEY
|
|
|
|
*/
|
|
|
|
#define BLE_TEMPERATURE_FLASH_RECORD_KEY "dev_record"
|
2025-04-12 18:24:59 +08:00
|
|
|
|
2025-04-26 23:37:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 配置文件easyflah KEY BIND MAC
|
|
|
|
*/
|
|
|
|
#define BLE_TEMPERATURE_FLASH_CONFIG_KEY_BIND_MAC "bind_mac"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 测温记录 easyflah KEY temperature
|
|
|
|
*/
|
|
|
|
#define BLE_TEMPERATURE_FLASH_RECORD_KEY_TEMPERATURE "m1_temperature"
|
|
|
|
/**
|
|
|
|
* 测温记录 easyflah KEY time
|
|
|
|
*/
|
|
|
|
#define BLE_TEMPERATURE_FLASH_RECORD_KEY_TIMESTAMP "m1_timestamp"
|
|
|
|
|
2025-04-12 18:24:59 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
APP_MODE_NORMAL,
|
|
|
|
APP_MODE_BIND,
|
|
|
|
} app_temperature_mode_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2025-04-21 18:02:49 +08:00
|
|
|
uint8_t device_name[16];
|
|
|
|
uint8_t device_mac[6];
|
2025-04-12 18:24:59 +08:00
|
|
|
uint16_t temperature_body;
|
|
|
|
uint16_t temperature_obj;
|
|
|
|
uint16_t temperature_env;
|
|
|
|
uint16_t batt_val;
|
2025-04-26 23:37:31 +08:00
|
|
|
uint16_t device_state;
|
2025-04-12 18:24:59 +08:00
|
|
|
}app_temperature_info_t;
|
|
|
|
|
2025-04-26 23:37:31 +08:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
//正在测量
|
|
|
|
STATE_DETECT_ING,
|
|
|
|
//测量完成
|
|
|
|
STATE_DETECT_FINISH,
|
|
|
|
} app_detect_state_t;
|
|
|
|
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* BOX 参数
|
|
|
|
*/
|
2025-04-12 18:24:59 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint8_t bind_mac[6];
|
|
|
|
uint16_t detect_interval;
|
|
|
|
}app_dev_info_t;
|
|
|
|
|
2025-04-21 18:02:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2025-04-26 23:37:31 +08:00
|
|
|
uint8_t timestamp[8];
|
2025-04-21 18:02:49 +08:00
|
|
|
uint16_t temperature_value;
|
|
|
|
}app_detect_record_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
UI_IDLE,
|
|
|
|
UI_WAIT_TEMPERATURE,
|
|
|
|
UI_BOX_BATTERY,
|
|
|
|
UI_BOX_BIND,
|
|
|
|
UI_SHOW_TEMPERATURE,
|
|
|
|
UI_SHOW_DEVICE_INFO,
|
|
|
|
UI_SHOW_MEMORY_INFO
|
|
|
|
}app_ui_mode;
|
|
|
|
|
2025-04-12 18:24:59 +08:00
|
|
|
void temperature_init(void);
|
|
|
|
void temperature_adv_callback(recv_adv_t *r_ind);
|
|
|
|
|
|
|
|
void app_enter_bind_mode(bool enter);
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 保存最新的一次记录
|
|
|
|
*/
|
|
|
|
void temperature_save_record(app_detect_record_t *record);
|
2025-04-26 23:37:31 +08:00
|
|
|
//void temperature_save_record(uint16_t t_value);
|
2025-04-21 18:02:49 +08:00
|
|
|
/**
|
|
|
|
* 读取最新的一次记录
|
|
|
|
*/
|
|
|
|
void temperature_read_record(app_detect_record_t *record);
|
2025-04-12 18:24:59 +08:00
|
|
|
|
2025-04-21 18:02:49 +08:00
|
|
|
void app_enter_ui(app_ui_mode mode);
|
2025-04-12 18:24:59 +08:00
|
|
|
#endif //_APP_TEMPERATURE_H_
|