1"""Blueberry gRPC Mock Service. 2 3This is simple mock service that is used to verify the implementation of the 4Blueberry gRPC device controller interface. 5""" 6 7from blueberry.grpc.proto import blueberry_device_controller_pb2 8from blueberry.grpc.proto import blueberry_device_controller_pb2_grpc 9 10 11class BlueberryDeviceControllerServicer( 12 blueberry_device_controller_pb2_grpc.BlueberryDeviceControllerServicer): 13 """A BlueberryTest gRPC server.""" 14 15 def __init__(self, *args, **kwargs): 16 super(BlueberryDeviceControllerServicer, self).__init__(*args, **kwargs) 17 self._error = "testing 123" 18 19 def SetDiscoverableMode(self, request, servicer_context): 20 """Sets the device's discoverable mode. 21 22 Args: 23 request: a blueberry_test_server_pb2.DiscoverableMode object containing 24 the "mode" to set the device to. 25 servicer_context: A grpc.ServicerContext for use during service of the 26 RPC. 27 28 Returns: 29 A blueberry_test_server_pb2.DiscoverableResult 30 """ 31 return blueberry_device_controller_pb2.DiscoverableResult( 32 result=True, 33 error=self._error) 34 35 def PairAndConnectBluetooth(self, request, servicer_context): 36 return blueberry_device_controller_pb2.PairAndConnectBluetoothResult( 37 pairing_time_sec=0.1, connection_time_sec=0.2, error=None) 38