mirror of
https://github.com/XorTroll/uLaunch
synced 2024-11-23 04:13:18 +00:00
Add MAC address too
This commit is contained in:
parent
7bf7fb9c8e
commit
34201ba020
4 changed files with 84 additions and 21 deletions
|
@ -9,4 +9,7 @@ namespace net
|
|||
Result GetInternetConnectionStatus(NifmInternetConnectionStatus* status);
|
||||
bool HasConnection();
|
||||
Result GetCurrentNetworkProfile(NetworkProfileData *data);
|
||||
Result GetMACAddress(u64 *out);
|
||||
|
||||
std::string FormatMACAddress(u64 addr);
|
||||
}
|
|
@ -9,44 +9,49 @@ namespace net
|
|||
Result Initialize()
|
||||
{
|
||||
if(serviceIsActive(&nifmsrv)) return 0;
|
||||
auto rc = smGetService(&nifmsrv, "nifm:u");
|
||||
auto rc = wlaninfInitialize();
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
if(serviceIsActive(&nifmgeneralsrv)) serviceClose(&nifmgeneralsrv);
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 cmdid;
|
||||
} *in = (decltype(in))ipcPrepareHeader(&c, sizeof(*in));
|
||||
in->magic = SFCI_MAGIC;
|
||||
in->cmdid = 4;
|
||||
|
||||
auto rc = serviceIpcDispatch(&nifmsrv);
|
||||
rc = smGetService(&nifmsrv, "nifm:u");
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
if(serviceIsActive(&nifmgeneralsrv)) serviceClose(&nifmgeneralsrv);
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 res;
|
||||
} *res = (decltype(res))r.Raw;
|
||||
u64 cmdid;
|
||||
} *in = (decltype(in))ipcPrepareHeader(&c, sizeof(*in));
|
||||
in->magic = SFCI_MAGIC;
|
||||
in->cmdid = 4;
|
||||
|
||||
rc = res->res;
|
||||
auto rc = serviceIpcDispatch(&nifmsrv);
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
serviceCreate(&nifmgeneralsrv, r.Handles[0]);
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 res;
|
||||
} *res = (decltype(res))r.Raw;
|
||||
|
||||
rc = res->res;
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
serviceCreate(&nifmgeneralsrv, r.Handles[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
void Finalize()
|
||||
{
|
||||
wlaninfExit();
|
||||
if(serviceIsActive(&nifmgeneralsrv)) serviceClose(&nifmgeneralsrv);
|
||||
if(serviceIsActive(&nifmsrv)) serviceClose(&nifmsrv);
|
||||
}
|
||||
|
@ -114,4 +119,54 @@ namespace net
|
|||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result GetMACAddress(u64 *out)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
auto srv = wlaninfGetServiceSession();
|
||||
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 cmdid;
|
||||
} *raw = (decltype(raw))ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmdid = 2;
|
||||
|
||||
auto rc = serviceIpcDispatch(srv);
|
||||
if(R_SUCCEEDED(rc))
|
||||
{
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct
|
||||
{
|
||||
u64 magic;
|
||||
u64 res;
|
||||
u64 mac;
|
||||
} *res = (decltype(res))r.Raw;
|
||||
|
||||
rc = res->res;
|
||||
if(R_SUCCEEDED(rc)) *out = res->mac;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
std::string FormatMACAddress(u64 addr)
|
||||
{
|
||||
std::stringstream strm;
|
||||
strm << std::hex << std::uppercase << addr;
|
||||
std::string str;
|
||||
auto sstrm = strm.str();
|
||||
for(u32 i = 0; i < 6; i++)
|
||||
{// AABBCCDDEEFF
|
||||
str += sstrm.substr(i * 2, 2);
|
||||
if(i < 5) str += ":";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
|
@ -84,6 +84,7 @@
|
|||
"set_usb_30": "USB 3.0 enabled",
|
||||
"set_nfc": "NFC enabled (amiibo)",
|
||||
"set_serial_no": "Console serial number",
|
||||
"set_mac_addr": "MAC address",
|
||||
"swkbd_console_nick_guide": "Enter new console nickname",
|
||||
"set_enable_conf": "Do you want to enable it?",
|
||||
"set_disable_conf": "Do you want to disable it?",
|
||||
|
|
|
@ -110,6 +110,10 @@ namespace ui
|
|||
char serial[0x20] = {0};
|
||||
setsysGetSerialNumber(serial);
|
||||
this->PushSettingItem(cfg::GetLanguageString(config.main_lang, config.default_lang, "set_serial_no"), EncodeForSettings<std::string>(serial), -1);
|
||||
u64 mac = 0;
|
||||
net::GetMACAddress(&mac);
|
||||
auto strmac = net::FormatMACAddress(mac);
|
||||
this->PushSettingItem(cfg::GetLanguageString(config.main_lang, config.default_lang, "set_mac_addr"), EncodeForSettings(strmac), -1);
|
||||
}
|
||||
|
||||
void SettingsMenuLayout::PushSettingItem(std::string name, std::string value_display, int id)
|
||||
|
|
Loading…
Reference in a new issue