rosalina/sysconfig: fix handling of disconnected routers in wifi forcing + handle leak

This commit is contained in:
TuxSH 2020-04-28 00:05:55 +01:00
parent 7dfa83b8c0
commit 8c54613e44
2 changed files with 10 additions and 8 deletions

View File

@ -32,6 +32,8 @@
extern Menu sysconfigMenu; extern Menu sysconfigMenu;
extern bool isConnectionForced; extern bool isConnectionForced;
void SysConfigMenu_UpdateStatus(bool control);
void SysConfigMenu_ToggleLEDs(void); void SysConfigMenu_ToggleLEDs(void);
void SysConfigMenu_ToggleWireless(void); void SysConfigMenu_ToggleWireless(void);
void SysConfigMenu_TogglePowerButton(void); void SysConfigMenu_TogglePowerButton(void);

View File

@ -151,7 +151,7 @@ void SysConfigMenu_ToggleWireless(void)
while(!terminationRequest); while(!terminationRequest);
} }
static void SysConfigMenu_UpdateStatus(bool control) void SysConfigMenu_UpdateStatus(bool control)
{ {
MenuItem *item = &sysconfigMenu.items[3]; MenuItem *item = &sysconfigMenu.items[3];
@ -170,8 +170,10 @@ static void SysConfigMenu_UpdateStatus(bool control)
static bool SysConfigMenu_ForceWifiConnection(int slot) static bool SysConfigMenu_ForceWifiConnection(int slot)
{ {
char ssid[0x20 + 1] = {0}; char ssid[0x20 + 1] = {0};
isConnectionForced = false;
acInit(); if(R_FAILED(acInit()))
return false;
acuConfig config = {0}; acuConfig config = {0};
ACU_CreateDefaultConfig(&config); ACU_CreateDefaultConfig(&config);
@ -185,13 +187,9 @@ static bool SysConfigMenu_ForceWifiConnection(int slot)
bool forcedConnection = false; bool forcedConnection = false;
if(R_SUCCEEDED(ACU_ConnectAsync(&config, connectEvent))) if(R_SUCCEEDED(ACU_ConnectAsync(&config, connectEvent)))
{ {
if(R_SUCCEEDED(svcWaitSynchronization(connectEvent, -1))) if(R_SUCCEEDED(svcWaitSynchronization(connectEvent, -1)) && R_SUCCEEDED(ACU_GetSSID(ssid)))
{
if(R_FAILED(ACU_GetSSID(ssid)))
ssid[0] = 0;
forcedConnection = true; forcedConnection = true;
} }
}
svcCloseHandle(connectEvent); svcCloseHandle(connectEvent);
if(forcedConnection) if(forcedConnection)
@ -199,6 +197,8 @@ static bool SysConfigMenu_ForceWifiConnection(int slot)
isConnectionForced = true; isConnectionForced = true;
SysConfigMenu_UpdateStatus(false); SysConfigMenu_UpdateStatus(false);
} }
else
acExit();
char infoString[80] = {0}; char infoString[80] = {0};
u32 infoStringColor = forcedConnection ? COLOR_GREEN : COLOR_RED; u32 infoStringColor = forcedConnection ? COLOR_GREEN : COLOR_RED;
@ -349,7 +349,7 @@ void SysConfigMenu_DisableForcedWifiConnection(void)
{ {
Draw_Lock(); Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "System configuration menu"); Draw_DrawString(10, 10, COLOR_TITLE, "System configuration menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Forced connection successfully disabled."); Draw_DrawString(10, 30, COLOR_WHITE, "Forced connection successfully disabled.\nNote: auto-connection may remain broken.");
u32 pressed = waitInputWithTimeout(1000); u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_B) if(pressed & BUTTON_B)