35 #pragma comment(lib, "Wlanapi.lib")
57 DWORD dwMaxClient = 2;
58 DWORD dwCurVersion = 0;
62 dwResult = WlanOpenHandle(dwMaxClient,
nullptr, &dwCurVersion, &hClient);
63 if (dwResult != ERROR_SUCCESS)
66 std::stringstream excmsg;
67 excmsg <<
"WlanOpenHandle failed with error: " << dwResult << std::endl;
72 return (
void*)hClient;
89 std::vector<PWLAN_INTERFACE_INFO> outputVector;
90 PWLAN_INTERFACE_INFO_LIST pIfList =
nullptr;
91 PWLAN_INTERFACE_INFO pIfInfo =
98 dwResult = WlanEnumInterfaces(hClient,
nullptr, &pIfList);
101 if (dwResult != ERROR_SUCCESS)
104 std::stringstream excmsg;
105 excmsg <<
"WlanEnumInterfaces failed with error: " << dwResult
114 for (i = 0; i < (int)pIfList->dwNumberOfItems; i++)
116 pIfInfo = (WLAN_INTERFACE_INFO*)&pIfList->InterfaceInfo[i];
117 outputVector.push_back(pIfInfo);
139 WCHAR GuidString[39] = {0};
145 iRet = StringFromGUID2(
146 ifaceGuid, (LPOLESTR)&GuidString,
147 sizeof(GuidString) /
sizeof(*GuidString));
159 wctostr = wcstombs_s(&sizeGUID, GuidChar, 100, GuidString, 100);
160 if ((wctostr == EINVAL) || (wctostr == ERANGE))
189 std::vector<PWLAN_INTERFACE_INFO> ifaceList;
191 PWLAN_INTERFACE_INFO output =
nullptr;
197 for (ifaceIter = ifaceList.begin(); ifaceIter != ifaceList.end();
200 if (
GUID2Str((*ifaceIter)->InterfaceGuid) == guid)
222 PWLAN_INTERFACE_INFO iface, HANDLE hClient)
227 PWLAN_AVAILABLE_NETWORK_LIST pBssList =
229 PWLAN_AVAILABLE_NETWORK pBssEntry =
232 GUID ifaceGuid = iface->InterfaceGuid;
234 std::vector<PWLAN_AVAILABLE_NETWORK> outputVector;
239 WLAN_RAW_DATA IeData;
240 WlanScan((HANDLE)hClient, &ifaceGuid,
nullptr, &IeData,
nullptr);
244 dwResult = WlanGetAvailableNetworkList(
245 (HANDLE)hClient, &ifaceGuid, 0,
nullptr, &pBssList);
248 if (dwResult != ERROR_SUCCESS)
251 std::stringstream excmsg;
252 excmsg <<
"WlanGetAvailableNetworkList failed with error: " << dwResult
259 for (
unsigned int j = 0; j < pBssList->dwNumberOfItems; j++)
261 pBssEntry = (WLAN_AVAILABLE_NETWORK*)&pBssList
263 outputVector.push_back(pBssEntry);
283 PWLAN_INTERFACE_INFO iface;
284 PWLAN_AVAILABLE_NETWORK output;
290 std::vector<PWLAN_AVAILABLE_NETWORK> pBssList =
295 for (netIter = pBssList.begin(); netIter != pBssList.end(); ++netIter)
297 if (
std::string((
char*)((*netIter)->dot11Ssid.ucSSID)) == ssid)
309 #endif // end of Windows auxiliary functions definition
318 std::vector<std::string> output;
323 char ifaceread[256], *netname;
333 "cat /proc/net/wireless|grep \"wlan\"|cut -d\" \" -f2|cut -d\":\" -f1",
335 if (!fgets(ifaceread, 3, cmdoutput))
339 netname =
::strtok(ifaceread,
"\n");
348 #if defined(__GNUC__)
353 std::vector<PWLAN_INTERFACE_INFO>
362 for (ifacesIter = ifaces.begin(); ifacesIter != ifaces.end(); ++ifacesIter)
364 output.push_back(
GUID2Str((*ifacesIter)->InterfaceGuid));
379 std::vector<std::string> output;
383 std::stringstream commandl;
395 commandl <<
"sudo iwlist "
397 <<
" scan|grep ESSID|cut -d\"\\\"\" -f2";
398 cmdoutput = popen(commandl.str().c_str(),
"r");
399 if (!fgets(listread, 3, cmdoutput))
412 #if defined(__GNUC__)
416 PWLAN_INTERFACE_INFO iface;
421 std::vector<PWLAN_AVAILABLE_NETWORK> pBssList =
426 for (netIter = pBssList.begin(); netIter != pBssList.end(); ++netIter)
428 output.push_back(
std::string((
char*)((*netIter)->dot11Ssid.ucSSID)));
446 std::stringstream commandl;
448 commandl <<
"sudo iwlist "
451 cmdoutput = popen(commandl.str().c_str(),
"r");
453 std::vector<std::string> powerReadV;
456 powerReadL = (
char*)malloc(256);
457 std::stringstream ssidLine;
459 ssidLine <<
"ESSID:\"" << ssid <<
"\"";
460 if (getline(&powerReadL, &readBytes, cmdoutput) < 0)
463 while (!strstr(powerReadL, ssidLine.str().c_str()))
466 if (getline(&powerReadL, &readBytes, cmdoutput))
477 strcpy(powerLine, (*ssiter).c_str());
493 #elif defined(_WIN32)
494 #if defined(__GNUC__)
497 PWLAN_AVAILABLE_NETWORK wlan;
502 return wlan->wlanSignalQuality;
521 outObservation.
power = (float)GetPower();
534 cerr <<
"[CWirelessPower::getObservation] Returning false due to "
537 cerr << e.what() << endl;
546 mrpt::make_aligned_shared<mrpt::obs::CObservationWirelessPower>();
559 pose_x = configSource.
read_float(iniSection,
"pose_x", 0,
true);
560 pose_y = configSource.
read_float(iniSection,
"pose_y", 0,
true);
561 pose_z = configSource.
read_float(iniSection,
"pose_z", 0,
true);
562 pose_roll = configSource.
read_float(iniSection,
"pose_roll", 0,
true);
563 pose_pitch = configSource.
read_float(iniSection,
"pose_pitch", 0,
true);
564 pose_yaw = configSource.
read_float(iniSection,
"pose_yaw", 0,
true);
566 ssid = configSource.
read_string(iniSection,
"ssid",
"",
true);
568 iniSection,
"guid",
"",
true);
572 #if defined(__GNUC__)