Skip to content

Commit fd22b7c

Browse files
author
Mirela Chirica
committed
Cellular: Added WISE-1570 handling for socket closing URC
1 parent 46603f8 commit fd22b7c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ using namespace mbed_cellular_util;
2727
QUECTEL_BC95_CellularStack::QUECTEL_BC95_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type)
2828
{
2929
_at.set_urc_handler("+NSONMI:", mbed::Callback<void()>(this, &QUECTEL_BC95_CellularStack::urc_nsonmi));
30+
_at.set_urc_handler("+NSOCLI:", mbed::Callback<void()>(this, &QUECTEL_BC95_CellularStack::urc_nsocli));
3031
}
3132

3233
QUECTEL_BC95_CellularStack::~QUECTEL_BC95_CellularStack()
@@ -88,6 +89,28 @@ void QUECTEL_BC95_CellularStack::urc_nsonmi()
8889
}
8990
}
9091

92+
void QUECTEL_BC95_CellularStack::urc_nsocli()
93+
{
94+
int sock_id = _at.read_int();
95+
96+
const nsapi_error_t err = _at.get_last_error();
97+
98+
if (err != NSAPI_ERROR_OK) {
99+
return;
100+
}
101+
102+
CellularSocket *sock = find_socket(sock_id);
103+
104+
if (sock) {
105+
sock->closed = true;
106+
if (sock->_cb) {
107+
sock->_cb(sock->_data);
108+
}
109+
tr_error("Socket closed %d", sock_id);
110+
}
111+
}
112+
113+
91114
int QUECTEL_BC95_CellularStack::get_max_socket_count()
92115
{
93116
return BC95_SOCKET_MAX;
@@ -100,6 +123,11 @@ bool QUECTEL_BC95_CellularStack::is_protocol_supported(nsapi_protocol_t protocol
100123

101124
nsapi_error_t QUECTEL_BC95_CellularStack::socket_close_impl(int sock_id)
102125
{
126+
CellularSocket *sock = find_socket(sock_id);
127+
128+
if (sock && sock->closed) {
129+
return NSAPI_ERROR_OK;
130+
}
103131
_at.cmd_start("AT+NSOCL=");
104132
_at.write_int(sock_id);
105133
_at.cmd_stop_read_resp();

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class QUECTEL_BC95_CellularStack : public AT_CellularStack {
5757
private:
5858
// URC handlers
5959
void urc_nsonmi();
60+
void urc_nsocli();
6061
};
6162
} // namespace mbed
6263
#endif /* QUECTEL_BC95_CELLULARSTACK_H_ */

0 commit comments

Comments
 (0)