ac.h
Go to the documentation of this file.
/**
* @file ac.h
* @brief AC service.
*/
#pragma once
#include <3ds/types.h>
/// Wifi security modes.
typedef enum {
AC_OPEN = 0, ///< Open authentication.
AC_WEP_40BIT = 1, ///< WEP 40-bit authentication.
AC_WEP_104BIT = 2, ///< WEP 104-bit authentication.
AC_WEP_128BIT = 3, ///< WEP 128-bit authentication.
AC_WPA_TKIP = 4, ///< WPA TKIP authentication.
AC_WPA2_TKIP = 5, ///< WPA2 TKIP authentication.
AC_WPA_AES = 6, ///< WPA AES authentication.
AC_WPA2_AES = 7, ///< WPA2 AES authentication.
} acSecurityMode;
/// Wifi access point types (bitfield).
enum {
AC_AP_TYPE_NONE = 0, ///< No access point/none allowed.
AC_AP_TYPE_SLOT1 = BIT(1), ///< Slot 1 in System Settings.
AC_AP_TYPE_SLOT2 = BIT(2), ///< Slot 2 in System Settings.
AC_AP_TYPE_SLOT3 = BIT(3), ///< Slot 3 in System Settings.
AC_AP_TYPE_ALL = 0x7FFFFFFF, ///< All access point types allowed.
};
/// Struct to contain the data for connecting to a Wifi network from a stored slot.
typedef struct {
u8 reserved[0x200];
} acuConfig;
/// Initializes AC.
Result acInit(void);
/// Exits AC.
void acExit(void);
/// Gets the current AC session handle.
Handle *acGetSessionHandle(void);
/// Waits for the system to connect to the internet.
Result acWaitInternetConnection(void);
/**
* @brief Describes the access point the console is currently connected to with AC_AP_TYPE_* flags.
* @param out Pointer to output the combination of AC_AP_TYPE_* flags describing the AP to.
*/
Result ACU_GetWifiStatus(u32 *out);
/**
* @brief Gets the connected Wifi status.
* @param out Pointer to output the connected Wifi status to. (1 = not connected, 3 = connected)
*/
Result ACU_GetStatus(u32 *out);
/**
* @brief Gets the connected Wifi security mode.
* @param mode Pointer to output the connected Wifi security mode to. (0 = Open Authentication, 1 = WEP 40-bit, 2 = WEP 104-bit, 3 = WEP 128-bit, 4 = WPA TKIP, 5 = WPA2 TKIP, 6 = WPA AES, 7 = WPA2 AES)
*/
Result ACU_GetSecurityMode(acSecurityMode *mode);
/**
* @brief Gets the connected Wifi SSID.
* @param SSID Pointer to output the connected Wifi SSID to.
*/
Result ACU_GetSSID(char *SSID);
/**
* @brief Gets the connected Wifi SSID length.
* @param out Pointer to output the connected Wifi SSID length to.
*/
Result ACU_GetSSIDLength(u32 *out);
/**
* @brief Determines whether proxy is enabled for the connected network.
* @param enable Pointer to output the proxy status to.
*/
Result ACU_GetProxyEnable(bool *enable);
/**
* @brief Gets the connected network's proxy port.
* @param out Pointer to output the proxy port to.
*/
Result ACU_GetProxyPort(u32 *out);
/**
* @brief Gets the connected network's proxy username.
* @param username Pointer to output the proxy username to. (The size must be at least 0x20-bytes)
*/
Result ACU_GetProxyUserName(char *username);
/**
* @brief Gets the connected network's proxy password.
* @param password Pointer to output the proxy password to. (The size must be at least 0x20-bytes)
*/
Result ACU_GetProxyPassword(char *password);
/**
* @brief Gets the last error to occur during a connection.
* @param errorCode Pointer to output the error code to.
*/
Result ACU_GetLastErrorCode(u32* errorCode);
/**
* @brief Gets the last detailed error to occur during a connection.
* @param errorCode Pointer to output the error code to.
*/
Result ACU_GetLastDetailErrorCode(u32* errorCode);
/**
* @brief Prepares a buffer to hold the configuration data to start a connection.
* @param config Pointer to an acuConfig struct to contain the data.
*/
Result ACU_CreateDefaultConfig(acuConfig* config);
/**
* @brief Sets something that makes the connection reliable.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
* @param area Always 2 ?
*/
Result ACU_SetNetworkArea(acuConfig* config, u8 area);
/**
* @brief Sets the slot to use when connecting.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
* @param type Allowed AP types bitmask, a combination of AC_AP_TYPE_* flags.
*/
Result ACU_SetAllowApType(acuConfig* config, u8 type);
/**
* @brief Sets something that makes the connection reliable.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
*/
Result ACU_SetRequestEulaVersion(acuConfig* config);
/**
* @brief Starts the connection procedure.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
* @param connectionHandle Handle created with svcCreateEvent to wait on until the connection succeeds or fails.
*/
Result ACU_ConnectAsync(const acuConfig* config, Handle connectionHandle);
/**
* @brief Selects the WiFi configuration slot for further ac:i operations.
* @param slot WiFi slot (0, 1 or 2).
*/
Result ACI_LoadNetworkSetting(u32 slot);
/**
* @brief Fetches the SSID of the previously selected WiFi configuration slot.
* @param[out] ssid Pointer to the output buffer of size 32B the SSID will be stored in.
*/
Result ACI_GetNetworkWirelessEssidSecuritySsid(void *ssid);
ACU_GetSSID
Result ACU_GetSSID(char *SSID)
Gets the connected Wifi SSID.
ACU_GetSSIDLength
Result ACU_GetSSIDLength(u32 *out)
Gets the connected Wifi SSID length.
AC_AP_TYPE_SLOT3
@ AC_AP_TYPE_SLOT3
Slot 3 in System Settings.
Definition: ac.h:26
AC_AP_TYPE_NONE
@ AC_AP_TYPE_NONE
No access point/none allowed.
Definition: ac.h:23
AC_AP_TYPE_SLOT2
@ AC_AP_TYPE_SLOT2
Slot 2 in System Settings.
Definition: ac.h:25
AC_AP_TYPE_ALL
@ AC_AP_TYPE_ALL
All access point types allowed.
Definition: ac.h:28
AC_AP_TYPE_SLOT1
@ AC_AP_TYPE_SLOT1
Slot 1 in System Settings.
Definition: ac.h:24
acGetSessionHandle
Handle * acGetSessionHandle(void)
Gets the current AC session handle.
ACU_ConnectAsync
Result ACU_ConnectAsync(const acuConfig *config, Handle connectionHandle)
Starts the connection procedure.
ACU_GetProxyUserName
Result ACU_GetProxyUserName(char *username)
Gets the connected network's proxy username.
ACU_SetRequestEulaVersion
Result ACU_SetRequestEulaVersion(acuConfig *config)
Sets something that makes the connection reliable.
ACU_GetSecurityMode
Result ACU_GetSecurityMode(acSecurityMode *mode)
Gets the connected Wifi security mode.
ACU_GetWifiStatus
Result ACU_GetWifiStatus(u32 *out)
Describes the access point the console is currently connected to with AC_AP_TYPE_* flags.
ACU_GetProxyEnable
Result ACU_GetProxyEnable(bool *enable)
Determines whether proxy is enabled for the connected network.
acWaitInternetConnection
Result acWaitInternetConnection(void)
Waits for the system to connect to the internet.
ACU_GetLastDetailErrorCode
Result ACU_GetLastDetailErrorCode(u32 *errorCode)
Gets the last detailed error to occur during a connection.
ACU_GetProxyPassword
Result ACU_GetProxyPassword(char *password)
Gets the connected network's proxy password.
ACI_LoadNetworkSetting
Result ACI_LoadNetworkSetting(u32 slot)
Selects the WiFi configuration slot for further ac:i operations.
acSecurityMode
acSecurityMode
Wifi security modes.
Definition: ac.h:10
AC_WPA_TKIP
@ AC_WPA_TKIP
WPA TKIP authentication.
Definition: ac.h:15
AC_WPA2_AES
@ AC_WPA2_AES
WPA2 AES authentication.
Definition: ac.h:18
AC_WPA_AES
@ AC_WPA_AES
WPA AES authentication.
Definition: ac.h:17
AC_WEP_128BIT
@ AC_WEP_128BIT
WEP 128-bit authentication.
Definition: ac.h:14
AC_WPA2_TKIP
@ AC_WPA2_TKIP
WPA2 TKIP authentication.
Definition: ac.h:16
AC_OPEN
@ AC_OPEN
Open authentication.
Definition: ac.h:11
AC_WEP_104BIT
@ AC_WEP_104BIT
WEP 104-bit authentication.
Definition: ac.h:13
AC_WEP_40BIT
@ AC_WEP_40BIT
WEP 40-bit authentication.
Definition: ac.h:12
ACU_GetProxyPort
Result ACU_GetProxyPort(u32 *out)
Gets the connected network's proxy port.
ACU_CreateDefaultConfig
Result ACU_CreateDefaultConfig(acuConfig *config)
Prepares a buffer to hold the configuration data to start a connection.
ACU_GetStatus
Result ACU_GetStatus(u32 *out)
Gets the connected Wifi status.
acExit
void acExit(void)
Exits AC.
ACU_SetNetworkArea
Result ACU_SetNetworkArea(acuConfig *config, u8 area)
Sets something that makes the connection reliable.
ACI_GetNetworkWirelessEssidSecuritySsid
Result ACI_GetNetworkWirelessEssidSecuritySsid(void *ssid)
Fetches the SSID of the previously selected WiFi configuration slot.
ACU_SetAllowApType
Result ACU_SetAllowApType(acuConfig *config, u8 type)
Sets the slot to use when connecting.
ACU_GetLastErrorCode
Result ACU_GetLastErrorCode(u32 *errorCode)
Gets the last error to occur during a connection.
acInit
Result acInit(void)
Initializes AC.
errorCode
void errorCode(errorConf *err, int error)
Sets error code to display.
acuConfig
Struct to contain the data for connecting to a Wifi network from a stored slot.
Definition: ac.h:32
types.h
Various system types.
BIT
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
u8
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
Handle
u32 Handle
Resource handle.
Definition: types.h:41
Result
s32 Result
Function result.
Definition: types.h:42
u32
uint32_t u32
32-bit unsigned integer
Definition: types.h:23