#include #include #include "../module-gui/gui/core/ImageManager.hpp" #include "log/log.hpp" #include "memory/usermem.h" #include "ticks.hpp" //module-applications #include "application-clock/ApplicationClock.hpp" #include "application-call/ApplicationCall.hpp" #include "application-viewer/ApplicationViewer.hpp" #include "application-desktop/ApplicationDesktop.hpp" #include "application-settings/ApplicationSettings.hpp" #include "application-notes/ApplicationNotes.hpp" #include "application-phonebook/ApplicationPhonebook.hpp" #include "application-messages/ApplicationMessages.hpp" #include "application-calllog/ApplicationCallLog.hpp" //module-services #include "service-appmgr/ApplicationManager.hpp" #include "service-evtmgr/EventManager.hpp" #include "service-db/ServiceDB.hpp" #include "service-db/api/DBServiceAPI.hpp" #include "service-cellular/ServiceCellular.hpp" #include "service-cellular/api/CellularServiceAPI.hpp" #include "service-audio/ServiceAudio.hpp" #include "service-audio/api/AudioServiceAPI.hpp" #include "service-bluetooth/ServiceBluetooth.hpp" #include "service-lwip/ServiceLwIP.hpp" //module-bsp #include "bsp/bsp.hpp" #include "bsp/rtc/rtc.hpp" #include "bsp/keyboard/keyboard.hpp" //module-vfs #include "vfs.hpp" //module-sys #include "SystemManager/SystemManager.hpp" class vfs vfs; class BlinkyService : public sys::Service { public: BlinkyService(const std::string &name) : sys::Service(name) { timer_id = CreateTimer(5000, true); //ReloadTimer(timer_id); } ~BlinkyService() { } // DBThreadResponseMessage* threadResponse = reinterpret_cast(ret.second.get()); // if((ret.first == sys::ReturnCodes::Success) && (threadResponse->retCode == true)){ // return std::move(threadResponse->records); // } // else{ // return std::make_unique>(); // } // Invoked upon receiving data message sys::Message_t DataReceivedHandler(sys::DataMessage *msgl,sys::ResponseMessage* resp=nullptr) override { #if 0 // M.P: left here on purpose //auto ret = AudioServiceAPI::PlaybackStart(this,"/home/mateusz/Music/limowreck.mp3"); /* auto ret = AudioServiceAPI::PlaybackStart(this,"sys/audio/limowreck.flac"); AudioServiceAPI::Stop(this); AudioServiceAPI::PlaybackStart(this,"sys/audio/limowreck.flac");*/ //vTaskDelay(3000); //AudioServiceAPI::SetOutputVolume(this,0.6); //auto ret = AudioServiceAPI::RecordingStart(this,"sys/audio/rec1mono.wav"); //vTaskDelay(3000); //ret = AudioServiceAPI::Stop(this); //vTaskDelay(500); //ret = AudioServiceAPI::PlaybackStart(this,"sys/audio/limowreck.flac"); //auto ret = AudioServiceAPI::RoutingStart(this); /* //AudioServiceAPI::RoutingRecordCtrl(this,true); vTaskDelay(1000); //AudioServiceAPI::RoutingSpeakerPhone(this,true); vTaskDelay(2000); AudioServiceAPI::Stop(this);*/ //auto ret = AudioServiceAPI::PlaybackStart(this,"sys/audio/limowreck.flac"); #endif return std::make_shared(); } // Invoked when timer ticked void TickHandler(uint32_t id) override { #if 0 // M.P: left here on purpose LOG_DEBUG("Blinky service tick!"); stopTimer(timer_id); std::shared_ptr msg = std::make_shared(static_cast(MessageType::AudioSetInputGain)); sys::Bus::SendUnicast(msg,GetName(),this); #endif } // Invoked during initialization sys::ReturnCodes InitHandler() override { return sys::ReturnCodes::Success; } sys::ReturnCodes DeinitHandler() override { return sys::ReturnCodes::Success; } sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final{return sys::ReturnCodes::Success;} uint32_t timer_id = 0; }; int main() { bsp::BoardInit(); LOG_PRINTF("Launching PurePhone..\n"); #if 1 auto sysmgr = std::make_shared(5000); sysmgr->StartSystem([sysmgr]()->int{ vfs.Init(); bool ret = false; ret |= sys::SystemManager::CreateService(std::make_shared("EventManager"), sysmgr.get()); ret |= sys::SystemManager::CreateService(std::make_shared(), sysmgr.get()); ret |= sys::SystemManager::CreateService(std::make_shared("Blinky"), sysmgr.get()); #if defined(TARGET_Linux) && not defined(SERIAL_PORT_PATH) // For now disable pernamenlty Service cellular when there is no GSM configured #else ret |= sys::SystemManager::CreateService(std::make_shared(), sysmgr.get()); #endif ret |= sys::SystemManager::CreateService(std::make_shared(), sysmgr.get()); ret |= sys::SystemManager::CreateService(std::make_shared(),sysmgr.get()); ret |= sys::SystemManager::CreateService(std::make_shared(),sysmgr.get()); //vector with launchers to applications std::vector > applications; applications.push_back(std::unique_ptr(new app::ApplicationViewerLauncher())); applications.push_back(std::unique_ptr(new app::ApplicationDesktopLauncher())); applications.push_back(std::unique_ptr(new app::ApplicationCallLauncher())); applications.push_back(std::unique_ptr(new app::ApplicationSettingsLauncher())); applications.push_back(std::unique_ptr(new app::ApplicationNotesLauncher())); applications.push_back(app::CreateLauncher("ApplicationCallLog")); applications.push_back(app::CreateLauncher("ApplicationPhonebook")); applications.push_back(app::CreateLauncher("ApplicationMessages")); //start application manager ret |= sysmgr->CreateService(std::make_shared("ApplicationManager", sysmgr.get(), applications), sysmgr.get()); if (ret) { return 0; } return 0; }); cpp_freertos::Thread::StartScheduler(); #endif return 1; }