From 4bfcdf37dafa7e1579af008c1dc87720b73d9e63 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Fri, 24 Oct 2025 01:46:08 -0400 Subject: [PATCH] LivoxProto1:enPcloudData: reorder success case here --- commonLibs/livoxProto1/device.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/commonLibs/livoxProto1/device.cpp b/commonLibs/livoxProto1/device.cpp index c3c23bf..d50539f 100644 --- a/commonLibs/livoxProto1/device.cpp +++ b/commonLibs/livoxProto1/device.cpp @@ -1533,19 +1533,24 @@ protected: return; } - // Check if response indicates success - if (response->command.cmd_set == 0x00 && - response->command.cmd_id == 0x04 && - response->ret_code == 0x00) + // Check for error first, return early on failure + if (!(response->command.cmd_set == 0x00 && + response->command.cmd_id == 0x04 && + response->ret_code == 0x00)) { - // Set the appropriate pcloud data active state based on command type - context->setPcloudDataActiveState(); - context->callOriginalCallback(true); + std::cerr << __func__ << ": Failed to enable pcloud data for dev " + "(" << context->device.discoveredDevice.deviceIdentifier + << ") @(" << context->device.discoveredDevice.ipAddr << "). " + << "cmd_set: " << (int)response->command.cmd_set + << ", cmd_id: " << (int)response->command.cmd_id + << ", ret_code: " << (int)response->ret_code << "\n"; + + context->callOriginalCallbackWithFailure(); return; } - // If we get here, the command failed - context->callOriginalCallbackWithFailure(); + context->setPcloudDataActiveState(); + context->callOriginalCallback(true); } void cleanup()