Move writing to shared page to the nwm init
This commit is contained in:
parent
ffe94421b2
commit
752cfcaaae
4 changed files with 26 additions and 16 deletions
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <random>
|
||||||
#include "core/hle/service/nwm/nwm.h"
|
#include "core/hle/service/nwm/nwm.h"
|
||||||
#include "core/hle/service/nwm/nwm_cec.h"
|
#include "core/hle/service/nwm/nwm_cec.h"
|
||||||
#include "core/hle/service/nwm/nwm_ext.h"
|
#include "core/hle/service/nwm/nwm_ext.h"
|
||||||
|
@ -10,6 +11,8 @@
|
||||||
#include "core/hle/service/nwm/nwm_soc.h"
|
#include "core/hle/service/nwm/nwm_soc.h"
|
||||||
#include "core/hle/service/nwm/nwm_tst.h"
|
#include "core/hle/service/nwm/nwm_tst.h"
|
||||||
#include "core/hle/service/nwm/nwm_uds.h"
|
#include "core/hle/service/nwm/nwm_uds.h"
|
||||||
|
#include "core/hle/shared_page.h"
|
||||||
|
#include "network/network.h"
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
@ -21,6 +24,21 @@ void Init() {
|
||||||
AddService(new NWM_SAP);
|
AddService(new NWM_SAP);
|
||||||
AddService(new NWM_SOC);
|
AddService(new NWM_SOC);
|
||||||
AddService(new NWM_TST);
|
AddService(new NWM_TST);
|
||||||
|
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 gen(rd());
|
||||||
|
std::uniform_int_distribution<> dis(0, std::numeric_limits<u8>::max());
|
||||||
|
auto mac = SharedPage::DefaultMac;
|
||||||
|
for (int i = 3; i < sizeof(SharedPage::MacAddress); ++i) {
|
||||||
|
mac[i] = static_cast<u8>(dis(gen));
|
||||||
|
}
|
||||||
|
if (auto room_member = Network::GetRoomMember().lock()) {
|
||||||
|
if (room_member->IsConnected()) {
|
||||||
|
mac = static_cast<SharedPage::MacAddress>(room_member->GetMacAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SharedPage::SetMacAddress(mac);
|
||||||
|
SharedPage::SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||||
|
|
|
@ -593,12 +593,6 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) {
|
||||||
node_info.push_back(current_node);
|
node_info.push_back(current_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto room_member = Network::GetRoomMember().lock()) {
|
|
||||||
if (room_member->IsConnected()) {
|
|
||||||
SharedPage::SetMacAddress(static_cast<SharedPage::MacAddress>(room_member->GetMacAddress()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushCopyObjects(connection_status_event);
|
rb.PushCopyObjects(connection_status_event);
|
||||||
|
|
|
@ -83,9 +83,6 @@ void Init() {
|
||||||
update_time_event =
|
update_time_event =
|
||||||
CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback);
|
CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback);
|
||||||
CoreTiming::ScheduleEvent(0, update_time_event);
|
CoreTiming::ScheduleEvent(0, update_time_event);
|
||||||
|
|
||||||
SetWifiLinkLevel(WifiLinkLevel::POOR);
|
|
||||||
SetMacAddress(DefaultMac);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMacAddress(const MacAddress& addr) {
|
void SetMacAddress(const MacAddress& addr) {
|
||||||
|
@ -96,4 +93,4 @@ void SetWifiLinkLevel(WifiLinkLevel level) {
|
||||||
shared_page.wifi_link_level = static_cast<u8>(level);
|
shared_page.wifi_link_level = static_cast<u8>(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace SharedPage
|
||||||
|
|
|
@ -39,13 +39,14 @@ union BatteryState {
|
||||||
|
|
||||||
using MacAddress = std::array<u8, 6>;
|
using MacAddress = std::array<u8, 6>;
|
||||||
|
|
||||||
// Default MAC address in the nintendo 3ds range
|
// Default MAC address in the Nintendo 3DS range
|
||||||
constexpr MacAddress DefaultMac = {0x40, 0xF4, 0x07, 0x00, 0x00, 0x00};
|
constexpr MacAddress DefaultMac = {0x40, 0xF4, 0x07, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
enum class WifiLinkLevel : u8 {
|
enum class WifiLinkLevel : u8 {
|
||||||
POOR = 0,
|
OFF = 0,
|
||||||
GOOD = 1,
|
POOR = 1,
|
||||||
BEST = 2,
|
GOOD = 2,
|
||||||
|
BEST = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SharedPageDef {
|
struct SharedPageDef {
|
||||||
|
@ -81,4 +82,4 @@ void SetMacAddress(const MacAddress&);
|
||||||
|
|
||||||
void SetWifiLinkLevel(WifiLinkLevel);
|
void SetWifiLinkLevel(WifiLinkLevel);
|
||||||
|
|
||||||
} // namespace
|
} // namespace SharedPage
|
||||||
|
|
Loading…
Reference in a new issue