mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: release resources in state machine. Made sure that athandler does not try process urc's after switch to data mode.
parent
7bc411eedb
commit
97cdbf769d
|
@ -402,6 +402,8 @@ void CellularConnectionFSM::device_ready()
|
||||||
_event_status_cb((nsapi_event_t)CellularDeviceReady, 0);
|
_event_status_cb((nsapi_event_t)CellularDeviceReady, 0);
|
||||||
}
|
}
|
||||||
_power->remove_device_ready_urc_cb(mbed::callback(this, &CellularConnectionFSM::ready_urc_cb));
|
_power->remove_device_ready_urc_cb(mbed::callback(this, &CellularConnectionFSM::ready_urc_cb));
|
||||||
|
_cellularDevice->close_power();
|
||||||
|
_power = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellularConnectionFSM::state_device_ready()
|
void CellularConnectionFSM::state_device_ready()
|
||||||
|
@ -434,7 +436,8 @@ void CellularConnectionFSM::state_sim_pin()
|
||||||
retry_state_or_fail();
|
retry_state_or_fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_cellularDevice->close_sim();
|
||||||
|
_sim = NULL;
|
||||||
if (_plmn) {
|
if (_plmn) {
|
||||||
enter_to_state(STATE_MANUAL_REGISTERING_NETWORK);
|
enter_to_state(STATE_MANUAL_REGISTERING_NETWORK);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -117,7 +117,9 @@ public:
|
||||||
*/
|
*/
|
||||||
CellularDevice *get_device();
|
CellularDevice *get_device();
|
||||||
|
|
||||||
/** Get cellular sim interface
|
/** Get cellular sim interface. SIM interface is released after SIM is open and ready for use (moving from STATE_SIM_PIN to next state).
|
||||||
|
* After SIM interface is closed this method will return NULL. SIM interface can be created again via CellularDevice
|
||||||
|
* which you can get with the method get_device().
|
||||||
* @return sim interface, NULL on failure
|
* @return sim interface, NULL on failure
|
||||||
*/
|
*/
|
||||||
CellularSIM *get_sim();
|
CellularSIM *get_sim();
|
||||||
|
|
|
@ -72,6 +72,7 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char
|
||||||
_fh_sigio_set(false),
|
_fh_sigio_set(false),
|
||||||
_processing(false),
|
_processing(false),
|
||||||
_ref_count(1),
|
_ref_count(1),
|
||||||
|
_is_fh_usable(true),
|
||||||
_stop_tag(NULL),
|
_stop_tag(NULL),
|
||||||
_delimiter(DEFAULT_DELIMITER),
|
_delimiter(DEFAULT_DELIMITER),
|
||||||
_prefix_matched(false),
|
_prefix_matched(false),
|
||||||
|
@ -151,6 +152,11 @@ void ATHandler::set_file_handle(FileHandle *fh)
|
||||||
_fileHandle = fh;
|
_fileHandle = fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATHandler::set_is_filehandle_usable(bool usable)
|
||||||
|
{
|
||||||
|
_is_fh_usable = usable;
|
||||||
|
}
|
||||||
|
|
||||||
nsapi_error_t ATHandler::set_urc_handler(const char *prefix, mbed::Callback<void()> callback)
|
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, callback)) {
|
||||||
|
@ -269,6 +275,10 @@ void ATHandler::restore_at_timeout()
|
||||||
|
|
||||||
void ATHandler::process_oob()
|
void ATHandler::process_oob()
|
||||||
{
|
{
|
||||||
|
if (!_is_fh_usable) {
|
||||||
|
tr_debug("process_oob, filehandle is not usable, return...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
lock();
|
lock();
|
||||||
tr_debug("process_oob readable=%d, pos=%u, len=%u", _fileHandle->readable(), _recv_pos, _recv_len);
|
tr_debug("process_oob readable=%d, pos=%u, len=%u", _fileHandle->readable(), _recv_pos, _recv_len);
|
||||||
if (_fileHandle->readable() || (_recv_pos < _recv_len)) {
|
if (_fileHandle->readable() || (_recv_pos < _recv_len)) {
|
||||||
|
|
|
@ -175,6 +175,13 @@ public:
|
||||||
*/
|
*/
|
||||||
void set_file_handle(FileHandle *fh);
|
void set_file_handle(FileHandle *fh);
|
||||||
|
|
||||||
|
/** Set is file handle usable. Some situations like after going to data mode, file handle is not usable anymore.
|
||||||
|
* Any items in queue are not to be processed.
|
||||||
|
*
|
||||||
|
* @param usable true for usable filehandle
|
||||||
|
*/
|
||||||
|
void set_is_filehandle_usable(bool usable);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void event();
|
void event();
|
||||||
#ifdef AT_HANDLER_MUTEX
|
#ifdef AT_HANDLER_MUTEX
|
||||||
|
@ -209,6 +216,7 @@ private:
|
||||||
|
|
||||||
bool _processing;
|
bool _processing;
|
||||||
int32_t _ref_count;
|
int32_t _ref_count;
|
||||||
|
bool _is_fh_usable;
|
||||||
|
|
||||||
//*************************************
|
//*************************************
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -360,8 +360,12 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
|
||||||
|
|
||||||
_at.resp_start("CONNECT", true);
|
_at.resp_start("CONNECT", true);
|
||||||
if (_at.get_last_error()) {
|
if (_at.get_last_error()) {
|
||||||
tr_warn("Failed to CONNECT");
|
tr_error("Failed to CONNECT");
|
||||||
|
return _at.get_last_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_at.set_is_filehandle_usable(false);
|
||||||
|
|
||||||
/* Initialize PPP
|
/* Initialize PPP
|
||||||
* If blocking: mbed_ppp_init() is a blocking call, it will block until
|
* If blocking: mbed_ppp_init() is a blocking call, it will block until
|
||||||
connected, or timeout after 30 seconds*/
|
connected, or timeout after 30 seconds*/
|
||||||
|
@ -385,6 +389,7 @@ nsapi_error_t AT_CellularNetwork::disconnect()
|
||||||
// will set the correct sigio and nonblocking
|
// will set the correct sigio and nonblocking
|
||||||
_at.lock();
|
_at.lock();
|
||||||
_at.set_file_handle(_at.get_file_handle());
|
_at.set_file_handle(_at.get_file_handle());
|
||||||
|
_at.set_is_filehandle_usable(true);
|
||||||
_at.unlock();
|
_at.unlock();
|
||||||
return err;
|
return err;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue