nettimer.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "nettimer.h"
  2. #include "../network_mgr/net_ctrl.h"
  3. #include "../network_mgr/sx1268/lora.h"
  4. OS_TMR netsend_timer; // 5分钟的定时器
  5. OS_TMR netsend_hour_timer; // 24小时的定时器
  6. timeout_t g_timeOut;
  7. timeout_t g_usmTimeOut; // 4G模块的连接超时状态
  8. timeout_t g_uart4Time; // 串口4的接收中断计时
  9. timeout_t g_uart5Time; // 串口5的接收中断计时
  10. timeout_t g_uart2Time; // 串口2的接收中断计时
  11. /*-----------------------------------------------------
  12. * 一分钟一次
  13. * ----------------------------------------------------*/
  14. void netsend_msg_timer(void *p_tmr, void *p_arg)
  15. {
  16. uint8_t i=0,j=0,k=0;
  17. static uint8_t _tick = 0;
  18. uint8_t sendbuff[160] = {0};
  19. uint8_t len = 0;
  20. if(g_runData.bUpdate!=0) return;
  21. if(sys_net.net_hdl && downlink_config.config_flag == CONFIG_WRITE){
  22. _tick++;
  23. g_runData.timeSendStatus = 1;
  24. printf("netsend hour start %d \r\n",TickCounter);
  25. if(!g_data4G.bconnect4G) { // 判断4G模块 mqtt是否连接
  26. g_data4G.errorTime++;
  27. if(g_data4G.errorTime>=60){ // mqtt 一个小时没有连接上,则芯片复位
  28. NVIC_SystemReset();//复位
  29. }
  30. }
  31. else g_data4G.errorTime = 0;
  32. g_runData.bsendOilData++;
  33. g_runData.bAutoReadOilData++;
  34. g_runData.bsendGatewaySttus++;
  35. g_runData.bsendGatewayVersion++;
  36. if(g_runData.loraConnectTime>=1) g_runData.loraConnectTime++;
  37. }
  38. // uplink_tax_statusmcmd_0x2002(sendbuff,&len,DEVICE_OILL,0);
  39. // tax_net_send(sendbuff,len,FIRST_TYPE_STATUS,COLL_UP_STATUS_CMD2002);
  40. // if(_tick>=3){
  41. // memset(sendbuff,0,sizeof(sendbuff));
  42. // uplink_tax_statusmcmd_0x2001(sendbuff,&len,DEVICE_OILL,0);
  43. // tax_net_send(sendbuff,len,0x02,0x2001);
  44. // _tick = 0;
  45. // }
  46. }
  47. void nettimer_init(void)
  48. {
  49. OS_ERR err;
  50. OSTmrCreate(&netsend_timer, "netsend_tmr", NETSEND_MSG_PERIOD, NETSEND_MSG_PERIOD, OS_OPT_TMR_PERIODIC, netsend_msg_timer, NULL, &err);
  51. OSTmrStart(&netsend_timer, &err);
  52. // OSTmrCreate(&netsend_timer, "netsend_tmr", NETSEND_MSG_PERIOD, NETSEND_MSG_PERIOD, OS_OPT_TMR_PERIODIC, netsend_msg_timer, NULL, &err);
  53. // OSTmrStart(&netsend_timer, &err);
  54. }