mirror of
https://github.com/Show-maket/EthernetMaket.git
synced 2025-05-04 15:20:18 +00:00
client hotfix
This commit is contained in:
parent
18f4d1372a
commit
ad8859af9a
@ -36,6 +36,11 @@ void onSend(){
|
||||
Serial.println("Sending Successfully");
|
||||
}
|
||||
|
||||
|
||||
// #define TEST_1
|
||||
#define TEST_2
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -54,8 +59,10 @@ void setup()
|
||||
client.setOnSendSuccess(onSend);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_2
|
||||
//* for many packets
|
||||
bool dataReady = false;
|
||||
#endif
|
||||
|
||||
void loop()
|
||||
{
|
||||
@ -74,10 +81,27 @@ void loop()
|
||||
Serial.println("connectNonBlock");
|
||||
client.startConnection(serverIP, SERVER_PORT);
|
||||
|
||||
#ifdef TEST_1
|
||||
//* for single packets
|
||||
client.dataWrite((uint8_t *)&packetCounter, sizeof(packetCounter));
|
||||
Serial.print("Sending packet: ");
|
||||
for (size_t j = 0; j < sizeof(packetCounter); j++)
|
||||
{
|
||||
Serial.print(((uint8_t *)&packetCounter)[j], HEX);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
packetCounter++;
|
||||
#endif
|
||||
#ifdef TEST_2
|
||||
//* for many packets
|
||||
dataReady = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(dataReady && client.isConnected())
|
||||
#ifdef TEST_2
|
||||
//* for many packets
|
||||
if(dataReady && client.isConnected()) //* check connection
|
||||
{
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
{
|
||||
@ -95,4 +119,5 @@ void loop()
|
||||
}
|
||||
dataReady = false;
|
||||
}
|
||||
#endif
|
||||
}
|
@ -263,17 +263,21 @@ bool EthernetMaketClient::dataWrite(){
|
||||
}
|
||||
lastActivityTime = millis();
|
||||
}
|
||||
if(ret){
|
||||
onSendSuccess();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool EthernetMaketClient::dataWrite(uint8_t* data, uint16_t dataSize, bool override) {
|
||||
void EthernetMaketClient::dataWrite(uint8_t* data, uint16_t dataSize, bool override) {
|
||||
if (this->dataSize == 0 || override) {
|
||||
this->dataPtr = data;
|
||||
this->dataSize = dataSize;
|
||||
return dataWrite();
|
||||
if(isConnected()){
|
||||
dataWrite();
|
||||
}
|
||||
} else {
|
||||
Serial.println("Data buffer is not empty. Write operation is ignored.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,6 +328,5 @@ void EthernetMaketClient::startConnection(IPAddress ip, uint16_t port, bool nonB
|
||||
dstIP = ip;
|
||||
dstPort = port;
|
||||
isNonBlocking = nonBlock;
|
||||
connectNonBlock(dstIP, dstPort);
|
||||
connectStatus = CONNECT_START;
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
ConnectionStatusSimple connectNonBlock(IPAddress ip, uint16_t port);
|
||||
void startConnection(IPAddress ip, uint16_t port, bool nonBlock = true);
|
||||
|
||||
bool dataWrite(uint8_t* data, uint16_t dataSize, bool override = false);
|
||||
void dataWrite(uint8_t* data, uint16_t dataSize, bool override = false);
|
||||
// bool send(uint8_t* data, uint16_t dataSize, IPAddress ip, uint16_t port);
|
||||
|
||||
void disconnect();
|
||||
|
Loading…
x
Reference in New Issue
Block a user