#ifndef _APP_TEMPERATURE_H_ #define _APP_TEMPERATURE_H_ #include #include #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" /** * 腋温计iT12 */ #define BLE_TEMPERATURE_DEVICE_IT12 "iT12" /** * 耳温计iT22 */ #define BLE_TEMPERATURE_DEVICE_IT22 "iT22" /** * 产品ID iT18 */ #define PRODUCTID "iT18" /** * 设备ID */ #define DEVICEID "iT18_C8478C428848" /** * 检测硬件间隔时间 */ #define BLE_TEMPERATURE_DETECT_DEVICE_INTERVAL 1000 /** * 显示温度最小值 低于该值显示LOW */ #define BLE_TEMPERATURE_LIMIT_MIN 3200 /** * 显示温度最大值 高于该值显示HIGH */ #define BLE_TEMPERATURE_LIMIT_MAX 4290 /** * 合法温度最小值 低于该值不计入测温记录 */ #define BLE_TEMPERATURE_MIN 2000 /** * 合法温度最大值 高于该值不计入测温记录 */ #define BLE_TEMPERATURE_MAX 5000 /** * 盒子复位GPIO */ #define BLE_TEMPERATURE_BOX_RESET_LCD 37 /** * 霍尔按键检测GPIO */ #define BLE_TEMPERATURE_HALL_DETECT_PIN 38 /** * 盒子电源控制GPIO */ #define BLE_TEMPERATURE_BOX_POWER_CTR 39 /** * 检测到充电仓关闭后延迟多长时间关机 */ #define BLE_TEMPERATURE_POWEROFF_TIMEOUT 3000 //ms /** * 进入绑定模式 等待多长时间进行BLE 设备扫描 */ #define BLE_TEMPERATURE_BIND_MODE_TIMEOUT 8000 //ms /** * 霍尔按键检测时间间隔 */ #define BLE_TEMPERATURE_HALL_DETECT_INTERVAL 50 //ms /** * 超时25s 都没有收到温度广播数据 回到等待测温页面 */ #define BLE_TEMPERATURE_IDLE_MODE_TIMEOUT 25000 //ms /** * 配置文件easyflah KEY */ #define BLE_TEMPERATURE_FLASH_CONFIG_KEY "dev_cfg" /** * 测温记录 easyflah KEY */ #define BLE_TEMPERATURE_FLASH_RECORD_KEY "dev_record" /** * MQTT ID and KEY */ #define SECUREID_MQTT "pokaAdmin" #define SECUREKEY_MQTT "poka@123456" /** * 配置文件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" typedef enum { APP_MODE_NORMAL, APP_MODE_BIND, } app_temperature_mode_t; typedef struct { uint8_t device_name[16]; uint8_t device_mac[6]; uint16_t temperature_body; uint16_t temperature_obj; uint16_t temperature_env; uint16_t batt_percent; uint16_t batt_val; uint16_t device_state; }app_temperature_info_t; /** * 盒子硬件信息 */ typedef struct { uint16_t battery_value; /** * 1 -- 盒子接入充电 0 -- 盒子未接入充电 */ uint16_t charge_state; /** * 0 -- 合盖 1 -- 开盖 */ uint16_t hall_state; }app_box_info_t; typedef enum { //正在测量 STATE_DETECT_ING, //测量完成 STATE_DETECT_FINISH, } app_detect_state_t; /** * BOX 参数 */ typedef struct { uint8_t bind_mac[6]; uint16_t detect_interval; }app_dev_info_t; typedef struct { uint8_t timestamp[8]; 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, UI_SHOW_LOW_BAT_INFO, }app_ui_mode; void temperature_init(void); void temperature_adv_callback(recv_adv_t *r_ind); void app_enter_bind_mode(bool enter); void mqtt_upload_temperature(uint16_t t_value); int mqtt_start(char username[],char password[]); void poka_client_password(); void poka_client_username(); void connnect_wifi(char *oob_ssid,char *connect_key); /** * 保存最新的一次记录 */ void temperature_save_record(app_detect_record_t *record); //void temperature_save_record(uint16_t t_value); /** * 读取最新的一次记录 */ void temperature_read_record(app_detect_record_t *record); void temperature_led_ble(bool onoff); void app_enter_ui(app_ui_mode mode); #endif //_APP_TEMPERATURE_H_