gateway_collect.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "gateway_collect.h"
  2. #include "../../User/includes.h"
  3. #include "../network_mgr/net_ctrl.h"
  4. #include "../dev_mgr/taxctrl/tax_ctrl.h"
  5. #include "../network/uplink.h"
  6. #include "../storage/AT24C128Opt.h"
  7. #include "../network/downlink.h"
  8. void * lora_queue_mem_calloc_must(void);
  9. int lora_queue_mem_free(void * p_msg);
  10. void lora_queue_insert(char *p_msg, uint32_t msg_len);
  11. static uint16_t _crc_get_gw(uint8_t *data, uint8_t size)
  12. {
  13. uint8_t i, crc = 0;
  14. for(i = 0;i < size;i++){
  15. crc ^=data[i];
  16. }
  17. return crc;
  18. }
  19. static uint16_t _crc_get1(uint8_t *data, uint8_t size)
  20. {
  21. uint8_t i, crc = 0;
  22. for(i = 0;i < size;i++){
  23. crc ^=data[i];
  24. }
  25. return crc;
  26. }
  27. /*-----------------------------------
  28. * 向服务器发送网关的信息
  29. * ----------------------------------*/
  30. void gateway_net_send_gatewayMsg(void)
  31. {
  32. uint8_t sendBuff[160];
  33. uint8_t sendLen = 0;
  34. static uint8_t bfirstPowerup = 0;
  35. static uint8_t timer = 0;
  36. if(bfirstPowerup==0){
  37. g_runData.bsendGatewaySttus = 1;
  38. g_runData.bsendGatewayVersion = 3;
  39. bfirstPowerup = 1;
  40. timer = 3;
  41. }
  42. if(g_runData.bsendGatewaySttus>=1){
  43. uplink_tax_statusmcmd_0x2002(sendBuff,&sendLen,DEVICE_OILL,0);
  44. tax_net_send(sendBuff,sendLen,FIRST_TYPE_STATUS,COLL_UP_STATUS_CMD2002);
  45. g_runData.bsendGatewaySttus = 0;
  46. }
  47. else if(g_runData.bsendGatewayVersion >= timer) {
  48. uplink_tax_statusmcmd_0x2001(sendBuff,&sendLen,DEVICE_OILL,0);
  49. tax_net_send(sendBuff,sendLen,FIRST_TYPE_STATUS,COLL_UP_STATUS_CMD2001);
  50. if(timer ==3) timer = 10;
  51. else if(timer == 10) timer = 60;
  52. else timer = 60;
  53. g_runData.bsendGatewayVersion = 0;
  54. printf("send gateway msg to server\r\n");
  55. }
  56. return;
  57. }