@ -1,26 +1,26 @@
# include "myfreertos.h"
# include "myfreertos.h"
char pubTopic [ 512 ] = " /sys/hp8oQhMZJ67/Device1/thing/event/property/post " ; // 发布的主题
char pubTopic [ 512 ] = " /sys/hp8oQhMZJ67/Device1/thing/event/property/post " ; // Publish topic
char subTopic [ 512 ] = " /sys/hp8oQhMZJ67/Device1/thing/service/property/set " ; // 订阅的主题
char subTopic [ 512 ] = " /sys/hp8oQhMZJ67/Device1/thing/service/property/set " ; // Subscribe topic
# define MQTT_SOCK 5
# define MQTT_SOCK 5
// 任务优先级
// task priority
# define START_TASK_PRIO 0
# define START_TASK_PRIO 0
// 任务堆栈大小
// Task stack size
# define START_STK_SIZE 128
# define START_STK_SIZE 128
// 任务句柄
// task handle
TaskHandle_t StartTask_Handler ;
TaskHandle_t StartTask_Handler ;
// 任务函数
// task function
void start_task ( void * pvParameters ) ;
void start_task ( void * pvParameters ) ;
// 任务优先级
// task priority
# define Sensor_Communication_TASK_PRIO 1 // 与传感器通信
# define Sensor_Communication_TASK_PRIO 1 // Communication with sensors
// 任务堆栈大小
// Task stack size
# define Sensor_Communication_STK_SIZE 512
# define Sensor_Communication_STK_SIZE 512
// 任务句柄
// task handle
TaskHandle_t Sensor_CommunicationTask_Handler ;
TaskHandle_t Sensor_CommunicationTask_Handler ;
// 任务函数
// task function
void Sensor_Communication_task ( void * pvParameters ) ;
void Sensor_Communication_task ( void * pvParameters ) ;
void Host_Computer_Communication ( void ) ;
void Host_Computer_Communication ( void ) ;
@ -28,16 +28,16 @@ void Host_Computer_Communication(void);
int isZeros ( u8 arr [ ] ) ;
int isZeros ( u8 arr [ ] ) ;
u8 RS485_RX_BUF_COPY [ 128 ] = { 0 } ;
u8 RS485_RX_BUF_COPY [ 128 ] = { 0 } ;
u8 cnt_flag = 0 , sub_flag = 0 , pub_flag = 0 ;
u8 cnt_flag = 0 , sub_flag = 0 , pub_flag = 0 ;
u16 time = 0 ; // 记录ping服务器的时间
u16 time = 0 ; // Record the time of pinging the server
char wet_temp [ 256 ] ; // 订阅与发布消息的缓存区
char wet_temp [ 256 ] ; // Cache area for subscription and publication of messages
u8 store_stage = 1 ; // 写入flash的阶段号, 断电重启后读取可以紧接着上次的阶段运行
u8 store_stage = 1 ; // Write the stage number of the flash, and after a power outage and restart, it can run immediately following the previous stage and status
extern PID pid ;
extern PID pid ;
extern float kd ;
extern float kd ;
extern float ki ;
extern float ki ;
u8 batch_sync_buf [ 11 ] ; // 单个同步剪切得到的数组
u8 batch_sync_buf [ 11 ] ; // Array obtained by single synchronous cutting
u8 ins_1 = 0 ;
u8 ins_1 = 0 ;
int diff = 0 ;
int diff = 0 ;
u8 gpio_state = 0x00 ; // 继电器状态
u8 gpio_state = 0x00 ; // relay status
u8 NUM = 1 ; // 批量同步发送的阶段号
u8 NUM = 1 ; // 批量同步发送的阶段号
u8 n ; // 阶段号
u8 n ; // 阶段号
u16 i ; // 序列号
u16 i ; // 序列号
@ -46,15 +46,15 @@ u8 cminute; //
u8 hot_clod_flag = 0 ; // 加热制冷标志位。hot_clod_flag=0, 不加热不制冷; hot_clod_flag=2,加热; hot_clod_flag=1,制冷
u8 hot_clod_flag = 0 ; // 加热制冷标志位。hot_clod_flag=0, 不加热不制冷; hot_clod_flag=2,加热; hot_clod_flag=1,制冷
u8 humidity_flag = 0 ; // 加湿除湿标志位。 humidity_flag=0, 不加湿不除湿; humidity_flag=2,加湿; humidity_flag=1, 除湿
u8 humidity_flag = 0 ; // 加湿除湿标志位。 humidity_flag=0, 不加湿不除湿; humidity_flag=2,加湿; humidity_flag=1, 除湿
u8 ALARM = 0 ; // 报警标志位。ALARM=0,不报警; ALARM=1,报警
u8 ALARM = 0 ; // 报警标志位。ALARM=0,不报警; ALARM=1,报警
u16 tick = 0 ; // tick大于600, 触发报警条件会报警; 小于600则不报警 。
u16 tick = 0 ; // tick大于600, 触发报警条件会报警; 小于600则不报警
u8 Feed_Dog_Count = 0 ; // 喂狗计时
u8 Feed_Dog_Count = 0 ; // Feeding dog timing
u8 now_stage = 1 ; // 当前运行阶段
u8 now_stage = 1 ; // Current operational phase
u16 tem , hum , red , blue , white ;
u16 tem , hum , red , blue , white ;
u8 hour , min ;
u8 hour , min ;
u8 change_stage_rev1 = 0 ;
u8 change_stage_rev1 = 0 ;
u8 change_stage_rev2 = 0 ;
u8 change_stage_rev2 = 0 ;
u8 change_stage_rev3 = 0 ;
u8 change_stage_rev3 = 0 ;
u8 rs485buf [ 8 ] = { 0x02 , 0x03 , 0x00 , 0x01 , 0x00 , 0x09 , 0xD4 , 0x3F } ; // 传感器交换数据
u8 rs485buf [ 8 ] = { 0x02 , 0x03 , 0x00 , 0x01 , 0x00 , 0x09 , 0xD4 , 0x3F } ; // Sensor exchange data
u16 sync_cnt = 0 ; // 同步环境控制参数的计数器, 到0同步
u16 sync_cnt = 0 ; // 同步环境控制参数的计数器, 到0同步
int T = 0 , H = 0 , C = 0 , G = 0 , current_T = 0 ;
int T = 0 , H = 0 , C = 0 , G = 0 , current_T = 0 ;
extern u8 total [ ] ;
extern u8 total [ ] ;
@ -65,12 +65,12 @@ float temperature = 0;
/*********************
/*********************
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *
入 口 函 数
entry function
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * * * * * */
void os_init ( void )
void os_init ( void )
{
{
// printf(" 入口函数调用成功 \r\n");
// printf(" Entry function call successful \r\n");
xTaskCreate ( ( TaskFunction_t ) start_task ,
xTaskCreate ( ( TaskFunction_t ) start_task ,
( char * ) " start_task " ,
( char * ) " start_task " ,
( uint16_t ) START_STK_SIZE ,
( uint16_t ) START_STK_SIZE ,
@ -82,7 +82,7 @@ void os_init(void)
/*********************
/*********************
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *
创 建 任 务 , 队 列 , 信 号 集 等 句 柄 , 也 可 以 测 试 用
Create handles for tasks , queues , signal sets , etc . , which can also be tested using
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * * * * * */
BaseType_t handler = 0 ;
BaseType_t handler = 0 ;
@ -100,7 +100,7 @@ BaseType_t handler11 = 0;
/*
/*
开 始 函 数 : 创 建 其 他 函 数 与 定 时 器
Start function : Create other functions and timers
*/
*/