main.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. *
  3. * Copyright (c) 2021 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdarg.h>
  21. #include <stdbool.h>
  22. #include <stdint.h>
  23. #include <FreeRTOS.h>
  24. #include <task.h>
  25. #include "KeyValueStorageTest.h"
  26. #include <platform/KeyValueStoreManager.h>
  27. #define APP_NAME "KVS-Test"
  28. #define APP_TASK_STACK_SIZE (3 * 1024)
  29. #define LOG_MODULE_ID 1
  30. namespace {
  31. StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)];
  32. StaticTask_t appTaskStruct;
  33. } // namespace
  34. void TestTask(void * pvParameter)
  35. {
  36. while (true)
  37. {
  38. qvCHIP_Printf(LOG_MODULE_ID, "Running Tests:");
  39. chip::RunKvsTest();
  40. vTaskDelay(60000); // Run every minute
  41. }
  42. }
  43. void Application_Init(void)
  44. {
  45. /* Launch application task */
  46. qvCHIP_Printf(LOG_MODULE_ID, "============================");
  47. qvCHIP_Printf(LOG_MODULE_ID, "Qorvo " APP_NAME " Launching");
  48. qvCHIP_Printf(LOG_MODULE_ID, "============================");
  49. // Run tests
  50. xTaskCreateStatic(TestTask, APP_NAME, 2048, NULL, 1, appStack, &appTaskStruct);
  51. }
  52. int main(void)
  53. {
  54. int result;
  55. /* Initialize Qorvo stack */
  56. result = qvCHIP_init(Application_Init);
  57. if (result < 0)
  58. {
  59. goto exit;
  60. }
  61. qvCHIP_Printf(LOG_MODULE_ID, "Starting FreeRTOS scheduler");
  62. vTaskStartScheduler();
  63. // Should never get here.
  64. qvCHIP_Printf(LOG_MODULE_ID, "vTaskStartScheduler() failed");
  65. exit:
  66. return 0;
  67. }