39 #include "safec_lib.h"
40 #ifdef USE_WIFI_PROFILE
45 #include "wifi_common_hal.h"
46 #include "wifiSrvMgrIarmIf.h"
49 static time_t firstExTime = 0;
51 GHashTable* hostIf_WiFi_SSID::ifHash = NULL;
53 hostIf_WiFi_SSID* hostIf_WiFi_SSID::getInstance(
int dev_id)
55 static hostIf_WiFi_SSID* pRet = NULL;
59 pRet = (hostIf_WiFi_SSID *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
63 ifHash = g_hash_table_new(NULL,NULL);
69 pRet =
new hostIf_WiFi_SSID(dev_id);
72 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create hostIf_WiFi_SSID instance..\n");
74 g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
79 GList* hostIf_WiFi_SSID::getAllInstances()
82 return g_hash_table_get_keys(ifHash);
86 void hostIf_WiFi_SSID::closeInstance(hostIf_WiFi_SSID *pDev)
90 g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
95 void hostIf_WiFi_SSID::closeAllInstances()
99 GList* tmp_list = g_hash_table_get_values (ifHash);
103 hostIf_WiFi_SSID* pDev = (hostIf_WiFi_SSID *)tmp_list->data;
104 tmp_list = tmp_list->next;
112 hostIf_WiFi_SSID::hostIf_WiFi_SSID(
int dev_id):
116 memset(status,0 ,
sizeof(status));
117 memset(alias, 0,
sizeof(alias));
118 memset(name,0,
sizeof(name));
119 memset(LowerLayers,0,
sizeof(LowerLayers));
120 memset(BSSID,0,
sizeof(BSSID));
121 memset(MACAddress,0,
sizeof(MACAddress));
122 memset(SSID,0,
sizeof(SSID));
125 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(
int ssidIndex)
128 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
131 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
133 hostIf_WiFi_SSID *pDev = hostIf_WiFi_SSID::getInstance(dev_id);
137 if (IARM_RESULT_SUCCESS != retVal)
139 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] IARM BUS CALL failed with : %d.\n", __FILE__, __FUNCTION__, retVal);
142 rc=strcpy_s(name,
sizeof(name),param.data.ssid.params.name);
147 rc=strcpy_s(BSSID,
sizeof(BSSID),param.data.ssid.params.bssid);
152 rc=strcpy_s(MACAddress,
sizeof(MACAddress),param.data.ssid.params.macaddr);
157 rc=strcpy_s(SSID,
sizeof(SSID),param.data.ssid.params.ssid);
162 rc=strcpy_s(status,
sizeof(status),param.data.ssid.params.status);
167 enable=param.data.ssid.params.enable;
168 firstExTime = time (NULL);
169 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
174 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s]Error! Unable to connect to wifi instance\n", __FILE__, __FUNCTION__);
179 void hostIf_WiFi_SSID::checkWifiSSIDFetch(
int ssidIndex)
182 time_t currExTime = time (NULL);
183 if ((currExTime - firstExTime ) > QUERY_INTERVAL)
185 ret = get_Device_WiFi_SSID_Fields(ssidIndex);
188 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] Failed to fetch : %d.\n", __FILE__, __FUNCTION__, ret);
193 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Enable(
HOSTIF_MsgData_t *stMsgData )
197 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
198 checkWifiSSIDFetch(ssidIndex);
200 stMsgData->
paramtype = hostIf_BooleanType;
202 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
206 int hostIf_WiFi_SSID::set_Device_WiFi_SSID_Enable(
HOSTIF_MsgData_t *stMsgData )
211 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Status(
HOSTIF_MsgData_t *stMsgData )
213 char ssidStatus[32] =
"Down";
217 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
218 checkWifiSSIDFetch(ssidIndex);
219 stMsgData->
paramtype = hostIf_StringType;
220 stMsgData->
paramLen = strlen(status);
221 snprintf(stMsgData->
paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN, status);
223 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
228 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Alias(
HOSTIF_MsgData_t *stMsgData )
232 int hostIf_WiFi_SSID::set_Device_WiFi_SSID_Alias(
HOSTIF_MsgData_t *stMsgData )
237 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Name(
HOSTIF_MsgData_t *stMsgData )
241 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
242 checkWifiSSIDFetch(ssidIndex);
243 snprintf(stMsgData->
paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN, name);
244 stMsgData->
paramtype = hostIf_StringType;
246 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
250 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_LastChange(
HOSTIF_MsgData_t *stMsgData )
255 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_LowerLayers(
HOSTIF_MsgData_t *stMsgData )
260 int hostIf_WiFi_SSID::set_Device_WiFi_SSID_LowerLayers(
HOSTIF_MsgData_t *stMsgData )
265 int hostIf_WiFi_SSID::hostIf_WiFi_SSID::get_Device_WiFi_SSID_BSSID(
HOSTIF_MsgData_t *stMsgData )
270 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
271 checkWifiSSIDFetch(ssidIndex);
272 snprintf(stMsgData->
paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN, BSSID);
273 stMsgData->
paramtype = hostIf_StringType;
274 stMsgData->
paramLen = strlen(BSSID);
275 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
280 int hostIf_WiFi_SSID::hostIf_WiFi_SSID::get_Device_WiFi_SSID_MACAddress(
HOSTIF_MsgData_t *stMsgData )
284 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
285 checkWifiSSIDFetch(ssidIndex);
286 snprintf(stMsgData->
paramValue, TR69HOSTIFMGR_MAX_PARAM_LEN, MACAddress);
287 stMsgData->
paramtype = hostIf_StringType;
288 stMsgData->
paramLen = strlen(MACAddress);
289 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
293 int hostIf_WiFi_SSID::get_Device_WiFi_SSID_SSID(
HOSTIF_MsgData_t *stMsgData )
297 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
298 checkWifiSSIDFetch(ssidIndex);
299 snprintf(stMsgData->
paramValue,TR69HOSTIFMGR_MAX_PARAM_LEN, SSID);
300 stMsgData->
paramtype = hostIf_StringType;
302 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
306 int hostIf_WiFi_SSID::set_Device_WiFi_SSID_SSID(
HOSTIF_MsgData_t *stMsgData )