// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "PlatformFactory.hpp" // applications #include #include #include // services #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main() { #if SYSTEM_VIEW_ENABLED SEGGER_SYSVIEW_Conf(); SEGGER_SYSVIEW_DisableEvents(SYSVIEW_EVTMASK_ISR_ENTER); SEGGER_SYSVIEW_DisableEvents(SYSVIEW_EVTMASK_ISR_EXIT); SEGGER_SYSVIEW_DisableEvents(SYSVIEW_EVTMASK_ISR_TO_SCHEDULER); SEGGER_SYSVIEW_WaitForConnection(); SEGGER_SYSVIEW_Start(); #endif auto platformFactory = bellhybrid::PlatformFactory(); auto platform = platformFactory.makePlatform(); if (!sys::SystemWatchdog::getInstance().init()) { LOG_ERROR("System watchdog failed to initialize"); // wait for the hardware watchdog (initialized in reset ISR) to reset the system while (1) ; } std::vector> systemServices; systemServices.emplace_back(sys::CreatorFor()); #if ENABLE_FILEINDEXER_SERVICE systemServices.emplace_back(sys::CreatorFor()); #endif systemServices.emplace_back(sys::CreatorFor()); systemServices.emplace_back(sys::CreatorFor()); systemServices.emplace_back(sys::CreatorFor()); systemServices.emplace_back(sys::CreatorFor()); systemServices.emplace_back(sys::CreatorFor()); systemServices.emplace_back(sys::CreatorFor()); systemServices.emplace_back(sys::CreatorFor()); systemServices.emplace_back(sys::CreatorFor()); auto sysmgr = std::make_shared(std::move(systemServices)); sysmgr->StartSystem( [&platform]() { try { platform->init(); } catch (const std::runtime_error &e) { LOG_FATAL("%s", e.what()); abort(); } Log::Logger::get().init(); /// force initialization of PhonenumberUtil because of its stack usage /// otherwise we would end up with an init race and PhonenumberUtil could /// be initiated in a task with stack not big enough to handle it i18n::phonenumbers::PhoneNumberUtil::GetInstance(); return true; }, [sysmgr]() { // vector with launchers to applications std::vector> applications; applications.push_back( app::CreateLauncher(app::applicationBellName, app::Closeable::False)); applications.push_back(app::CreateLauncher(app::applicationBellSettingsName)); applications.push_back(app::CreateLauncher(app::applicationBellAlarmName)); // start application manager return sysmgr->RunSystemService( std::make_shared( app::manager::ApplicationManager::ServiceName, std::move(applications), app::applicationBellName), sysmgr.get()); }); LOG_PRINTF("Launching BellHybrid \n"); LOG_PRINTF("commit: %s tag: %s branch: %s\n", GIT_REV, GIT_TAG, GIT_BRANCH); cpp_freertos::Thread::StartScheduler(); return 0; }