From d1fb56454f01bb859b7fada08f6348d1b35682fb Mon Sep 17 00:00:00 2001 From: Joel16 Date: Thu, 2 Aug 2018 23:10:09 -0500 Subject: [PATCH] Minor console version changes - Now displays wifi mac addrs - Displays card slot - Displays NAND/Original lfcs - Properly get 3dsident version isntead of hardcoded string. --- console/source/main.c | 105 +++++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 38 deletions(-) diff --git a/console/source/main.c b/console/source/main.c index 8b901df..8426c2d 100644 --- a/console/source/main.c +++ b/console/source/main.c @@ -39,26 +39,26 @@ void Init_Services(void) mcuHwcInit(); ptmuInit(); socInit((u32*)memalign(0x1000, 0x10000), 0x10000); - - FS_OpenArchive(&archive, ARCHIVE_SDMC); if (Utils_IsN3DS()) osSetSpeedupEnable(true); APT_GetAppCpuTimeLimit(&cpu_time_limit); APT_SetAppCpuTimeLimit(30); + + FS_OpenArchive(&archive, ARCHIVE_SDMC); } void Term_Services(void) { + FS_CloseArchive(archive); + if (cpu_time_limit != UINT32_MAX) APT_SetAppCpuTimeLimit(cpu_time_limit); if (Utils_IsN3DS()) osSetSpeedupEnable(false); - FS_CloseArchive(archive); - socExit(); ptmuExit(); mcuHwcExit(); @@ -79,6 +79,7 @@ int main(int argc, char *argv[]) //------------------------Variable Declaration-------------------------// //=====================================================================// + Result ret = 0; double wifiPercent = 0, volPercent = 0, _3dSliderPercent = 0; u32 ip = 0; unsigned int principalID = 0; @@ -87,6 +88,8 @@ int main(int argc, char *argv[]) char sdFreeSize[16], sdTotalSize[16], ctrFreeSize[16], ctrTotalSize[16], country[0x3], name[0x16], nnid[0x11], timeZone[0x41]; AccountDataBlock accountDataBlock; bool displayInfo = true; // By default nothing is hidden. + char ssid[0x20], passphrase[0x40]; + wifiSlotStructure slotData; hidScanInput(); u32 kHeld = hidKeysHeld(); @@ -99,12 +102,21 @@ int main(int argc, char *argv[]) //=====================================================================// //------------------------------MISC Info (continued)------------------// //=====================================================================// + + Utils_GetSizeString(sdFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_SD)); + Utils_GetSizeString(sdTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_SD)); + printf("\x1b[36;1m*\x1b[0m SD Size: \x1b[36;1m%s\x1b[0m / \x1b[36;1m%s\x1b[0m \n", sdFreeSize, sdTotalSize); + + Utils_GetSizeString(ctrFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND)); + Utils_GetSizeString(ctrTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND)); + printf("\x1b[36;1m*\x1b[0m CTR Size: \x1b[36;1m%s\x1b[0m / \x1b[36;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize); printf("\x1b[36;1m*\x1b[0m Installed titles: SD: \x1b[36;1m%lu\x1b[0m (NAND: \x1b[36;1m%lu\x1b[0m)\n", Misc_TitleCount(MEDIATYPE_SD), Misc_TitleCount(MEDIATYPE_NAND)); - ip = gethostid(); + char hostname[128]; + ret = gethostname(hostname, sizeof(hostname)); if (displayInfo) - printf("\x1b[36;1m*\x1b[0m IP: \x1b[36;1m%lu.%lu.%lu.%lu\x1b[0m \n\n", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF); + printf("\x1b[36;1m*\x1b[0m IP: \x1b[36;1m%s\x1b[0m \n\n", hostname); else printf("\x1b[36;1m*\x1b[0m IP: \x1b[36;1m%s\x1b[0m \n\n", NULL); @@ -139,41 +151,62 @@ int main(int argc, char *argv[]) if (R_SUCCEEDED(ACI_LoadWiFiSlot(0))) { - char ssid[0x20], passphrase[0x40]; - if (R_SUCCEEDED(ACI_GetSSID(ssid))) printf("\x1b[32;1m*\x1b[0m WiFi 1 SSID: \x1b[32;1m%s\x1b[0m\n", ssid); if (R_SUCCEEDED(ACI_GetPassphrase(passphrase))) printf("\x1b[32;1m*\x1b[0m WiFi 1 pass: \x1b[32;1m%s\x1b[0m\n", displayInfo? passphrase : NULL); - printf("\x1b[32;1m*\x1b[0m WiFi 1 security: \x1b[32;1m%s\x1b[0m\n\n", displayInfo? WiFi_GetSecurityMode() : NULL); + printf("\x1b[32;1m*\x1b[0m WiFi 1 security: \x1b[32;1m%s\x1b[0m\n", displayInfo? WiFi_GetSecurityMode() : NULL); + + if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID, (u8*)&slotData))) && (slotData.set)) + { + if (displayInfo) + printf("\x1b[32;1m*\x1b[0m WiFi 1 mac: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2], + slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]); + else + printf("\x1b[32;1m*\x1b[0m WiFi 1 mac: \x1b[32;1m%s\x1b[0m\n\n", NULL); + } } if (R_SUCCEEDED(ACI_LoadWiFiSlot(1))) { - char ssid[0x20], passphrase[0x40]; - if (R_SUCCEEDED(ACI_GetSSID(ssid))) printf("\x1b[32;1m*\x1b[0m WiFi 2 SSID: \x1b[32;1m%s\x1b[0m\n", ssid); if (R_SUCCEEDED(ACI_GetPassphrase(passphrase))) printf("\x1b[32;1m*\x1b[0m WiFi 2 pass: \x1b[32;1m%s\x1b[0m\n", displayInfo? passphrase : NULL); - printf("\x1b[32;1m*\x1b[0m WiFi 2 security: \x1b[32;1m%s\x1b[0m\n\n", displayInfo? WiFi_GetSecurityMode() : NULL); + printf("\x1b[32;1m*\x1b[0m WiFi 2 security: \x1b[32;1m%s\x1b[0m\n", displayInfo? WiFi_GetSecurityMode() : NULL); + + if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 1, (u8*)&slotData))) && (slotData.set)) + { + if (displayInfo) + printf("\x1b[32;1m*\x1b[0m WiFi 2 mac: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2], + slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]); + else + printf("\x1b[32;1m*\x1b[0m WiFi 2 mac: \x1b[32;1m%s\x1b[0m\n\n", NULL); + } } if (R_SUCCEEDED(ACI_LoadWiFiSlot(2))) - { - char ssid[0x20], passphrase[0x40]; - + { if (R_SUCCEEDED(ACI_GetSSID(ssid))) printf("\x1b[32;1m*\x1b[0m WiFi 3 SSID: \x1b[32;1m%s\x1b[0m\n", ssid); if (R_SUCCEEDED(ACI_GetPassphrase(passphrase))) printf("\x1b[32;1m*\x1b[0m WiFi 3 pass: \x1b[32;1m%s\x1b[0m\n", displayInfo? passphrase : NULL); - printf("\x1b[32;1m*\x1b[0m WiFi 3 security: \x1b[32;1m%s\x1b[0m\n\n", displayInfo? WiFi_GetSecurityMode() : NULL); + printf("\x1b[32;1m*\x1b[0m WiFi 3 security: \x1b[32;1m%s\x1b[0m\n", displayInfo? WiFi_GetSecurityMode() : NULL); + + if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 2, (u8*)&slotData))) && (slotData.set)) + { + if (displayInfo) + printf("\x1b[32;1m*\x1b[0m WiFi 3 mac: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2], + slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]); + else + printf("\x1b[32;1m*\x1b[0m WiFi 3 mac: \x1b[32;1m%s\x1b[0m\n\n", NULL); + } } printf("\x1b[32;1m> Press any key to exit =)\x1b[0m"); @@ -181,7 +214,7 @@ int main(int argc, char *argv[]) consoleInit(GFX_TOP, NULL); printf("\x1b[1;1H"); //Move the cursor to the top left corner of the screen - printf("\x1b[32;1m3DSident 0.7.9\x1b[0m\n\n"); + printf("\x1b[32;1m3DSident v%d.%d.%d\x1b[0m\n\n", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO); //=====================================================================// //------------------------------Firm Info------------------------------// @@ -201,7 +234,8 @@ int main(int argc, char *argv[]) printf("\x1b[31;1m*\x1b[0m Language: \x1b[31;1m%s\x1b[0m \n", System_GetLang()); printf("\x1b[31;1m*\x1b[0m Device ID: \x1b[31;1m%lu \n", displayInfo? Kernel_GetDeviceId() : 0); printf("\x1b[31;1m*\x1b[0m ECS Device ID: \x1b[31;1m%llu \n", displayInfo? System_GetSoapId() : 0); - printf("\x1b[31;1m*\x1b[0m Local friend code seed: \x1b[31;1m%010llX\x1b[0m \n", displayInfo? System_GetLocalFriendCodeSeed() : 0); + printf("\x1b[31;1m*\x1b[0m Original Local friend code seed: \x1b[31;1m%010llX\x1b[0m \n", displayInfo? System_GetLocalFriendCodeSeed() : 0); + printf("\x1b[31;1m*\x1b[0m NAND Local friend code seed: \x1b[31;1m%s\x1b[0m \n", displayInfo? System_GetNANDLocalFriendCodeSeed() : NULL); printf("\x1b[31;1m*\x1b[0m MAC Address: \x1b[31;1m%s\x1b[0m \n", displayInfo? System_GetMacAddress() : 0); printf("\x1b[31;1m*\x1b[0m Serial number: \x1b[31;1m%s\x1b[0m \n", displayInfo? System_GetSerialNumber() : 0); printf("\x1b[31;1m*\x1b[0m SDMC CID: \x1b[31;1m%s\x1b[0m \n", displayInfo? Kernel_GetSDMCCID() : 0); @@ -213,53 +247,48 @@ int main(int argc, char *argv[]) //----------------------------Battery Info-----------------------------// //=====================================================================// - printf("\x1b[19;0H"); - if ((R_SUCCEEDED(MCUHWC_GetBatteryLevel(&battery_percent))) || R_SUCCEEDED(PTMU_GetBatteryChargeState(&battery_status))) - printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n", battery_percent, battery_status); - printf("\x1b[20;0H"); + if (R_SUCCEEDED(MCUHWC_GetBatteryLevel(&battery_percent))) + printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m ", battery_percent); + if (R_SUCCEEDED(PTMU_GetBatteryChargeState(&battery_status))) + printf("(\x1b[34;1m%s\x1b[0m) \n\n", battery_status? "charging" : "not charging"); + + printf("\x1b[21;0H"); if (R_SUCCEEDED(MCUHWC_GetBatteryVoltage(&battery_volt))) printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m) \n", battery_volt, 5.0 * ((double)battery_volt / 256.0));//,(Estimated: %0.1lf V) estimatedVolt); - printf("\x1b[21;0H"); + printf("\x1b[22;0H"); if (R_SUCCEEDED(PTMU_GetAdapterState(&is_connected))) printf("\x1b[34;1m*\x1b[0m Adapter state: \x1b[34;1m%s\x1b[0m\n", is_connected? "connected " : "disconnected"); - printf("\x1b[22;0H"); + printf("\x1b[23;0H"); if ((R_SUCCEEDED(MCUHWC_GetFwVerHigh(&fw_ver_high))) && (R_SUCCEEDED(MCUHWC_GetFwVerLow(&fw_ver_low)))) - printf("\x1b[34;1m*\x1b[0m MCU firmware: \x1b[34;1m%u.%u\x1b[0m\n\n", (fw_ver_high - 16), fw_ver_low); + printf("\x1b[34;1m*\x1b[0m MCU firmware: \x1b[34;1m%u.%u\x1b[0m\n\n", (fw_ver_high - 0x10), fw_ver_low); //=====================================================================// //------------------------------Misc Info------------------------------// //=====================================================================// - - printf("\x1b[24;0H"); - Utils_GetSizeString(sdFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_SD)); - Utils_GetSizeString(sdTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_SD)); - printf("\x1b[36;1m*\x1b[0m SD Size: \x1b[36;1m%s\x1b[0m / \x1b[36;1m%s\x1b[0m \n", sdFreeSize, sdTotalSize); printf("\x1b[25;0H"); - Utils_GetSizeString(ctrFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND)); - Utils_GetSizeString(ctrTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND)); - printf("\x1b[36;1m*\x1b[0m CTR Size: \x1b[36;1m%s\x1b[0m / \x1b[36;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize); - - printf("\x1b[26;0H"); printf("\x1b[36;1m*\x1b[0m Brightness level: \x1b[36;1m%s\x1b[0m \n", Hardware_GetBrightness(GSPLCD_SCREEN_TOP)); - printf("\x1b[27;0H"); + printf("\x1b[26;0H"); wifiPercent = (osGetWifiStrength() * 33.3333333333); printf("\x1b[36;1m*\x1b[0m WiFi signal strength: \x1b[36;1m%d\x1b[0m (\x1b[36;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent); - printf("\x1b[28;0H"); + printf("\x1b[27;0H"); if (R_SUCCEEDED(HIDUSER_GetSoundVolume(&volume))) { volPercent = (volume * 1.5873015873); printf("\x1b[36;1m*\x1b[0m Volume slider state: \x1b[36;1m%d\x1b[0m (\x1b[36;1m%.0lf%%\x1b[0m) \n", volume, volPercent); } - printf("\x1b[29;0H"); + printf("\x1b[28;0H"); _3dSliderPercent = (osGet3DSliderState() * 100.0); printf("\x1b[36;1m*\x1b[0m 3D slider state: \x1b[36;1m%.1lf\x1b[0m (\x1b[36;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent); + + printf("\x1b[29;0H"); + printf("\x1b[36;1m*\x1b[0m Card slot status: \x1b[36;1m%s\x1b[0m \n", Hardware_GetCardSlotStatus()); gspWaitForVBlank(); hidScanInput();