55 0: self.tr("idle"), |
55 0: self.tr("idle"), |
56 1: self.tr("connecting"), |
56 1: self.tr("connecting"), |
57 2: self.tr("connected, waiting for IP address"), |
57 2: self.tr("connected, waiting for IP address"), |
58 3: self.tr("connected"), |
58 3: self.tr("connected"), |
59 }, |
59 }, |
60 "pimoroni": { |
60 "picowireless": { |
61 0: self.tr("idle"), |
61 0: self.tr("idle"), |
62 1: self.tr("no matching access point found"), |
62 1: self.tr("no matching access point found"), |
63 2: self.tr("network scan completed"), |
63 2: self.tr("network scan completed"), |
64 3: self.tr("connected"), |
64 3: self.tr("connected"), |
65 4: self.tr("connection failed"), |
65 4: self.tr("connection failed"), |
68 7: self.tr("AP listening"), |
68 7: self.tr("AP listening"), |
69 8: self.tr("AP connected"), |
69 8: self.tr("AP connected"), |
70 9: self.tr("AP failed"), |
70 9: self.tr("AP failed"), |
71 }, |
71 }, |
72 } |
72 } |
73 # TODO: must be specific (picow, pimoroni) |
73 # TODO: must be specific (picow, picowireless) |
74 self.__securityTranslations = { |
74 self.__securityTranslations = { |
75 "picow": { |
75 "picow": { |
76 0: self.tr("open", "open WiFi network"), |
76 0: self.tr("open", "open WiFi network"), |
77 1: "WEP", |
77 1: "WEP", |
78 2: "WPA", |
78 2: "WPA", |
425 def hasWifi(self): |
425 def hasWifi(self): |
426 """ |
426 """ |
427 Public method to check the availability of WiFi. |
427 Public method to check the availability of WiFi. |
428 |
428 |
429 @return tuple containing a flag indicating the availability of WiFi |
429 @return tuple containing a flag indicating the availability of WiFi |
430 and the WiFi type (picow or pimoroni) |
430 and the WiFi type (picow or picowireless) |
431 @rtype tuple of (bool, str) |
431 @rtype tuple of (bool, str) |
432 @exception OSError raised to indicate an issue with the device |
432 @exception OSError raised to indicate an issue with the device |
433 """ |
433 """ |
434 # picowireless: |
434 # picowireless: |
435 # It seems to take up to 20 sec to detect, that no Pico Wireless Pack is |
435 # It seems to take up to 20 sec to detect, that no Pico Wireless Pack is |
653 """.format( |
653 """.format( |
654 repr(ssid), |
654 repr(ssid), |
655 repr(password if password else ""), |
655 repr(password if password else ""), |
656 repr(country if country else "XX"), |
656 repr(country if country else "XX"), |
657 ) |
657 ) |
658 elif self._deviceData["wifi_type"] == "pimoroni": |
658 elif self._deviceData["wifi_type"] == "picowireless": |
659 command = """ |
659 command = """ |
660 def connect_wifi(ssid, password): |
660 def connect_wifi(ssid, password): |
661 import picowireless as pw |
661 import picowireless as pw |
662 import ujson |
662 import ujson |
663 from time import sleep |
663 from time import sleep |
730 print(not wifi.isconnected()) |
730 print(not wifi.isconnected()) |
731 |
731 |
732 disconnect_wifi() |
732 disconnect_wifi() |
733 del disconnect_wifi |
733 del disconnect_wifi |
734 """ |
734 """ |
735 elif self._deviceData["wifi_type"] == "pimoroni": |
735 elif self._deviceData["wifi_type"] == "picowireless": |
736 command = """ |
736 command = """ |
737 def disconnect_wifi(): |
737 def disconnect_wifi(): |
738 import picowireless as pw |
738 import picowireless as pw |
739 from time import sleep |
739 from time import sleep |
740 |
740 |
798 else: |
798 else: |
799 secrets = "WIFI_SSID = {0}\nWIFI_KEY = {1}\n".format( |
799 secrets = "WIFI_SSID = {0}\nWIFI_KEY = {1}\n".format( |
800 repr(ssid), |
800 repr(ssid), |
801 repr(password) if password else '""', |
801 repr(password) if password else '""', |
802 ) |
802 ) |
803 if self._deviceData["wifi_type"] == "pimoroni": |
803 if self._deviceData["wifi_type"] == "picowireless": |
804 wifiConnectFile = "pimoroniWiFiConnect.py" |
804 wifiConnectFile = "pimoroniWiFiConnect.py" |
805 else: |
805 else: |
806 wifiConnectFile = "mpyWiFiConnect.py" |
806 wifiConnectFile = "mpyWiFiConnect.py" |
807 try: |
807 try: |
808 # write secrets file |
808 # write secrets file |
1077 security, |
1077 security, |
1078 repr(password), |
1078 repr(password), |
1079 ifconfig, |
1079 ifconfig, |
1080 repr(country if country else "XX"), |
1080 repr(country if country else "XX"), |
1081 ) |
1081 ) |
1082 elif self._deviceData["wifi_type"] == "pimoroni": |
1082 elif self._deviceData["wifi_type"] == "picowireless": |
1083 # AP is fixed at channel 6 |
1083 # AP is fixed at channel 6 |
1084 command = """ |
1084 command = """ |
1085 def start_ap(ssid, password): |
1085 def start_ap(ssid, password): |
1086 import picowireless as pw |
1086 import picowireless as pw |
1087 |
1087 |
1119 Public method to stop the access point interface. |
1119 Public method to stop the access point interface. |
1120 |
1120 |
1121 @return tuple containg a flag indicating success and an error message |
1121 @return tuple containg a flag indicating success and an error message |
1122 @rtype tuple of (bool, str) |
1122 @rtype tuple of (bool, str) |
1123 """ |
1123 """ |
1124 if self._deviceData["wifi_type"] in ("picow", "pimoroni"): |
1124 if self._deviceData["wifi_type"] in ("picow", "picowireless"): |
1125 return self.deactivateInterface("AP") |
1125 return self.deactivateInterface("AP") |
1126 else: |
1126 else: |
1127 return super().stopAccessPoint() |
1127 return super().stopAccessPoint() |
1128 |
1128 |
1129 def getConnectedClients(self): |
1129 def getConnectedClients(self): |