Skip to content

Conversation

mathieucarbou
Copy link
Member

@mathieucarbou mathieucarbou commented Apr 11, 2025

This PR complements the work from @gnalbandian in PR #47

  • Add ESP-IDf related api even on Arduino since compatible
  • Treat Arduino API as delegates on esp-idf layer

@mathieucarbou
Copy link
Member Author

@gnalbandian : FYI the new PR that I will complement.

@mathieucarbou mathieucarbou marked this pull request as ready for review April 11, 2025 09:33
@mathieucarbou mathieucarbou requested review from me-no-dev, vortigont, a team and Copilot April 11, 2025 09:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • CMakeLists.txt: Language not supported
  • idf_component_examples/client/CMakeLists.txt: Language not supported

@mathieucarbou mathieucarbou requested a review from me-no-dev April 11, 2025 10:25
@mathieucarbou mathieucarbou force-pushed the async_tcp_no_arduino branch 2 times, most recently from 306ef2e to 392e870 Compare April 11, 2025 11:17
@gnalbandian
Copy link

Hi @everyone! @mathieucarbou I've made a quick read over the code changes and it seems pretty good to me.
I see you've done some variables and functions cleanup also. I didn't know for sure if they were meant to be use or not so I leaved them untouched.
I'll try to test the new code today and come back with some feedback.
Thanks everyone for the work implied!

@gnalbandian
Copy link

gnalbandian commented Apr 11, 2025

Everything good! Works without issues in my app.

The only thing I noticed while testing some examples is that the client _pcb->local_port gets zeroed before the client disconnect callback gets called. Maybe it's fine. I've seen this behavior in the main branch also.

I (5856) AsyncTCP: ** data received by client: 62214: len=202
I (5856) AsyncTCP: ** data received by client: 62214: len=1440
I (5866) AsyncTCP: ** data received by client: 0: len=117 // <- See here
I (5866) AsyncTCP: ** client has been disconnected: 0 // <- See here

This is the code:

client->onConnect([](void *arg, AsyncClient *client)
    {
        ESP_LOGI("AsyncTCP", "** client has been connected: %" PRIu16 "\n", client->localPort());

        client->onDisconnect([](void *arg, AsyncClient *client) {
            ESP_LOGI("AsyncTCP", "** client has been disconnected: %" PRIu16 "\n", client->localPort());
            client->close(true);
            delete client;
        });

        client->onData([](void *arg, AsyncClient *client, void *data, size_t len) {
            ESP_LOGI("AsyncTCP", "** data received by client: %" PRIu16 ": len=%u\n", client->localPort(), len);
        });

        client->write("GET /README.md HTTP/1.1\r\nHost: 192.168.2.33 \r\nUser-Agent: ESP\r\nConnection: close\r\n\r\n");
    });

@mathieucarbou
Copy link
Member Author

Thanks for reporting that, I will create an issue from that and talk with the team.

- Added preprocessor macros to detect and separate ESP-IDF vs Arduino
@mathieucarbou mathieucarbou merged commit 790d218 into main Apr 16, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants