My Project
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
ac.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <3ds.h>
3 
4 static Handle acHandle;
5 
7 {
8  return srvGetServiceHandle(&acHandle, "ac:u");
9 }
10 
12 {
13  return svcCloseHandle(acHandle);
14 }
15 
16 // ptr=0x200-byte outbuf
18 {
19  if(!servhandle)servhandle=&acHandle;
20  u32 tmp0, tmp1;
21  Result ret=0;
22  u32 *cmdbuf = getThreadCommandBuffer();
23 
24  tmp0 = cmdbuf[0x100>>2];
25  tmp1 = cmdbuf[0x104>>2];
26 
27  cmdbuf[0] = 0x00010000;
28  cmdbuf[0x100>>2] = 0x00800002;
29  cmdbuf[0x104>>2] = (u32)ptr;
30 
31  if((ret = svcSendSyncRequest(*servhandle))!=0)return ret;
32 
33  cmdbuf[0x100>>2] = tmp0;
34  cmdbuf[0x104>>2] = tmp1;
35 
36  return (Result)cmdbuf[1];
37 }
38 
39 // Unknown what this cmd does at the time of writing. (ptr=0x200-byte inbuf/outbuf)
40 Result ACU_cmd26(Handle* servhandle, u32 *ptr, u8 val)
41 {
42  if(!servhandle)servhandle=&acHandle;
43  u32 tmp0, tmp1;
44  Result ret=0;
45  u32 *cmdbuf = getThreadCommandBuffer();
46 
47  tmp0 = cmdbuf[0x100>>2];
48  tmp1 = cmdbuf[0x104>>2];
49 
50  cmdbuf[0] = 0x00260042;
51  cmdbuf[1] = (u32)val;
52  cmdbuf[0x100>>2] = 0x00800002;
53  cmdbuf[0x104>>2] = (u32)ptr;
54  cmdbuf[2] = 0x00800002;
55  cmdbuf[3] = (u32)ptr;
56 
57  if((ret = svcSendSyncRequest(*servhandle))!=0)return ret;
58 
59  cmdbuf[0x100>>2] = tmp0;
60  cmdbuf[0x104>>2] = tmp1;
61 
62  return (Result)cmdbuf[1];
63 }
64 
65 Result ACU_GetWifiStatus(Handle* servhandle, u32 *out)
66 {
67  if(!servhandle)servhandle=&acHandle;
68  Result ret=0;
69  u32 *cmdbuf = getThreadCommandBuffer();
70 
71  cmdbuf[0] = 0x000D0000;
72 
73  if((ret = svcSendSyncRequest(*servhandle))!=0)return ret;
74 
75  *out = cmdbuf[2];
76 
77  return (Result)cmdbuf[1];
78 }
79 
81 {
82  Handle servhandle = 0;
83  Result ret=0;
84  u32 outval=0;
85 
86  if((ret = srvGetServiceHandle(&servhandle, "ac:u"))!=0)return ret;
87 
88  while(1)
89  {
90  ret = ACU_GetWifiStatus(&servhandle, &outval);
91  if(ret==0 && outval==1)break;
92  }
93 
94  svcCloseHandle(servhandle);
95 
96  return ret;
97 }
Result ACU_CreateDefaultConfig(Handle *servhandle, u32 *ptr)
Definition: ac.c:17
s32 Result
Definition: types.h:42
s32 svcCloseHandle(Handle handle)
Result srvGetServiceHandle(Handle *out, const char *name)
Definition: srv.c:109
Result ACU_WaitInternetConnection()
Definition: ac.c:80
Result ACU_cmd26(Handle *servhandle, u32 *ptr, u8 val)
Definition: ac.c:40
Result acInit()
Definition: ac.c:6
u32 Handle
Definition: types.h:41
u32 * getThreadCommandBuffer(void)
uint8_t u8
Definition: types.h:21
uint32_t u32
Definition: types.h:23
Result acExit()
Definition: ac.c:11
s32 svcSendSyncRequest(Handle session)
Result ACU_GetWifiStatus(Handle *servhandle, u32 *out)
Definition: ac.c:65