Implement some missing/wrong AC functionality. (#7171)

* Implement some missing/wrong AC functionality.

* Schedule NDM connect event into the future

* Disable NDM connect for now as it's causing issues

* Apply latest changes and suggestions.

* Workaround to fake wifi connection.

* Add missing command to ac:i

* Fix compilation

* Fix error codes for CamcelConnectAsync

* Fix missing global state.
This commit is contained in:
PabloMK7 2024-01-12 18:15:47 +01:00 committed by GitHub
parent 6cbdc73f53
commit 19d5695aa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 375 additions and 58 deletions

View file

@ -85,6 +85,12 @@ Handler::Handler(Core::Timing& timing, u64 override_init_time) : timing(timing)
float slidestate = Settings::values.factor_3d.GetValue() / 100.0f;
shared_page.sliderstate_3d = static_cast<float_le>(slidestate);
// TODO(PabloMK7)
// Set wifi state to internet, to fake a connection from the NDM service.
// Remove once it is figured out how NDM uses AC to connect at console boot.
SetWifiLinkLevel(WifiLinkLevel::Best);
SetWifiState(WifiState::Internet);
}
u64 Handler::GetSystemTimeSince2000() const {
@ -136,10 +142,24 @@ void Handler::SetMacAddress(const MacAddress& addr) {
std::memcpy(shared_page.wifi_macaddr, addr.data(), sizeof(MacAddress));
}
MacAddress Handler::GetMacAddress() {
MacAddress addr;
std::memcpy(addr.data(), shared_page.wifi_macaddr, sizeof(MacAddress));
return addr;
}
void Handler::SetWifiLinkLevel(WifiLinkLevel level) {
shared_page.wifi_link_level = static_cast<u8>(level);
}
WifiLinkLevel Handler::GetWifiLinkLevel() {
return static_cast<WifiLinkLevel>(shared_page.wifi_link_level);
}
void Handler::SetWifiState(WifiState state) {
shared_page.wifi_state = static_cast<u8>(state);
}
void Handler::Set3DLed(u8 state) {
shared_page.ledstate_3d = state;
}

View file

@ -53,10 +53,20 @@ using MacAddress = std::array<u8, 6>;
constexpr MacAddress DefaultMac = {0x40, 0xF4, 0x07, 0x00, 0x00, 0x00};
enum class WifiLinkLevel : u8 {
OFF = 0,
POOR = 1,
GOOD = 2,
BEST = 3,
Off = 0,
Poor = 1,
Good = 2,
Best = 3,
};
enum class WifiState : u8 {
Invalid = 0,
Enabled = 1,
Internet = 2,
Local1 = 3,
Local2 = 4,
Local3 = 6,
Disabled = 7,
};
struct SharedPageDef {
@ -70,7 +80,7 @@ struct SharedPageDef {
DateTime date_time_1; // 40
u8 wifi_macaddr[6]; // 60
u8 wifi_link_level; // 66
u8 wifi_unknown2; // 67
u8 wifi_state; // 67
INSERT_PADDING_BYTES(0x80 - 0x68); // 68
float_le sliderstate_3d; // 80
u8 ledstate_3d; // 84
@ -90,8 +100,14 @@ public:
void SetMacAddress(const MacAddress&);
MacAddress GetMacAddress();
void SetWifiLinkLevel(WifiLinkLevel);
WifiLinkLevel GetWifiLinkLevel();
void SetWifiState(WifiState);
void Set3DLed(u8);
void Set3DSlider(float);