Skip to content

Commit f47b431

Browse files
author
Veijo Pesonen
committed
Adjust OOB thread's stack size and check start() status
1 parent b2e9c9b commit f47b431

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

ESP8266Interface.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int ESP8266Interface::connect(const char *ssid, const char *pass, nsapi_security
125125

126126
void ESP8266Interface::start_bg_oob()
127127
{
128-
static const uint32_t _stack_sz = 2048;
128+
static const uint32_t _stack_sz = 1536;
129129

130130
if (!_oob_thr_sta) {
131131
_oob_thr_sta = (unsigned char*) (malloc(_stack_sz));
@@ -139,17 +139,20 @@ void ESP8266Interface::start_bg_oob()
139139
_oob_thr = new Thread(osPriorityNormal,
140140
_stack_sz,
141141
_oob_thr_sta,
142-
"oob_proc");
142+
"esp8266_oob");
143143
}
144-
145144
if (!_oob_thr) {
146145
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_THREAD_CREATE_FAILED), \
147-
"ESP8266::start_bg_oob: no thread");
146+
"ESP8266::start_bg_oob: thread creation failed");
148147
}
149148

150149
if (_oob_thr->get_state() == rtos::Thread::Deleted) {
151150
_oob_thr_run = true;
152-
_oob_thr->start(callback(this, &ESP8266Interface::bg_process_oob));
151+
osStatus status = _oob_thr->start(callback(this, &ESP8266Interface::thr_process_oob));
152+
if (status != osOK) {
153+
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_THREAD_CREATE_FAILED), \
154+
"ESP8266::start_bg_oob: thread start failed");
155+
}
153156
}
154157
}
155158

@@ -661,7 +664,6 @@ void ESP8266Interface::update_conn_state_cb()
661664
// Start from scratch if connection drops/is dropped
662665
case NSAPI_STATUS_DISCONNECTED:
663666
_started = false;
664-
_initialized = false;
665667
break;
666668
// Handled on AT layer
667669
case NSAPI_STATUS_LOCAL_UP:
@@ -676,7 +678,7 @@ void ESP8266Interface::update_conn_state_cb()
676678
}
677679
}
678680

679-
void ESP8266Interface::bg_process_oob()
681+
void ESP8266Interface::thr_process_oob()
680682
{
681683
while (_oob_thr_run) {
682684
if (_initialized) {

ESP8266Interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface
372372
rtos::Thread *_oob_thr;
373373
unsigned char *_oob_thr_sta;
374374
bool _oob_thr_run;
375-
void bg_process_oob();
375+
void thr_process_oob();
376376
void start_bg_oob();
377377
};
378378

0 commit comments

Comments
 (0)