|
18 | 18 | #include "CellularStateMachine.h"
|
19 | 19 | #include "CellularDevice.h"
|
20 | 20 | #include "CellularLog.h"
|
21 |
| -#include "Thread.h" |
22 |
| -#include "mbed_shared_queues.h" |
23 | 21 |
|
24 | 22 | #ifndef MBED_TRACE_MAX_LEVEL
|
25 | 23 | #define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO
|
@@ -51,9 +49,6 @@ const int DEVICE_READY = 0x04;
|
51 | 49 | namespace mbed {
|
52 | 50 |
|
53 | 51 | CellularStateMachine::CellularStateMachine(CellularDevice &device, events::EventQueue &queue, CellularNetwork &nw) :
|
54 |
| -#ifdef MBED_CONF_RTOS_PRESENT |
55 |
| - _queue_thread(0), |
56 |
| -#endif |
57 | 52 | _cellularDevice(device), _state(STATE_INIT), _next_state(_state), _target_state(_state),
|
58 | 53 | _event_status_cb(0), _network(nw), _queue(queue), _sim_pin(0), _retry_count(0),
|
59 | 54 | _event_timeout(-1), _event_id(-1), _plmn(0), _command_success(false),
|
@@ -106,16 +101,6 @@ void CellularStateMachine::reset()
|
106 | 101 | void CellularStateMachine::stop()
|
107 | 102 | {
|
108 | 103 | tr_debug("CellularStateMachine stop");
|
109 |
| -#ifdef MBED_CONF_RTOS_PRESENT |
110 |
| - if (_queue_thread) { |
111 |
| - _queue_thread->terminate(); |
112 |
| - delete _queue_thread; |
113 |
| - _queue_thread = NULL; |
114 |
| - } |
115 |
| -#else |
116 |
| - _queue.chain(NULL); |
117 |
| -#endif |
118 |
| - |
119 | 104 | reset();
|
120 | 105 | _event_id = STM_STOPPED;
|
121 | 106 | }
|
@@ -643,24 +628,11 @@ void CellularStateMachine::event()
|
643 | 628 |
|
644 | 629 | nsapi_error_t CellularStateMachine::start_dispatch()
|
645 | 630 | {
|
646 |
| -#ifdef MBED_CONF_RTOS_PRESENT |
647 |
| - if (!_queue_thread) { |
648 |
| - _queue_thread = new rtos::Thread(osPriorityNormal, 2048, NULL, "stm_queue"); |
649 |
| - _event_id = STM_STOPPED; |
650 |
| - } |
651 |
| - |
652 |
| - if (_event_id == STM_STOPPED) { |
653 |
| - if (_queue_thread->start(callback(&_queue, &events::EventQueue::dispatch_forever)) != osOK) { |
654 |
| - report_failure("Failed to start thread."); |
655 |
| - stop(); |
656 |
| - return NSAPI_ERROR_NO_MEMORY; |
657 |
| - } |
| 631 | + if (_event_id != -1) { |
| 632 | + tr_warn("Canceling ongoing event (%d)", _event_id); |
| 633 | + _queue.cancel(_event_id); |
658 | 634 | }
|
659 |
| - |
660 | 635 | _event_id = -1;
|
661 |
| -#else |
662 |
| - _queue.chain(mbed_event_queue()); |
663 |
| -#endif |
664 | 636 | return NSAPI_ERROR_OK;
|
665 | 637 | }
|
666 | 638 |
|
|
0 commit comments