Topic/dm wifi#414
Conversation
RDKEMW-14888 : Observing error logs captured from RTMessages in tr69h…
There was a problem hiding this comment.
Pull request overview
This PR updates the WiFi EndPoint cache refresh logic to be more tolerant of incomplete JSON-RPC responses from NetworkManager (specifically around the interfaces array and WiFi enabled field), favoring warnings and retaining previously cached values rather than failing the refresh.
Changes:
- Downgrades certain JSON parsing failures (missing
interfaces, missing WiFi interface, invalid/missingenabled) from hard errors to warnings. - Guards iteration and parsing to avoid dereferencing when
interfacesis not an array or the WiFi interface is not found. - Keeps the prior cached
Enablevalue when the WiFienabledvalue cannot be determined.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -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); | |||
| @@ -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__); | |||
| } | |||
| } | |||
There was a problem hiding this comment.
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.
No description provided.