From f587b45b38f1e0e54c8cce4e46603fc30ffd587d Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Sun, 7 Sep 2025 11:42:32 -0400 Subject: [PATCH] livoxProto1: Connecting to bcast-advertised device works :) We tested it. It's important to note that between test runs, we need to take into account the fact that the Avia stops sending bcast adverts when it's been handshaken. So the retry-delay-ms may be longer due to the fact that the Avia may not be sending adverts for a good portion of that retry-delay-ms time. --- bodies/dev/avia0.daps | 2 +- commonLibs/livoxProto1/device.cpp | 8 ++++++++ senseApis/livoxGen1/livoxGen1.cpp | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bodies/dev/avia0.daps b/bodies/dev/avia0.daps index 44c515d..e1778f7 100644 --- a/bodies/dev/avia0.daps +++ b/bodies/dev/avia0.daps @@ -1,4 +1,4 @@ +edev|avia0| structural-implexor|livoxGen1()|livoxProto1( - handshake-timeout-ms=1000|retry-delay-ms=1000) + handshake-timeout-ms=1000) |3JEDK380010Z39 diff --git a/commonLibs/livoxProto1/device.cpp b/commonLibs/livoxProto1/device.cpp index 11ddaa9..541a7c2 100644 --- a/commonLibs/livoxProto1/device.cpp +++ b/commonLibs/livoxProto1/device.cpp @@ -129,6 +129,14 @@ void Device::connect() return; } + /** FIXME: + * This won't work unless we return control to the ComponentThread's run() + * loop during the retry-delay time so that the ComponentThread can actually + * run the BroadcastListener's recv() calls and actually receive the + * device's broadcast messages. + * Think about ways to perhaps make all of this asynchronous. The main issue + * is that this whole sequence is synchronous. + */ // Wait retry delay, then try known device again std::this_thread::sleep_for(std::chrono::milliseconds(retryDelayMs)); if (connectToKnownDevice()) { diff --git a/senseApis/livoxGen1/livoxGen1.cpp b/senseApis/livoxGen1/livoxGen1.cpp index 2ed6ddd..7e4ae09 100644 --- a/senseApis/livoxGen1/livoxGen1.cpp +++ b/senseApis/livoxGen1/livoxGen1.cpp @@ -153,7 +153,7 @@ extern "C" int livoxGen1_attachDeviceReq( // Parse integer parameters from provider params with defaults int handshakeTimeoutMs = 250; // Default: 50ms - int retryDelayMs = 500; // Default: 500ms + int retryDelayMs = 2000; // Default: 500ms uint8_t smoSubnetNbits = 24; // Default: /24 subnet uint16_t dataPort = 56000; // Default data port uint16_t cmdPort = 56001; // Default command port