main.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. *
  3. * Copyright (c) 2020 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 <lib/shell/Engine.h>
  18. #include <lib/core/CHIPCore.h>
  19. #include <lib/support/Base64.h>
  20. #include <lib/support/CHIPArgParser.hpp>
  21. #include <lib/support/CodeUtils.h>
  22. #include <lib/support/logging/CHIPLogging.h>
  23. #include <ChipShellCollection.h>
  24. #include <lib/support/CHIPMem.h>
  25. #include <platform/CHIPDeviceLayer.h>
  26. using namespace chip;
  27. using namespace chip::Shell;
  28. int main()
  29. {
  30. chip::Platform::MemoryInit();
  31. chip::DeviceLayer::PlatformMgr().InitChipStack();
  32. chip::DeviceLayer::PlatformMgr().StartEventLoopTask();
  33. #if CHIP_DEVICE_CONFIG_ENABLE_WPA
  34. chip::DeviceLayer::ConnectivityManagerImpl().StartWiFiManagement();
  35. #endif
  36. const int rc = Engine::Root().Init();
  37. if (rc != 0)
  38. {
  39. ChipLogError(Shell, "Streamer initialization failed: %d", rc);
  40. return rc;
  41. }
  42. cmd_misc_init();
  43. cmd_otcli_init();
  44. #if CHIP_SHELL_ENABLE_CMD_SERVER
  45. cmd_app_server_init();
  46. #endif
  47. Engine::Root().RunMainLoop();
  48. return 0;
  49. }