83 0: self.tr("open", "open WiFi network"), |
83 0: self.tr("open", "open WiFi network"), |
84 1: "WEP", |
84 1: "WEP", |
85 2: "WPA", |
85 2: "WPA", |
86 3: "WPA2", |
86 3: "WPA2", |
87 4: "WPA/WPA2", |
87 4: "WPA/WPA2", |
88 5: "WPA2 (CCMP)", |
88 5: "WPA2", |
89 6: "WPA3", |
89 6: "WPA3", |
90 7: "WPA2/WPA3", |
90 7: "WPA2/WPA3", |
91 }, |
91 }, |
92 "picowireless": { |
92 "picowireless": { |
93 2: "WPA", |
93 2: "WPA", |
94 4: "WPA2 (CCMP)", |
94 4: "WPA2", |
95 5: "WEP", |
95 5: "WEP", |
96 7: self.tr("open", "open WiFi network"), |
96 7: self.tr("open", "open WiFi network"), |
97 8: self.tr("automatic"), |
97 8: self.tr("automatic"), |
98 }, |
98 }, |
99 } |
99 } |
661 ap = { |
661 ap = { |
662 'active': pw.get_connection_status() in (7, 8, 9), |
662 'active': pw.get_connection_status() in (7, 8, 9), |
663 'connected': pw.get_connection_status() == 8, |
663 'connected': pw.get_connection_status() == 8, |
664 'status': pw.get_connection_status(), |
664 'status': pw.get_connection_status(), |
665 'mac': ubinascii.hexlify(pw.get_mac_address(), ':').decode(), |
665 'mac': ubinascii.hexlify(pw.get_mac_address(), ':').decode(), |
|
666 'ap_security': pw.get_current_encryption_type(), |
666 } |
667 } |
667 if ap['active']: |
668 if ap['active']: |
668 ap['essid'] = pw.get_current_ssid() |
669 ap['essid'] = pw.get_current_ssid() |
669 ap['ifconfig'] = ( |
670 ap['ifconfig'] = ( |
670 ip_str(pw.get_ip_address()), |
671 ip_str(pw.get_ip_address()), |
722 ][station["ap_security"]] |
723 ][station["ap_security"]] |
723 except KeyError: |
724 except KeyError: |
724 station["ap_security"] = self.tr("unknown ({0})").format( |
725 station["ap_security"] = self.tr("unknown ({0})").format( |
725 station["ap_security"] |
726 station["ap_security"] |
726 ) |
727 ) |
727 if "ap_security" in ap and self._deviceData["wifi_type"] == "picow": |
728 if "ap_security" in ap: |
728 try: |
729 if self._deviceData["wifi_type"] == "picow": |
729 ap["ap_security"] = self.__securityMapping[ap["ap_security"]] |
730 try: |
730 except KeyError: |
731 ap["ap_security"] = self.__securityMapping[ap["ap_security"]] |
|
732 except KeyError: |
|
733 ap["ap_security"] = self.tr("unknown ({0})").format( |
|
734 ap["ap_security"] |
|
735 ) |
|
736 elif self._deviceData["wifi_type"] == "picowireless": |
|
737 # translate the numerical AP security to a string |
|
738 try: |
|
739 ap["ap_security"] = self.__securityTranslations["picowireless"][ |
|
740 ap["ap_security"] |
|
741 ] |
|
742 except KeyError: |
|
743 ap["ap_security"] = self.tr("unknown ({0})").format( |
|
744 ap["ap_security"] |
|
745 ) |
|
746 else: |
731 ap["ap_security"] = self.tr("unknown ({0})").format(ap["ap_security"]) |
747 ap["ap_security"] = self.tr("unknown ({0})").format(ap["ap_security"]) |
732 |
748 |
733 return station, ap, overall |
749 return station, ap, overall |
734 |
750 |
735 def connectWifi(self, ssid, password, hostname): |
751 def connectWifi(self, ssid, password, hostname): |
1359 if self._deviceData["wifi_type"] in ("picow", "picowireless"): |
1375 if self._deviceData["wifi_type"] in ("picow", "picowireless"): |
1360 return self.deactivateInterface("AP") |
1376 return self.deactivateInterface("AP") |
1361 else: |
1377 else: |
1362 return super().stopAccessPoint() |
1378 return super().stopAccessPoint() |
1363 |
1379 |
|
1380 def getSecurityModes(self): |
|
1381 """ |
|
1382 Public method to get a list of security modes supported by the device. |
|
1383 |
|
1384 @return list of supported security modes |
|
1385 @rtype list of str |
|
1386 """ |
|
1387 if self._deviceData["wifi_type"] == "picowireless": |
|
1388 # Pimoroni picowireless supports just WPA2 in AP mode. |
|
1389 return ["SEC_WPA2"] |
|
1390 else: |
|
1391 return super().getSecurityModes() |
|
1392 |
1364 def getConnectedClients(self): |
1393 def getConnectedClients(self): |
1365 """ |
1394 """ |
1366 Public method to get a list of connected clients. |
1395 Public method to get a list of connected clients. |
1367 |
1396 |
1368 @return a tuple containing a list of tuples containing the client MAC-Address |
1397 @return a tuple containing a list of tuples containing the client MAC-Address |