at_init_air720.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * File : at_sample_air720.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2019-12-07 liang.shao first version
  23. */
  24. #include <at_device_air720.h>
  25. #include "sys_config.h"
  26. #include <easyflash.h>
  27. #define LOG_TAG "at.reg"
  28. #include <at_log.h>
  29. #define AIR720_SAMPLE_DEIVCE_NAME "air720"
  30. #define AT_DEVICE_CTRL_REBOOT 0x0DL
  31. extern rt_uint8_t export_logdata_flag;
  32. extern int w5500Start(void);
  33. static struct at_device_air720 sim0 =
  34. {
  35. AIR720_SAMPLE_DEIVCE_NAME,
  36. AIR720_SAMPLE_CLIENT_NAME,
  37. AIR720_SAMPLE_POWER_PIN,
  38. AIR720_SAMPLE_STATUS_PIN,
  39. AIR720_SAMPLE_RECV_BUFF_LEN,
  40. };
  41. //static int air720_device_register(void)
  42. int air720_device_register(void)
  43. {
  44. struct at_device_air720 *air720 = &sim0;
  45. extern Sector qxz;
  46. if(ef_get_env_blob("upload_mode_swtich_flag", &qxz.Param.upload_mode_swtich_flag, sizeof(qxz.Param.upload_mode_swtich_flag) , NULL) )
  47. //如果设置为有线网络连接+device_sn不是初始值18054384,则不初始化
  48. {
  49. if((qxz.Param.upload_mode_swtich_flag) && (rt_strcmp(qxz.Param.device_sn, "18054384" ) != 0))
  50. {
  51. LOG_W("qxz.Param.device_sn != 18054384");
  52. //w5500Start();
  53. goto end;
  54. }
  55. else if(qxz.Param.upload_mode_swtich_flag)
  56. {
  57. LOG_W("Use W5500 , jump Air720");
  58. //w5500Start();
  59. goto end;
  60. }
  61. }
  62. if(ef_get_env_blob("export_logdata_flag", &export_logdata_flag, sizeof(export_logdata_flag) , NULL))
  63. {
  64. if(export_logdata_flag == 1)
  65. {
  66. LOG_W("detect logdata export flag. jump over 4G init !");
  67. goto end;
  68. }//如果当前需要导出数据 则不初始化联网
  69. }
  70. //2023.6.9 新增延时3秒 为参数校验争取时间
  71. rt_thread_mdelay(3000);
  72. return at_device_register(&(air720->device),
  73. air720->device_name,
  74. air720->client_name,
  75. AT_DEVICE_CLASS_AIR720,
  76. (void *) air720);
  77. end:
  78. return RT_EOK;
  79. }
  80. INIT_APP_EXPORT(air720_device_register);
  81. //INIT_COMPONENT_EXPORT(air720_device_register);
  82. //MSH_CMD_EXPORT(air720_device_register, air720_device_register);
  83. //MSH_CMD_EXPORT_ALIAS(air720_reboot, reboot_720, reboot_720 to manual);
  84. //int air720_reboot(void)
  85. //{
  86. // struct at_device_air720 *air720 = &sim0;
  87. // air720->device.is_init = RT_FALSE;//可以启动初始化线程
  88. // return at_device_control(&(air720->device), AT_DEVICE_CTRL_REBOOT, RT_NULL);
  89. //}