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

Make the ESP32 Echo Server use Inet #534

Merged

Conversation

sagar-apple
Copy link
Contributor

Problem

The ESP32 WiFi-echo example doesn't use the InetLayer and so doesn't pass signals through the CHIP stack

Summary of Changes

  • Switched the server to use Inet UDPEndPoints instead of BSD Sockets via the ESP32's LwIP.
  • Added an Echo send call to the Server (so it actually sends the Echo back to the client)
  • Added a local Echo Client(enabled by default) so that the end-to-end Echo Server <-> Client flow can be run without hopping onto the ESP32's SoftAP.

fixes #533

}
ESP_LOGI(TAG, "Socket created");
ESP_LOGI(TAG, "UDP packet received from %s:%u to %s:%u (%zu bytes)", src_addr, packet_info->SrcPort, dest_addr,
packet_info->DestPort, static_cast<size_t>(buffer->DataLength()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: rather than calling buffer->DataLength() repeatedly, I'd assign it to a const value at the top of the block and then use that const value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I'll push a follow-up.

static const char * TAG = "echo_client";
static const char * PAYLOAD = "Message from echo client!";

static void udp_client_task(void * pvParameters)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan to use InetLayer for client (maybe in a follow on PR)?

Copy link
Contributor Author

@sagar-apple sagar-apple Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally chose not to use Inet on the first pass of this Client. I wanted the client to emulate a pure socket echo client. Mainly to demonstrate that the Server will respond to anything, not just things delivered via CHIP components.

Like you suggested, I might migrate it in a follow-up PR if we see fit.

@pan-apple
Copy link
Contributor

LGTM

@BroderickCarlin BroderickCarlin merged commit 6432172 into project-chip:master Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update ESP32 WiFi Echo example to use the InetLayer
7 participants