Arduino Core 3 (#407)
* Add and remove libs and components for Arduino Core 3 * Arduino Core 3 * Add back Solo1 * Change ESP32-S3 to 4MB build * Update README.md * Fix retain and number of retries * Fix rolling log * Fix defaults * Fix BleScanner on Solo1 * Export settings * Import settings * Fix HA Battery voltage * Change submodule * Update espMqttClient and AsyncTCP * Webserial and MQTT/Network reconnecting * Update nuki_ble --------- Co-authored-by: iranl <iranl@github.com>
This commit is contained in:
42
lib/AsyncTCP/examples/ClientServer/Client/Client.ino
Normal file
42
lib/AsyncTCP/examples/ClientServer/Client/Client.ino
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <AsyncTCP.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
static void replyToServer(void* arg) {
|
||||
AsyncClient* client = reinterpret_cast<AsyncClient*>(arg);
|
||||
|
||||
// send reply
|
||||
if (client->space() > 32 && client->canSend()) {
|
||||
char message[32];
|
||||
client->add(message, strlen(message));
|
||||
client->send();
|
||||
}
|
||||
}
|
||||
|
||||
/* event callbacks */
|
||||
static void handleData(void* arg, AsyncClient* client, void *data, size_t len) {
|
||||
Serial.printf("\n data received from %s \n", client->remoteIP().toString().c_str());
|
||||
Serial.write((uint8_t*)data, len);
|
||||
|
||||
}
|
||||
|
||||
void onConnect(void* arg, AsyncClient* client) {
|
||||
Serial.printf("\n client has been connected to %s on port %d \n", SERVER_HOST_NAME, TCP_PORT);
|
||||
replyToServer(client);
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(20);
|
||||
|
||||
AsyncClient* client = new AsyncClient;
|
||||
client->onData(&handleData, client);
|
||||
client->onConnect(&onConnect, client);
|
||||
client->connect(SERVER_HOST_NAME, TCP_PORT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user