1import time 2from uwb import uwb_ranging_params 3from typing import List 4from mobly.controllers import android_device 5from mobly.controllers.android_device_lib import jsonrpc_client_base 6from mobly.snippet import errors 7 8CALLBACK_WAIT_TIME_SEC = 3 9STOP_CALLBACK_WAIT_TIME_SEC = 6 10 11 12class GenericRangingDecorator(): 13 14 def __init__(self, ad: android_device.AndroidDevice): 15 """Initialize the ranging device. 16 17 Args: 18 ad: android device object 19 """ 20 self.ad = ad 21 self._callback_keys = {} 22 self._event_handlers = {} 23 self.log = self.ad.log 24 25 def start_uwb_ranging(self, params: uwb_ranging_params.UwbRangingParams): 26 callback_key = "fira_session_%s" % 1 27 handler = self.ad.ranging.startUwbRanging(callback_key, params.to_dict()) 28 29 def stop_uwb_ranging(self, params: uwb_ranging_params.UwbRangingParams): 30 callback_key = "fira_session_%s" % 1 31 handler = self.ad.ranging.stopUwbRanging(callback_key) 32