mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: AT handler to support only one callback per URC/prefix
parent
870c3bce59
commit
f016d1126f
|
|
@ -143,7 +143,7 @@ TEST_F(TestATHandler, test_ATHandler_remove_urc_handler)
|
|||
at.set_urc_handler(ch, cb);
|
||||
|
||||
//This does nothing!!!
|
||||
at.remove_urc_handler(ch, cb);
|
||||
at.remove_urc_handler(ch);
|
||||
}
|
||||
|
||||
TEST_F(TestATHandler, test_ATHandler_get_last_error)
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ nsapi_error_t ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()>
|
|||
return ATHandler_stub::nsapi_error_value;
|
||||
}
|
||||
|
||||
void ATHandler::remove_urc_handler(const char *prefix, mbed::Callback<void()> callback)
|
||||
void ATHandler::remove_urc_handler(const char *prefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ void ATHandler::set_is_filehandle_usable(bool usable)
|
|||
|
||||
nsapi_error_t ATHandler::set_urc_handler(const char *prefix, mbed::Callback<void()> callback)
|
||||
{
|
||||
if (find_urc_handler(prefix, &callback)) {
|
||||
if (find_urc_handler(prefix)) {
|
||||
tr_warn("URC already added with prefix: %s", prefix);
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
|
@ -186,12 +186,12 @@ nsapi_error_t ATHandler::set_urc_handler(const char *prefix, mbed::Callback<void
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
void ATHandler::remove_urc_handler(const char *prefix, mbed::Callback<void()> callback)
|
||||
void ATHandler::remove_urc_handler(const char *prefix)
|
||||
{
|
||||
struct oob_t *current = _oobs;
|
||||
struct oob_t *prev = NULL;
|
||||
while (current) {
|
||||
if (strcmp(prefix, current->prefix) == 0 && current->cb == callback) {
|
||||
if (strcmp(prefix, current->prefix) == 0) {
|
||||
if (prev) {
|
||||
prev->next = current->next;
|
||||
} else {
|
||||
|
|
@ -205,11 +205,11 @@ void ATHandler::remove_urc_handler(const char *prefix, mbed::Callback<void()> ca
|
|||
}
|
||||
}
|
||||
|
||||
bool ATHandler::find_urc_handler(const char *prefix, mbed::Callback<void()> *callback)
|
||||
bool ATHandler::find_urc_handler(const char *prefix)
|
||||
{
|
||||
struct oob_t *oob = _oobs;
|
||||
while (oob) {
|
||||
if (strcmp(prefix, oob->prefix) == 0 && oob->cb == *callback) {
|
||||
if (strcmp(prefix, oob->prefix) == 0) {
|
||||
return true;
|
||||
}
|
||||
oob = oob->next;
|
||||
|
|
|
|||
|
|
@ -109,9 +109,8 @@ public:
|
|||
/** Remove urc handler from linked list of urc's
|
||||
*
|
||||
* @param prefix Register urc prefix for callback. Urc could be for example "+CMTI: "
|
||||
* @param callback Callback, which is called if urc is found in AT response
|
||||
*/
|
||||
void remove_urc_handler(const char *prefix, mbed::Callback<void()> callback);
|
||||
void remove_urc_handler(const char *prefix);
|
||||
|
||||
ATHandler *_nextATHandler; // linked list
|
||||
|
||||
|
|
@ -515,7 +514,7 @@ private:
|
|||
const char *mem_str(const char *dest, size_t dest_len, const char *src, size_t src_len);
|
||||
|
||||
// check is urc is already added
|
||||
bool find_urc_handler(const char *prefix, mbed::Callback<void()> *callback);
|
||||
bool find_urc_handler(const char *prefix);
|
||||
|
||||
// print contents of a buffer to trace log
|
||||
void debug_print(char *p, int len);
|
||||
|
|
|
|||
|
|
@ -56,12 +56,12 @@ AT_CellularNetwork::~AT_CellularNetwork()
|
|||
|
||||
for (int type = 0; type < CellularNetwork::C_MAX; type++) {
|
||||
if (has_registration((RegistrationType)type) != RegistrationModeDisable) {
|
||||
_at.remove_urc_handler(at_reg[type].urc_prefix, _urc_funcs[type]);
|
||||
_at.remove_urc_handler(at_reg[type].urc_prefix);
|
||||
}
|
||||
}
|
||||
|
||||
_at.remove_urc_handler("NO CARRIER", callback(this, &AT_CellularNetwork::urc_no_carrier));
|
||||
_at.remove_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));
|
||||
_at.remove_urc_handler("NO CARRIER");
|
||||
_at.remove_urc_handler("+CGEV:");
|
||||
free_credentials();
|
||||
}
|
||||
|
||||
|
|
@ -456,7 +456,7 @@ nsapi_error_t AT_CellularNetwork::disconnect()
|
|||
|
||||
_at.restore_at_timeout();
|
||||
|
||||
_at.remove_urc_handler("+CGEV:", callback(this, &AT_CellularNetwork::urc_cgev));
|
||||
_at.remove_urc_handler("+CGEV:");
|
||||
call_network_cb(NSAPI_STATUS_DISCONNECTED);
|
||||
|
||||
return _at.unlock_return_error();
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ GEMALTO_CINTERION_CellularStack::GEMALTO_CINTERION_CellularStack(ATHandler &atHa
|
|||
|
||||
GEMALTO_CINTERION_CellularStack::~GEMALTO_CINTERION_CellularStack()
|
||||
{
|
||||
_at.remove_urc_handler("^SIS:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sis));
|
||||
_at.remove_urc_handler("^SISW:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sisw));
|
||||
_at.remove_urc_handler("^SISR:", mbed::Callback<void()>(this, &GEMALTO_CINTERION_CellularStack::urc_sisr));
|
||||
_at.remove_urc_handler("^SIS:");
|
||||
_at.remove_urc_handler("^SISW:");
|
||||
_at.remove_urc_handler("^SISR:");
|
||||
}
|
||||
|
||||
GEMALTO_CINTERION_CellularStack::CellularSocket *GEMALTO_CINTERION_CellularStack::find_socket(int sock_id)
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@ nsapi_error_t QUECTEL_BG96_CellularPower::set_device_ready_urc_cb(mbed::Callback
|
|||
|
||||
void QUECTEL_BG96_CellularPower::remove_device_ready_urc_cb(mbed::Callback<void()> callback)
|
||||
{
|
||||
_at.remove_urc_handler(DEVICE_READY_URC, callback);
|
||||
_at.remove_urc_handler(DEVICE_READY_URC);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue