Skip to content

Commit 0df07e6

Browse files
authored
Merge pull request #11937 from AriParkkila/cell-remove-rx-avail
Cellular: Replace CellularSocket.rx_avail with pending_bytes
2 parents e4b3603 + adba109 commit 0df07e6

File tree

5 files changed

+6
-14
lines changed

5 files changed

+6
-14
lines changed

features/cellular/framework/AT/AT_CellularStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ nsapi_size_or_error_t AT_CellularStack::socket_sendto(nsapi_socket_t handle, con
274274
return NSAPI_ERROR_NO_SOCKET;
275275
}
276276

277-
if (socket->closed && !socket->rx_avail) {
277+
if (socket->closed && !socket->pending_bytes) {
278278
tr_info("sendto socket %d closed", socket->id);
279279
return NSAPI_ERROR_NO_CONNECTION;
280280
}

features/cellular/framework/AT/AT_CellularStack.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase {
112112
closed(false),
113113
started(false),
114114
tx_ready(false),
115-
rx_avail(false),
116115
tls_socket(false),
117116
pending_bytes(0)
118117
{
@@ -130,7 +129,6 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase {
130129
bool closed; // socket has been closed by a peer
131130
bool started; // socket has been opened on modem stack
132131
bool tx_ready; // socket is ready for sending on modem stack
133-
bool rx_avail; // socket has data for reading on modem stack
134132
bool tls_socket; // socket uses modem's internal TLS socket functionality
135133
nsapi_size_t pending_bytes; // The number of received bytes pending
136134
};

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void GEMALTO_CINTERION_CellularStack::sisr_urc_handler(int sock_id, int urc_code
9999
if (sock) {
100100
if (urc_code == 1) { // data available
101101
if (sock->_cb) {
102-
sock->rx_avail = true;
102+
sock->pending_bytes = 1;
103103
sock->_cb(sock->_data);
104104
}
105105
}
@@ -387,9 +387,9 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
387387

388388
// we must use this flag, otherwise ^SISR URC can come while we are reading response and there is
389389
// no way to detect if that is really an URC or response
390-
if (!socket->rx_avail) {
390+
if (!socket->pending_bytes) {
391391
_at.process_oob(); // check for ^SISR URC
392-
if (!socket->rx_avail) {
392+
if (!socket->pending_bytes) {
393393
tr_debug("Socekt %d recv would block", socket->id);
394394
return NSAPI_ERROR_WOULD_BLOCK;
395395
}
@@ -430,12 +430,12 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
430430
tr_error("Socket %d recvfrom failed!", socket->id);
431431
return NSAPI_ERROR_DEVICE_ERROR;
432432
}
433-
socket->rx_avail = false;
433+
socket->pending_bytes = 0;
434434
if (len >= (nsapi_size_or_error_t)size) {
435435
len = (nsapi_size_or_error_t)size;
436436
int remain_len = _at.read_int();
437437
if (remain_len > 0) {
438-
socket->rx_avail = true;
438+
socket->pending_bytes = 1;
439439
}
440440
}
441441

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ void UBLOX_AT_CellularStack::UUSORD_URC()
5555

5656
socket = find_socket(a);
5757
if (socket != NULL) {
58-
socket->rx_avail = true;
5958
socket->pending_bytes = b;
6059
// No debug prints here as they can affect timing
6160
// and cause data loss in UARTSerial
@@ -76,7 +75,6 @@ void UBLOX_AT_CellularStack::UUSORF_URC()
7675

7776
socket = find_socket(a);
7877
if (socket != NULL) {
79-
socket->rx_avail = true;
8078
socket->pending_bytes = b;
8179
// No debug prints here as they can affect timing
8280
// and cause data loss in UARTSerial
@@ -353,7 +351,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
353351
}
354352
timer.stop();
355353

356-
socket->rx_avail = false;
357354
socket->pending_bytes = 0;
358355
if (!count || (_at.get_last_error() != NSAPI_ERROR_OK)) {
359356
return NSAPI_ERROR_WOULD_BLOCK;
@@ -398,7 +395,6 @@ void UBLOX_AT_CellularStack::clear_socket(CellularSocket *socket)
398395
if (socket != NULL) {
399396
socket->id = SOCKET_UNUSED;
400397
socket->started = false;
401-
socket->rx_avail = false;
402398
socket->pending_bytes = 0;
403399
socket->closed = true;
404400
if (socket->_cb) {

features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularStack.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void UBLOX_N2XX_CellularStack::NSONMI_URC()
5454

5555
socket = find_socket(a);
5656
if (socket != NULL) {
57-
socket->rx_avail = true;
5857
socket->pending_bytes = b;
5958
// No debug prints here as they can affect timing
6059
// and cause data loss in UARTSerial
@@ -209,7 +208,6 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
209208
}
210209
timer.stop();
211210

212-
socket->rx_avail = false;
213211
socket->pending_bytes = 0;
214212
if (!count || (_at.get_last_error() != NSAPI_ERROR_OK)) {
215213
return NSAPI_ERROR_WOULD_BLOCK;

0 commit comments

Comments
 (0)