Skip to content

Commit ad6324f

Browse files
committed
tools: serial_throughput: set time before test
Set the remote time before running the throughput test to avoid the remote regenerating keys on every packet sent and received. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 73090b7 commit ad6324f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/infuse_iot/tools/serial_throughput.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
import random
99
import sys
1010
import time
11+
from datetime import datetime
1112

1213
from infuse_iot.commands import InfuseCommand
1314
from infuse_iot.common import InfuseID, InfuseType
15+
from infuse_iot.definitions.rpc import time_set
1416
from infuse_iot.epacket.packet import Auth, PacketOutput
17+
from infuse_iot.rpc_client import RpcClient
1518
from infuse_iot.socket_comms import (
1619
ClientNotificationEpacketReceived,
1720
GatewayRequestEpacketSend,
1821
LocalClient,
1922
default_multicast_address,
2023
)
24+
from infuse_iot.time import InfuseTime
2125

2226

2327
class SubCommand(InfuseCommand):
@@ -38,6 +42,11 @@ def __init__(self, args):
3842
self._client = LocalClient(default_multicast_address(), 1.0)
3943
self._iterations = args.iterations
4044

45+
def run_time_set(self):
46+
rpc_client = RpcClient(self._client, 128, InfuseID.GATEWAY)
47+
params = time_set.request(InfuseTime.epoch_time_from_unix(datetime.now().timestamp()))
48+
rpc_client.run_standard_cmd(time_set.COMMAND_ID, Auth.DEVICE, bytes(params), time_set.response.from_buffer_copy)
49+
4150
def run_send_test(self, num, size, queue_size):
4251
assert size >= 4
4352
self._client.set_rx_timeout(0.2)
@@ -85,6 +94,9 @@ def run(self):
8594
if not self._client.comms_check():
8695
sys.exit("No communications gateway detected (infuse gateway/bt_native)")
8796

97+
# Set remote time to avoid key regeneration on every packet
98+
self.run_time_set()
99+
88100
# No queuing
89101
print(f"Averaged across {self._iterations} packets with no queuing:")
90102
self.run_send_test(self._iterations, 4, 1)

0 commit comments

Comments
 (0)