Job_SignsPads/ESP32/software/main/inc/main.h
2025-04-22 11:14:45 +08:00

203 lines
5.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Date: 2024-07-11 11:15:25
* @LastEditors: lzc56 563451665@qq.com
* @LastEditTime: 2025-01-10 09:05:19
* @FilePath: \software\main\inc\main.h
*/
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __MAIN_H__
#define __MAIN_H__
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_task_wdt.h"
#include "esp_system.h"
#include "esp_app_desc.h"
#include "esp_netif.h"
#include "esp_event.h"
#include "esp_log.h"
//------------Protobuf---------------//
#include "pb.h"
#include "pb_encode.h"
#include "pb_decode.h"
#include "AlgCommunicate.pb.h"
#ifdef __cplusplus
extern "C"
{
#endif
//--------------------------------------------------------配置
// 网络配置
typedef struct network_Config_T
{
char serialNumber[32];
char wifi_ssid[32];
char wifi_password[64];
char mqtt_ip[64];
int mqtt_port;
char mqtt_username[64];
char mqtt_password[64];
} network_Config_t;
// 系统配置
typedef struct System_Config_T
{
char device_ver[32];
char device_MAC[32];
char device_SN[32];
} System_Config_t;
// 用户配置
typedef struct User_Config_T
{
// Basic
char user_breathDay[32];
char user_name[32];
char user_age;
char user_sex;
char user_height;
char user_weight;
char user_timeZone;
// Move
int user_w_moveKeep;
char user_w_moveOpen;
// Leave
int user_w_leaveKeep;
// Breath
char user_w_breathKeep;
char user_w_breathMax;
char user_w_breathMin;
// Heartbeat
char user_w_heartBeatKeep;
char user_w_heartBeatMax;
char user_w_heartBeatMin;
// NightLight
int user_nightLightEnable;
} User_Config_t;
// 预警消息
typedef struct WarningMsg_T
{
// 超过阈值时的滴答计数器
uint64_t Breath_OverThreshold_CountTick;
uint64_t Heart_OverThreshold_CountTick;
uint64_t Move_OverThreshold_CountTick;
uint64_t Leave_OverThreshold_CountTick;
// 超过阈值时的时间戳
uint64_t Breath_OverThreshold_TimeStamp;
uint64_t Heart_OverThreshold_TimeStamp;
uint64_t Move_OverThreshold_TimeStamp;
uint64_t Leave_OverThreshold_TimeStamp;
// 持续时间的记录ms
uint64_t Breath_KeepTime_Record;
uint64_t Heart_KeepTime_Record;
uint64_t Move_KeepTime_Record;
uint64_t Leave_KeepTime_Record;
// 滴答定时器的时间记录
uint64_t SysTick_Count;
} WarningMsg_t;
//--------------------------------------------------------状态
typedef struct System_Status_T
{
uint64_t timeStamp;
char net_ConnectStatus;
char mqtt_ConnectStatus;
char net_ReConfigStatus;
} System_Status_t;
//--------------------------------------------------------数据
typedef struct SingsData_T
{
char inOffBed;
char heartBeat;
char breathRate;
char moveMent;
} SingsData_t;
typedef struct UploadData_T
{
//----------------------------------------------------------------体征数据
char heartBeat; // 心率
char breathRate; // 呼吸
char movement; // 体动
char bedStatus; // 在离床
//----------------------------------------------------------------设备数据
int32_t deviceHealth; // 设备健康
int32_t opticalFibre; //
int32_t sensorLoad; //
int32_t lightSignal; //
long long timeStamp; // 时间戳
//----------------------------------------------------------------日志数据
float max;
float opticalPower;
float opticalPowerOrigin;
float opticalPowerRecord;
float opticalPowerRecord_2;
//----------------------------------------------------------------日志数据
char logData[1024];
//----------------------------------------------------------------工厂数据
char factoryData[1024];
} UploadData_t;
//--------------------------------------------------------宏定义
#define THE_VERSION 1 // 1表示康养 0表示BCS
#define OPM_UPLOAD_SWITCH 0 // 1表示启动上传光功率 0表示不上传
#define CONNECTED 1 // 已经链接成功
#define DISCONNECTED 0 // 没有链接成功
#define SYS_LED_PIN_ON 1
#define SYS_LED_PIN_OFF 0
#define SYS_LED_PIN_NUM (GPIO_NUM_7)
#if THE_VERSION
#define DEFAULT_SN "105240901001"
#define DEFAULT_MQTT_IP "114.215.254.18"
#define DEFAULT_MQTT_PORT 1883
#define DEFAULT_MQTT_USERNAME "device"
#define DEFAULT_MQTT_PASSWORD "sH9xBWo0wS4Xzy%nDlCH"
#else
#define DEFAULT_SN "105240901001"
#define DEFAULT_MQTT_IP "miot.bewatec.com.cn"
#define DEFAULT_MQTT_PORT 1884
#define DEFAULT_MQTT_USERNAME "device"
#define DEFAULT_MQTT_PASSWORD "HSQz4QY1tWzwWFKM"
#endif
#define COM_OTA_MSG_OK 1
#define COM_OTA_MSG_DONE 3
#define COM_OTA_MSG_RESEND 2
extern SingsData_t SingsData;
extern WarningMsg_t WarningMsg;
extern UploadData_t UploadData;
extern User_Config_t User_Config;
extern System_Config_t System_Config;
extern System_Status_t System_Status;
extern network_Config_t network_Config;
extern TimerHandle_t NetConfig_timer;
extern EventGroupHandle_t ledEventGroup;
extern EventGroupHandle_t xComEventGroup;
extern SemaphoreHandle_t OTA_startSemaphore;
extern SemaphoreHandle_t MQTT_startSemaphore;
extern SemaphoreHandle_t OTA_deviceUpgradeDoneSemaphore;
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H__ */