Console should now display all the new info

Also display WiFi quality along wth RSSI
This commit is contained in:
Joel16 2018-10-21 00:20:05 -05:00
parent 83d3211c48
commit 816ef0a32b
6 changed files with 59 additions and 11 deletions

View File

@ -82,6 +82,19 @@ u32 SwitchIdent_GetWlanState(Service *srv) {
return out;
}
u32 SwitchIdent_GetWlanQuality(u32 dBm) {
u32 quality = 0;
if (dBm <= -100)
quality = 0;
else if (dBm >= -50)
quality = 100;
else
quality = 2 * (dBm + 100);
return quality;
}
u32 SwitchIdent_GetWlanRSSI(Service *srv) {
Result ret = 0;
u32 out = 0;
@ -90,4 +103,4 @@ u32 SwitchIdent_GetWlanRSSI(Service *srv) {
return -1;
return out;
}
}

View File

@ -2,6 +2,7 @@
#define _SWITCHIDENT_WLAN_H_
u32 SwitchIdent_GetWlanState(Service *srv);
u32 SwitchIdent_GetWlanQuality(u32 dBm);
u32 SwitchIdent_GetWlanRSSI(Service *srv);
#endif

View File

@ -37,7 +37,7 @@ INCLUDES := include ../common
EXEFS_SRC := exefs_src
VERSION_MAJOR := 0
VERSION_MINOR := 1
VERSION_MINOR := 2
VERSION_MICRO := 0
APP_TITLE := SwitchIdent-console

View File

