Wyatt Hepler | bfb669d | 2020-09-03 13:32:00 -0700 | [diff] [blame] | 1 | // Copyright 2020 The Pigweed Authors |
shaneajg | 02d127a | 2020-08-11 12:54:56 -0400 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | // use this file except in compliance with the License. You may obtain a copy of |
| 5 | // the License at |
| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | // License for the specific language governing permissions and limitations under |
| 13 | // the License. |
| 14 | |
| 15 | #include <array> |
shaneajg | 02d127a | 2020-08-11 12:54:56 -0400 | [diff] [blame] | 16 | #include <string_view> |
| 17 | |
Wyatt Hepler | bad6d27 | 2022-02-16 07:15:07 -0800 | [diff] [blame] | 18 | #include "pw_assert/check.h" |
Alexei Frolov | d3e5cb7 | 2021-01-08 13:08:45 -0800 | [diff] [blame] | 19 | #include "pw_hdlc/encoder.h" |
| 20 | #include "pw_hdlc/rpc_packets.h" |
shaneajg | 02d127a | 2020-08-11 12:54:56 -0400 | [diff] [blame] | 21 | #include "pw_log/log.h" |
| 22 | #include "pw_rpc/echo_service_nanopb.h" |
| 23 | #include "pw_rpc/server.h" |
Jiaming Wang | 35b4ea3 | 2020-10-06 15:23:48 -0700 | [diff] [blame] | 24 | #include "pw_rpc_system_server/rpc_server.h" |
Wyatt Hepler | 6c5df35 | 2022-06-29 00:15:46 +0000 | [diff] [blame] | 25 | #include "pw_span/span.h" |
shaneajg | 02d127a | 2020-08-11 12:54:56 -0400 | [diff] [blame] | 26 | |
Wyatt Hepler | b8db509 | 2020-09-17 10:36:41 -0700 | [diff] [blame] | 27 | namespace hdlc_example { |
| 28 | namespace { |
| 29 | |
Wyatt Hepler | b8db509 | 2020-09-17 10:36:41 -0700 | [diff] [blame] | 30 | pw::rpc::EchoService echo_service; |
| 31 | |
Jiaming Wang | 35b4ea3 | 2020-10-06 15:23:48 -0700 | [diff] [blame] | 32 | void RegisterServices() { |
Wyatt Hepler | f3d00d2 | 2020-12-07 15:54:29 -0800 | [diff] [blame] | 33 | pw::rpc::system_server::Server().RegisterService(echo_service); |
Jiaming Wang | 35b4ea3 | 2020-10-06 15:23:48 -0700 | [diff] [blame] | 34 | } |
Prashanth Swaminathan | dd748d5 | 2020-11-19 13:44:58 -0800 | [diff] [blame] | 35 | |
Wyatt Hepler | b8db509 | 2020-09-17 10:36:41 -0700 | [diff] [blame] | 36 | } // namespace |
| 37 | |
| 38 | void Start() { |
Wyatt Hepler | f3d00d2 | 2020-12-07 15:54:29 -0800 | [diff] [blame] | 39 | pw::rpc::system_server::Init(); |
Alexei Frolov | 6053c31 | 2020-12-09 22:43:55 -0800 | [diff] [blame] | 40 | |
Wyatt Hepler | b8db509 | 2020-09-17 10:36:41 -0700 | [diff] [blame] | 41 | // Set up the server and start processing data. |
| 42 | RegisterServices(); |
| 43 | |
Wyatt Hepler | b8db509 | 2020-09-17 10:36:41 -0700 | [diff] [blame] | 44 | PW_LOG_INFO("Starting pw_rpc server"); |
Wyatt Hepler | bad6d27 | 2022-02-16 07:15:07 -0800 | [diff] [blame] | 45 | PW_CHECK_OK(pw::rpc::system_server::Start()); |
shaneajg | 02d127a | 2020-08-11 12:54:56 -0400 | [diff] [blame] | 46 | } |
| 47 | |
Wyatt Hepler | b8db509 | 2020-09-17 10:36:41 -0700 | [diff] [blame] | 48 | } // namespace hdlc_example |