| #include "pw_system/init.h" |
| #include "pw_system/rpc_server.h" |
| #include "math_service.h" |
| #include "pw_rpc/echo_service_nanopb.h" |
| #include "pw_log/log.h" |
| #include "pw_thread/sleep.h" |
| #include <chrono> |
| |
| MathService math_service; |
| pw::rpc::EchoService echo_service; |
| |
| namespace pw::system { |
| |
| // This will run once after pw::system::Init() completes. This callback must |
| // return or it will block the work queue. |
| void UserAppInit() { |
| PW_LOG_INFO("Registering custom MathService"); |
| GetRpcServer().RegisterService(math_service); |
| PW_LOG_INFO("Registering EchoService"); |
| GetRpcServer().RegisterService(echo_service); |
| } |
| |
| } // namespace pw::system |
| |
| int main() { |
| pw::system::Init(); |
| |
| PW_LOG_INFO("pw_system initialized, main thread sleeping..."); |
| while (true) { |
| pw::this_thread::sleep_for(std::chrono::seconds(10)); |
| PW_LOG_INFO("Simulated device is still alive"); |
| } |
| return 0; |
| } |