main.c 2.3 KB

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