Skip to content

Commit

Permalink
Add DeviceDiceSDPInterface.send()
Browse files Browse the repository at this point in the history
  • Loading branch information
sktometometo committed Nov 29, 2023
1 parent 6eb19e9 commit 2f05f09
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion python/esp_now_ros/smart_device_protocol_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down

0 comments on commit 2f05f09

Please sign in to comment.