Add possibility to test URC handlers

pull/11495/head
Kimmo Vaisanen 2019-09-16 13:56:34 +03:00
parent d83f52a2a1
commit 5778bc7326
2 changed files with 13 additions and 0 deletions

View File

@ -54,6 +54,8 @@ int ATHandler_stub::int_valid_count_table[kRead_int_table_size];
int ATHandler_stub::int_count = kRead_int_table_size;
bool ATHandler_stub::process_oob_urc = false;
std::vector<ATHandler_stub::urc_handler> ATHandler_stub::urc_handlers;
int ATHandler_stub::read_string_index = kRead_string_table_size;
const char *ATHandler_stub::read_string_table[kRead_string_table_size];
int ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
@ -111,6 +113,7 @@ bool ATHandler::get_debug() const
ATHandler::~ATHandler()
{
ATHandler_stub::urc_handlers.clear();
}
void ATHandler::inc_ref_count()
@ -149,6 +152,9 @@ void ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()> cb)
return;
}
ATHandler_stub::urc_handler handler = { .urc = urc, .cb = cb };
ATHandler_stub::urc_handlers.push_back(handler);
if (ATHandler_stub::call_immediately) {
cb();
}

View File

@ -22,6 +22,7 @@
#include "ATHandler.h"
#include "FileHandle_stub.h"
#include "Callback.h"
#include "vector"
#ifndef __AT_HANDLER_STUB_H__
#define __AT_HANDLER_STUB_H__
@ -61,6 +62,12 @@ extern int int_count;
extern int resp_stop_success_count;
extern bool process_oob_urc;
struct urc_handler {
const char *urc;
mbed::Callback<void()> cb;
};
extern std::vector<urc_handler> urc_handlers;
extern bool get_debug_flag;
bool is_get_debug_run();
void get_debug_clear();