diff --git a/common/netstatus.h b/common/netstatus.h new file mode 100644 index 0000000..ceebc2b --- /dev/null +++ b/common/netstatus.h @@ -0,0 +1,5 @@ +#pragma once +#include "common.h" + +bool netstatusGetDetails(AssetId *id); + diff --git a/nx_main/nx_netstatus.c b/nx_main/nx_netstatus.c new file mode 100644 index 0000000..378e30f --- /dev/null +++ b/nx_main/nx_netstatus.c @@ -0,0 +1,36 @@ +#include "../common/common.h" + +bool netstatusGetDetails(AssetId *id) { + Result rc=0; + NifmInternetConnectionType contype; + u32 wifiStrength=0; + NifmInternetConnectionStatus connectionStatus; + + rc = nifmGetInternetConnectionStatus(&contype, &wifiStrength, &connectionStatus); + if (R_FAILED(rc)) { + *id = AssetId_airplane_icon; + return true; + } + + if (contype == NifmInternetConnectionType_Ethernet) { + if (connectionStatus != NifmInternetConnectionStatus_Connected) + *id = AssetId_eth_none_icon; + else + *id = AssetId_eth_icon; + return true; + } + + if (wifiStrength==0) { + *id = AssetId_wifi_none_icon; + return true; + } + + if (wifiStrength==3) + *id = AssetId_wifi3_icon; + if (wifiStrength==2) + *id = AssetId_wifi2_icon; + else + *id = AssetId_wifi1_icon; + + return true; +} diff --git a/pc_main/pc_netstatus.c b/pc_main/pc_netstatus.c new file mode 100644 index 0000000..dc4e1ab --- /dev/null +++ b/pc_main/pc_netstatus.c @@ -0,0 +1,6 @@ +#include "../common/common.h" + +bool netstatusGetDetails(AssetId *id) { + *id = AssetId_wifi3_icon; + return true; +}