main.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 "Timer_Module.h"
  15. #include "Log_Module.h"
  16. #include "Tuoreniot.h"
  17. #include "bc260y.h"
  18. #include "At_Module.h"
  19. // 计时器
  20. static struct TIMER_Struct timer;
  21. //static uint8_t send_flag = 1;
  22. //static char AT_CMD[512];
  23. //static char pridnsaddr[20];
  24. int main(void)
  25. {
  26. // uint8_t memmem_flag = 0;
  27. Timer_Init();//定时器
  28. Usart1_Init();//打印串口
  29. Usart2_Init();//4G模块通信
  30. GPIOA_Init();//4G模块DTR IO口
  31. OLED_Init();
  32. OLED_Clear();
  33. OLED_ShowString(1, 1, "MS:");
  34. Log_Printf_Debug("1234\r\n");
  35. // my_delay_ms(5000);
  36. //注册设备,最多失败三次
  37. regist_device_sync();
  38. Log_Printf_Debug("注册结束\r\n");
  39. while(1)
  40. {
  41. // 循环执行udp客户端OLED_ShowNum
  42. OLED_ShowNum(1, 4, time_get_delay(&timer), 6);
  43. if(time_get_delay(&timer) > 60 * 1000)
  44. {
  45. time_clear(&timer);
  46. }
  47. // if(send_flag == 1)
  48. // {
  49. // enum Result result = bc260y.exit_sleep_2_sync();
  50. // if(result==Result_Success)
  51. // {
  52. // Log_Printf_Debug("退出休眠成功\r\n");
  53. // result = bc260y.set_qisde_sync(1);//开启回显
  54. // }
  55. // if(result==Result_Success)
  56. // {
  57. // Log_Printf_Debug("开启回显成功\r\n");
  58. // memset(pridnsaddr, 0, sizeof(pridnsaddr));
  59. // result = bc260y.query_dns_sync(pridnsaddr); // 查询DNS
  60. // Log_Printf_Debug("DNS: %s, %d\r\n", pridnsaddr, strlen(pridnsaddr));
  61. // }
  62. // if(result==Result_Success)
  63. // {
  64. // Log_Printf_Debug("查询DNS成功\r\n");
  65. // if(strlen(pridnsaddr) <= 1)
  66. // {
  67. // result = bc260y.set_dns_sync("114.114.114.114", "8.8.8.8"); // 设置DNS
  68. // if(result==Result_Success)
  69. // {
  70. // Log_Printf_Debug("设置DNS成功\r\n");
  71. // memset(pridnsaddr, 0, sizeof(pridnsaddr));
  72. // result = bc260y.query_dns_sync(pridnsaddr); // 查询DNS
  73. // Log_Printf_Debug("DNS: %s, %d\r\n", pridnsaddr, strlen(pridnsaddr));
  74. // }
  75. // }
  76. //
  77. // }
  78. //
  79. // send_flag = 0;
  80. // }
  81. // AT_Handle();
  82. pump_business_loop_execution();
  83. }
  84. }