902 lines
18 KiB
C
902 lines
18 KiB
C
#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"
|
|
/**
|
|
* 耳温计iT22
|
|
*/
|
|
#define BLE_TEMPERATURE_DEVICE_IT22 "iT22"
|
|
/**
|
|
* 产品ID iT18
|
|
*/
|
|
#define PRODUCTID "iT18"
|
|
/**
|
|
* 设备ID
|
|
*/
|
|
#define DEVICEID "iT18_C8478C428848"
|
|
/**
|
|
* 检测硬件间隔时间
|
|
*/
|
|
#define BLE_TEMPERATURE_DETECT_DEVICE_INTERVAL 1000
|
|
|
|
/**
|
|
* 蓝牙扫描间隔时间
|
|
*/
|
|
#define BLE_SCAN_INTERVAL 8000
|
|
|
|
/**
|
|
* 显示温度最小值 低于该值显示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 30000 //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 "poka"
|
|
#define SECUREKEY_MQTT "Poka&Lock12345"
|
|
|
|
/**
|
|
* 配置文件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"
|
|
/**
|
|
* 音量记录 easyflah KEY volume
|
|
*/
|
|
#define BLE_TEMPERATURE_FLASH_RECORD_KEY_VOLUME "m1_volume"
|
|
|
|
#define BATTERY_TABLE_SIZE 662 // 查表法数据点数量
|
|
static const struct {
|
|
u16 voltage; // 电压值(mV)
|
|
u32 mah; // 对应电量
|
|
} voltage_table[BATTERY_TABLE_SIZE] = {
|
|
{4179, 0},
|
|
{4174, 670},
|
|
{4171, 1340},
|
|
{4169, 2020},
|
|
{4166, 2690},
|
|
{4164, 3360},
|
|
{4160, 4030},
|
|
{4159, 4700},
|
|
{4156, 5370},
|
|
{4153, 6050},
|
|
{4151, 6720},
|
|
{4148, 7390},
|
|
{4145, 8060},
|
|
{4143, 8730},
|
|
{4140, 9400},
|
|
{4138, 10070},
|
|
{4135, 10750},
|
|
{4133, 11420},
|
|
{4129, 12090},
|
|
{4125, 12760},
|
|
{4122, 13430},
|
|
{4120, 14100},
|
|
{4116, 14770},
|
|
{4112, 15450},
|
|
{4109, 16120},
|
|
{4106, 16790},
|
|
{4101, 17460},
|
|
{4096, 18130},
|
|
{4093, 18800},
|
|
{4087, 19470},
|
|
{4082, 20150},
|
|
{4078, 20820},
|
|
{4074, 21490},
|
|
{4068, 22160},
|
|
{4064, 22830},
|
|
{4059, 23510},
|
|
{4055, 24180},
|
|
{4050, 24850},
|
|
{4046, 25520},
|
|
{4042, 26190},
|
|
{4038, 26860},
|
|
{4034, 27530},
|
|
{4031, 28210},
|
|
{4028, 28880},
|
|
{4024, 29550},
|
|
{4020, 30220},
|
|
{4018, 30890},
|
|
{4015, 31560},
|
|
{4013, 32240},
|
|
{4009, 32910},
|
|
{4007, 33580},
|
|
{4005, 34250},
|
|
{4002, 34920},
|
|
{4000, 35600},
|
|
{3997, 36270},
|
|
{3995, 36940},
|
|
{3992, 37610},
|
|
{3991, 38280},
|
|
{3988, 38950},
|
|
{3986, 39620},
|
|
{3983, 40290},
|
|
{3983, 40970},
|
|
{3980, 41640},
|
|
{3977, 42310},
|
|
{3976, 42980},
|
|
{3973, 43650},
|
|
{3972, 44320},
|
|
{3970, 44990},
|
|
{3968, 45670},
|
|
{3966, 46340},
|
|
{3964, 47010},
|
|
{3961, 47680},
|
|
{3960, 48350},
|
|
{3957, 49020},
|
|
{3956, 49700},
|
|
{3954, 50370},
|
|
{3953, 51040},
|
|
{3950, 51710},
|
|
{3948, 52380},
|
|
{3946, 53060},
|
|
{3945, 53730},
|
|
{3943, 54400},
|
|
{3942, 55070},
|
|
{3940, 55740},
|
|
{3938, 56410},
|
|
{3935, 57080},
|
|
{3935, 57760},
|
|
{3933, 58430},
|
|
{3931, 59100},
|
|
{3929, 59770},
|
|
{3928, 60440},
|
|
{3925, 61110},
|
|
{3923, 61780},
|
|
{3923, 62460},
|
|
{3920, 63130},
|
|
{3918, 63800},
|
|
{3917, 64470},
|
|
{3915, 65140},
|
|
{3914, 65810},
|
|
{3912, 66480},
|
|
{3910, 67160},
|
|
{3909, 67830},
|
|
{3908, 68500},
|
|
{3906, 69170},
|
|
{3904, 69840},
|
|
{3902, 70510},
|
|
{3900, 71190},
|
|
{3899, 71860},
|
|
{3898, 72530},
|
|
{3896, 73200},
|
|
{3894, 73870},
|
|
{3892, 74540},
|
|
{3890, 75210},
|
|
{3889, 75890},
|
|
{3888, 76560},
|
|
{3887, 77230},
|
|
{3884, 77900},
|
|
{3882, 78570},
|
|
{3881, 79240},
|
|
{3879, 79920},
|
|
{3878, 80590},
|
|
{3876, 81260},
|
|
{3874, 81930},
|
|
{3872, 82600},
|
|
{3871, 83270},
|
|
{3870, 83940},
|
|
{3869, 84620},
|
|
{3867, 85290},
|
|
{3865, 85960},
|
|
{3864, 86630},
|
|
{3862, 87300},
|
|
{3860, 87970},
|
|
{3859, 88640},
|
|
{3857, 89320},
|
|
{3855, 89990},
|
|
{3855, 90660},
|
|
{3853, 91330},
|
|
{3851, 92000},
|
|
{3850, 92680},
|
|
{3848, 93350},
|
|
{3846, 94020},
|
|
{3845, 94690},
|
|
{3844, 95360},
|
|
{3840, 96030},
|
|
{3840, 96700},
|
|
{3839, 97370},
|
|
{3837, 98050},
|
|
{3835, 98720},
|
|
{3834, 99390},
|
|
{3832, 100060},
|
|
{3830, 100730},
|
|
{3830, 101400},
|
|
{3829, 102080},
|
|
{3826, 102750},
|
|
{3825, 103420},
|
|
{3823, 104090},
|
|
{3821, 104760},
|
|
{3819, 105430},
|
|
{3819, 106100},
|
|
{3816, 106770},
|
|
{3815, 107450},
|
|
{3814, 108120},
|
|
{3812, 108790},
|
|
{3811, 109460},
|
|
{3809, 110130},
|
|
{3808, 110800},
|
|
{3806, 111470},
|
|
{3805, 112140},
|
|
{3804, 112820},
|
|
{3803, 113490},
|
|
{3800, 114160},
|
|
{3799, 114830},
|
|
{3798, 115500},
|
|
{3796, 116170},
|
|
{3794, 116840},
|
|
{3794, 117510},
|
|
{3792, 118190},
|
|
{3789, 118860},
|
|
{3789, 119530},
|
|
{3788, 120200},
|
|
{3787, 120870},
|
|
{3784, 121540},
|
|
{3783, 122210},
|
|
{3780, 122890},
|
|
{3780, 123560},
|
|
{3778, 124230},
|
|
{3777, 124900},
|
|
{3776, 125570},
|
|
{3774, 126240},
|
|
{3772, 126920},
|
|
{3771, 127590},
|
|
{3769, 128260},
|
|
{3769, 128930},
|
|
{3768, 129600},
|
|
{3766, 130270},
|
|
{3765, 130940},
|
|
{3763, 131620},
|
|
{3761, 132290},
|
|
{3760, 132960},
|
|
{3758, 133630},
|
|
{3757, 134300},
|
|
{3755, 134970},
|
|
{3754, 135640},
|
|
{3754, 136310},
|
|
{3752, 136990},
|
|
{3750, 137660},
|
|
{3749, 138330},
|
|
{3748, 139000},
|
|
{3746, 139670},
|
|
{3745, 140340},
|
|
{3743, 141010},
|
|
{3742, 141690},
|
|
{3741, 142360},
|
|
{3740, 143030},
|
|
{3738, 143700},
|
|
{3738, 144370},
|
|
{3735, 145040},
|
|
{3734, 145710},
|
|
{3732, 146380},
|
|
{3732, 147060},
|
|
{3730, 147730},
|
|
{3729, 148400},
|
|
{3727, 149070},
|
|
{3726, 149740},
|
|
{3725, 150410},
|
|
{3723, 151090},
|
|
{3722, 151760},
|
|
{3720, 152430},
|
|
{3720, 153100},
|
|
{3717, 153770},
|
|
{3716, 154440},
|
|
{3716, 155110},
|
|
{3714, 155790},
|
|
{3712, 156460},
|
|
{3712, 157130},
|
|
{3710, 157800},
|
|
{3709, 158470},
|
|
{3708, 159140},
|
|
{3707, 159810},
|
|
{3705, 160490},
|
|
{3704, 161160},
|
|
{3703, 161830},
|
|
{3702, 162500},
|
|
{3701, 163170},
|
|
{3700, 163840},
|
|
{3699, 164520},
|
|
{3697, 165190},
|
|
{3697, 165860},
|
|
{3695, 166530},
|
|
{3694, 167200},
|
|
{3693, 167870},
|
|
{3691, 168540},
|
|
{3690, 169210},
|
|
{3689, 169890},
|
|
{3688, 170560},
|
|
{3688, 171230},
|
|
{3686, 171900},
|
|
{3685, 172570},
|
|
{3683, 173240},
|
|
{3683, 173920},
|
|
{3681, 174590},
|
|
{3680, 175260},
|
|
{3679, 175930},
|
|
{3678, 176600},
|
|
{3677, 177270},
|
|
{3677, 177940},
|
|
{3677, 178610},
|
|
{3673, 179290},
|
|
{3673, 179960},
|
|
{3672, 180630},
|
|
{3672, 181300},
|
|
{3672, 181970},
|
|
{3669, 182650},
|
|
{3668, 183320},
|
|
{3668, 183990},
|
|
{3666, 184660},
|
|
{3666, 185330},
|
|
{3665, 186000},
|
|
{3664, 186670},
|
|
{3664, 187350},
|
|
{3662, 188020},
|
|
{3661, 188690},
|
|
{3661, 189360},
|
|
{3659, 190030},
|
|
{3658, 190700},
|
|
{3657, 191380},
|
|
{3656, 192050},
|
|
{3656, 192720},
|
|
{3654, 193390},
|
|
{3654, 194060},
|
|
{3653, 194740},
|
|
{3653, 195410},
|
|
{3652, 196080},
|
|
{3650, 196750},
|
|
{3649, 197420},
|
|
{3648, 198090},
|
|
{3647, 198770},
|
|
{3647, 199440},
|
|
{3646, 200110},
|
|
{3645, 200780},
|
|
{3646, 201450},
|
|
{3644, 202120},
|
|
{3642, 202800},
|
|
{3642, 203470},
|
|
{3642, 204140},
|
|
{3640, 204810},
|
|
{3641, 205480},
|
|
{3639, 206150},
|
|
{3638, 206820},
|
|
{3638, 207500},
|
|
{3637, 208170},
|
|
{3637, 208840},
|
|
{3637, 209510},
|
|
{3636, 210180},
|
|
{3636, 210850},
|
|
{3635, 211530},
|
|
{3633, 212200},
|
|
{3633, 212870},
|
|
{3632, 213540},
|
|
{3632, 214210},
|
|
{3631, 214880},
|
|
{3629, 215550},
|
|
{3628, 216220},
|
|
{3628, 216900},
|
|
{3627, 217570},
|
|
{3626, 218240},
|
|
{3626, 218910},
|
|
{3626, 219580},
|
|
{3625, 220250},
|
|
{3625, 220920},
|
|
{3625, 221600},
|
|
{3623, 222270},
|
|
{3621, 222940},
|
|
{3621, 223610},
|
|
{3621, 224280},
|
|
{3621, 224950},
|
|
{3620, 225620},
|
|
{3620, 226300},
|
|
{3619, 226970},
|
|
{3619, 227640},
|
|
{3618, 228310},
|
|
{3617, 228980},
|
|
{3617, 229650},
|
|
{3617, 230330},
|
|
{3616, 231000},
|
|
{3615, 231670},
|
|
{3614, 232340},
|
|
{3613, 233010},
|
|
{3612, 233680},
|
|
{3612, 234350},
|
|
{3612, 235020},
|
|
{3612, 235700},
|
|
{3610, 236370},
|
|
{3610, 237040},
|
|
{3610, 237710},
|
|
{3610, 238380},
|
|
{3609, 239050},
|
|
{3608, 239730},
|
|
{3607, 240400},
|
|
{3606, 241070},
|
|
{3606, 241740},
|
|
{3606, 242410},
|
|
{3605, 243080},
|
|
{3605, 243750},
|
|
{3605, 244420},
|
|
{3603, 245090},
|
|
{3603, 245770},
|
|
{3602, 246440},
|
|
{3601, 247110},
|
|
{3601, 247780},
|
|
{3601, 248450},
|
|
{3601, 249120},
|
|
{3599, 249790},
|
|
{3598, 250470},
|
|
{3597, 251140},
|
|
{3597, 251810},
|
|
{3597, 252480},
|
|
{3596, 253150},
|
|
{3596, 253820},
|
|
{3595, 254490},
|
|
{3594, 255160},
|
|
{3594, 255840},
|
|
{3594, 256510},
|
|
{3593, 257180},
|
|
{3593, 257850},
|
|
{3593, 258520},
|
|
{3592, 259190},
|
|
{3592, 259870},
|
|
{3591, 260540},
|
|
{3590, 261210},
|
|
{3590, 261880},
|
|
{3590, 262550},
|
|
{3588, 263220},
|
|
{3588, 263890},
|
|
{3587, 264570},
|
|
{3587, 265240},
|
|
{3586, 265910},
|
|
{3586, 266580},
|
|
{3585, 267250},
|
|
{3585, 267920},
|
|
{3584, 268590},
|
|
{3583, 269260},
|
|
{3583, 269940},
|
|
{3583, 270610},
|
|
{3583, 271280},
|
|
{3581, 271950},
|
|
{3581, 272620},
|
|
{3580, 273290},
|
|
{3580, 273960},
|
|
{3579, 274640},
|
|
{3579, 275310},
|
|
{3578, 275980},
|
|
{3577, 276650},
|
|
{3577, 277320},
|
|
{3578, 277990},
|
|
{3577, 278660},
|
|
{3577, 279340},
|
|
{3575, 280010},
|
|
{3575, 280680},
|
|
{3575, 281350},
|
|
{3574, 282020},
|
|
{3574, 282690},
|
|
{3574, 283370},
|
|
{3572, 284040},
|
|
{3571, 284710},
|
|
{3571, 285380},
|
|
{3570, 286050},
|
|
{3570, 286720},
|
|
{3570, 287390},
|
|
{3569, 288070},
|
|
{3568, 288740},
|
|
{3567, 289410},
|
|
{3567, 290080},
|
|
{3568, 290750},
|
|
{3567, 291420},
|
|
{3566, 292090},
|
|
{3566, 292770},
|
|
{3565, 293440},
|
|
{3564, 294110},
|
|
{3565, 294780},
|
|
{3564, 295450},
|
|
{3563, 296120},
|
|
{3562, 296790},
|
|
{3562, 297470},
|
|
{3561, 298140},
|
|
{3561, 298810},
|
|
{3560, 299480},
|
|
{3559, 300150},
|
|
{3559, 300820},
|
|
{3558, 301500},
|
|
{3558, 302170},
|
|
{3557, 302840},
|
|
{3557, 303510},
|
|
{3556, 304180},
|
|
{3555, 304850},
|
|
{3554, 305520},
|
|
{3554, 306190},
|
|
{3553, 306870},
|
|
{3553, 307540},
|
|
{3552, 308210},
|
|
{3551, 308880},
|
|
{3551, 309550},
|
|
{3551, 310220},
|
|
{3551, 310890},
|
|
{3549, 311570},
|
|
{3549, 312240},
|
|
{3548, 312910},
|
|
{3548, 313580},
|
|
{3547, 314250},
|
|
{3547, 314920},
|
|
{3545, 315590},
|
|
{3545, 316270},
|
|
{3544, 316940},
|
|
{3544, 317610},
|
|
{3543, 318280},
|
|
{3542, 318950},
|
|
{3542, 319620},
|
|
{3541, 320300},
|
|
{3541, 320970},
|
|
{3541, 321640},
|
|
{3540, 322310},
|
|
{3540, 322980},
|
|
{3538, 323660},
|
|
{3537, 324330},
|
|
{3537, 325000},
|
|
{3536, 325670},
|
|
{3537, 326340},
|
|
{3536, 327010},
|
|
{3535, 327680},
|
|
{3534, 328360},
|
|
{3533, 329030},
|
|
{3532, 329700},
|
|
{3532, 330370},
|
|
{3531, 331040},
|
|
{3531, 331710},
|
|
{3530, 332380},
|
|
{3530, 333050},
|
|
{3529, 333730},
|
|
{3528, 334400},
|
|
{3528, 335070},
|
|
{3527, 335740},
|
|
{3526, 336410},
|
|
{3526, 337080},
|
|
{3525, 337750},
|
|
{3524, 338430},
|
|
{3522, 339100},
|
|
{3522, 339770},
|
|
{3522, 340440},
|
|
{3521, 341110},
|
|
{3520, 341780},
|
|
{3520, 342450},
|
|
{3518, 343120},
|
|
{3517, 343800},
|
|
{3517, 344470},
|
|
{3515, 345140},
|
|
{3516, 345810},
|
|
{3515, 346480},
|
|
{3513, 347150},
|
|
{3513, 347820},
|
|
{3513, 348490},
|
|
{3512, 349170},
|
|
{3511, 349840},
|
|
{3510, 350510},
|
|
{3509, 351180},
|
|
{3508, 351850},
|
|
{3508, 352520},
|
|
{3506, 353190},
|
|
{3506, 353860},
|
|
{3504, 354530},
|
|
{3504, 355200},
|
|
{3505, 355880},
|
|
{3504, 356550},
|
|
{3501, 357220},
|
|
{3501, 357890},
|
|
{3500, 358560},
|
|
{3500, 359230},
|
|
{3499, 359900},
|
|
{3498, 360570},
|
|
{3497, 361240},
|
|
{3496, 361910},
|
|
{3495, 362580},
|
|
{3494, 363260},
|
|
{3493, 363930},
|
|
{3491, 364600},
|
|
{3490, 365270},
|
|
{3490, 365940},
|
|
{3490, 366610},
|
|
{3488, 367280},
|
|
{3487, 367950},
|
|
{3486, 368620},
|
|
{3486, 369290},
|
|
{3485, 369960},
|
|
{3484, 370630},
|
|
{3482, 371300},
|
|
{3482, 371970},
|
|
{3481, 372640},
|
|
{3479, 373320},
|
|
{3479, 373990},
|
|
{3477, 374660},
|
|
{3476, 375330},
|
|
{3475, 376000},
|
|
{3473, 376670},
|
|
{3472, 377340},
|
|
{3470, 378010},
|
|
{3469, 378680},
|
|
{3469, 379350},
|
|
{3469, 380020},
|
|
{3467, 380690},
|
|
{3465, 381370},
|
|
{3464, 382040},
|
|
{3464, 382710},
|
|
{3463, 383380},
|
|
{3460, 384050},
|
|
{3460, 384720},
|
|
{3459, 385390},
|
|
{3456, 386060},
|
|
{3457, 386730},
|
|
{3455, 387400},
|
|
{3454, 388080},
|
|
{3453, 388750},
|
|
{3451, 389420},
|
|
{3449, 390090},
|
|
{3449, 390760},
|
|
{3446, 391430},
|
|
{3445, 392100},
|
|
{3444, 392770},
|
|
{3443, 393440},
|
|
{3441, 394110},
|
|
{3439, 394780},
|
|
{3438, 395450},
|
|
{3438, 396130},
|
|
{3436, 396800},
|
|
{3434, 397470},
|
|
{3433, 398140},
|
|
{3430, 398810},
|
|
{3429, 399480},
|
|
{3428, 400150},
|
|
{3427, 400820},
|
|
{3425, 401490},
|
|
{3424, 402160},
|
|
{3422, 402840},
|
|
{3421, 403510},
|
|
{3419, 404180},
|
|
{3417, 404850},
|
|
{3416, 405520},
|
|
{3415, 406190},
|
|
{3412, 406860},
|
|
{3411, 407530},
|
|
{3409, 408200},
|
|
{3408, 408870},
|
|
{3407, 409540},
|
|
{3406, 410210},
|
|
{3404, 410880},
|
|
{3403, 411560},
|
|
{3401, 412230},
|
|
{3399, 412900},
|
|
{3398, 413570},
|
|
{3396, 414240},
|
|
{3394, 414910},
|
|
{3393, 415580},
|
|
{3391, 416250},
|
|
{3389, 416920},
|
|
{3386, 417590},
|
|
{3384, 418260},
|
|
{3382, 418930},
|
|
{3381, 419610},
|
|
{3379, 420280},
|
|
{3376, 420950},
|
|
{3375, 421620},
|
|
{3372, 422290},
|
|
{3369, 422960},
|
|
{3367, 423630},
|
|
{3364, 424300},
|
|
{3361, 424970},
|
|
{3358, 425640},
|
|
{3354, 426310},
|
|
{3351, 426980},
|
|
{3348, 427650},
|
|
{3343, 428330},
|
|
{3339, 429000},
|
|
{3335, 429670},
|
|
{3331, 430340},
|
|
{3324, 431010},
|
|
{3318, 431680},
|
|
{3312, 432350},
|
|
{3305, 433020},
|
|
{3297, 433690},
|
|
{3289, 434360},
|
|
{3280, 435030},
|
|
{3269, 435700},
|
|
{3257, 436370},
|
|
{3245, 437040},
|
|
{3229, 437710},
|
|
{3212, 438380},
|
|
{3193, 439050},
|
|
{3174, 439720},
|
|
{3151, 440390},
|
|
{3125, 441060},
|
|
{3096, 441740},
|
|
{3065, 442410},
|
|
{3029, 443080},
|
|
{3000, 443570}
|
|
};
|
|
|
|
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;
|
|
uint8_t volume;
|
|
}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[]);
|
|
int mqtt_start2(char* username,char *password ,char * client_id);
|
|
void poka_client_password();
|
|
void poka_client_username();
|
|
void connnect_wifi(char *oob_ssid,char *connect_key);
|
|
void timer_ble_scan_callback(void *arg);
|
|
|
|
/**
|
|
* 保存最新的一次记录
|
|
*/
|
|
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);
|
|
|
|
void volume_read_record(app_detect_record_t *record);
|
|
|
|
void volume_save_record(app_detect_record_t *record);
|
|
#endif //_APP_TEMPERATURE_H_
|