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

Push 512 instead of 256 bytes, async socket close #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/NBClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ int NBClient::ready()

case CLIENT_STATE_CLOSE_SOCKET: {

MODEM.sendf("AT+USOCL=%d", _socket);
MODEM.sendf("AT+USOCL=%d,1", _socket);

_state = CLIENT_STATE_WAIT_CLOSE_SOCKET;
ready = 0;
Expand Down Expand Up @@ -285,13 +285,13 @@ size_t NBClient::write(const uint8_t* buf, size_t size)
size_t written = 0;
String command;

command.reserve(19 + (size > 256 ? 256 : size) * 2);
command.reserve(19 + (size > 512 ? 512 : size) * 2);

while (size) {
size_t chunkSize = size;

if (chunkSize > 256) {
chunkSize = 256;
if (chunkSize > 512) {
chunkSize = 512;
}

command.reserve(19 + chunkSize * 2);
Expand Down Expand Up @@ -436,7 +436,7 @@ void NBClient::stop()
return;
}

MODEM.sendf("AT+USOCL=%d", _socket);
MODEM.sendf("AT+USOCL=%d,1", _socket);
MODEM.waitForResponse(10000);

NBSocketBuffer.close(_socket);
Expand All @@ -455,4 +455,4 @@ void NBClient::handleUrc(const String& urc)
}
}
}
}
}