main_ns.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. *
  3. * Copyright (c) 2022 Project CHIP Authors
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <lib/shell/Engine.h>
  20. #include <lib/support/logging/CHIPLogging.h>
  21. #include <ChipShellCollection.h>
  22. #include "cmsis_os2.h"
  23. #include "openiotsdk_platform.h"
  24. using namespace ::chip;
  25. using namespace ::chip::Shell;
  26. int main()
  27. {
  28. if (openiotsdk_platform_init())
  29. {
  30. ChipLogError(Shell, "Open IoT SDK platform initialization failed");
  31. return EXIT_FAILURE;
  32. }
  33. ChipLogProgress(Shell, "Open IoT SDK shell example application start");
  34. if (openiotsdk_network_init(true))
  35. {
  36. ChipLogError(Shell, "Network initialization failed");
  37. return EXIT_FAILURE;
  38. }
  39. if (openiotsdk_chip_init())
  40. {
  41. ChipLogError(Shell, "Open IoT SDK CHIP stack initialization failed");
  42. return EXIT_FAILURE;
  43. }
  44. // Initialize the default streamer that was linked.
  45. int ret = Engine::Root().Init();
  46. if (ret)
  47. {
  48. ChipLogError(Shell, "Streamer initialization failed [%d]", ret);
  49. return EXIT_FAILURE;
  50. }
  51. cmd_misc_init();
  52. ChipLogProgress(Shell, "Open IoT SDK shell example application run");
  53. Engine::Root().RunMainLoop();
  54. return EXIT_SUCCESS;
  55. }