Fixing broadcast polling for more than 1 server

This commit is contained in:
Rodrigo Alfonso
2023-02-04 20:44:15 -03:00
parent d33cfdcb94
commit 91caddf97c
2 changed files with 12 additions and 2 deletions

View File

@@ -260,7 +260,7 @@ Whenever either side expects something to be sent from the other (as SPI is alwa
⚠️ IDs are randomly generated. Each time you broadcast or connect, the adapter assigns you a new id.
⚠️ Reading broadcasts is a two-step process: First, you send `0x1c`. Then, wait until the adapter retrieves data (games usually wait 1 full second). Lastly, send a `0x1e` and it will return what's described above.
⚠️ Reading broadcasts is a three-step process: First, you send `0x1c` (you will get an ACK instantly), and start waiting until the adapter retrieves data (games usually wait 1 full second). Then, send a `0x1d` and it will return what's described above. Lastly, send a `0x1e` to finish the process (you can ignore what the adapter returns here). If you don't send that last `0x1e`, the next command will fail.
#### Setup - `0x17`

View File

@@ -78,6 +78,7 @@
#define LINK_WIRELESS_COMMAND_START_HOST 0x19
#define LINK_WIRELESS_COMMAND_ACCEPT_CONNECTIONS 0x1a
#define LINK_WIRELESS_COMMAND_BROADCAST_READ_START 0x1c
#define LINK_WIRELESS_COMMAND_BROADCAST_READ_POLL 0x1d
#define LINK_WIRELESS_COMMAND_BROADCAST_READ_END 0x1e
#define LINK_WIRELESS_COMMAND_CONNECT 0x1f
#define LINK_WIRELESS_COMMAND_IS_FINISHED_CONNECT 0x20
@@ -254,7 +255,7 @@ class LinkWireless {
wait(LINK_WIRELESS_BROADCAST_SEARCH_WAIT);
auto result = sendCommand(LINK_WIRELESS_COMMAND_BROADCAST_READ_END);
auto result = sendCommand(LINK_WIRELESS_COMMAND_BROADCAST_READ_POLL);
bool success2 =
result.success &&
result.responses.size() % LINK_WIRELESS_BROADCAST_RESPONSE_LENGTH == 0;
@@ -265,6 +266,15 @@ class LinkWireless {
return false;
}
bool success3 =
sendCommand(LINK_WIRELESS_COMMAND_BROADCAST_READ_END).success;
if (!success3) {
reset();
lastError = COMMAND_FAILED;
return false;
}
u32 totalBroadcasts =
result.responses.size() / LINK_WIRELESS_BROADCAST_RESPONSE_LENGTH;