mirror of
https://github.com/mtheall/ftpd.git
synced 2024-11-23 09:39:43 +00:00
3DS: Keep wifi alive when lid is closed
This commit is contained in:
parent
49535886fa
commit
16c59354da
@ -3,7 +3,7 @@
|
|||||||
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
|
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
|
||||||
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
|
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
|
||||||
//
|
//
|
||||||
// Copyright (C) 2020 Michael Theall
|
// Copyright (C) 2022 Michael Theall
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
@ -63,6 +63,9 @@ constexpr auto SOCU_BUFFERSIZE = 0x100000;
|
|||||||
|
|
||||||
static_assert (SOCU_BUFFERSIZE % SOCU_ALIGN == 0);
|
static_assert (SOCU_BUFFERSIZE % SOCU_ALIGN == 0);
|
||||||
|
|
||||||
|
/// \brief Whether ndm:u is locked
|
||||||
|
bool s_ndmuLocked = false;
|
||||||
|
|
||||||
/// \brief Whether soc:u is active
|
/// \brief Whether soc:u is active
|
||||||
std::atomic<bool> s_socuActive = false;
|
std::atomic<bool> s_socuActive = false;
|
||||||
/// \brief soc:u buffer
|
/// \brief soc:u buffer
|
||||||
@ -209,8 +212,22 @@ void startNetwork ()
|
|||||||
if (R_FAILED (socInit (s_socuBuffer, SOCU_BUFFERSIZE)))
|
if (R_FAILED (socInit (s_socuBuffer, SOCU_BUFFERSIZE)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
aptSetSleepAllowed (false);
|
||||||
|
|
||||||
|
Result res;
|
||||||
|
if (R_FAILED (res = NDMU_EnterExclusiveState(NDM_EXCLUSIVE_STATE_INFRASTRUCTURE)))
|
||||||
|
error ("Failed to enter exclusive NDM state: 0x%lx\n", res);
|
||||||
|
else if (R_FAILED (res = NDMU_LockState ()))
|
||||||
|
{
|
||||||
|
error ("Failed to lock NDM: 0x%lx\n", res);
|
||||||
|
NDMU_LeaveExclusiveState ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
s_ndmuLocked = true;
|
||||||
|
|
||||||
s_socuActive = true;
|
s_socuActive = true;
|
||||||
info ("Wifi connected\n");
|
info ("Wifi connected\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Draw citro3d logo
|
/// \brief Draw citro3d logo
|
||||||
@ -349,6 +366,7 @@ bool platform::init ()
|
|||||||
osSetSpeedupEnable (true);
|
osSetSpeedupEnable (true);
|
||||||
|
|
||||||
acInit ();
|
acInit ();
|
||||||
|
ndmuInit ();
|
||||||
ptmuInit ();
|
ptmuInit ();
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
romfsInit ();
|
romfsInit ();
|
||||||
@ -533,9 +551,20 @@ void platform::exit ()
|
|||||||
C3D_Fini ();
|
C3D_Fini ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (s_ndmuLocked)
|
||||||
|
{
|
||||||
|
NDMU_UnlockState ();
|
||||||
|
NDMU_LeaveExclusiveState ();
|
||||||
|
aptSetSleepAllowed (true);
|
||||||
|
s_ndmuLocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (s_socuActive)
|
if (s_socuActive)
|
||||||
|
{
|
||||||
socExit ();
|
socExit ();
|
||||||
s_socuActive = false;
|
s_socuActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
std::free (s_socuBuffer);
|
std::free (s_socuBuffer);
|
||||||
|
|
||||||
aptUnhook (&s_aptHookCookie);
|
aptUnhook (&s_aptHookCookie);
|
||||||
@ -549,6 +578,7 @@ void platform::exit ()
|
|||||||
romfsExit ();
|
romfsExit ();
|
||||||
#endif
|
#endif
|
||||||
ptmuExit ();
|
ptmuExit ();
|
||||||
|
ndmuExit ();
|
||||||
acExit ();
|
acExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user