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

Drastically speedup client.read() operation #439

Merged
merged 3 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions libraries/SocketWrapper/src/MbedClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ void arduino::MbedClient::readSocket() {
do {
if (rxBuffer.availableForStore() == 0) {
yield();
delay(100);
continue;
}
mutex->lock();
Expand All @@ -34,7 +33,6 @@ void arduino::MbedClient::readSocket() {
}
if (ret == NSAPI_ERROR_WOULD_BLOCK || ret == 0) {
yield();
delay(100);
mutex->unlock();
continue;
}
Expand Down Expand Up @@ -71,7 +69,7 @@ void arduino::MbedClient::configureSocket(Socket *_s) {
}
mutex->lock();
if (reader_th == nullptr) {
reader_th = new rtos::Thread;
reader_th = new rtos::Thread(osPriorityNormal - 2);
reader_th->start(mbed::callback(this, &MbedClient::readSocket));
}
mutex->unlock();
Expand Down
2 changes: 1 addition & 1 deletion libraries/SocketWrapper/src/MbedClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MbedClient : public arduino::Client {
int connectSSL(IPAddress ip, uint16_t port);
int connectSSL(const char* host, uint16_t port, bool disableSNI = false);
size_t write(uint8_t);
size_t write(const uint8_t* buf, size_t size);
size_t write(const uint8_t* buf, size_t size) override;
int available();
int read();
int read(uint8_t* buf, size_t size);
Expand Down