@@ -27,10 +27,13 @@ using namespace mbed_cellular_util;
27
27
QUECTEL_BC95_CellularStack::QUECTEL_BC95_CellularStack (ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type)
28
28
{
29
29
_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));
30
31
}
31
32
32
33
QUECTEL_BC95_CellularStack::~QUECTEL_BC95_CellularStack ()
33
34
{
35
+ _at.set_urc_handler (" +NSONMI:" , NULL );
36
+ _at.set_urc_handler (" +NSOCLI:" , NULL );
34
37
}
35
38
36
39
nsapi_error_t QUECTEL_BC95_CellularStack::socket_listen (nsapi_socket_t handle, int backlog)
@@ -88,6 +91,28 @@ void QUECTEL_BC95_CellularStack::urc_nsonmi()
88
91
}
89
92
}
90
93
94
+ void QUECTEL_BC95_CellularStack::urc_nsocli ()
95
+ {
96
+ int sock_id = _at.read_int ();
97
+
98
+ const nsapi_error_t err = _at.get_last_error ();
99
+
100
+ if (err != NSAPI_ERROR_OK) {
101
+ return ;
102
+ }
103
+
104
+ CellularSocket *sock = find_socket (sock_id);
105
+
106
+ if (sock) {
107
+ sock->closed = true ;
108
+ if (sock->_cb ) {
109
+ sock->_cb (sock->_data );
110
+ }
111
+ tr_info (" Socket closed %d" , sock_id);
112
+ }
113
+ }
114
+
115
+
91
116
int QUECTEL_BC95_CellularStack::get_max_socket_count ()
92
117
{
93
118
return BC95_SOCKET_MAX;
@@ -100,6 +125,11 @@ bool QUECTEL_BC95_CellularStack::is_protocol_supported(nsapi_protocol_t protocol
100
125
101
126
nsapi_error_t QUECTEL_BC95_CellularStack::socket_close_impl (int sock_id)
102
127
{
128
+ CellularSocket *sock = find_socket (sock_id);
129
+
130
+ if (sock && sock->closed ) {
131
+ return NSAPI_ERROR_OK;
132
+ }
103
133
_at.cmd_start (" AT+NSOCL=" );
104
134
_at.write_int (sock_id);
105
135
_at.cmd_stop_read_resp ();
0 commit comments