34 #ifdef USE_WIFI_PROFILE
39 #include "Device_WiFi_EndPoint.h"
41 #include "safec_lib.h"
44 #include "wifiSrvMgrIarmIf.h"
47 GHashTable* hostIf_WiFi_EndPoint::ifHash = NULL;
59 ifHash = g_hash_table_new(NULL,NULL);
68 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create hostIf_WiFi_EndPoint instance..\n");
70 g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
75 GList* hostIf_WiFi_EndPoint::getAllInstances()
78 return g_hash_table_get_keys(ifHash);
86 g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
91 void hostIf_WiFi_EndPoint::closeAllInstances()
95 GList* tmp_list = g_hash_table_get_values (ifHash);
100 tmp_list = tmp_list->next;
107 hostIf_WiFi_EndPoint::hostIf_WiFi_EndPoint (
int dev_id) :
110 ProfileNumberOfEntries(0)
112 memset(Status, 0, 64);
113 memset(Alias, 0, 64);
114 memset(ProfileReference, 0, 256);
115 memset(SSIDReference, 0, 256);
116 stats.LastDataDownlinkRate = 0;
117 stats.LastDataUplinkRate = 0;
118 stats.SignalStrength = 0;
119 stats.Retransmissions = 0;
129 if (OK != refreshCache ())
131 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Enable = [%d]\n", __FUNCTION__, Enable);
133 stMsgData->
paramtype = hostIf_BooleanType;
134 stMsgData->
paramLen =
sizeof (bool);
147 if (OK != refreshCache ())
149 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Status = [%s]\n", __FUNCTION__, Status);
155 stMsgData->
paramtype = hostIf_StringType;
156 stMsgData->
paramLen = strlen (Status);
164 if (OK != refreshCache ())
166 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Alias = [%s]\n", __FUNCTION__, Alias);
172 stMsgData->
paramtype = hostIf_StringType;
173 stMsgData->
paramLen = strlen (Alias);
220 if (OK != refreshCache ())
222 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Stats.LastDataDownlinkRate = [%lu]\n", __FUNCTION__, stats.LastDataDownlinkRate);
224 stMsgData->
paramtype = hostIf_UnsignedLongType;
225 stMsgData->
paramLen =
sizeof (
unsigned long);
232 if (OK != refreshCache ())
234 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Stats.LastDataUplinkRate = [%lu]\n", __FUNCTION__, stats.LastDataUplinkRate);
236 stMsgData->
paramtype = hostIf_UnsignedLongType;
237 stMsgData->
paramLen =
sizeof (
unsigned long);
244 if (OK != refreshCache ())
246 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Stats.SignalStrength = [%d]\n", __FUNCTION__, stats.SignalStrength);
248 stMsgData->
paramtype = hostIf_IntegerType;
256 if (OK != refreshCache ())
258 RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s] Stats.Retransmissions = [%u]\n", __FUNCTION__, stats.Retransmissions);
260 stMsgData->
paramtype = hostIf_UnsignedLongType;
261 stMsgData->
paramLen =
sizeof (
unsigned long);
268 int hostIf_WiFi_EndPoint::refreshCache()
272 static time_t time_of_last_successful_query = 0;
273 static int last_call_status = NOK;
276 std::lock_guard<std::mutex> lg (m);
279 if ((last_call_status == OK ) && (time (0) <= time_of_last_successful_query + 1))
281 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] Cache not stale. last call status is SUCCESS, Refresh not required.\n", __FUNCTION__);
287 if (IARM_RESULT_SUCCESS != retVal)
289 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] Cache refresh failed. IARM_Bus_Call to netsrvmgr returned [%d]\n", __FUNCTION__, retVal);
290 last_call_status = NOK;
294 time_of_last_successful_query = time (0);
296 Enable = param.data.endPointInfo.enable;
297 strncpy (Status, param.data.endPointInfo.status, BUFF_LENGTH_64);
298 strncpy (Alias, param.data.endPointInfo.alias, BUFF_LENGTH_64);
299 strncpy (ProfileReference, param.data.endPointInfo.ProfileReference, BUFF_LENGTH_256);
300 strncpy (SSIDReference, param.data.endPointInfo.SSIDReference, BUFF_LENGTH_256);
301 ProfileNumberOfEntries = param.data.endPointInfo.ProfileNumberOfEntries;
302 stats.LastDataDownlinkRate = param.data.endPointInfo.stats.lastDataDownlinkRate;
303 stats.LastDataUplinkRate = param.data.endPointInfo.stats.lastDataUplinkRate;
304 stats.SignalStrength = param.data.endPointInfo.stats.signalStrength;
305 stats.Retransmissions = param.data.endPointInfo.stats.retransmissions;
307 RDK_LOG (RDK_LOG_DEBUG, LOG_TR69HOSTIF,
"[%s] Cache refreshed.\n", __FUNCTION__);
309 if (
false == param.data.endPointInfo.enable)
311 RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF,
"[%s] EndPoint is disabled\n", __FUNCTION__);
312 last_call_status = NOK;
315 last_call_status = OK;