oneshot.c 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-01-25 winner micro
  9. */
  10. #include <rtthread.h>
  11. #include "oneshot.h"
  12. #include "wm_wifi_oneshot.h"
  13. #include "wm_wifi.h"
  14. /* start oneshot */
  15. int wm_oneshot_start(WM_ONESHOT_MODE mode, wm_oneshot_callback callback)
  16. {
  17. tls_wifi_oneshot_callback_register(callback);
  18. if(mode == WM_UDP)
  19. {
  20. tls_wifi_set_oneshot_config_mode(0);
  21. }
  22. else if (mode == WM_APSOCKET)
  23. {
  24. tls_wifi_set_oneshot_config_mode(1);
  25. }
  26. else if(mode == WM_APWEB)
  27. {
  28. tls_wifi_set_oneshot_config_mode(2);
  29. }
  30. else
  31. {
  32. return -1;
  33. }
  34. tls_wifi_set_oneshot_flag(1);
  35. return 0;
  36. }
  37. /* stop oneshot */
  38. int wm_oneshot_stop(void)
  39. {
  40. tls_wifi_oneshot_callback_delete();
  41. tls_wifi_set_oneshot_flag(0);
  42. return 0;
  43. }
  44. /* get status */
  45. int wm_oneshot_get(void)
  46. {
  47. return tls_wifi_get_oneshot_flag();
  48. }