2014-04-22 04:58:05 +02:00
|
|
|
#include <stdlib.h>
|
2014-12-13 17:36:54 +01:00
|
|
|
#include <3ds/types.h>
|
|
|
|
#include <3ds/svc.h>
|
|
|
|
#include <3ds/srv.h>
|
|
|
|
#include <3ds/services/ac.h>
|
2014-04-22 04:58:05 +02:00
|
|
|
|
2014-08-25 18:14:48 +02:00
|
|
|
static Handle acHandle;
|
|
|
|
|
2015-09-06 18:13:31 +02:00
|
|
|
Result acInit(void)
|
2014-08-25 18:14:48 +02:00
|
|
|
{
|
2015-07-16 08:40:11 +02:00
|
|
|
Result ret = srvGetServiceHandle(&acHandle, "ac:u");
|
|
|
|
if(!ret)return ret;
|
|
|
|
return srvGetServiceHandle(&acHandle, "ac:i");
|
2014-08-25 18:14:48 +02:00
|
|
|
}
|
|
|
|
|
2015-09-06 18:13:31 +02:00
|
|
|
Result acExit(void)
|
2014-08-25 18:14:48 +02:00
|
|
|
{
|
|
|
|
return svcCloseHandle(acHandle);
|
|
|
|
}
|
|
|
|
|
2014-08-21 19:25:36 +02:00
|
|
|
// ptr=0x200-byte outbuf
|
2014-08-25 18:14:48 +02:00
|
|
|
Result ACU_CreateDefaultConfig(Handle* servhandle, u32 *ptr)
|
2014-04-22 04:58:05 +02:00
|
|
|
{
|
2014-08-25 18:14:48 +02:00
|
|
|
if(!servhandle)servhandle=&acHandle;
|
2014-04-22 04:58:05 +02:00
|
|
|
u32 tmp0, tmp1;
|
|
|
|
Result ret=0;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
|
|
|
|
|
|
|
tmp0 = cmdbuf[0x100>>2];
|
|
|
|
tmp1 = cmdbuf[0x104>>2];
|
|
|
|
|
|
|
|
cmdbuf[0] = 0x00010000;
|
|
|
|
cmdbuf[0x100>>2] = 0x00800002;
|
|
|
|
cmdbuf[0x104>>2] = (u32)ptr;
|
|
|
|
|
2014-08-25 18:14:48 +02:00
|
|
|
if((ret = svcSendSyncRequest(*servhandle))!=0)return ret;
|
2014-04-22 04:58:05 +02:00
|
|
|
|
|
|
|
cmdbuf[0x100>>2] = tmp0;
|
|
|
|
cmdbuf[0x104>>2] = tmp1;
|
|
|
|
|
|
|
|
return (Result)cmdbuf[1];
|
|
|
|
}
|
|
|
|
|
2014-08-21 19:25:36 +02:00
|
|
|
// Unknown what this cmd does at the time of writing. (ptr=0x200-byte inbuf/outbuf)
|
2014-08-25 18:14:48 +02:00
|
|
|
Result ACU_cmd26(Handle* servhandle, u32 *ptr, u8 val)
|
2014-04-22 04:58:05 +02:00
|
|
|
{
|
2014-08-25 18:14:48 +02:00
|
|
|
if(!servhandle)servhandle=&acHandle;
|
2014-04-22 04:58:05 +02:00
|
|
|
u32 tmp0, tmp1;
|
|
|
|
Result ret=0;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
|
|
|
|
|
|
|
tmp0 = cmdbuf[0x100>>2];
|
|
|
|
tmp1 = cmdbuf[0x104>>2];
|
|
|
|
|
|
|
|
cmdbuf[0] = 0x00260042;
|
|
|
|
cmdbuf[1] = (u32)val;
|
|
|
|
cmdbuf[0x100>>2] = 0x00800002;
|
|
|
|
cmdbuf[0x104>>2] = (u32)ptr;
|
|
|
|
cmdbuf[2] = 0x00800002;
|
|
|
|
cmdbuf[3] = (u32)ptr;
|
|
|
|
|
2014-08-25 18:14:48 +02:00
|
|
|
if((ret = svcSendSyncRequest(*servhandle))!=0)return ret;
|
2014-04-22 04:58:05 +02:00
|
|
|
|
|
|
|
cmdbuf[0x100>>2] = tmp0;
|
|
|
|
cmdbuf[0x104>>2] = tmp1;
|
|
|
|
|
|
|
|
return (Result)cmdbuf[1];
|
|
|
|
}
|
|
|
|
|
2014-08-25 18:14:48 +02:00
|
|
|
Result ACU_GetWifiStatus(Handle* servhandle, u32 *out)
|
2014-04-22 04:58:05 +02:00
|
|
|
{
|
2014-08-25 18:14:48 +02:00
|
|
|
if(!servhandle)servhandle=&acHandle;
|
2014-04-22 04:58:05 +02:00
|
|
|
Result ret=0;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
|
|
|
|
|
|
|
cmdbuf[0] = 0x000D0000;
|
|
|
|
|
2014-08-25 18:14:48 +02:00
|
|
|
if((ret = svcSendSyncRequest(*servhandle))!=0)return ret;
|
2014-04-22 04:58:05 +02:00
|
|
|
|
|
|
|
*out = cmdbuf[2];
|
|
|
|
|
|
|
|
return (Result)cmdbuf[1];
|
|
|
|
}
|
|
|
|
|
2015-09-06 18:13:31 +02:00
|
|
|
Result ACU_WaitInternetConnection(void)
|
2014-04-22 04:58:05 +02:00
|
|
|
{
|
|
|
|
Handle servhandle = 0;
|
|
|
|
Result ret=0;
|
|
|
|
u32 outval=0;
|
|
|
|
|
2014-07-28 23:23:24 +02:00
|
|
|
if((ret = srvGetServiceHandle(&servhandle, "ac:u"))!=0)return ret;
|
2014-04-22 04:58:05 +02:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2014-08-25 18:14:48 +02:00
|
|
|
ret = ACU_GetWifiStatus(&servhandle, &outval);
|
2015-05-26 19:49:37 +02:00
|
|
|
if(ret==0 && outval!=0)break;
|
2014-04-22 04:58:05 +02:00
|
|
|
}
|
|
|
|
|
2014-07-28 20:58:47 +02:00
|
|
|
svcCloseHandle(servhandle);
|
2014-04-22 04:58:05 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|