client hotfix

This commit is contained in:
2024-11-20 16:45:02 +03:00
parent 18f4d1372a
commit ad8859af9a
3 changed files with 35 additions and 7 deletions

View File

@ -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
}