mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-27 23:32:39 +02:00
Implemented nifmGetInternetConnectionStatus
This commit is contained in:
parent
b49cb8a1a6
commit
9c016a4cee
@ -16,6 +16,19 @@ typedef enum {
|
||||
NifmServiceType_Admin = 3, ///< Initializes nifm:a.
|
||||
} NifmServiceType;
|
||||
|
||||
typedef enum {
|
||||
NifmInternetConnectionType_WiFi = 1, ///< Wi-Fi connection is used.
|
||||
NifmInternetConnectionType_Ethernet = 2, ///< Ethernet connection is used.
|
||||
} NifmInternetConnectionType;
|
||||
|
||||
typedef enum {
|
||||
NifmInternetConnectionStatus_ConnectingUnknown1 = 0, ///< Unknown internet connection status 1.
|
||||
NifmInternetConnectionStatus_ConnectingUnknown2 = 1, ///< Unknown internet connection status 2.
|
||||
NifmInternetConnectionStatus_ConnectingUnknown3 = 2, ///< Unknown internet connection status 3 (conntest?).
|
||||
NifmInternetConnectionStatus_ConnectingUnknown4 = 3, ///< Unknown internet connection status 4.
|
||||
NifmInternetConnectionStatus_Connected = 4, ///< Internet is connected.
|
||||
} NifmInternetConnectionStatus;
|
||||
|
||||
/**
|
||||
* @brief Sets the \ref NifmServiceType for initialization. Call this function before \ref nifmInitialize.
|
||||
* @note By default nifm:u will be used.
|
||||
@ -34,6 +47,12 @@ Result nifmIsWirelessCommunicationEnabled(bool* out);
|
||||
*/
|
||||
Result nifmSetWirelessCommunicationEnabled(bool enable);
|
||||
|
||||
/**
|
||||
* @note Will fail with 0xd46ed if Internet is neither connecting or connected (airplane mode or no known network in reach).
|
||||
* @param wifiStrength Strength of the Wi-Fi signal in number of bars from 0 to 3.
|
||||
*/
|
||||
Result nifmGetInternetConnectionStatus(NifmInternetConnectionType* connectionType, u32* wifiStrength, NifmInternetConnectionStatus* connectionStatus);
|
||||
|
||||
Result nifmIsEthernetCommunicationEnabled(bool* out);
|
||||
Result nifmIsAnyForegroundRequestAccepted(bool* out);
|
||||
Result nifmPutToSleep(void);
|
||||
|
@ -315,6 +315,54 @@ Result nifmWakeUp(void) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nifmGetInternetConnectionStatus(NifmInternetConnectionType* connectionType, u32* wifiStrength, NifmInternetConnectionStatus* connectionStatus)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_nifmIGS, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 18;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nifmIGS);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 out1;
|
||||
u8 out2;
|
||||
u8 out3;
|
||||
} PACKED *resp;
|
||||
|
||||
serviceIpcParse(&g_nifmIGS, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (connectionType)
|
||||
*connectionType = resp->out1;
|
||||
|
||||
if (wifiStrength)
|
||||
*wifiStrength = resp->out2;
|
||||
|
||||
if (connectionStatus)
|
||||
*connectionStatus = resp->out3;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _nifmCreateGeneralService(Service* out, u64 in) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
Loading…
Reference in New Issue
Block a user