Skip to content

Commit f016d11

Browse files
author
Mirela Chirica
committed
Cellular: AT handler to support only one callback per URC/prefix
1 parent 870c3bc commit f016d11

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

UNITTESTS/features/cellular/framework/AT/athandler/athandlertest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ TEST_F(TestATHandler, test_ATHandler_remove_urc_handler)
143143
at.set_urc_handler(ch, cb);
144144

145145
//This does nothing!!!
146-
at.remove_urc_handler(ch, cb);
146+
at.remove_urc_handler(ch);
147147
}
148148

149149
TEST_F(TestATHandler, test_ATHandler_get_last_error)

UNITTESTS/stubs/ATHandler_stub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ nsapi_error_t ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()>
105105
return ATHandler_stub::nsapi_error_value;
106106
}
107107

108-
void ATHandler::remove_urc_handler(const char *prefix, mbed::Callback<void()> callback)
108+
void ATHandler::remove_urc_handler(const char *prefix)
109109
{
110110
}
111111

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void ATHandler::set_is_filehandle_usable(bool usable)
159159

160160
nsapi_error_t ATHandler::set_urc_handler(const char *prefix, mbed::Callback<void()> callback)
161161
{
162-
if (find_urc_handler(prefix, &callback)) {
162+
if (find_urc_handler(prefix)) {
163163
tr_warn("URC already added with prefix: %s", prefix);
164164
return NSAPI_ERROR_OK;
165165
}
@@ -186,12 +186,12 @@ nsapi_error_t ATHandler::set_urc_handler(const char *prefix, mbed::Callback<void
186186
return NSAPI_ERROR_OK;
187187
}
188188

189-
void ATHandler::remove_urc_handler(const char *prefix, mbed::Callback<void()> callback)
189+
void ATHandler::remove_urc_handler(const char *prefix)
190190
{
191191
struct oob_t *current = _oobs;
192192
struct oob_t *prev = NULL;
193193
while (current) {
194-
if (strcmp(prefix, current->prefix) == 0 && current->cb == callback) {
194+
if (strcmp(prefix, current->prefix) == 0) {
195195
if (prev) {
196196
prev->next = current->next;
197197
} else {
@@ -205,11 +205,11 @@ void ATHandler::remove_urc_handler(const char *prefix, mbed::Callback<void()> ca
205205
}
206206
}
207207

208-
bool ATHandler::find_urc_handler(const char *prefix, mbed::Callback<void()> *callback)
208+
bool ATHandler::find_urc_handler(const char *prefix)
209209
{
210210
struct oob_t *oob = _oobs;
211211
while (oob) {
212-
if (strcmp(prefix, oob->prefix) == 0 && oob->cb == *callback) {
212+
if (strcmp(prefix, oob->prefix) == 0) {
213213
return true;
214214
}
215215
oob = oob->next;

features/cellular/framework/AT/ATHandler.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ class ATHandler {
109109
/** Remove urc handler from linked list of urc's
110110
*
111111
* @param prefix Register urc prefix for callback. Urc could be for example "+CMTI: "
112-
* @param callback Callback, which is called if urc is found in AT response
113112
*/
114-
void remove_urc_handler(const char *prefix, mbed::Callback<void()> callback);
113+
void remove_urc_handler(const char *prefix);
115114

116115
ATHandler *_nextATHandler; // linked list
117116

@@ -515,7 +514,7 @@ class ATHandler {
515514
const char *mem_str(const char *dest, size_t dest_len, const char *src, size_t src_len);
516515

517516
// check is urc is already added
518-
bool find_urc_handler(const char *prefix, mbed::Callback<void()> *callback);
517+
bool find_urc_handler(const char *prefix);
519518

520519
// print contents of a buffer to trace log
521520
void debug_print(char *p, int len);

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ AT_CellularNetwork::~AT_CellularNetwork()
5656

5757
for (int type = 0; type < CellularNetwork::C_MAX; type++) {
5858
if (has_registration((RegistrationType)type) != RegistrationModeDisable) {
59-
_at.remove_urc_handler(at_reg[type].urc_prefix, _urc_funcs[type]);
59+
_at.remove_urc_handler(at_reg[type].urc_prefix);
6060
}
6161
}
6262

63-
_at.remove_urc_handler("NO CARRIER", callback(this, &AT_CellularNetwork::urc_no_carrier));
64-
_at.remove_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));
63+
_at.remove_urc_handler("NO CARRIER");
64+
_at.remove_urc_handler("+CGEV:");
6565
free_credentials();
6666
}
6767

@@ -456,7 +456,7 @@ nsapi_error_t AT_CellularNetwork::disconnect()
456456

457457
_at.restore_at_timeout();
458458

459-
_at.remove_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));
459+
_at.remove_urc_handler("+CGEV:");
460460
call_network_cb(NSAPI_STATUS_DISCONNECTED);
461461

462462
return _at.unlock_return_error();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ GEMALTO_CINTERION_CellularStack::GEMALTO_CINTERION_CellularStack(ATHandler &atHa
3939

4040
GEMALTO_CINTERION_CellularStack::~GEMALTO_CINTERION_CellularStack()
4141
{
42-
_at.remove_urc_handler("^SIS:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sis));
43-
_at.remove_urc_handler("^SISW:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sisw));
44-
_at.remove_urc_handler("^SISR:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sisr));
42+
_at.remove_urc_handler("^SIS:");
43+
_at.remove_urc_handler("^SISW:");
44+
_at.remove_urc_handler("^SISR:");
4545
}
4646

4747
GEMALTO_CINTERION_CellularStack::CellularSocket *GEMALTO_CINTERION_CellularStack::find_socket(int sock_id)

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularPower.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ nsapi_error_t QUECTEL_BG96_CellularPower::set_device_ready_urc_cb(mbed::Callback
3232

3333
void QUECTEL_BG96_CellularPower::remove_device_ready_urc_cb(mbed::Callback<void()> callback)
3434
{
35-
_at.remove_urc_handler(DEVICE_READY_URC, callback);
35+
_at.remove_urc_handler(DEVICE_READY_URC);
3636
}

0 commit comments

Comments
 (0)