@ -3,13 +3,17 @@
#include <inttypes.h>
#include <switch.h>
#include "fs.h"
#include "kernel.h"
#include "misc.h"
#include "power.h"
#include "storage.h"
#include "system.h"
#include "utils.h"
#include "wlan.h"
static Service setsys_service;
static Service setsys_service, psm_service, wlaninf_service;
static FsDeviceOperator fsDeviceOperator;
static void SwitchIdent_InitServices(void) {
Result ret = 0;
@ -40,9 +44,25 @@ static void SwitchIdent_InitServices(void) {
if (R_FAILED(ret = nsInitialize()))
printf("nsInitialize() failed: 0x%x.\n\n", ret);
if (R_FAILED(ret = psmInitialize()))
printf("psmInitialize() failed: 0x%x.\n\n", ret);
if (R_FAILED(ret = smGetService(&psm_service, "psm")))
printf("psmInitialize() failed: 0x%x.\n\n", ret);
if (R_FAILED(ret = smGetService(&wlaninf_service, "wlan:inf")))
printf("wlaninfInitialize() failed: 0x%x.\n\n", ret);
if (R_FAILED(ret = fsOpenDeviceOperator(&fsDeviceOperator)))
printf("fsOpenDeviceOperator() failed: 0x%x.\n\n", ret);
}
static void SwitchIdent_TermServices(void) {
fsDeviceOperatorClose(&fsDeviceOperator);
serviceClose(&wlaninf_service);
serviceClose(&psm_service);
psmExit();
nsExit();
apmExit();
appletExit();
@ -61,7 +81,7 @@ int main(int argc, char **argv) {
SwitchIdent_InitServices();
printf("\x1b[1;1H"); //Move the cursor to the top left corner of the screen
printf("\x1b[32;1mSwitchIdent %d.%d %s\x1b[0m\n\n", VERSION_MAJOR, VERSION_MINOR, SwitchIdent_IsSafeMode()? "(SafeMode)" : "");
printf("\x1b[32;1mSwitchIdent v%d.%d %s\x1b[0m\n\n", VERSION_MAJOR, VERSION_MINOR, SwitchIdent_IsSafeMode()? "(SafeMode)" : "");
/*
Kernel/Hardware info:
@ -78,7 +98,18 @@ int main(int argc, char **argv) {
*/
printf("\x1b[33;1m*\x1b[0m Region: \x1b[33;1m%s\n", SwitchIdent_GetRegion());
printf("\x1b[33;1m*\x1b[0m CPU clock: \x1b[33;1m%lu\x1b[0m MHz\n", SwitchIdent_GetCPUClock());
printf("\x1b[33;1m*\x1b[0m GPU clock: \x1b[33;1m%lu\x1b[0m MHz\n\n", SwitchIdent_GetGPUClock());
printf("\x1b[33;1m*\x1b[0m GPU clock: \x1b[33;1m%lu\x1b[0m MHz\n", SwitchIdent_GetGPUClock());
printf("\x1b[33;1m*\x1b[0m Wireless LAN: \x1b[33;1m%s\x1b[0m (RSSI: \x1b[33;1m%d\x1b[0m) (Quality: \x1b[33;1m%lu\x1b[0m)\n", SwitchIdent_GetFlag(SetSysFlag_WirelessLanEnable)? "Enabled" : "Disabled", SwitchIdent_GetWlanRSSI(&wlaninf_service), SwitchIdent_GetWlanQuality(SwitchIdent_GetWlanRSSI(&wlaninf_service)));
printf("\x1b[33;1m*\x1b[0m Bluetooth: \x1b[33;1m%s\x1b[0m\n\n", SwitchIdent_GetFlag(SetSysFlag_BluetoothEnable)? "Enabled" : "Disabled");
/*
Battery info:
*/
printf("\x1b[94;1m*\x1b[0m Battery percentage: \x1b[94;1m%lu %%\x1b[0m (\x1b[94;1m%s\x1b[0m) \x1b[0m\n", SwitchIdent_GetBatteryPercent(), SwitchIdent_IsCharging()? "charging" : "not charging");
printf("\x1b[94;1m*\x1b[0m Battery voltage state: \x1b[94;1m%s\n", SwitchIdent_GetVoltageState(&psm_service));
printf("\x1b[94;1m*\x1b[0m Battery charger type: \x1b[94;1m%s\n", SwitchIdent_GetChargerType());
printf("\x1b[94;1m*\x1b[0m Battery charging enabled: \x1b[94;1m%s\n", SwitchIdent_IsChargingEnabled(&psm_service)? "Yes" : "No");
printf("\x1b[94;1m*\x1b[0m Battery ample power supplied: \x1b[94;1m%s\n\n", SwitchIdent_IsEnoughPowerSupplied(&psm_service)? "Yes" : "No");
/*
Misc info:
@ -91,7 +122,9 @@ int main(int argc, char **argv) {
printf("\x1b[36;1m*\x1b[0m Bluetooth: \x1b[36;1m%s\n", SwitchIdent_GetFlag(SetSysFlag_BluetoothEnable)? "Enabled" : "Disabled");
printf("\x1b[36;1m*\x1b[0m NFC: \x1b[36;1m%s\n", SwitchIdent_GetFlag(SetSysFlag_NfcEnable)? "Enabled" : "Disabled");
printf("\x1b[36;1m*\x1b[0m Automatic update: \x1b[36;1m%s\n", SwitchIdent_GetFlag(SetSysFlag_AutoUpdateEnable)? "Enabled" : "Disabled");
printf("\x1b[36;1m*\x1b[0m Console information upload: \x1b[36;1m%s\n\n", SwitchIdent_GetFlag(SetSysFlag_ConsoleInformationUpload)? "Enabled" : "Disabled");
printf("\x1b[36;1m*\x1b[0m Console information upload: \x1b[36;1m%s\n", SwitchIdent_GetFlag(SetSysFlag_ConsoleInformationUpload)? "Enabled" : "Disabled");
printf("\x1b[36;1m*\x1b[0m SD card status: \x1b[36;1m%s\n", SwitchIdent_IsSDCardInserted(&fsDeviceOperator)? "Inserted" : "Not inserted");
printf("\x1b[36;1m*\x1b[0m Game card status: \x1b[36;1m%s\n\n", SwitchIdent_IsGameCardInserted(&fsDeviceOperator)? "Inserted" : "Not inserted");
char sd_total_str[16], sd_free_str[16], sd_used_str[16];
Utils_GetSizeString(sd_total_str, SwitchIdent_GetTotalStorage(FsStorageId_SdCard));

View File

@ -37,9 +37,9 @@ INCLUDES := include ../common
EXEFS_SRC := exefs_src
ROMFS := romfs
VERSION_MAJOR := 1
VERSION_MINOR := 0
VERSION_MICRO := 1
VERSION_MAJOR := 0
VERSION_MINOR := 2
VERSION_MICRO := 0
APP_TITLE := SwitchIdent-gui
APP_AUTHOR := Joel16

View File

@ -47,7 +47,8 @@ static void Menu_System(void) {
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 50, "Region:", SwitchIdent_GetRegion());
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 100, "CPU clock:", "%lu MHz", SwitchIdent_GetCPUClock());
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 150, "GPU clock:", "%lu MHz", SwitchIdent_GetGPUClock());
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 200, "Wireless LAN:", "%s (state: %d) (RSSI: %d)", SwitchIdent_GetFlag(SetSysFlag_WirelessLanEnable)? "Enabled" : "Disabled", SwitchIdent_GetWlanState(&wlaninf_service), SwitchIdent_GetWlanRSSI(&wlaninf_service));
//Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 200, "Wireless LAN:", "%s (state: %d) (RSSI: %d)", SwitchIdent_GetFlag(SetSysFlag_WirelessLanEnable)? "Enabled" : "Disabled", SwitchIdent_GetWlanState(&wlaninf_service), SwitchIdent_GetWlanRSSI(&wlaninf_service));
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 200, "Wireless LAN:", "%s (RSSI: %d) (Quality: %lu)", SwitchIdent_GetFlag(SetSysFlag_WirelessLanEnable)? "Enabled" : "Disabled", SwitchIdent_GetWlanRSSI(&wlaninf_service), SwitchIdent_GetWlanQuality(SwitchIdent_GetWlanRSSI(&wlaninf_service)));
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 250, "Bluetooth:", "%s", SwitchIdent_GetFlag(SetSysFlag_BluetoothEnable)? "Enabled" : "Disabled");
Menu_DrawItem(450, 250 + ((MENU_Y_DIST - item_height) / 2) + 300, "NFC:", SwitchIdent_GetFlag(SetSysFlag_NfcEnable)? "Enabled" : "Disabled");
}
@ -158,7 +159,7 @@ void Menu_Main(void) {
SDL_DrawRect(0, 0, 1280, 50, STATUS_BAR_COLOUR);
SDL_DrawRect(0, 50, 400, 670, MENU_BAR_COLOUR);
SDL_DrawText(30, ((50 - title_height) / 2), 25, BACKGROUND_COLOUR, "SwitchIdent");// 0x%lx 0x%lx", connect, disconnect);
SDL_DrawTextf(30, ((50 - title_height) / 2), 25, BACKGROUND_COLOUR, "SwitchIdent v%d.%d", VERSION_MAJOR, VERSION_MINOR);// 0x%lx 0x%lx", connect, disconnect);
SDL_DrawBanner(400 + ((880 - (banner_width)) / 2), 80);