Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion pywifi/_wifiutil_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,29 @@ def scan_results(self, obj):

if networks[i].dot11Ssid.ucSSID != b'':
ssid += "%c" % networks[i].dot11Ssid.ucSSID[j]

#This part is used for converting to UTF-8 encoded SSID
temp_cnt = 0
temp_hex_res = 0
bytes_list = []
converted_name = ""
for bin_encode_char in ssid:
if (33 <= ord(bin_encode_char) <= 126):
converted_name = converted_name + bin_encode_char
else:
temp_cnt = temp_cnt + 1
temp_now = int(str(bin(ord(bin_encode_char)))[2:6], 2)
temp_now1 = int(str(bin(ord(bin_encode_char)))[6:10], 2)
temp_hex_res = temp_hex_res + temp_now * 16 + temp_now1
bytes_list.append(temp_hex_res)
temp_hex_res = 0
if temp_cnt == 3:
converted_name = converted_name + bytes(bytes_list).decode('utf-8', 'ignore')
bytes_list = []
temp_hex_res = 0
temp_cnt = 0
ssid = converted_name
#print("Work + " + ssid + " strlen : " + str(len(ssid)))
#End of converting part
bss_list = pointer(WLAN_BSS_LIST())
self._wlan_get_network_bss_list(self._handle,
byref(obj['guid']), byref(bss_list), networks[i].dot11Ssid, networks[i].bSecurityEnabled)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_wifi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#coding=utf-8
import pywifi
import time
A = 41
n = 3.7
wifi = pywifi.PyWiFi()
iface = wifi.interfaces()[0]
iface.scan()
result=iface.scan_results()
time.sleep(2)

for i in range(len(result)):
SSID = result[i].ssid
SIGNAL = result[i].signal
RSSI = SIGNAL
if SSID != "" :
print(str(SSID) + ' ' + str(SIGNAL) + " %.2f" % length + ' m')