From 6a956aff8533dcb51207bc5aa3d6a9aec3dab7c5 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Thu, 22 Aug 2024 23:17:06 -0300 Subject: [PATCH] LinkCable: Unified timeout and remoteTimeout --- README.md | 3 +-- lib/LinkCable.hpp | 6 ------ lib/LinkUniversal.hpp | 8 +++----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e3e607b..aec1875 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/LinkCable.hpp b/lib/LinkCable.hpp index 54f82df..74ad37c 100644 --- a/lib/LinkCable.hpp +++ b/lib/LinkCable.hpp @@ -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; }; diff --git a/lib/LinkUniversal.hpp b/lib/LinkUniversal.hpp index 09af52c..6b2c861 100644 --- a/lib/LinkUniversal.hpp +++ b/lib/LinkUniversal.hpp @@ -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),