• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021-2023 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of 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,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
16"""Client and server classes corresponding to protobuf-defined services."""
17import grpc
18
19from . import emulated_bluetooth_packets_pb2 as emulated__bluetooth__packets__pb2
20from . import emulated_bluetooth_pb2 as emulated__bluetooth__pb2
21
22
23class EmulatedBluetoothServiceStub(object):
24    """An Emulated Bluetooth Service exposes the emulated bluetooth chip from the
25    android emulator. It allows you to register emulated bluetooth devices and
26    control the packets that are exchanged between the device and the world.
27
28    This service enables you to establish a "virtual network" of emulated
29    bluetooth devices that can interact with each other.
30
31    Note: This is not yet finalized, it is likely that these definitions will
32    evolve.
33    """
34
35    def __init__(self, channel):
36        """Constructor.
37
38        Args:
39            channel: A grpc.Channel.
40        """
41        self.registerClassicPhy = channel.stream_stream(
42            '/android.emulation.bluetooth.EmulatedBluetoothService/registerClassicPhy',
43            request_serializer=emulated__bluetooth__pb2.RawData.SerializeToString,
44            response_deserializer=emulated__bluetooth__pb2.RawData.FromString,
45        )
46        self.registerBlePhy = channel.stream_stream(
47            '/android.emulation.bluetooth.EmulatedBluetoothService/registerBlePhy',
48            request_serializer=emulated__bluetooth__pb2.RawData.SerializeToString,
49            response_deserializer=emulated__bluetooth__pb2.RawData.FromString,
50        )
51        self.registerHCIDevice = channel.stream_stream(
52            '/android.emulation.bluetooth.EmulatedBluetoothService/registerHCIDevice',
53            request_serializer=emulated__bluetooth__packets__pb2.HCIPacket.SerializeToString,
54            response_deserializer=emulated__bluetooth__packets__pb2.HCIPacket.FromString,
55        )
56
57
58class EmulatedBluetoothServiceServicer(object):
59    """An Emulated Bluetooth Service exposes the emulated bluetooth chip from the
60    android emulator. It allows you to register emulated bluetooth devices and
61    control the packets that are exchanged between the device and the world.
62
63    This service enables you to establish a "virtual network" of emulated
64    bluetooth devices that can interact with each other.
65
66    Note: This is not yet finalized, it is likely that these definitions will
67    evolve.
68    """
69
70    def registerClassicPhy(self, request_iterator, context):
71        """Connect device to link layer. This will establish a direct connection
72        to the emulated bluetooth chip and configure the following:
73
74        - Each connection creates a new device and attaches it to the link layer
75        - Link Layer packets are transmitted directly to the phy
76
77        This should be used for classic connections.
78
79        This is used to directly connect various android emulators together.
80        For example a wear device can connect to an android emulator through
81        this.
82        """
83        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
84        context.set_details('Method not implemented!')
85        raise NotImplementedError('Method not implemented!')
86
87    def registerBlePhy(self, request_iterator, context):
88        """Connect device to link layer. This will establish a direct connection
89        to root canal and execute the following:
90
91        - Each connection creates a new device and attaches it to the link layer
92        - Link Layer packets are transmitted directly to the phy
93
94        This should be used for BLE connections.
95
96        This is used to directly connect various android emulators together.
97        For example a wear device can connect to an android emulator through
98        this.
99        """
100        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
101        context.set_details('Method not implemented!')
102        raise NotImplementedError('Method not implemented!')
103
104    def registerHCIDevice(self, request_iterator, context):
105        """Connect the device to the emulated bluetooth chip. The device will
106        participate in the network. You can configure the chip to scan, advertise
107        and setup connections with other devices that are connected to the
108        network.
109
110        This is usually used when you have a need for an emulated bluetooth chip
111        and have a bluetooth stack that can interpret and handle the packets
112        correctly.
113
114        For example the apache nimble stack can use this endpoint as the
115        transport layer.
116        """
117        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
118        context.set_details('Method not implemented!')
119        raise NotImplementedError('Method not implemented!')
120
121
122def add_EmulatedBluetoothServiceServicer_to_server(servicer, server):
123    rpc_method_handlers = {
124        'registerClassicPhy': grpc.stream_stream_rpc_method_handler(
125            servicer.registerClassicPhy,
126            request_deserializer=emulated__bluetooth__pb2.RawData.FromString,
127            response_serializer=emulated__bluetooth__pb2.RawData.SerializeToString,
128        ),
129        'registerBlePhy': grpc.stream_stream_rpc_method_handler(
130            servicer.registerBlePhy,
131            request_deserializer=emulated__bluetooth__pb2.RawData.FromString,
132            response_serializer=emulated__bluetooth__pb2.RawData.SerializeToString,
133        ),
134        'registerHCIDevice': grpc.stream_stream_rpc_method_handler(
135            servicer.registerHCIDevice,
136            request_deserializer=emulated__bluetooth__packets__pb2.HCIPacket.FromString,
137            response_serializer=emulated__bluetooth__packets__pb2.HCIPacket.SerializeToString,
138        ),
139    }
140    generic_handler = grpc.method_handlers_generic_handler(
141        'android.emulation.bluetooth.EmulatedBluetoothService', rpc_method_handlers
142    )
143    server.add_generic_rpc_handlers((generic_handler,))
144
145
146# This class is part of an EXPERIMENTAL API.
147class EmulatedBluetoothService(object):
148    """An Emulated Bluetooth Service exposes the emulated bluetooth chip from the
149    android emulator. It allows you to register emulated bluetooth devices and
150    control the packets that are exchanged between the device and the world.
151
152    This service enables you to establish a "virtual network" of emulated
153    bluetooth devices that can interact with each other.
154
155    Note: This is not yet finalized, it is likely that these definitions will
156    evolve.
157    """
158
159    @staticmethod
160    def registerClassicPhy(
161        request_iterator,
162        target,
163        options=(),
164        channel_credentials=None,
165        call_credentials=None,
166        insecure=False,
167        compression=None,
168        wait_for_ready=None,
169        timeout=None,
170        metadata=None,
171    ):
172        return grpc.experimental.stream_stream(
173            request_iterator,
174            target,
175            '/android.emulation.bluetooth.EmulatedBluetoothService/registerClassicPhy',
176            emulated__bluetooth__pb2.RawData.SerializeToString,
177            emulated__bluetooth__pb2.RawData.FromString,
178            options,
179            channel_credentials,
180            insecure,
181            call_credentials,
182            compression,
183            wait_for_ready,
184            timeout,
185            metadata,
186        )
187
188    @staticmethod
189    def registerBlePhy(
190        request_iterator,
191        target,
192        options=(),
193        channel_credentials=None,
194        call_credentials=None,
195        insecure=False,
196        compression=None,
197        wait_for_ready=None,
198        timeout=None,
199        metadata=None,
200    ):
201        return grpc.experimental.stream_stream(
202            request_iterator,
203            target,
204            '/android.emulation.bluetooth.EmulatedBluetoothService/registerBlePhy',
205            emulated__bluetooth__pb2.RawData.SerializeToString,
206            emulated__bluetooth__pb2.RawData.FromString,
207            options,
208            channel_credentials,
209            insecure,
210            call_credentials,
211            compression,
212            wait_for_ready,
213            timeout,
214            metadata,
215        )
216
217    @staticmethod
218    def registerHCIDevice(
219        request_iterator,
220        target,
221        options=(),
222        channel_credentials=None,
223        call_credentials=None,
224        insecure=False,
225        compression=None,
226        wait_for_ready=None,
227        timeout=None,
228        metadata=None,
229    ):
230        return grpc.experimental.stream_stream(
231            request_iterator,
232            target,
233            '/android.emulation.bluetooth.EmulatedBluetoothService/registerHCIDevice',
234            emulated__bluetooth__packets__pb2.HCIPacket.SerializeToString,
235            emulated__bluetooth__packets__pb2.HCIPacket.FromString,
236            options,
237            channel_credentials,
238            insecure,
239            call_credentials,
240            compression,
241            wait_for_ready,
242            timeout,
243            metadata,
244        )
245