mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Move device_ready from power to device
parent
38f79a9b65
commit
e49f90fb0b
|
|
@ -232,6 +232,17 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_modem_debug_on)
|
|||
dev.close_sms();
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_is_ready)
|
||||
{
|
||||
EventQueue que;
|
||||
FileHandle_stub fh1;
|
||||
ATHandler at(&fh1, que, 0, ",");
|
||||
|
||||
AT_CellularDevice dev(&fh1);
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||
EXPECT_TRUE(NSAPI_ERROR_OK == dev.is_ready());
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_set_power_save_mode)
|
||||
{
|
||||
EventQueue que;
|
||||
|
|
|
|||
|
|
@ -123,17 +123,6 @@ TEST_F(TestAT_CellularPower, test_AT_CellularPower_reset)
|
|||
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == pow.reset());
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularPower, test_AT_CellularPower_is_device_ready)
|
||||
{
|
||||
EventQueue que;
|
||||
FileHandle_stub fh1;
|
||||
ATHandler at(&fh1, que, 0, ",");
|
||||
|
||||
AT_CellularPower pow(at);
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
|
||||
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == pow.is_device_ready());
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularPower, test_AT_CellularPower_set_device_ready_urc_cb)
|
||||
{
|
||||
EventQueue que;
|
||||
|
|
|
|||
|
|
@ -151,6 +151,11 @@ void AT_CellularDevice::modem_debug_on(bool on)
|
|||
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularDevice::is_ready()
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularDevice::set_power_save_mode(int periodic_time, int active_time)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
|
|
|
|||
|
|
@ -64,8 +64,3 @@ void AT_CellularPower::remove_device_ready_urc_cb(mbed::Callback<void()> callbac
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularPower::is_device_ready()
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,11 @@ public:
|
|||
|
||||
virtual void modem_debug_on(bool on) {}
|
||||
|
||||
virtual nsapi_error_t is_ready()
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t set_power_save_mode(int periodic_time, int active_time)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static void wait_for_power(CellularPower *pwr)
|
|||
err = pwr->set_at_mode();
|
||||
}
|
||||
|
||||
TEST_ASSERT(pwr->is_device_ready() == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT(cellular_device->is_ready() == NSAPI_ERROR_OK);
|
||||
|
||||
pwr->remove_device_ready_urc_cb(&urc_callback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,6 +250,13 @@ public:
|
|||
*/
|
||||
virtual void modem_debug_on(bool on) = 0;
|
||||
|
||||
/** Check whether the device is ready to accept commands.
|
||||
*
|
||||
* @return NSAPI_ERROR_OK on success
|
||||
* NSAPI_ERROR_DEVICE_ERROR on failure
|
||||
*/
|
||||
virtual nsapi_error_t is_ready() = 0;
|
||||
|
||||
/** Set power save mode
|
||||
*
|
||||
* @remark See 3GPP TS 27.007 PSM for details
|
||||
|
|
|
|||
|
|
@ -93,13 +93,6 @@ public:
|
|||
*/
|
||||
virtual nsapi_error_t reset() = 0;
|
||||
|
||||
/** Check whether the device is ready to accept commands.
|
||||
*
|
||||
* @return NSAPI_ERROR_OK on success
|
||||
* NSAPI_ERROR_DEVICE_ERROR on failure
|
||||
*/
|
||||
virtual nsapi_error_t is_device_ready() = 0;
|
||||
|
||||
/** Set URC callback function for device specific ready urc. URC is defined in device specific
|
||||
* power API. Used in startup sequence to listen when device is ready
|
||||
* for using at commands and possible sim.
|
||||
|
|
|
|||
|
|
@ -366,6 +366,21 @@ void AT_CellularDevice::modem_debug_on(bool on)
|
|||
ATHandler::set_debug_list(_modem_debug_on);
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularDevice::is_ready()
|
||||
{
|
||||
_at->lock();
|
||||
_at->cmd_start("AT");
|
||||
_at->cmd_stop_read_resp();
|
||||
|
||||
// we need to do this twice because for example after data mode the first 'AT' command will give modem a
|
||||
// stimulus that we are back to command mode.
|
||||
_at->clear_error();
|
||||
_at->cmd_start("AT");
|
||||
_at->cmd_stop_read_resp();
|
||||
|
||||
return _at->unlock_return_error();
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularDevice::set_power_save_mode(int periodic_time, int active_time)
|
||||
{
|
||||
_at->lock();
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
virtual void modem_debug_on(bool on);
|
||||
|
||||
virtual nsapi_error_t is_ready();
|
||||
|
||||
virtual nsapi_error_t set_power_save_mode(int periodic_time, int active_time = 0);
|
||||
|
||||
virtual nsapi_error_t init_module();
|
||||
|
|
|
|||
|
|
@ -74,21 +74,6 @@ nsapi_error_t AT_CellularPower::reset()
|
|||
return _at.unlock_return_error();
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularPower::is_device_ready()
|
||||
{
|
||||
_at.lock();
|
||||
_at.cmd_start("AT");
|
||||
_at.cmd_stop_read_resp();
|
||||
|
||||
// we need to do this twice because for example after data mode the first 'AT' command will give modem a
|
||||
// stimulus that we are back to command mode.
|
||||
_at.clear_error();
|
||||
_at.cmd_start("AT");
|
||||
_at.cmd_stop_read_resp();
|
||||
|
||||
return _at.unlock_return_error();
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularPower::set_device_ready_urc_cb(mbed::Callback<void()> callback)
|
||||
{
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@ public:
|
|||
|
||||
virtual nsapi_error_t reset();
|
||||
|
||||
virtual nsapi_error_t is_device_ready();
|
||||
|
||||
virtual nsapi_error_t set_device_ready_urc_cb(mbed::Callback<void()> callback);
|
||||
|
||||
virtual void remove_device_ready_urc_cb(mbed::Callback<void()> callback);
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ void CellularStateMachine::state_init()
|
|||
if (!_power) {
|
||||
_power = _cellularDevice.open_power();
|
||||
}
|
||||
_cb_data.error = _power->is_device_ready();
|
||||
_cb_data.error = _cellularDevice.is_ready();
|
||||
if (_cb_data.error != NSAPI_ERROR_OK) {
|
||||
_event_timeout = _start_time;
|
||||
if (_start_time > 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue