atdev_utils.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**************************************************************************//**
  2. *
  3. * @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2022-9-19 Wayne First version
  10. *
  11. ******************************************************************************/
  12. #include <rtthread.h>
  13. #if defined(PKG_USING_AT_DEVICE)
  14. #include <at_device.h>
  15. static void at_wifi_set(int argc, char **argv)
  16. {
  17. struct at_device_ssid_pwd sATDConf;
  18. struct at_device *at_dev = RT_NULL;
  19. /* If the number of arguments less than 2 */
  20. if (argc != 3)
  21. {
  22. rt_kprintf("\n");
  23. rt_kprintf("at_wifi_set <ssid> <password>\n");
  24. return ;
  25. }
  26. sATDConf.ssid = argv[1]; //ssid
  27. sATDConf.password = argv[2]; //password
  28. if ((at_dev = at_device_get_first_initialized()) != RT_NULL)
  29. at_device_control(at_dev, AT_DEVICE_CTRL_SET_WIFI_INFO, &sATDConf);
  30. else
  31. {
  32. rt_kprintf("Can't find any initialized AT device.\n");
  33. }
  34. }
  35. #ifdef FINSH_USING_MSH
  36. MSH_CMD_EXPORT(at_wifi_set, AT device wifi set ssid / password function);
  37. #endif
  38. #endif /* #if defined(PKG_USING_AT_DEVICE) */