Skip to content

Commit 5b2a9f6

Browse files
committed
ac: add SSID-related ac:i functions
ACI_LoadNetworkSetting and ACI_GetNetworkWirelessEssidSecuritySsid, plus acGetSessionHandle.
1 parent 0f09885 commit 5b2a9f6

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

  • libctru
    • include/3ds/services
    • source/services

libctru/include/3ds/services/ac.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Result acInit(void);
2727
/// Exits AC.
2828
void acExit(void);
2929

30+
/// Gets the current AC session handle.
31+
Handle *acGetSessionHandle(void);
32+
3033
/// Waits for the system to connect to the internet.
3134
Result acWaitInternetConnection(void);
3235

@@ -128,3 +131,15 @@ Result ACU_SetRequestEulaVersion(acuConfig* config);
128131
* @param connectionHandle Handle created with svcCreateEvent to wait on until the connection succeeds or fails.
129132
*/
130133
Result ACU_ConnectAsync(const acuConfig* config, Handle connectionHandle);
134+
135+
/**
136+
* @brief Selects the WiFi configuration slot for further ac:i operations.
137+
* @param slot WiFi slot (0, 1 or 2).
138+
*/
139+
Result ACI_LoadNetworkSetting(u32 slot);
140+
141+
/**
142+
* @brief Fetches the SSID of the previously selected WiFi configuration slot.
143+
* @param[out] ssid Pointer to the output buffer of size 32B the SSID will be stored in.
144+
*/
145+
Result ACI_GetNetworkWirelessEssidSecuritySsid(void *ssid);

libctru/source/services/ac.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <3ds/synchronization.h>
77
#include <3ds/services/ac.h>
88
#include <3ds/ipc.h>
9+
#include <string.h>
910

1011
static Handle acHandle;
1112
static int acRefCount;
@@ -30,6 +31,11 @@ void acExit(void)
3031
svcCloseHandle(acHandle);
3132
}
3233

34+
Handle *acGetSessionHandle(void)
35+
{
36+
return &acHandle;
37+
}
38+
3339
Result acWaitInternetConnection(void)
3440
{
3541
Result ret = 0;
@@ -284,3 +290,36 @@ Result ACU_GetProxyUserName(char *username)
284290

285291
return (Result)cmdbuf[1];
286292
}
293+
294+
Result ACI_LoadNetworkSetting(u32 slot)
295+
{
296+
u32 *cmdbuf = getThreadCommandBuffer();
297+
298+
cmdbuf[0] = IPC_MakeHeader(0x401,1,0); // 0x04010040
299+
cmdbuf[1] = slot;
300+
301+
Result ret = 0;
302+
if(R_FAILED(ret = svcSendSyncRequest(acHandle))) return ret;
303+
304+
return (Result)cmdbuf[1];
305+
}
306+
307+
Result ACI_GetNetworkWirelessEssidSecuritySsid(void *ssid)
308+
{
309+
u32* cmdbuf = getThreadCommandBuffer();
310+
u32* staticbufs = getThreadStaticBuffers();
311+
312+
cmdbuf[0] = IPC_MakeHeader(0x40F,0,0); // 0x040F0000
313+
314+
u32 staticbufBackup[2];
315+
memcpy(staticbufBackup, staticbufs, 8);
316+
317+
staticbufs[0] = IPC_Desc_StaticBuffer(0x20, 0); // at most 32 bytes
318+
staticbufs[1] = (u32)ssid;
319+
320+
Result ret = svcSendSyncRequest(acHandle);
321+
322+
memcpy(staticbufs, staticbufBackup, 8);
323+
324+
return R_SUCCEEDED(ret) ? (Result)cmdbuf[1] : ret;
325+
}

0 commit comments

Comments
 (0)