1 /* 2 * Copyright 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 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "grpcpp/channel.h" 20 #include "packet_streamer.pb.h" 21 22 namespace netsim::packet { 23 /* 24 25 // Example: 26 auto channel = PacketStreamerClientHelper.CreateChannel(); 27 std::unique_ptr<PacketStreamer::Stub> stub = PacketStreamer::NewStub(channel); 28 29 ::grpc::ClientContext context; 30 // set deadline, add metadata to context 31 32 PacketsRequest initial_request; 33 Stream bt_stream = stub.StreamPackets(&context); 34 initial_request.mutable_initial_info().set_name("Pixel_XL_3"); 35 initial_request.mutable_initial_info().mutable_chip().set_kind(ChipKind::BLUETOOTH); 36 bt_stream.write(initial_request); 37 38 Stream wifi_stream = stub.StreamPackets(&context); 39 initial_request.mutable_initial_info().set_name("Pixel_XL_3"); 40 initial_request.mutable_initial_info().mutable_chip().set_kind(ChipKind::WIFI); 41 wifi_stream.write(initial_request); 42 */ 43 using Stream = std::unique_ptr< 44 ::grpc::ClientReaderWriter<packet::PacketRequest, packet::PacketResponse>>; 45 46 // Configure the endpoint for a server other than the local netsimd server. 47 void SetPacketStreamEndpoint(const std::string &endpoint); 48 49 std::shared_ptr<grpc::Channel> CreateChannel( 50 std::string rootcanal_default_commands_file = "", 51 std::string rootcanal_controller_properties_file = ""); 52 53 } // namespace netsim::packet 54