blob: 1fe8eb1b1c600e7e64ce5aa0ca72ecfaddd52537 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
"""Blueberry Test Client.
Simple gRPC client to test the Blueberry Mock server.
"""
from absl import app
from absl import flags
import grpc
# Internal import
from blueberry.grpc.proto import blueberry_device_controller_pb2
from blueberry.grpc.proto import blueberry_device_controller_pb2_grpc
FLAGS = flags.FLAGS
flags.DEFINE_string('server', 'dns:///[::1]:10000', 'server address')
def _UpdateDiscoveryMode(stub, request):
try:
print('try SetDiscoverableMode')
response = stub.SetDiscoverableMode(request)
print('complete response')
print(response)
return 0
except grpc.RpcError as rpc_error:
print(rpc_error)
return -1
def main(unused_argv):
channel_creds = loas2.loas2_channel_credentials()
with grpc.secure_channel(FLAGS.server, channel_creds) as channel:
grpc.channel_ready_future(channel).result()
stub = blueberry_device_controller_pb2_grpc.BlueberryDeviceControllerStub(
channel)
print('request grpc')
request = blueberry_device_controller_pb2.DiscoverableMode(
mode=True)
print('Call _UpdateDiscoveryMode')
return _UpdateDiscoveryMode(stub, request)
if __name__ == '__main__':
app.run(main)
|