main.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "At_Module.h"
  20. // 6365736869303036
  21. uint8_t mcu_id[8] = "ceshi006";
  22. // 计时器
  23. static struct TIMER_Struct timer;
  24. static uint8_t regist_flag = 0;
  25. char ch[30] = "11111111111111111111111111111";
  26. int main(void)
  27. {
  28. // uint8_t memmem_flag = 0;
  29. Timer_Init();//定时器
  30. Usart1_Init();//打印串口
  31. Usart2_Init();//4G模块通信
  32. GPIOA_Init();//4G模块DTR IO口
  33. OLED_Init();
  34. OLED_Clear();
  35. OLED_ShowString(1, 1, "MS:");
  36. Log_Printf_Debug("1234\r\n");
  37. bytesToHex(ch, mcu_id, sizeof(mcu_id));
  38. // 通讯流程初始化
  39. PUMPBUSINESS_Init();
  40. while(1)
  41. {
  42. // 循环执行udp客户端OLED_ShowNum
  43. OLED_ShowNum(1, 4, time_get_delay(&timer), 6);
  44. if(time_get_delay(&timer) > 60 * 1000)
  45. {
  46. time_clear(&timer);
  47. }
  48. // 注册接口使用方法
  49. if(regist_flag == 0)
  50. {
  51. if(TUORENIOT_GetCodeOfRegistResponse() != 200)
  52. {
  53. Log_Printf_Debug("开始注册\r\n");
  54. // 开始注册
  55. REGIST_Start();
  56. }
  57. else
  58. {
  59. Log_Printf_Debug("已注册\r\n");
  60. }
  61. regist_flag = 1;
  62. }
  63. // 通讯流程处理
  64. PUMPBUSINESS_ProcessHandle();
  65. }
  66. }