mirror of
https://github.com/afska/gba-link-connection.git
synced 2026-10-03 06:17:07 -05:00
Fixing broadcast polling for more than 1 server
This commit is contained in:
@@ -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`
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user