mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: review fixes and fixed unit tests.
parent
12e1f07150
commit
f7f21dc377
|
@ -195,8 +195,8 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_set_access_technology()
|
|||
ATHandler at(&fh1, que, 0, ",");
|
||||
|
||||
AT_CellularNetwork cn(at);
|
||||
CHECK(NSAPI_ERROR_UNSUPPORTED == cn.set_access_technology(CellularNetwork::operator_t::RAT_UNKNOWN));
|
||||
CHECK(NSAPI_ERROR_UNSUPPORTED == cn.set_access_technology(CellularNetwork::operator_t::RAT_GSM_COMPACT));
|
||||
CHECK(NSAPI_ERROR_UNSUPPORTED == cn.set_access_technology(CellularNetwork::RAT_UNKNOWN));
|
||||
CHECK(NSAPI_ERROR_UNSUPPORTED == cn.set_access_technology(CellularNetwork::RAT_GSM_COMPACT));
|
||||
}
|
||||
|
||||
void Test_AT_CellularNetwork::test_AT_CellularNetwork_scan_plmn()
|
||||
|
|
|
@ -287,7 +287,7 @@ void Test_ATHandler::test_ATHandler_cmd_start()
|
|||
ATHandler at(&fh1, que, 0, ",");
|
||||
mbed_poll_stub::revents_value = POLLOUT;
|
||||
mbed_poll_stub::int_value = 1;
|
||||
fh1.size_value = 1;
|
||||
fh1.size_value = 3;
|
||||
at.cmd_start("s");
|
||||
mbed_poll_stub::revents_value = POLLIN;
|
||||
mbed_poll_stub::int_value = 0;
|
||||
|
@ -303,12 +303,13 @@ void Test_ATHandler::test_ATHandler_write_int()
|
|||
FileHandle_stub fh1;
|
||||
|
||||
ATHandler at(&fh1, que, 0, ",");
|
||||
fh1.size_value = -1;
|
||||
at.write_int(4);
|
||||
|
||||
at.clear_error();
|
||||
mbed_poll_stub::revents_value = POLLOUT;
|
||||
mbed_poll_stub::int_value = 1;
|
||||
fh1.size_value = 1;
|
||||
fh1.size_value = 6;
|
||||
at.write_int(4);
|
||||
|
||||
at.write_int(2147483647);
|
||||
|
@ -331,7 +332,7 @@ void Test_ATHandler::test_ATHandler_write_string()
|
|||
at.clear_error();
|
||||
mbed_poll_stub::revents_value = POLLOUT;
|
||||
mbed_poll_stub::int_value = 1;
|
||||
fh1.size_value = 1;
|
||||
fh1.size_value = -1;
|
||||
at.cmd_start("s");
|
||||
at.write_string("help", true);
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == at.get_last_error());
|
||||
|
@ -339,7 +340,7 @@ void Test_ATHandler::test_ATHandler_write_string()
|
|||
at.clear_error();
|
||||
mbed_poll_stub::revents_value = POLLOUT;
|
||||
mbed_poll_stub::int_value = 1;
|
||||
fh1.size_value = 3;
|
||||
fh1.size_value = -1;
|
||||
at.write_string("help", true);
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == at.get_last_error());
|
||||
|
||||
|
@ -357,6 +358,7 @@ void Test_ATHandler::test_ATHandler_cmd_stop()
|
|||
FileHandle_stub fh1;
|
||||
|
||||
ATHandler at(&fh1, que, 0, ",");
|
||||
fh1.size_value = -1;
|
||||
at.cmd_stop();
|
||||
|
||||
at.write_string("help", true);
|
||||
|
@ -371,6 +373,7 @@ void Test_ATHandler::test_ATHandler_write_bytes()
|
|||
FileHandle_stub fh1;
|
||||
|
||||
ATHandler at(&fh1, que, 0, ",");
|
||||
fh1.size_value = -1;
|
||||
uint8_t data[] = "data";
|
||||
at.write_bytes(data, 4);
|
||||
|
||||
|
|
|
@ -79,9 +79,10 @@ void ATHandler::set_file_handle(FileHandle *fh)
|
|||
{
|
||||
}
|
||||
|
||||
void ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()> cb)
|
||||
nsapi_error_t ATHandler::set_urc_handler(const char *urc, mbed::Callback<void()> cb)
|
||||
{
|
||||
ATHandler_stub::callback = cb;
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t ATHandler::get_last_error() const
|
||||
|
|
|
@ -33,6 +33,11 @@ AT_CellularNetwork::~AT_CellularNetwork()
|
|||
{
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::init()
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||
const char *username, const char *password)
|
||||
{
|
||||
|
@ -56,6 +61,11 @@ nsapi_error_t AT_CellularNetwork::connect()
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::activate_context()
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::open_data_channel()
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
|
@ -100,11 +110,17 @@ nsapi_ip_stack_t AT_CellularNetwork::string_to_stack_type(const char* pdp_type)
|
|||
return IPV4_STACK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_registration_urc(bool urc_on)
|
||||
nsapi_error_t AT_CellularNetwork::set_registration_urc(RegistrationType type, bool urc_on)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_network_registering_mode(NWRegisteringMode& mode)
|
||||
{
|
||||
mode = NWModeAutomatic;
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
|
@ -171,16 +187,22 @@ void AT_CellularNetwork::urc_no_carrier()
|
|||
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_access_technology_impl(operator_t::RadioAccessTechnology opsAct)
|
||||
nsapi_error_t AT_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_access_technology(operator_t::RadioAccessTechnology opAct)
|
||||
nsapi_error_t AT_CellularNetwork::set_access_technology(RadioAccessTechnology opAct)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_access_technology(RadioAccessTechnology& rat)
|
||||
{
|
||||
rat = RAT_CATM1;
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::scan_plmn(operList_t &operators, int &opsCount)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
|
|
|
@ -64,3 +64,13 @@ nsapi_error_t AT_CellularPower::opt_receive_period(int mode, EDRXAccessTechnolog
|
|||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularPower::set_device_ready_urc_cb(mbed::Callback<void()> callback)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
void AT_CellularPower::remove_device_ready_urc_cb(mbed::Callback<void()> callback){
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static uint8_t filehandle_stub_table_pos = 0;
|
|||
class FileHandle_stub : public FileHandle
|
||||
{
|
||||
public:
|
||||
size_t size_value;
|
||||
ssize_t size_value;
|
||||
|
||||
FileHandle_stub() {size_value = 0;}
|
||||
|
||||
|
@ -47,9 +47,11 @@ public:
|
|||
}
|
||||
|
||||
virtual ssize_t write(const void *buffer, size_t size){
|
||||
if( size_value ) {
|
||||
if (size_value > 0) {
|
||||
size_value--;
|
||||
return size;
|
||||
} else if (size_value < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace mbed
|
|||
CellularConnectionFSM::CellularConnectionFSM() :
|
||||
_serial(0), _state(STATE_INIT), _next_state(_state), _status_callback(0), _event_status_cb(0), _network(0), _power(0), _sim(0),
|
||||
_queue(8 * EVENTS_EVENT_SIZE), _queue_thread(0), _cellularDevice(0), _retry_count(0), _event_timeout(-1),
|
||||
_at_queue(8 * EVENTS_EVENT_SIZE), _eventID(0)
|
||||
_at_queue(8 * EVENTS_EVENT_SIZE), _event_id(0)
|
||||
{
|
||||
memset(_sim_pin, 0, sizeof(_sim_pin));
|
||||
#if MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY == 0
|
||||
|
@ -528,8 +528,8 @@ void CellularConnectionFSM::event()
|
|||
if (_event_timeout == -1) {
|
||||
_event_timeout = 0;
|
||||
}
|
||||
_eventID = _queue.call_in(_event_timeout*1000, callback(this, &CellularConnectionFSM::event));
|
||||
if (!_eventID) {
|
||||
_event_id = _queue.call_in(_event_timeout*1000, callback(this, &CellularConnectionFSM::event));
|
||||
if (!_event_id) {
|
||||
report_failure("Cellular event failure!");
|
||||
return;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ void CellularConnectionFSM::network_callback(nsapi_event_t ev, intptr_t ptr)
|
|||
if ((cellular_connection_status_t)ev == CellularRegistrationStatusChanged && _state == STATE_REGISTERING_NETWORK) {
|
||||
// expect packet data so only these states are valid
|
||||
if (ptr == CellularNetwork::RegisteredHomeNetwork && CellularNetwork::RegisteredRoaming) {
|
||||
_queue.cancel(_eventID);
|
||||
_queue.cancel(_event_id);
|
||||
continue_from_state(STATE_ATTACHING_NETWORK);
|
||||
}
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ void CellularConnectionFSM::ready_urc_cb()
|
|||
tr_debug("Device ready URC func called");
|
||||
if (_state == STATE_DEVICE_READY && _power->set_at_mode() == NSAPI_ERROR_OK) {
|
||||
tr_debug("State was STATE_DEVICE_READY and at mode ready, cancel state and move to next");
|
||||
_queue.cancel(_eventID);
|
||||
_queue.cancel(_event_id);
|
||||
if (device_ready()) {
|
||||
continue_from_state(STATE_SIM_PIN);
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ private:
|
|||
int _retry_array_length;
|
||||
events::EventQueue _at_queue;
|
||||
char _st_string[20];
|
||||
int _eventID;
|
||||
int _event_id;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue