A12_SOCKET_example.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2020  Jinan Bosai Network Technology Co., LTD
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <unistd.h>
  18. #include <math.h>
  19. #include "ohos_init.h"
  20. #include "cmsis_os2.h"
  21. #include "SOCKET.h"
  22. #define TASK_STACK_SIZE 1024*8
  23. #define TASK_PRIO 25
  24. static void ExampleTask(void)
  25. {
  26. BoardInit();
  27. while (1) {
  28. printf("=======================================\r\n");
  29. printf("*************A12_SOCKET_example***********\r\n");
  30. printf("=======================================\r\n");
  31. RelayStatusSet(ON);
  32. LedRedStatusSet(OFF);
  33. LedGreenStatusSet(OFF);
  34. LedBlueStatusSet(ON);
  35. osDelay(200);
  36. LedRedStatusSet(ON);
  37. LedGreenStatusSet(OFF);
  38. LedBlueStatusSet(OFF);
  39. osDelay(200);
  40. LedRedStatusSet(OFF);
  41. LedGreenStatusSet(ON);
  42. LedBlueStatusSet(OFF);
  43. osDelay(200);
  44. // LedBlueStatusSet(ON);
  45. }
  46. }
  47. /**
  48. * @brief Main Entry of the A22_MQ2 Example
  49. *
  50. */
  51. static void ExampleEntry(void)
  52. {
  53. osThreadAttr_t attr;
  54. attr.name = "ExampleTask";
  55. attr.attr_bits = 0U;
  56. attr.cb_mem = NULL;
  57. attr.cb_size = 0U;
  58. attr.stack_mem = NULL;
  59. attr.stack_size = TASK_STACK_SIZE;
  60. attr.priority = TASK_PRIO;
  61. if (osThreadNew((osThreadFunc_t)ExampleTask, NULL, &attr) == NULL) {
  62. printf("Failed to create ExampleTask!\n");
  63. }
  64. }
  65. APP_FEATURE_INIT(ExampleEntry);