Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Notify when there is data in socket rx buffer#831

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Helienzo wants to merge1 commit intoarduino:main
base:main
Choose a base branch
Loading
fromHelienzo:feature/async_notify_socket_data
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletionslibraries/SocketWrapper/src/MbedClient.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,10 @@ void arduino::MbedClient::readSocket() {
int ret = NSAPI_ERROR_WOULD_BLOCK;
do {
if (rxBuffer.availableForStore() == 0) {
// Notify that the buffer is full and data needs to be processed
if (_data_available_cb) {
_data_available_cb();
}
yield();
continue;
}
Expand All@@ -42,6 +46,10 @@ void arduino::MbedClient::readSocket() {
mutex->unlock();
_status = true;
} while (ret == NSAPI_ERROR_WOULD_BLOCK || ret > 0);
// Notify about data in RX Buffer
if (_data_available_cb) {
_data_available_cb();
}
}
cleanup:
_status = false;
Expand Down
5 changes: 5 additions & 0 deletionslibraries/SocketWrapper/src/MbedClient.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,6 +89,10 @@ class MbedClient : public arduino::Client {
return sock != nullptr;
}

void registerDataAvailableCb(mbed::Callback<void(void)> cb) {
_data_available_cb = cb;
}

void setSocket(Socket* _sock);
Socket* getSocket() { return sock; };

Expand All@@ -114,6 +118,7 @@ class MbedClient : public arduino::Client {
}

private:
mbed::Callback<void(void)> _data_available_cb;
RingBufferN<SOCKET_BUFFER_SIZE> rxBuffer;
bool _status = false;
bool borrowed_socket = false;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp