Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
Expand Down Expand Up @@ -359,12 +360,10 @@ int hostIf_WiFi_EndPoint::refreshCache()

if (!cJSON_IsArray(interfaces))
{
RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] WifiState result missing interfaces array\n", __FUNCTION__);
cJSON_Delete(root);
return NOK;
RDK_LOG (RDK_LOG_WARN, LOG_TR69HOSTIF, "[%s] WifiState result missing interfaces array\n", __FUNCTION__);
}

for (int i = 0; i < cJSON_GetArraySize(interfaces); i++) {
for (int i = 0; cJSON_IsArray(interfaces) && i < cJSON_GetArraySize(interfaces); i++) {
interface = cJSON_GetArrayItem(interfaces, i);
if (!cJSON_IsObject(interface)) {
interface = nullptr;
Expand All @@ -378,13 +377,13 @@ int hostIf_WiFi_EndPoint::refreshCache()

if (!interface)
{
RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] WIFI interface not found\n", __FUNCTION__);
cJSON_Delete(root);
return NOK;
RDK_LOG (RDK_LOG_WARN, LOG_TR69HOSTIF, "[%s] WIFI interface not found, keeping existing Enable value\n", __FUNCTION__);
}

//ASSIGN TO OP HERE
cJSON *result = cJSON_GetObjectItem(interface, "enabled");
if (interface)
{
cJSON *result = cJSON_GetObjectItem(interface, "enabled");
if (cJSON_IsBool(result))
{
Enable = cJSON_IsTrue(result);
Expand All @@ -395,10 +394,9 @@ int hostIf_WiFi_EndPoint::refreshCache()
}
else
{
RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] WIFI interface missing valid enabled field\n", __FUNCTION__);
cJSON_Delete(root);
return NOK;
RDK_LOG (RDK_LOG_WARN, LOG_TR69HOSTIF, "[%s] WIFI interface missing valid enabled field, keeping existing Enable value\n", __FUNCTION__);
}
}
Comment on lines 361 to +399

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refreshCache() now tolerates missing/invalid interfaces / enabled and keeps the prior Enable value, but the rest of the function still treats the refresh as successful (cache timestamp/last_call_status updated later) and downstream logic uses Enable to decide whether the endpoint is disabled. This can cause stale Enable to be cached and potentially report an enabled endpoint as disabled (or vice versa) when the response is incomplete. Consider tracking whether Enable was actually refreshed; if not, avoid marking the cache refresh successful (e.g., set last_call_status = NOK / skip updating the cache timestamp) or derive disabled status from state instead of a potentially-stale Enable.

Copilot uses AI. Check for mistakes.

cJSON *state = cJSON_GetObjectItem(jsonObj, "state");
if (!cJSON_IsNumber(state))
Expand Down
Loading