From 2f05f09f6b087fb64bd7cbaf6823d50bb27b3415 Mon Sep 17 00:00:00 2001 From: Koki Shinjo Date: Wed, 29 Nov 2023 13:55:57 +0900 Subject: [PATCH] Add DeviceDiceSDPInterface.send() --- .../esp_now_ros/smart_device_protocol_interface.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/esp_now_ros/smart_device_protocol_interface.py b/python/esp_now_ros/smart_device_protocol_interface.py index 44fee210..3e96ff1a 100644 --- a/python/esp_now_ros/smart_device_protocol_interface.py +++ b/python/esp_now_ros/smart_device_protocol_interface.py @@ -103,7 +103,18 @@ def _remove_timeout_device(self): @property def device_interfaces(self): return self._device_interfaces - + + def send(self, target: Union[Tuple, str], frame: Union[DataFrame, MetaFrame], num_trial=1): + if isinstance(target, str): + for src_address, device_interface in self._device_interfaces.items(): + if device_interface["device_name"] == target: + target_address = src_address + break + else: + raise ValueError(f"Unknown device name: {target}") + else: + target_address = target + super().send(target_address, frame, num_trial) class DeviceDictSDPInterfaceWithInterfaceCallback(DeviceDictSDPInterface): def __init__(