165 lines
3.1 KiB
C
Raw Normal View History

#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"
/**
* iT12
*/
#define BLE_TEMPERATURE_DEVICE_IT12 "iT12"
/**
* iT19
*/
#define BLE_TEMPERATURE_DEVICE_IT19 "iT19"
/**
*
*/
#define BLE_TEMPERATURE_DETECT_INTERVAL 5000
/**
* LOW
*/
#define BLE_TEMPERATURE_LIMIT_MIN 3200
/**
* HIGH
*/
#define BLE_TEMPERATURE_LIMIT_MAX 4200
/**
* 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
/**
* 10s 广
*/
#define BLE_TEMPERATURE_IDLE_MODE_TIMEOUT 10000 //ms
/**
* easyflah KEY
*/
#define BLE_TEMPERATURE_FLASH_CONFIG_KEY "dev_cfg"
/**
* easyflah KEY
*/
#define BLE_TEMPERATURE_FLASH_RECORD_KEY "dev_record"
/**
* 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_val;
uint16_t device_state;
}app_temperature_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
}app_ui_mode;
void temperature_init(void);
void temperature_adv_callback(recv_adv_t *r_ind);
void app_enter_bind_mode(bool enter);
/**
*
*/
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 app_enter_ui(app_ui_mode mode);
#endif //_APP_TEMPERATURE_H_