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

send on WiFiClient in AsyncClient OnData problem! #44

Closed
mcr-ksh opened this issue May 17, 2017 · 6 comments
Closed

send on WiFiClient in AsyncClient OnData problem! #44

mcr-ksh opened this issue May 17, 2017 · 6 comments
Labels

Comments

@mcr-ksh
Copy link

mcr-ksh commented May 17, 2017

Hello,

thanks for this library. Seems a step towards the right direction as the performance is really bad without it. However, I have trouble getting to run the function in a right way.

Scenario: I have a async client connection and a normal WiFiclient connection and want to send data received from the async client through the WiFiclient.

I have a strange behavior when sending data through WiFiClient.
I receive data from a callback function onData() and send the data through a WiFiclient socket.

    client->onData([](void *arg, AsyncClient *c, void *data, size_t len) {
        Serial.print("async_recv(): onData len = %d\n", len);
        if ( send_sock(&wifi_client, (const uint8_t *)data, len) != len )
        {
           Serial.print("async_recv(): onData send failed\n");
        }
    }, NULL);

The client->write function returns before hand, see blow:

send_sock(): -->
:wr
:ww
send_sock(): FAILED: send 0 of amount of 420 bytes. connected 1. available 0
_send_sock(): 0 <--_
**:sent 420**

thus, the function returns 0 written bytes as a return code, and the kernel does acknowledge the ":send 420"
at a later point. Here an example of a successful send in sync:

send_sock(): -->
:wr
**:sent 10**
:ww
_send_sock(): 10 <--_

What could cause this behavior?

Best
M

@me-no-dev
Copy link
Owner

what is send_sock() ?

@me-no-dev
Copy link
Owner

oh... you want to send data to a normal client from Async callback? tat is not possible ;) regular client uses delay and yield and those are not permitted in Async

@mcr-ksh
Copy link
Author

mcr-ksh commented May 17, 2017

well, that explains it. I wanted to use two async sockets if possible but doing protocol work in two async sockets is nuts.

is there an option to make use of the delay to wait until the packet arrives in the async callback?

@me-no-dev
Copy link
Owner

Better do all synch work in the loop and set flags in the async callbacks

@stale
Copy link

stale bot commented Sep 21, 2019

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 21, 2019
@stale
Copy link

stale bot commented Oct 5, 2019

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants