28 #include "libIBusDaemon.h"
29 #include "wifiSrvMgrIarmIf.h"
32 #include "NetworkMgrMain.h"
34 #define NM_MGR_WIFI_CLIENT "NetworkMgrWiFiClientApps"
36 #include "safec_lib.h"
38 #define STRCPY_S(dest,size,source) \
42 int Net_Srv_Reg_Events =
false;
43 int Wifi_Mgr_Reg_Events =
false;
45 typedef enum _NetworkManager_Route_EventId_t {
46 IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_DATA=10,
47 IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_MAX,
48 } IARM_Bus_NetworkManager_Route_EventId_t;
52 Test_getAvailableSSIDs,
57 Test_initiateWPSPairing,
58 Test_initiateWPSPairing2,
63 Test_getRadioStatsProps,
65 #ifdef ENABLE_LOST_FOUND
68 Test_getConnectedSSID,
69 Test_getEndPointProps,
70 Test_getAvailableSSIDsWithName,
71 Test_getAvailableSSIDsIncr,
72 Test_stopProgressiveScanning,
74 Test_cancelWPSPairing,
75 Test_nm_registerForEvents,
76 Test_nm_unregisterForEvents,
77 Test_wifi_registerForEvents,
78 Test_wifi_unregisterForEvents,
82 struct { option number;
const char* name; } options[] =
84 { Test_getAvailableSSIDs,
"getAvailableSSIDs" },
85 { Test_getCurrentState,
"getCurrentState" },
86 { Test_setEnabled,
"setEnabled" },
87 { Test_getPairedSSID,
"getPairedSSID" },
88 { Test_connect,
"connect" },
89 { Test_initiateWPSPairing,
"initiateWPSPairing" },
90 { Test_initiateWPSPairing2,
"initiateWPSPairing2" },
91 { Test_saveSSID,
"saveSSID" },
92 { Test_clearSSID,
"clearSSID" },
93 { Test_isPaired,
"isPaired" },
94 { Test_getRadioProps,
"getRadioProps" },
95 { Test_getRadioStatsProps,
"getRadioStatsProps" },
96 { Test_getSSIDProps,
"getSSIDProps" },
97 #ifdef ENABLE_LOST_FOUND
98 { Test_getLAFState,
"getLAFState" },
100 { Test_getConnectedSSID,
"getConnectedSSID" },
101 { Test_getEndPointProps,
"getEndPointProps" },
102 { Test_getAvailableSSIDsWithName,
"getAvailableSSIDsWithName" },
103 { Test_getAvailableSSIDsIncr,
"getAvailableSSIDsAsycIncr" },
104 { Test_stopProgressiveScanning,
"stopProgressiveWifiScanning" },
105 { Test_disconnectSSID,
"disconnectSSID" },
106 { Test_cancelWPSPairing,
"cancelWPSPairing" },
107 { Test_nm_registerForEvents,
"net_srv_mgr_registerForEvents" },
108 { Test_nm_unregisterForEvents,
"net_srv_mgr_unregisterForEvents" },
109 { Test_wifi_registerForEvents,
"wifi_mgr_registerForEvents" },
110 { Test_wifi_unregisterForEvents,
"wifi_mgr_unregisterForEvents" },
114 static bool user_answers_yes_to(
const char* question)
117 std::cout <<
"\n" << question <<
" (y/n) ";
119 return answer ==
'y' || answer ==
'Y';
122 static void WIFI_MGR_API_getAvailableSSIDsWithName()
125 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
126 char ssid[64] = {
'\0'};
130 memset(¶m, 0,
sizeof(param));
131 printf(
"[%s] Entering...\r\n", __FUNCTION__);
132 printf(
"\nEnter SSID to get the info :");
134 printf(
"\nEnter the band to scan 2.4 / 5 / 0 :");
136 STRCPY_S(param.SSID,
sizeof(param.SSID), ssid);
137 param.frequency = freq;
139 printf(
"\n***********************************");
141 printf(
"\n***********************************\n");
143 if(retVal == IARM_RESULT_SUCCESS && param.status)
151 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
154 static void WIFI_MGR_API_stopProgressiveScanning()
157 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
160 printf(
"[%s] Entering...\r\n", __FUNCTION__);
162 memset(¶m, 0,
sizeof(param));
166 printf(
"\n***********************************");
168 printf(
"\n***********************************\n");
170 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
175 static void WIFI_MGR_API_disconnectSSID()
178 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
181 printf(
"[%s] Entering...\r\n", __FUNCTION__);
183 memset(¶m, 0,
sizeof(param));
187 printf(
"\n***********************************");
189 printf(
"\n***********************************\n");
191 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
196 static void WIFI_MGR_API_cancelWPSPairing()
199 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
202 printf(
"[%s] Entering...\r\n", __FUNCTION__);
204 memset(¶m, 0,
sizeof(param));
208 printf(
"\n***********************************");
210 printf(
"\n***********************************\n");
212 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
217 static void WIFI_MGR_API_getAvailableSSIDsIncr()
220 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
222 memset(¶m, 0,
sizeof(param));
224 printf(
"[%s] Entering...\r\n", __FUNCTION__);
227 printf(
"\n***********************************");
229 printf(
"\n***********************************\n");
231 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
236 static void WIFI_MGR_API_getAvailableSSIDs()
239 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
241 memset(¶m, 0,
sizeof(param));
243 printf(
"[%s] Entering...\r\n", __FUNCTION__);
246 printf(
"\n***********************************");
248 printf(
"\n***********************************\n");
250 if(retVal == IARM_RESULT_SUCCESS && param.status) {
256 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
260 static void WIFI_MGR_API_getCurrentState()
263 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
266 printf(
"[%s] Entering...\r\n", __FUNCTION__);
267 memset(¶m, 0,
sizeof(param));
271 printf(
"\n***********************************");
273 printf(
"\n***********************************\n");
275 if(retVal == IARM_RESULT_SUCCESS && param.status) {
276 printf(
" \"getCurrentState\" : %d \n", param.data.wifiStatus );
278 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
282 #ifdef ENABLE_LOST_FOUND
283 static void WIFI_MGR_API_getLAFState()
286 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
289 printf(
"[%s] Entering...\r\n", __FUNCTION__);
290 memset(¶m, 0,
sizeof(param));
294 printf(
"\n***********************************");
296 printf(
"\n***********************************\n");
298 if(retVal == IARM_RESULT_SUCCESS && param.status) {
299 printf(
" \"getLAFState\" : %d \n", param.data.wifiLNFStatus );
301 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
305 static void WIFI_MGR_API_setEnabled()
308 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
310 printf(
"[%s] Entering...\r\n", __FUNCTION__);
311 memset(¶m, 0,
sizeof(param));
313 param.data.setwifiadapter.enable = user_answers_yes_to(
"Press Y/y for setEnabled(true), anything else for setEnabled(false)");
316 if(retVal == IARM_RESULT_SUCCESS) {
319 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
324 static void WIFI_MGR_API_getPairedSSID()
327 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
331 printf(
"[%s] Entering...\r\n", __FUNCTION__);
333 memset(¶m, 0,
sizeof(param));
337 printf(
"\n***********************************");
339 printf(
"\n***********************************\n");
341 ssid = param.data.getPairedSSID.ssid;
342 if(retVal == IARM_RESULT_SUCCESS) {
343 printf(
"\nSSID: %s \n", (ssid)?ssid:
"No ssid is assigned.");
346 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
350 static void WIFI_MGR_API_connect()
353 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
355 std::string ssid, passphrase, ans;
358 printf(
"[%s] Entering...\r\n", __FUNCTION__);
359 memset(¶m, 0,
sizeof(param));
361 printf(
"\n***********************************");
363 printf(
"\n***********************************\n");
365 printf(
"Would like to connect using ssid & passphrase. (Y/N)?" );
368 if(!strcasecmp(ans.c_str(),
"Y"))
370 std::cout<<
" Enter ssid : ";
372 std::cout <<
" Enter passphrase : " ;
373 std::cin >> passphrase;
374 std::cout <<
" Enter securitymode : " ;
375 std::cin >> securitymode;
376 STRCPY_S (param.data.connect.ssid,
sizeof(param.data.connect.ssid), ssid.c_str());
377 STRCPY_S (param.data.connect.passphrase,
sizeof(param.data.connect.passphrase), passphrase.c_str());
378 param.data.connect.security_mode=(
SsidSecurity)securitymode;
379 printf(
"\n ssid = %s passphrase = %s security mode = %d",param.data.connect.ssid,param.data.connect.passphrase,param.data.connect.security_mode);
382 printf(
"\nNot selected any ssid & passphrase. so, connect\n" );
389 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
393 static void WIFI_MGR_API_initiateWPSPairing()
396 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
398 printf(
"[%s] Entering...\r\n", __FUNCTION__);
402 printf(
"\n***********************************");
404 printf(
"\n***********************************\n");
405 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
409 static void WIFI_MGR_API_initiateWPSPairing2()
411 printf(
"[%s] Entering...\r\n", __FUNCTION__);
414 if (user_answers_yes_to(
"PBC ?"))
415 wps_parameters.pbc =
true;
416 else if (user_answers_yes_to(
"Auto-generate PIN ?"))
417 wps_parameters.pin[0] =
'\0';
418 else if (user_answers_yes_to(
"Use serialized PIN ?"))
419 strcpy(wps_parameters.pin,
"xxxxxxxx");
423 std::cout <<
"\nEnter PIN (8 digits): ";
425 strncpy(wps_parameters.pin, pin.c_str(), 8);
430 printf(
"\n***********************************");
432 if (wps_parameters.status ==
true && !wps_parameters.pbc)
434 printf(
"\n***********************************\n");
436 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
440 static void WIFI_MGR_API_saveSSID()
443 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
444 std::string ssid, passphrase, ans;
447 printf(
"[%s] Entering...\r\n", __FUNCTION__);
448 memset(¶m, 0,
sizeof(param));
449 printf(
"\n***********************************");
451 printf(
"\n***********************************\n");
453 printf(
"This would saves the ssid and passphrase for future sessions.\n" );
454 std::cout <<
"Enter ssid :" ;
456 std::cout <<
"\nEnter passphrase :" ;
457 std::cin >> passphrase;
458 STRCPY_S (param.data.connect.ssid,
sizeof(param.data.connect.ssid), ssid.c_str());
459 STRCPY_S (param.data.connect.passphrase,
sizeof(param.data.connect.passphrase), passphrase.c_str());
463 printf(
"\n%s : %s \n",
IARM_BUS_WIFI_MGR_API_saveSSID, ((retVal == IARM_RESULT_SUCCESS && param.status)?
"Successfully saved the SSID":
"failed to save SSID"));
464 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
468 static void WIFI_MGR_API_clearSSID()
471 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
474 printf(
"[%s] Entering...\r\n", __FUNCTION__);
476 memset(¶m, 0,
sizeof(param));
480 printf(
"\n***********************************");
482 printf(
"\n***********************************\n");
484 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
488 static void WIFI_MGR_API_isPaired()
491 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
494 printf(
"[%s] Entering...\r\n", __FUNCTION__);
496 memset(¶m, 0,
sizeof(param));
500 printf(
"\n***********************************");
502 printf(
"\n***********************************\n");
503 printf(
"%s \n", (param.data.isPaired)?
"Paied.":
"Not paired.");
505 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
509 static void WIFI_MGR_API_getConnectedSSID() {
511 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
514 printf(
"[%s] Entering...\r\n", __FUNCTION__);
516 memset(¶m, 0,
sizeof(param));
520 printf(
"\n***********************************");
522 printf(
"\n***********************************\n");
524 printf(
"Connected SSID info: \n \
527 \tPhyRate : \"%f\"\n \
528 \tNoise : \"%f\" \n \
530 \tSignalStrength(rssi) : \"%f\" \n \
531 \tFrequency : \"%d\"\n \
532 \tSecurityMode : \"%d\"\n ",
533 param.data.getConnectedSSID.ssid, \
534 param.data.getConnectedSSID.bssid, \
535 param.data.getConnectedSSID.rate, \
536 param.data.getConnectedSSID.noise, \
537 param.data.getConnectedSSID.band, \
538 param.data.getConnectedSSID.signalStrength, \
539 param.data.getConnectedSSID.frequency, \
540 param.data.getConnectedSSID.securityMode);
542 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
546 static void WIFI_MGR_API_getEndPointProps()
549 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
552 printf(
"[%s] Entering...\r\n", __FUNCTION__);
554 memset(¶m, 0,
sizeof(param));
558 printf(
"\n***********************************");
560 printf(
"\n***********************************\n");
562 printf(
"\n Profile : \"EndPoint.1.\": \n \
563 [Enable : \"%d\"| Status : \"%s\" | SSIDReference : \"%s\" ] \n",
564 param.data.endPointInfo.enable, param.data.endPointInfo.status, param.data.endPointInfo.SSIDReference);
566 printf(
" \n Profile : \"EndPoint.1.Stats.\": \n \
567 [SignalStrength : \"%d\"| Retransmissions : \"%ld\" | LastDataUplinkRate : \"%ld\" | LastDataDownlinkRate : \" %ld\" ] \n",
568 param.data.endPointInfo.stats.signalStrength, param.data.endPointInfo.stats.retransmissions,
569 param.data.endPointInfo.stats.lastDataDownlinkRate, param.data.endPointInfo.stats.lastDataUplinkRate);
571 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
576 static void WIFI_MGR_API_getSSIDProps()
579 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
582 printf(
"[%s] Entering...\r\n", __FUNCTION__);
584 memset(¶m, 0,
sizeof(param));
588 printf(
"\n***********************************");
590 printf(
"\n***********************************\n");
591 std::cout <<
"enable : " << param.data.ssid.params.enable << std::endl;
592 std::cout <<
"status : " << param.data.ssid.params.status << std::endl;
593 std::cout <<
"name : " << param.data.ssid.params.name << std::endl;
594 std::cout <<
"bssid : " << param.data.ssid.params.bssid << std::endl;
595 std::cout <<
"macaddr : " << param.data.ssid.params.macaddr << std::endl;
596 std::cout <<
"ssid : " << param.data.ssid.params.ssid << std::endl;
598 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
603 static void WIFI_MGR_API_getRadioProps()
606 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
609 printf(
"[%s] Entering...\r\n", __FUNCTION__);
611 memset(¶m, 0,
sizeof(param));
615 printf(
"\n***********************************");
617 printf(
"\n***********************************\n");
618 std::cout <<
"enable : " << param.data.radio.params.enable << std::endl;
619 std::cout <<
"status : " << param.data.radio.params.status << std::endl;
620 std::cout <<
"name : " << param.data.radio.params.name << std::endl;
621 std::cout <<
"maxBitRate : " << param.data.radio.params.maxBitRate << std::endl;
622 std::cout <<
"supportedFrequencyBands : " << param.data.radio.params.supportedFrequencyBands << std::endl;
623 std::cout <<
"operatingFrequencyBand : "<< param.data.radio.params.operatingFrequencyBand << std::endl;
624 std::cout <<
"autoChannelEnable : "<< param.data.radio.params.autoChannelEnable << std::endl;
625 std::cout <<
"autoChannelRefreshPeriod : "<< param.data.radio.params.autoChannelRefreshPeriod << std::endl;
626 std::cout <<
"autoChannelSupported : "<< param.data.radio.params.autoChannelSupported << std::endl;
627 std::cout <<
"channelsInUse : " << param.data.radio.params.channelsInUse << std::endl;
628 std::cout <<
"channel : " << param.data.radio.params.channel << std::endl;
629 std::cout <<
"extensionChannel : " << param.data.radio.params.extensionChannel << std::endl;
630 std::cout <<
"guardInterval : " << param.data.radio.params.guardInterval << std::endl;
631 std::cout <<
"mcs : " << param.data.radio.params.mcs << std::endl;
632 std::cout <<
"operatingChannelBandwidth : " << param.data.radio.params.operatingChannelBandwidth << std::endl;
633 std::cout <<
"operatingStandards : " << param.data.radio.params.operatingStandards << std::endl;
634 std::cout <<
"possibleChannels : " << param.data.radio.params.possibleChannels << std::endl;
635 std::cout <<
"regulatoryDomain : " << param.data.radio.params.regulatoryDomain << std::endl;
637 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
641 static void WIFI_MGR_API_getRadioStatsProps()
644 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
647 printf(
"[%s] Entering...\r\n", __FUNCTION__);
649 memset(¶m, 0,
sizeof(param));
653 printf(
"\n***********************************");
655 printf(
"\n***********************************\n");
656 std::cout <<
"BytesSent : " << param.data.radio_stats.params.bytesSent << std::endl;
657 std::cout <<
"BytesReceived : " << param.data.radio_stats.params.bytesReceived << std::endl;
658 std::cout <<
"PacketsSent : " << param.data.radio_stats.params.packetsSent << std::endl;
659 std::cout <<
"PacketsReceived : " << param.data.radio_stats.params.packetsReceived << std::endl;
660 std::cout <<
"ErrorsSent : " << param.data.radio_stats.params.errorsSent << std::endl;
661 std::cout <<
"ErrorsReceived : "<< param.data.radio_stats.params.errorsReceived << std::endl;
662 std::cout <<
"DiscardPacketsSent : " << param.data.radio_stats.params.discardPacketsSent << std::endl;
663 std::cout <<
"DiscardPacketsReceived : " << param.data.radio_stats.params.discardPacketsReceived << std::endl;
664 std::cout <<
"PLCPErrorCount : " << param.data.radio_stats.params.plcErrorCount << std::endl;
665 std::cout <<
"FCSErrorCount : " << param.data.radio_stats.params.fcsErrorCount << std::endl;
666 std::cout <<
"InvalidMACCount : " << param.data.radio_stats.params.invalidMACCount << std::endl;
667 std::cout <<
"PacketsOtherReceived : " << param.data.radio_stats.params.packetsOtherReceived << std::endl;
669 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
673 #define IARM_CHECK(FUNC) { \
674 if ((res = FUNC) != IARM_RESULT_SUCCESS) { \
675 printf("IARM %s: %s\n", #FUNC, \
676 res == IARM_RESULT_INVALID_PARAM ? "invalid param" : ( \
677 res == IARM_RESULT_INVALID_STATE ? "invalid state" : ( \
678 res == IARM_RESULT_IPCCORE_FAIL ? "ipcore fail" : ( \
679 res == IARM_RESULT_OOM ? "oom" : "unknown")))); \
683 printf("IARM %s: success\n", #FUNC); \
686 #endif //#ifdef ENABLE_IARM
689 static void eventHandler_nm_mgr(
const char *owner, IARM_EventId_t eventId,
void *data,
size_t len)
691 if (strcmp(owner, IARM_BUS_NM_SRV_MGR_NAME) != 0)
693 printf (
"ERROR - nm_mgr unexpected event: owner %s, eventId: %d, data: %p, size: %d.\n", owner, (
int)eventId, data, len);
696 if (data ==
nullptr || len == 0)
698 printf (
"ERROR - event with NO DATA: eventId: %d, data: %p, size: %d.\n", (
int)eventId, data, len);
704 case IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_ENABLED_STATUS:
707 printf (
"IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_ENABLED_STATUS interface = %s, enabled = %d\n",
708 e->interface, e->status);
711 case IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_CONNECTION_STATUS:
714 printf (
"IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_CONNECTION_STATUS interface = %s, connected = %d\n",
715 e->interface, e->status);
718 case IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_IPADDRESS:
721 printf (
"IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_IPADDRESS interface = %s, ip_address = %s, acquired = %d\n",
722 e->interface, e->ip_address, e->acquired);
725 case IARM_BUS_NETWORK_MANAGER_EVENT_DEFAULT_INTERFACE:
728 printf (
"IARM_BUS_NETWORK_MANAGER_EVENT_DEFAULT_INTERFACE oldInterface = %s newInterface = %s\n",
729 e->oldInterface, e->newInterface);
732 case IARM_BUS_NETWORK_MANAGER_EVENT_SET_INTERFACE_ENABLED:
735 printf (
"IARM_BUS_NETWORK_MANAGER_EVENT_SET_INTERFACE_ENABLED = %d \n", iarmData.isInterfaceEnabled);
738 case IARM_BUS_NETWORK_MANAGER_EVENT_SET_INTERFACE_CONTROL_PERSISTENCE:
741 printf (
"IARM_BUS_NETWORK_MANAGER_EVENT_SET_INTERFACE_CONTROL_PERSISTENCE = %d for interface %s\n", iarmData.isInterfaceEnabled,
742 iarmData.setInterface);
745 case IARM_BUS_NETWORK_MANAGER_EVENT_WIFI_INTERFACE_STATE:
748 printf (
"IARM_BUS_NETWORK_MANAGER_EVENT_SET_INTERFACE_ENABLED = %d \n", iarmData.isInterfaceEnabled);
751 case IARM_BUS_NETWORK_MANAGER_EVENT_SWITCH_TO_PRIVATE:
753 printf(
"IARM_BUS_NETWORK_MANAGER_EVENT_SWITCH_TO_PRIVATE broadcast!");
756 case IARM_BUS_NETWORK_MANAGER_EVENT_STOP_LNF_WHILE_DISCONNECTED:
758 printf(
"IARM_BUS_NETWORK_MANAGER_EVENT_STOP_LNF_WHILE_DISCONNECTED event!");
761 case IARM_BUS_NETWORK_MANAGER_EVENT_AUTO_SWITCH_TO_PRIVATE_ENABLED:
763 printf(
"IARM_BUS_NETWORK_MANAGER_EVENT_AUTO_SWITCH_TO_PRIVATE_ENABLED event!");
766 case IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_DATA:
768 printf(
"IARM_BUS_NETWORK_MANAGER_EVENT_ROUTE_DATA event!");
773 #endif //#ifdef ENABLE_IARM
776 static void eventHandler_wifi_mgr(
const char *owner, IARM_EventId_t eventId,
void *data,
size_t len)
778 if (strcmp(owner, IARM_BUS_NM_SRV_MGR_NAME) != 0)
780 printf (
"ERROR - wifi_mgr unexpected event: owner %s, eventId: %d, data: %p, size: %d.\n", owner, (
int)eventId, data, len);
783 if (data ==
nullptr || len == 0)
785 printf (
"ERROR - event with NO DATA: eventId: %d, data: %p, size: %d.\n", (
int)eventId, data, len);
791 case IARM_BUS_WIFI_MGR_EVENT_onAvailableSSIDs:
794 printf (
"IARM_BUS_WIFI_MGR_EVENT_onAvailableSSIDs data.wifiSSIDList.ssid_list = %s\n",
795 e->data.wifiSSIDList.ssid_list);
798 case IARM_BUS_WIFI_MGR_EVENT_onAvailableSSIDsIncr:
801 printf (
"IARM_BUS_WIFI_MGR_EVENT_onAvailableSSIDsIncr data.wifiSSIDList.more_data = %d data.wifiSSIDList.ssid_list = %s\n",
802 e->data.wifiSSIDList.more_data, e->data.wifiSSIDList.ssid_list);
805 case IARM_BUS_WIFI_MGR_EVENT_onError:
808 printf (
"IARM_BUS_WIFI_MGR_EVENT_onError data.wifiError.code = %d\n",
809 e->data.wifiError.code);
812 case IARM_BUS_WIFI_MGR_EVENT_onWIFIStateChanged:
815 printf (
"IARM_BUS_WIFI_MGR_EVENT_onWIFIStateChanged data.wifiStateChange.state = %d\n",
816 e->data.wifiStateChange.state);
819 case IARM_BUS_WIFI_MGR_EVENT_onSSIDsChanged:
822 printf (
"IARM_BUS_WIFI_MGR_EVENT_onSSIDsChanged data.wifiSSIDList.ssid_list = %s data.wifiStateChange.state = %d \n",
823 e->data.wifiSSIDList.ssid_list, e->data.wifiStateChange.state);
828 #endif //#ifdef ENABLE_IARM
830 static void NET_MGR_registerForEvents()
833 printf(
"[%s] Entering...\r\n", __FUNCTION__);
835 if (Net_Srv_Reg_Events)
837 printf(
"[%s] Already registered\n", __FUNCTION__);
841 Net_Srv_Reg_Events =
true;
844 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_ENABLED_STATUS, eventHandler_nm_mgr) );
845 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_CONNECTION_STATUS, eventHandler_nm_mgr) );
846 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_IPADDRESS, eventHandler_nm_mgr) );
847 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_DEFAULT_INTERFACE, eventHandler_nm_mgr) );
848 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_SET_INTERFACE_ENABLED, eventHandler_nm_mgr) );
849 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_SET_INTERFACE_CONTROL_PERSISTENCE, eventHandler_nm_mgr) );
850 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_WIFI_INTERFACE_STATE , eventHandler_nm_mgr) );
851 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_SWITCH_TO_PRIVATE, eventHandler_nm_mgr) );
852 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_STOP_LNF_WHILE_DISCONNECTED, eventHandler_nm_mgr) );
853 IARM_CHECK(
IARM_Bus_RegisterEventHandler(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETWORK_MANAGER_EVENT_AUTO_SWITCH_TO_PRIVATE_ENABLED, eventHandler_nm_mgr) );
857 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
861 static void WIFI_MGR_registerForEvents()
864 printf(
"[%s] Entering...\r\n", __FUNCTION__);
866 if (Wifi_Mgr_Reg_Events)
868 printf(
"[%s] Already registered\n", __FUNCTION__);
872 Wifi_Mgr_Reg_Events =
true;
883 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
887 static void NET_MGR_unregisterForEvents()
890 printf(
"[%s] Entering...\r\n", __FUNCTION__);
892 if (!Net_Srv_Reg_Events)
894 printf(
"[%s] Already unregistered\n", __FUNCTION__);
912 Net_Srv_Reg_Events =
false;
915 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
919 static void WIFI_MGR_unregisterForEvents()
922 printf(
"[%s] Entering...\r\n", __FUNCTION__);
924 if (!Wifi_Mgr_Reg_Events)
926 printf(
"[%s] Already unregistered\n", __FUNCTION__);
937 Wifi_Mgr_Reg_Events =
false;
940 printf(
"[%s] Exiting..\r\n", __FUNCTION__);
944 static void cleanup()
947 if (Wifi_Mgr_Reg_Events)
949 WIFI_MGR_unregisterForEvents();
951 if (Net_Srv_Reg_Events)
953 NET_MGR_unregisterForEvents();
955 #endif //#ifdef ENABLE_IARM
959 void signal_handler (
int sigNum)
962 printf (
"%s(): Received signal %d \n",__FUNCTION__, sigNum);
968 #endif //#ifdef ENABLE_IARM
976 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
980 signal (SIGHUP, signal_handler);
981 signal (SIGINT, signal_handler);
982 signal (SIGQUIT, signal_handler);
983 signal (SIGTERM, signal_handler);
990 printf(
"\n==================================================================\n");
991 printf(
"***** Network Mgr: Execute WiFi Manager Api's **** ");
992 printf(
"\n==================================================================\n");
993 for (
int n =
sizeof(options)/
sizeof(options[0]), i = 0; i < n; i++)
994 printf(
"%d. %s\n", options[i].number, options[i].name);
995 printf(
"\n==================================================================\n");
996 printf(
"\n Selection: " );
1001 case Test_getAvailableSSIDs:
1002 WIFI_MGR_API_getAvailableSSIDs();
1004 case Test_getAvailableSSIDsWithName:
1005 WIFI_MGR_API_getAvailableSSIDsWithName();
1007 case Test_getCurrentState:
1008 WIFI_MGR_API_getCurrentState();
1010 case Test_setEnabled:
1011 WIFI_MGR_API_setEnabled();
1013 case Test_getPairedSSID:
1014 WIFI_MGR_API_getPairedSSID();
1017 WIFI_MGR_API_connect();
1019 case Test_initiateWPSPairing:
1020 WIFI_MGR_API_initiateWPSPairing();
1022 case Test_initiateWPSPairing2:
1023 WIFI_MGR_API_initiateWPSPairing2();
1026 WIFI_MGR_API_saveSSID();
1028 case Test_clearSSID:
1029 WIFI_MGR_API_clearSSID();
1032 WIFI_MGR_API_isPaired();
1034 case Test_getRadioProps:
1035 WIFI_MGR_API_getRadioProps();
1037 case Test_getRadioStatsProps:
1038 WIFI_MGR_API_getRadioStatsProps();
1040 case Test_getSSIDProps:
1041 WIFI_MGR_API_getSSIDProps();
1043 #ifdef ENABLE_LOST_FOUND
1044 case Test_getLAFState:
1045 WIFI_MGR_API_getLAFState();
1048 case Test_getConnectedSSID:
1049 WIFI_MGR_API_getConnectedSSID();
1051 case Test_getEndPointProps:
1052 WIFI_MGR_API_getEndPointProps();
1054 case Test_getAvailableSSIDsIncr:
1055 WIFI_MGR_API_getAvailableSSIDsIncr();
1057 case Test_stopProgressiveScanning:
1058 WIFI_MGR_API_stopProgressiveScanning();
1060 case Test_disconnectSSID:
1061 WIFI_MGR_API_disconnectSSID();
1063 case Test_cancelWPSPairing:
1064 WIFI_MGR_API_cancelWPSPairing();
1066 case Test_nm_registerForEvents:
1067 NET_MGR_registerForEvents();
1069 case Test_nm_unregisterForEvents:
1070 NET_MGR_unregisterForEvents();
1072 case Test_wifi_registerForEvents:
1073 WIFI_MGR_registerForEvents();
1075 case Test_wifi_unregisterForEvents:
1076 WIFI_MGR_unregisterForEvents();
1080 printf(
"Wrong Input..., try again.\n" );