Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify connection timeouts more #40

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions RF24Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,6 @@ void serialip_appcall(void)
{
uip_userdata_t* u = (uip_userdata_t*)uip_conn->appstate;

#if UIP_CONNECTION_TIMEOUT > 0
if (u && u->connectTimeout > 0) {
if (!u->initialData) {
u->connectTimer = millis();
u->initialData = true;
}
else if (millis() - u->connectTimer > u->connectTimeout) {
u->state |= UIP_CLIENT_CLOSE;
u->connectTimer = millis();
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.println("UIP Client close(timeout)"););
}
}
#endif

/*******Connected**********/
if (!u && uip_connected())
{
Expand All @@ -264,9 +250,6 @@ void serialip_appcall(void)

if (u)
{
#if UIP_CONNECTION_TIMEOUT > 0
u->connectTimer = millis();
#endif
uip_conn->appstate = u;
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.print(F("UIPClient allocated state: ")); Serial.println(u->state, BIN););
}
Expand All @@ -276,6 +259,16 @@ void serialip_appcall(void)
}
}

#if UIP_CONNECTION_TIMEOUT > 0
if (u && u->connectTimeout > 0) {
if (millis() - u->connectTimer > u->connectTimeout) {
u->state |= UIP_CLIENT_CLOSE;
u->connectTimer = millis();
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.println("UIP Client close(timeout)"););
}
}
#endif

/*******User Data RX**********/
if (u)
{
Expand Down Expand Up @@ -433,7 +426,6 @@ uip_userdata_t* RF24Client::_allocateData()
data->dataPos = 0;
data->out_pos = 0;
data->hold = 0;
data->initialData = false;
#if (UIP_CONNECTION_TIMEOUT > 0)
data->connectTimer = millis();
data->connectTimeout = UIP_CONNECTION_TIMEOUT;
Expand Down
1 change: 0 additions & 1 deletion RF24Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ typedef struct
uint32_t connectTimer;
#endif
uint8_t myData[OUTPUT_BUFFER_SIZE];
bool initialData;
} uip_userdata_t;

class RF24Client : public Client
Expand Down