Explorar o código

Give the user more information when using WiFi

Inform the user about these case:
 - A NEx.hda is set up but no WiFi SSID in ini is set
 - A SSID is set in ini but no NEx.hda exist on the SD card
 - Inform the user when WiFi authentication has failed
 - Inform the user when no SSID is found
 - Inform the user when connected but no IP is given
 - Inform the user when a general WiFi failure occurs
 - Reword "BlueSCSI Toolbox enabled = 0/1" to "BlueSCSI Toolbox enabled/disabled"
J. Morio Sakaguchi hai 2 meses
pai
achega
7d566b844c

+ 28 - 7
lib/BlueSCSI_platform_RP2MCU/BlueSCSI_platform_network.cpp

@@ -142,11 +142,7 @@ bool platform_network_wifi_join(char *ssid, char *password)
 		ret = cyw43_arch_wifi_connect_async(ssid, password, CYW43_AUTH_WPA2_MIXED_PSK);
 	}
 
-	if (ret != 0)
-	{
-		logmsg("Wi-Fi connection failed: ", ret);
-	}
-	else
+	if (ret == 0)
 	{
 		// Short single blink at start of connection sequence
 		PICO_W_LED_OFF();
@@ -155,17 +151,42 @@ bool platform_network_wifi_join(char *ssid, char *password)
 		delay(PICO_W_SHORT_BLINK_DELAY);
 		PICO_W_LED_OFF();
 	}
-	
+	else
+	{
+		logmsg("Error occurred starting the Wi-Fi interface to SSID ", ssid);
+	}
 	return (ret == 0);
 }
 
 void platform_network_poll()
 {
+	static int last_network_status = CYW43_LINK_DOWN;
 	if (!network_in_use)
 		return;
-
+	int status = cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA);
+	char * ssid = scsiDev.boardCfg.wifiSSID;
+	if ((last_network_status != status) && (status == CYW43_LINK_BADAUTH || status == CYW43_LINK_NONET || status == CYW43_LINK_FAIL || status == CYW43_LINK_NOIP))
+	{
+		switch (status)
+		{
+			case CYW43_LINK_NOIP:
+				logmsg("WiFi connected to ", ssid, " but was not assigned in an IP");
+				break;
+			case CYW43_LINK_BADAUTH:
+				logmsg("Wi-Fi authentication failure connecting to \"", ssid, "\", please check the setting \"WiFiPassword\" in ", CONFIGFILE);
+				break;
+			case CYW43_LINK_NONET:
+				logmsg("Wi-Fi SSID ", ssid, " not found, possible of out range or down");
+				break;
+			case CYW43_LINK_FAIL:
+				logmsg("WiFi connection to ", ssid, " failed");
+				break;
+		}
+		last_network_status = status;
+	}
 	scsiNetworkPurge();
 	cyw43_arch_poll();
+
 }
 
 int platform_network_send(uint8_t *buf, size_t len)

+ 6 - 1
src/BlueSCSI.cpp

@@ -850,7 +850,7 @@ static void reinitSCSI()
   scsiInit();
 
 #ifdef BLUESCSI_NETWORK
-  if (platform_network_supported()) {
+  if (scsiDiskCheckAnyNetworkDevicesConfigured() && platform_network_supported()) {
     if (scsiDiskCheckAnyNetworkDevicesConfigured())
     {
       platform_network_init(scsiDev.boardCfg.wifiMACAddress);
@@ -861,6 +861,11 @@ static void reinitSCSI()
     }
     else
     {
+      if (platform_network_supported() && scsiDev.boardCfg.wifiSSID[0] != '\0')
+      {
+        logmsg("Wi-Fi SSID specified as \"", scsiDev.boardCfg.wifiSSID, "\", but no SCSI ID assigned to a network device");
+        logmsg("Please create an empty file \"NEx.hda\", where x is the SCSI ID of the network device, on the SD card");
+      }
       platform_network_deinit();
     }
   }

+ 1 - 1
src/BlueSCSI_Toolbox.cpp

@@ -35,7 +35,7 @@ extern "C" int8_t scsiToolboxEnabled()
     if (enabled == -1)
     {
         enabled = ini_getbool("SCSI", "EnableToolbox", 1, CONFIGFILE);
-        dbgmsg("BlueSCSI Toolbox enabled = ", enabled);
+        dbgmsg("BlueSCSI Toolbox enabled = ", enabled == 1 ? "enabled" : "disabled");
     }
     return enabled == 1;
 }

+ 1 - 0
src/BlueSCSI_disk.cpp

@@ -1426,6 +1426,7 @@ void s2s_configInit(S2S_BoardCfg* config)
     ini_gets("SCSI", "WiFiSSID", "", tmp, sizeof(tmp), CONFIGFILE);
     if (tmp[0]) memcpy(config->wifiSSID, tmp, sizeof(config->wifiSSID));
 
+
     memset(tmp, 0, sizeof(tmp));
     ini_gets("SCSI", "WiFiPassword", "", tmp, sizeof(tmp), CONFIGFILE);
     if (tmp[0]) memcpy(config->wifiPassword, tmp, sizeof(config->wifiPassword));