-
Notifications
You must be signed in to change notification settings - Fork 194
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
EspNow send function not working properly #315
Comments
do not block in the callbacks, its a real bad idea, just try to get the data out as fast as possible, and then try to evaluate the data in a lower priority task/ thread. Keep in mind that both callbacks running directly in the wifi_driver thread context not in your context. So you will kill the wifi essentially if you do this. you can inject a std::channel in both the recv and send callback and then just work with the data you got in the main thread / lower prio thread . |
Okay, that's not good practice. But ideally I could send and receive simultaneously, right? |
the callbacks are not related to the part where you can do stuff, they inform you that 'a your packet was send successfully 'b you got a new packet. So you can call send() whenever you want it has no direct blocking connection. This all have nothing to do with simultaneously. |
And it has nothing to do with |
To make your case a bit more clear, you have the main task where you do the work, you aquire a lock in the main task, while you have the lock aquired, the thread gets preamptid into the higher prio wifi_thread task. ( the main task still has the lock) . The callback now is executed inside the wifi_driver, trying to get the lock-> It will wait forever because the task has higher prio. You are in a deadlock |
@Vollbrecht thanks for explaining. Closing. |
I probably explained myself badly. While I shouldn't do lengthy operations in the callback function, even if the receive callback is blocked I should still be able to send messages. I understand the reason why that's happening, I'm just suggesting that this should not happen. The code above is just an explanatory example |
OK I understand your request, but I'm not sure we can do it. If you look at the source code, |
Alright. I opened this issue because for me it was difficult to find out the reason why the send function was not working in certain conditions. Thanks both for your quick reply |
on another note if you are using esp-idf 5, the callback we are providing is something suboptimal, we just implemented a quick fix to have both v4 and v5 working, but with v5 you get some more meta information around |
The send function is not working if something is blocking the receive callback.
For example:
I know that this isn't the right way to use the receive callback but can't we send messages while the receive callback is being executed?
The text was updated successfully, but these errors were encountered: