blob: 11d1218c1f22691007953c800acbedd470ec19a3 [file] [log] [blame]
Wyatt Heplerbfb669d2020-09-03 13:32:00 -07001// Copyright 2020 The Pigweed Authors
shaneajg02d127a2020-08-11 12:54:56 -04002//
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>
shaneajg02d127a2020-08-11 12:54:56 -040016#include <string_view>
17
Wyatt Heplerbad6d272022-02-16 07:15:07 -080018#include "pw_assert/check.h"
Alexei Frolovd3e5cb72021-01-08 13:08:45 -080019#include "pw_hdlc/encoder.h"
20#include "pw_hdlc/rpc_packets.h"
shaneajg02d127a2020-08-11 12:54:56 -040021#include "pw_log/log.h"
22#include "pw_rpc/echo_service_nanopb.h"
23#include "pw_rpc/server.h"
Jiaming Wang35b4ea32020-10-06 15:23:48 -070024#include "pw_rpc_system_server/rpc_server.h"
Wyatt Hepler6c5df352022-06-29 00:15:46 +000025#include "pw_span/span.h"
shaneajg02d127a2020-08-11 12:54:56 -040026
Wyatt Heplerb8db5092020-09-17 10:36:41 -070027namespace hdlc_example {
28namespace {
29
Wyatt Heplerb8db5092020-09-17 10:36:41 -070030pw::rpc::EchoService echo_service;
31
Jiaming Wang35b4ea32020-10-06 15:23:48 -070032void RegisterServices() {
Wyatt Heplerf3d00d22020-12-07 15:54:29 -080033 pw::rpc::system_server::Server().RegisterService(echo_service);
Jiaming Wang35b4ea32020-10-06 15:23:48 -070034}
Prashanth Swaminathandd748d52020-11-19 13:44:58 -080035
Wyatt Heplerb8db5092020-09-17 10:36:41 -070036} // namespace
37
38void Start() {
Wyatt Heplerf3d00d22020-12-07 15:54:29 -080039 pw::rpc::system_server::Init();
Alexei Frolov6053c312020-12-09 22:43:55 -080040
Wyatt Heplerb8db5092020-09-17 10:36:41 -070041 // Set up the server and start processing data.
42 RegisterServices();
43
Wyatt Heplerb8db5092020-09-17 10:36:41 -070044 PW_LOG_INFO("Starting pw_rpc server");
Wyatt Heplerbad6d272022-02-16 07:15:07 -080045 PW_CHECK_OK(pw::rpc::system_server::Start());
shaneajg02d127a2020-08-11 12:54:56 -040046}
47
Wyatt Heplerb8db5092020-09-17 10:36:41 -070048} // namespace hdlc_example