mirror of
https://github.com/afska/gba-link-connection.git
synced 2026-10-01 21:36:53 -05:00
LinkCable: Unified timeout and remoteTimeout
This commit is contained in:
@@ -66,8 +66,7 @@ The library uses message queues to send/receive data and transmits when it's pos
|
||||
Name | Type | Default | Description
|
||||
--- | --- | --- | ---
|
||||
`baudRate` | **BaudRate** | `BAUD_RATE_1` | Sets a specific baud rate.
|
||||
`timeout` | **u32** | `3` | Number of *frames* without a `SERIAL` IRQ to reset the connection.
|
||||
`remoteTimeout` | **u32** | `3` | Number of *frames* receiving `0xFFFF` from other player to mark it as disconnected.
|
||||
`timeout` | **u32** | `3` | Maximum number of *frames* without receiving data from other player before marking them as disconnected or resetting the connection.
|
||||
`interval` | **u16** | `50` | Number of *1024-cycle ticks* (61.04μs) between transfers *(50 = 3.052ms)*. It's the interval of Timer #`sendTimerId`. Lower values will transfer faster but also consume more CPU.
|
||||
`sendTimerId` | **u8** *(0~3)* | `3` | GBA Timer to use for sending.
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ static volatile char LINK_CABLE_VERSION[] = "LinkCable/v7.0.0";
|
||||
|
||||
#define LINK_CABLE_MAX_PLAYERS 4
|
||||
#define LINK_CABLE_DEFAULT_TIMEOUT 3
|
||||
#define LINK_CABLE_DEFAULT_REMOTE_TIMEOUT 3
|
||||
#define LINK_CABLE_DEFAULT_INTERVAL 50
|
||||
#define LINK_CABLE_DEFAULT_SEND_TIMER_ID 3
|
||||
#define LINK_CABLE_DISCONNECTED 0xffff
|
||||
@@ -103,8 +102,6 @@ class LinkCable {
|
||||
* @param baudRate Sets a specific baud rate.
|
||||
* @param timeout Number of *frames* without a `SERIAL` IRQ to reset the
|
||||
* connection.
|
||||
* @param remoteTimeout Number of *frames* receiving `0xFFFF` from other
|
||||
* player to mark it as disconnected.
|
||||
* @param interval Number of *1024-cycle ticks* (61.04μs) between transfers
|
||||
* *(50 = 3.052ms)*. It's the interval of Timer #`sendTimerId`. Lower values
|
||||
* will transfer faster but also consume more CPU.
|
||||
@@ -112,12 +109,10 @@ class LinkCable {
|
||||
*/
|
||||
explicit LinkCable(BaudRate baudRate = BAUD_RATE_1,
|
||||
u32 timeout = LINK_CABLE_DEFAULT_TIMEOUT,
|
||||
u32 remoteTimeout = LINK_CABLE_DEFAULT_REMOTE_TIMEOUT,
|
||||
u16 interval = LINK_CABLE_DEFAULT_INTERVAL,
|
||||
u8 sendTimerId = LINK_CABLE_DEFAULT_SEND_TIMER_ID) {
|
||||
this->config.baudRate = baudRate;
|
||||
this->config.timeout = timeout;
|
||||
this->config.remoteTimeout = remoteTimeout;
|
||||
this->config.interval = interval;
|
||||
this->config.sendTimerId = sendTimerId;
|
||||
}
|
||||
@@ -351,7 +346,6 @@ class LinkCable {
|
||||
struct Config {
|
||||
BaudRate baudRate;
|
||||
u32 timeout;
|
||||
u32 remoteTimeout;
|
||||
u32 interval;
|
||||
u8 sendTimerId;
|
||||
};
|
||||
|
||||
@@ -102,7 +102,6 @@ class LinkUniversal {
|
||||
struct CableOptions {
|
||||
LinkCable::BaudRate baudRate;
|
||||
u32 timeout;
|
||||
u32 remoteTimeout;
|
||||
u16 interval;
|
||||
u8 sendTimerId;
|
||||
};
|
||||
@@ -134,7 +133,6 @@ class LinkUniversal {
|
||||
CableOptions cableOptions =
|
||||
CableOptions{LinkCable::BaudRate::BAUD_RATE_1,
|
||||
LINK_CABLE_DEFAULT_TIMEOUT,
|
||||
LINK_CABLE_DEFAULT_REMOTE_TIMEOUT,
|
||||
LINK_CABLE_DEFAULT_INTERVAL,
|
||||
LINK_CABLE_DEFAULT_SEND_TIMER_ID},
|
||||
WirelessOptions wirelessOptions =
|
||||
@@ -146,9 +144,9 @@ class LinkUniversal {
|
||||
LINK_WIRELESS_DEFAULT_SEND_TIMER_ID,
|
||||
LINK_WIRELESS_DEFAULT_ASYNC_ACK_TIMER_ID},
|
||||
int randomSeed = 123) {
|
||||
this->linkCable = new LinkCable(
|
||||
cableOptions.baudRate, cableOptions.timeout, cableOptions.remoteTimeout,
|
||||
cableOptions.interval, cableOptions.sendTimerId);
|
||||
this->linkCable =
|
||||
new LinkCable(cableOptions.baudRate, cableOptions.timeout,
|
||||
cableOptions.interval, cableOptions.sendTimerId);
|
||||
this->linkWireless = new LinkWireless(
|
||||
wirelessOptions.retransmission, true,
|
||||
Link::_min(wirelessOptions.maxPlayers, LINK_UNIVERSAL_MAX_PLAYERS),
|
||||
|
||||
Reference in New Issue
Block a user