mirror of
https://github.com/Show-maket/EthernetMaket.git
synced 2025-06-28 05:09:38 +00:00
state mashine upd
This commit is contained in:
@ -10,7 +10,10 @@ enum ConnectionStatusSimple{
|
||||
CONNECT_SUCCESS = 1,
|
||||
CONNECT_CONNECTING = 2,
|
||||
CONNECT_START = 3,
|
||||
CONNECT_IDLE = 4
|
||||
CONNECT_IDLE = 4,
|
||||
CONNECT_CONNECTED = 5,
|
||||
CONNECT_STOP_START = 6,
|
||||
CONNECT_STOP_WAITING = 7,
|
||||
};
|
||||
|
||||
|
||||
|
@ -45,4 +45,42 @@ ConnectionStatusSimple EthernetMaketClient::connectNonBlock(IPAddress ip, uint16
|
||||
}
|
||||
|
||||
return CONNECT_CONNECTING;
|
||||
}
|
||||
}
|
||||
|
||||
void EthernetMaketClient::disconnect(){
|
||||
if (_sock == MAX_SOCK_NUM)
|
||||
return;
|
||||
::disconnect(_sock);
|
||||
}
|
||||
|
||||
void EthernetMaketClient::close(){
|
||||
if (_sock == MAX_SOCK_NUM)
|
||||
return;
|
||||
::close(_sock);
|
||||
_sock = MAX_SOCK_NUM;
|
||||
}
|
||||
|
||||
// void EthernetMaketClient::stop() {
|
||||
// if (_sock == MAX_SOCK_NUM)
|
||||
// return;
|
||||
|
||||
// // attempt to close the connection gracefully (send a FIN to other side)
|
||||
// disconnect(_sock);
|
||||
// unsigned long start = millis();
|
||||
|
||||
// // wait a second for the connection to close
|
||||
// uint8_t s;
|
||||
// do {
|
||||
// s = status();
|
||||
// if (s == SnSR::CLOSED)
|
||||
// break; // exit the loop
|
||||
// delay(1);
|
||||
// } while (millis() - start < 1000);
|
||||
|
||||
// // if it hasn't closed, close it forcefully
|
||||
// if (status() != SnSR::CLOSED)
|
||||
// close(_sock);
|
||||
|
||||
// EthernetClass::_server_port[_sock] = 0;
|
||||
// _sock = MAX_SOCK_NUM;
|
||||
// }
|
||||
|
@ -9,7 +9,9 @@ public:
|
||||
using EthernetClient::EthernetClient;
|
||||
|
||||
ConnectionStatusSimple connectNonBlock(IPAddress ip, uint16_t port);
|
||||
|
||||
// void stop() override;
|
||||
void disconnect();
|
||||
void close();
|
||||
|
||||
};
|
||||
#endif // __MAKET_TCP_H__
|
Reference in New Issue
Block a user