• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef TEST_SIMULATION_RPC_TEST
20 #define TEST_SIMULATION_RPC_TEST
21 
22 #include <stdint.h>
23 
24 #include "chre/util/pigweed/rpc_client.h"
25 #include "chre/util/pigweed/rpc_server.h"
26 #include "chre/util/singleton.h"
27 #include "rpc_test.pb.h"
28 #include "rpc_test.rpc.pb.h"
29 
30 namespace chre {
31 
32 constexpr uint64_t kPwRcpServerAppId = 0x0123456789000001;
33 constexpr uint64_t kPwRcpClientAppId = 0x0123456789000002;
34 
35 class RpcTestService final
36     : public chre::rpc::pw_rpc::nanopb::RpcTestService::Service<
37           RpcTestService> {
38  public:
39   // Increment RPC unary service definition.
40   // See generated IncrementService::Service for more details.
41   pw::Status Increment(const chre_rpc_NumberMessage &request,
42                        chre_rpc_NumberMessage &response);
43 };
44 
45 struct Env {
46   RpcTestService mRpcTestService;
47   chre::RpcServer mServer;
48   chre::RpcClient mClient{kPwRcpServerAppId};
49   pw::rpc::NanopbUnaryReceiver<chre_rpc_NumberMessage> mIncrementCall;
50   uint32_t mNumber;
51 };
52 
53 typedef Singleton<Env> EnvSingleton;
54 
55 }  // namespace chre
56 
57 #endif  // TEST_SIMULATION_RPC_TEST