Danger-alarm/SOFTWARE/Server/hc-12/hc-12.h

80 lines
1.3 KiB
C
Raw Normal View History

2024-06-03 16:27:41 +08:00
#ifndef HC_12_H
#define HC_12_H
#include <stdio.h>
#include <wiringPi.h>
#include <wiringSerial.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "../libconf/libconf.h"
#define BUFFER 1024
#define MAIL "gomail -r \"%s\" -s \"%s\" -t \"%s\""
typedef struct CONF {
char *mail;
char *temperature;
char *co;
char *co2;
char *MYSQL_ON;
char *PUSH_MYSQL_DATA_TIME;
char *MYSQL_HOST;
char *MYSQL_PORT_;
char *MYSQL_USRT;
char *MYSQL_PASSWORD;
char *MYSQL_DB;
char *MYSQL_TABLES;
} CONF;
typedef struct DATA {
// 存储实际传感器数据
float ds18b20;
float ch4;
float rp2040;
float rp2040_f;
float co;
float co2;
float ch4_;
// 超过阈值次数
int ds18b20_num;
int ch4_num;
int rp2040_num;
int co_num;
int co2_num;
// 共享内存
int *ds18b20_shm;
int *co_shm;
int *co2_shm;
// 第一次发送Mail标志
int ds18b20_1st;
int ch4_1st;
int co_1st;
int co2_1st;
// 持续浓度时候,等待时间再发送Mail
int _time;
} DATA;
// 定义包含两个结构体的参数结构体
typedef struct {
CONF *conf;
DATA *data;
} Thread;
#endif