Skip to content

Commit 5778bc7

Browse files
author
Kimmo Vaisanen
committed
Add possibility to test URC handlers
1 parent d83f52a commit 5778bc7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

UNITTESTS/stubs/ATHandler_stub.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ int ATHandler_stub::int_valid_count_table[kRead_int_table_size];
5454
int ATHandler_stub::int_count = kRead_int_table_size;
5555
bool ATHandler_stub::process_oob_urc = false;
5656

57+
std::vector<ATHandler_stub::urc_handler> ATHandler_stub::urc_handlers;
58+
5759
int ATHandler_stub::read_string_index = kRead_string_table_size;
5860
const char *ATHandler_stub::read_string_table[kRead_string_table_size];
5961
int ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
@@ -111,6 +113,7 @@ bool ATHandler::get_debug() const
111113

112114
ATHandler::~ATHandler()
113115
{
116+
ATHandler_stub::urc_handlers.clear();
114117
}
115118

116119
void ATHandler::inc_ref_count()
@@ -149,6 +152,9 @@ void ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()> cb)
149152
return;
150153
}
151154

155+
ATHandler_stub::urc_handler handler = { .urc = urc, .cb = cb };
156+
ATHandler_stub::urc_handlers.push_back(handler);
157+
152158
if (ATHandler_stub::call_immediately) {
153159
cb();
154160
}

UNITTESTS/stubs/ATHandler_stub.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ATHandler.h"
2323
#include "FileHandle_stub.h"
2424
#include "Callback.h"
25+
#include "vector"
2526

2627
#ifndef __AT_HANDLER_STUB_H__
2728
#define __AT_HANDLER_STUB_H__
@@ -61,6 +62,12 @@ extern int int_count;
6162
extern int resp_stop_success_count;
6263
extern bool process_oob_urc;
6364

65+
struct urc_handler {
66+
const char *urc;
67+
mbed::Callback<void()> cb;
68+
};
69+
extern std::vector<urc_handler> urc_handlers;
70+
6471
extern bool get_debug_flag;
6572
bool is_get_debug_run();
6673
void get_debug_clear();

0 commit comments

Comments
 (0)