main.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "stm32f10x.h"
  5. #include "Timer.h"
  6. #include "OLED.h"
  7. #include "GPIOA.h"
  8. #include "Usart1.h"
  9. #include "Usart2.h"
  10. #include "Regist.h"
  11. #include "PumpBusiness.h"
  12. #include "CONFIG.h"
  13. #include "mbedtls_util.h"
  14. #include "Common_Util.h"
  15. #include "Timer_Module.h"
  16. #include "Log_Module.h"
  17. #include "Tuoreniot.h"
  18. #include "bc260y.h"
  19. #include "esp32.h"
  20. #include "At_Module.h"
  21. // 6365736869303036
  22. uint8_t mcu_id[8] = "ceshi006";
  23. // 计时器
  24. static struct TIMER_Struct timer;
  25. static uint8_t regist_flag = 0;
  26. char ch[30] = "11111111111111111111111111111";
  27. int main(void)
  28. {
  29. // uint8_t memmem_flag = 0;
  30. Timer_Init();//定时器
  31. Usart1_Init();//打印串口
  32. Usart2_Init();//4G模块通信
  33. GPIOA_Init();//4G模块DTR IO口
  34. OLED_Init();
  35. OLED_Clear();
  36. OLED_ShowString(1, 1, "MS:");
  37. Log_Printf_Debug("1234\r\n");
  38. bytesToHex(ch, mcu_id, sizeof(mcu_id));
  39. // 通讯流程初始化
  40. PUMPBUSINESS_Init();
  41. while(1)
  42. {
  43. // 循环执行udp客户端OLED_ShowNum
  44. OLED_ShowNum(1, 4, time_get_delay(&timer), 6);
  45. if(time_get_delay(&timer) > 60 * 1000)
  46. {
  47. time_clear(&timer);
  48. }
  49. // 注册接口使用方法
  50. if(regist_flag == 0)
  51. {
  52. if(TUORENIOT_GetCodeOfRegistResponse() != 200)
  53. {
  54. Log_Printf_Debug("开始注册\r\n");
  55. // 开始注册
  56. REGIST_Start();
  57. }
  58. else
  59. {
  60. Log_Printf_Debug("已注册\r\n");
  61. }
  62. regist_flag = 1;
  63. }
  64. // 通讯流程处理
  65. PUMPBUSINESS_ProcessHandle();
  66. }
  67. }