#include #include #include #include "stm32f10x.h" #include "Timer.h" #include "OLED.h" #include "GPIOA.h" #include "Usart1.h" #include "Usart2.h" #include "Regist.h" #include "PumpBusiness.h" #include "CONFIG.h" #include "mbedtls_util.h" #include "Common_Util.h" #include "Timer_Module.h" #include "Log_Module.h" #include "Tuoreniot.h" #include "bc260y.h" #include "esp32.h" #include "At_Module.h" // 6365736869303036 uint8_t mcu_id[8] = "ceshi007"; // 计时器 static struct TIMER_Struct timer; static uint8_t regist_flag = 0; char ch[30] = "11111111111111111111111111111"; int main(void) { // uint8_t memmem_flag = 0; Timer_Init();//定时器 Usart1_Init();//打印串口 Usart2_Init();//4G模块通信 GPIOA_Init();//4G模块DTR IO口 OLED_Init(); OLED_Clear(); OLED_ShowString(1, 1, "MS:"); Log_Printf_Debug("1234\r\n"); bytesToHex(ch, mcu_id, sizeof(mcu_id)); // 通讯流程初始化 PUMPBUSINESS_Init(); while(1) { // 循环执行udp客户端OLED_ShowNum OLED_ShowNum(1, 4, time_get_delay(&timer), 6); if(time_get_delay(&timer) > 60 * 1000) { time_clear(&timer); } // 注册接口使用方法 if(regist_flag == 0) { if(TUORENIOT_GetCodeOfRegistResponse() != 200) { Log_Printf_Debug("开始注册\r\n"); // 开始注册 REGIST_Start(); } else { Log_Printf_Debug("已注册\r\n"); } regist_flag = 1; } //判断注册流程是否成功 if(REGIST_GetStatus() == REGIST_Status_Done) { Log_Printf_Debug("注册结束\r\n"); if(REGIST_GetResult() == REGIST_Result_Success) { Log_Printf_Debug("注册成功: %d\r\n", REGIST_GetResult()); Network_Success_Flag = 1; } else if(REGIST_GetResult() == REGIST_Result_Failure) { Log_Printf_Debug("注册失败: %d\r\n", REGIST_GetResult()); Network_Success_Flag = 0; } // 重置注册 REGIST_Reset(); } // 通讯流程处理 PUMPBUSINESS_ProcessHandle(); } }