Added code for using the ac:u service.

This commit is contained in:
yellows8 2014-04-21 22:58:05 -04:00
parent 9fcca821fe
commit a3be8c58b3
2 changed files with 95 additions and 0 deletions

8
libctru/include/ctr/AC.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef AC_H
#define AC_H
Result ACU_GetWifiStatus(Handle servhandle, u32 *out);
Result ACU_WaitInternetConnection();
#endif

87
libctru/source/AC.c Normal file
View File

@ -0,0 +1,87 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctr/types.h>
#include <ctr/AC.h>
#include <ctr/svc.h>
#include <ctr/srv.h>
Result ACU_cmd1(Handle servhandle, u32 *ptr)//Unknown what this cmd does at the time of writing. (ptr=0x200-byte outbuf)
{
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;
if((ret = svc_sendSyncRequest(servhandle))!=0)return ret;
cmdbuf[0x100>>2] = tmp0;
cmdbuf[0x104>>2] = tmp1;
return (Result)cmdbuf[1];
}
Result ACU_cmd26(Handle servhandle, u32 *ptr, u8 val)//Unknown what this cmd does at the time of writing. (ptr=0x200-byte inbuf/outbuf)
{
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;
if((ret = svc_sendSyncRequest(servhandle))!=0)return ret;
cmdbuf[0x100>>2] = tmp0;
cmdbuf[0x104>>2] = tmp1;
return (Result)cmdbuf[1];
}
Result ACU_GetWifiStatus(Handle servhandle, u32 *out)
{
Result ret=0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x000D0000;
if((ret = svc_sendSyncRequest(servhandle))!=0)return ret;
*out = cmdbuf[2];
return (Result)cmdbuf[1];
}
Result ACU_WaitInternetConnection()
{
Handle servhandle = 0;
Result ret=0;
u32 outval=0;
if((ret = srv_getServiceHandle(NULL, &servhandle, "ac:u"))!=0)return ret;
while(1)
{
ret = ACU_GetWifiStatus(servhandle, &outval);
if(ret==0 && outval==1)break;
}
svc_closeHandle(servhandle);
return ret;
}