Remove CellularBase and AT_CellularBase

Removed CellularBase and AT_CellularBase from cellular stack and updated both code and unittests accordingly.

Moved property handling into AT_CellularDevice
pull/11996/head
Antti Kauppila 2019-11-28 11:32:04 +02:00
parent 8d246d8ac1
commit e51230c5e4
109 changed files with 685 additions and 943 deletions

View File

@ -1,159 +0,0 @@
/*
* Copyright (c) 2018, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "AT_CellularBase.h"
#include "events/EventQueue.h"
#include "AT_CellularNetwork.h"
#include "ATHandler_stub.h"
#include "FileHandle_stub.h"
#include <string.h>
using namespace mbed;
using namespace events;
class my_base : public AT_CellularBase {
public:
my_base(ATHandler &at) : AT_CellularBase(at)
{
}
bool check_not_supported()
{
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
0, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
1, // AT_CGAUTH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
};
set_cellular_properties(cellular_properties);
return get_property(PROPERTY_AT_CGSN_WITH_TYPE);
}
bool check_supported()
{
return get_property(PROPERTY_AT_CGDATA);
}
void reset_property_array()
{
_property_array = NULL;
}
};
// AStyle ignored as the definition is not clear due to preprocessor usage
// *INDENT-OFF*
class TestAT_CellularBase : public testing::Test {
protected:
void SetUp()
{
}
void TearDown()
{
}
};
// *INDENT-ON*
TEST_F(TestAT_CellularBase, Create)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 100, ",");
AT_CellularBase *unit = new AT_CellularBase(ah);
EXPECT_TRUE(unit != NULL);
delete unit;
}
TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_at_handler)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 100, ",");
AT_CellularBase at(ah);
EXPECT_TRUE(&ah == &at.get_at_handler());
}
TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_device_error)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularBase at(ah);
ATHandler_stub::device_err_value.errCode = 8;
EXPECT_EQ(8, at.get_device_error().errCode);
ATHandler_stub::device_err_value.errCode = 0;
}
TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_cellular_properties)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularBase at(ah);
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
0, // AT_CGSN_WITH_TYPE
1, // AT_CGDATA
1, // AT_CGAUTH
1, // PROPERTY_IPV4_STACK
0, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
};
at.set_cellular_properties(cellular_properties);
}
TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
my_base my_at(ah);
EXPECT_EQ(true, my_at.check_supported());
EXPECT_EQ(false, my_at.check_not_supported());
}
TEST_F(TestAT_CellularBase, test_invalid_params)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
my_base my_at(ah);
my_at.reset_property_array(); // as array is a static variable, it might have been set in previous tests
my_at.set_cellular_properties(NULL);
// Property array not set
EXPECT_EQ(0, my_at.get_property(AT_CellularBase::PROPERTY_IPV4_PDP_TYPE));
}

View File

@ -1,30 +0,0 @@
####################
# UNIT TESTS
####################
# Add test specific include paths
set(unittest-includes ${unittest-includes}
features/cellular/framework/AT/AT_CellularBase
../features/cellular/framework/AT
../features/cellular/framework/common
../features/frameworks/mbed-trace
../features/frameworks/nanostack-libservice/mbed-client-libservice
../features/netsocket
)
# Source files
set(unittest-sources
../features/cellular/framework/AT/AT_CellularBase.cpp
)
# Test files
set(unittest-test-sources
features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp
stubs/mbed_assert_stub.cpp
stubs/ATHandler_stub.cpp
stubs/EventQueue_stub.cpp
stubs/FileHandle_stub.cpp
stubs/ConditionVariable_stub.cpp
stubs/Mutex_stub.cpp
)

View File

@ -26,8 +26,8 @@
#include "AT_CellularStack.h"
#include "Semaphore_stub.h"
#include "CellularDevice_stub.h"
#include "AT_CellularDevice_stub.h"
#include "equeue_stub.h"
#include "AT_CellularBase_stub.h"
#include "CellularUtil_stub.h"
#include "PinNames.h"
@ -76,7 +76,7 @@ protected:
// *INDENT-ON*
class my_stack : public AT_CellularStack {
public:
my_stack(ATHandler &atHandler) : AT_CellularStack(atHandler, 1, IPV4_STACK) {}
my_stack(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularStack(atHandler, 1, IPV4_STACK, device) {}
virtual int get_max_socket_count()
{
return 1;
@ -117,9 +117,9 @@ public:
class my_AT_CTX : public AT_CellularContext {
public:
my_AT_CTX(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
AT_CellularContext(at, device, apn), _st(at)
AT_CellularContext(at, device, apn), _st(at, *get_device())
{
AT_CellularBase_stub::supported_bool = false;
AT_CellularDevice_stub::supported_bool = false;
}
virtual ~my_AT_CTX() {}
@ -152,7 +152,7 @@ public:
class my_AT_CTXIPV6 : public AT_CellularContext {
public:
my_AT_CTXIPV6(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
AT_CellularContext(at, device, apn), _st(at) {}
AT_CellularContext(at, device, apn), _st(at, *get_device()) {}
virtual ~my_AT_CTXIPV6() {}
virtual NetworkStack *get_stack()
{
@ -579,13 +579,13 @@ TEST_F(TestAT_CellularContext, connect_disconnect_sync)
ATHandler_stub::read_string_index = 2;
ASSERT_EQ(ctx1.connect(), NSAPI_ERROR_OK);
AT_CellularBase_stub::supported_bool = true;
AT_CellularDevice_stub::supported_bool = true;
ASSERT_EQ(ctx1.disconnect(), NSAPI_ERROR_OK);
ATHandler_stub::resp_info_true_counter = 1;
ATHandler_stub::read_string_table[1] = (char *)"IPV4V6";
ATHandler_stub::read_string_index = 2;
ASSERT_EQ(ctx1.connect(), NSAPI_ERROR_OK);
AT_CellularBase_stub::supported_bool = false;
AT_CellularDevice_stub::supported_bool = false;
ASSERT_EQ(ctx1.disconnect(), NSAPI_ERROR_OK);
ATHandler_stub::resp_info_true_counter = 1;

View File

@ -21,7 +21,6 @@ set(unittest-sources
set(unittest-test-sources
features/cellular/framework/AT/at_cellularcontext/at_cellularcontexttest.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/AT_CellularStack_stub.cpp
stubs/AT_CellularNetwork_stub.cpp

View File

@ -18,7 +18,7 @@
#include <string.h>
#include "AT_CellularDevice.h"
#include "ATHandler_stub.h"
#include "AT_CellularBase_stub.h"
#include "AT_CellularDevice_stub.h"
using namespace mbed;
using namespace events;
@ -70,7 +70,6 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_at_handler)
EXPECT_TRUE(dev.open_network(&fh1)); // AT fh1 ref count 2
dev.modem_debug_on(true);
EXPECT_TRUE(dev.open_sms(&fh2));
AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
EXPECT_TRUE(dev.open_information(&fh3));
ATHandler_stub::fh_value = &fh1;
@ -132,7 +131,6 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_network)
AT_CellularDevice dev(&fh1);
EXPECT_TRUE(dev.open_network(&fh1));
AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
EXPECT_EQ(ATHandler_stub::ref_count, 1);
dev.close_network();
@ -144,7 +142,6 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_sms)
AT_CellularDevice dev(&fh1);
EXPECT_TRUE(dev.open_sms(&fh1));
AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
EXPECT_EQ(ATHandler_stub::ref_count, 1);
dev.close_sms();
@ -159,16 +156,11 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_information)
EXPECT_TRUE(dev.open_information(&fh1));
ATHandler_stub::fh_value = NULL;
AT_CellularBase_stub::handler_value = NULL;
dev.close_information();
EventQueue que;
ATHandler_stub::fh_value = &fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularBase_stub::handler_value = &at;
EXPECT_TRUE(dev.open_information(&fh1));
AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
dev.close_information();

View File

@ -29,7 +29,6 @@ set(unittest-test-sources
stubs/AT_CellularSMS_stub.cpp
stubs/AT_CellularInformation_stub.cpp
stubs/CellularUtil_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/NetworkInterface_stub.cpp
stubs/NetworkInterfaceDefaults_stub.cpp
stubs/EventQueue_stub.cpp

View File

@ -19,10 +19,11 @@
#include "ATHandler_stub.h"
#include "events/EventQueue.h"
#include "FileHandle_stub.h"
#include "AT_CellularBase_stub.h"
#include "CellularDevice_stub.h"
#include "AT_CellularDevice_stub.h"
#include "ATHandler.h"
#include "myCellularDevice.h"
#include "AT_CellularInformation.h"
#include "AT_CellularBase.h"
using namespace mbed;
using namespace events;
@ -38,11 +39,17 @@ protected:
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::read_string_value = NULL;
ATHandler_stub::ssize_value = 0;
_dev = new myCellularDevice(&_fh);
}
void TearDown()
{
delete _dev;
}
FileHandle_stub _fh;
AT_CellularDevice *_dev;
};
// *INDENT-ON*
@ -51,7 +58,7 @@ TEST_F(TestAT_CellularInformation, Create)
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation *unit = new AT_CellularInformation(ah);
AT_CellularInformation *unit = new AT_CellularInformation(ah, *_dev);
EXPECT_TRUE(unit != NULL);
delete unit;
}
@ -61,7 +68,7 @@ TEST_F(TestAT_CellularInformation, test_AT_CellularInformation_get_manufacturer)
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation aci(ah);
AT_CellularInformation aci(ah, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::read_string_value = (char *)"some";
@ -83,7 +90,7 @@ TEST_F(TestAT_CellularInformation, test_AT_CellularInformation_get_model)
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation aci(ah);
AT_CellularInformation aci(ah, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::read_string_value = (char *)"model";
@ -106,7 +113,7 @@ TEST_F(TestAT_CellularInformation, test_AT_CellularInformation_get_revision)
ATHandler ah(&fh, eq, 0, ",");
//Used heap var here to visit heap constructor
AT_CellularInformation *aci = new AT_CellularInformation(ah);
AT_CellularInformation *aci = new AT_CellularInformation(ah, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::read_string_value = (char *)"revision";
@ -132,7 +139,7 @@ TEST_F(TestAT_CellularInformation, test_AT_CellularInformation_get_serial_number
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation aci(ah);
AT_CellularInformation aci(ah, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::read_string_value = (char *)"1234567";
@ -148,14 +155,14 @@ TEST_F(TestAT_CellularInformation, test_AT_CellularInformation_get_serial_number
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == aci.get_serial_number(buf, 8, CellularInformation::SN));
EXPECT_TRUE(strlen(buf) == 0);
AT_CellularBase_stub::supported_bool = false;
AT_CellularDevice_stub::supported_bool = false;
EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == aci.get_serial_number(buf, 8, CellularInformation::IMEI));
EXPECT_TRUE(strlen(buf) == 0);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::read_string_value = (char *)"1234567";
ATHandler_stub::ssize_value = 7;
AT_CellularBase_stub::supported_bool = true;
AT_CellularDevice_stub::supported_bool = true;
EXPECT_TRUE(NSAPI_ERROR_OK == aci.get_serial_number(buf, 8, CellularInformation::IMEI));
EXPECT_TRUE(strcmp("1234567", buf) == 0);
@ -168,7 +175,7 @@ TEST_F(TestAT_CellularInformation, TestAT_CellularInformation_get_imsi)
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation aci(ah);
AT_CellularInformation aci(ah, *_dev);
char imsi[16];
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
@ -195,7 +202,7 @@ TEST_F(TestAT_CellularInformation, TestAT_CellularInformation_get_iccid)
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation aci(ah);
AT_CellularInformation aci(ah, *_dev);
char buf[16];
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;

View File

@ -9,6 +9,7 @@ set(unittest-includes ${unittest-includes}
../features/cellular/framework/common
../features/cellular/framework/AT
../features/frameworks/mbed-client-randlib/mbed-client-randlib
../features/netsocket/cellular
)
# Source files
@ -21,10 +22,16 @@ set(unittest-sources
set(unittest-test-sources
features/cellular/framework/AT//at_cellularinformation/at_cellularinformationtest.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/EventQueue_stub.cpp
stubs/FileHandle_stub.cpp
stubs/mbed_assert_stub.cpp
stubs/ConditionVariable_stub.cpp
stubs/CellularDevice_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/CellularContext_stub.cpp
stubs/AT_CellularContext_stub.cpp
stubs/AT_CellularNetwork_stub.cpp
stubs/NetworkInterface_stub.cpp
stubs/NetworkInterfaceDefaults_stub.cpp
stubs/Mutex_stub.cpp
)

View File

@ -24,6 +24,9 @@
#include "CellularLog.h"
#include "ATHandler_stub.h"
#include "AT_CellularStack.h"
#include "myCellularDevice.h"
#include "CellularDevice_stub.h"
#include "AT_CellularDevice_stub.h"
using namespace mbed;
using namespace events;
@ -40,17 +43,25 @@ protected:
ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::int_value = -1;
AT_CellularDevice_stub::supported_bool = false;
_dev = new myCellularDevice(&_fh);
}
void TearDown()
{
delete _dev;
AT_CellularDevice_stub::supported_bool = false;
}
FileHandle_stub _fh;
AT_CellularDevice *_dev;
};
class my_AT_CN : public AT_CellularNetwork {
public:
my_AT_CN(ATHandler &atHandler) : AT_CellularNetwork(atHandler) {}
my_AT_CN(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device) {}
virtual ~my_AT_CN() {}
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat)
{
@ -58,16 +69,6 @@ public:
}
};
class my_AT_CNipv6 : public AT_CellularNetwork {
public:
my_AT_CNipv6(ATHandler &atHandler) : AT_CellularNetwork(atHandler) {}
virtual ~my_AT_CNipv6() {}
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat)
{
return NSAPI_ERROR_OK;
}
};
static int network_cb_count;
static void network_cb(nsapi_event_t ev, intptr_t intptr)
{
@ -80,7 +81,7 @@ TEST_F(TestAT_CellularNetwork, Create)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork *cn = new AT_CellularNetwork(at);
AT_CellularNetwork *cn = new AT_CellularNetwork(at, *_dev);
EXPECT_TRUE(cn != NULL);
delete cn;
}
@ -120,7 +121,7 @@ TEST_F(TestAT_CellularNetwork, test_urc_creg)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
cn.attach(status_cb_urc);
EXPECT_STREQ("+CEREG:", ATHandler_stub::urc_handlers[0].urc);
@ -174,7 +175,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_registration)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_registration());
@ -195,7 +196,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_registration_params)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
ATHandler_stub::int_value = 3;
CellularNetwork::registration_params_t reg_params;
@ -236,7 +237,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_registration_params)
ASSERT_EQ(reg_params._act, CellularNetwork::RAT_EGPRS);
ASSERT_EQ(reg_params._cell_id, -1);
my_AT_CN nw(at);
my_AT_CN nw(at, *_dev);
reg_params._status = CellularNetwork::NotRegistered;
reg_params._act = CellularNetwork::RAT_GSM;
@ -300,7 +301,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_registration_status_chang
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
cn.attach(&disconnect_cb);
@ -353,7 +354,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_network_registering_m
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::int_value = 0;
CellularNetwork::NWRegisteringMode mode = CellularNetwork::NWModeManual;
@ -372,7 +373,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_registration_urc)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
CellularNetwork::RegistrationType type = CellularNetwork::C_EREG;
ASSERT_EQ(NSAPI_ERROR_OK, cn.set_registration_urc(type, true));
@ -381,7 +382,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_registration_urc)
type = CellularNetwork::C_REG;
ASSERT_EQ(NSAPI_ERROR_OK, cn.set_registration_urc(type, true));
my_AT_CN nw(at);
my_AT_CN nw(at, *_dev);
type = CellularNetwork::C_EREG;
ASSERT_EQ(NSAPI_ERROR_OK, nw.set_registration_urc(type, true));
type = CellularNetwork::C_GREG;
@ -440,7 +441,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_attach)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::int_value = 0;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_attach());
ATHandler_stub::int_value = 1;
@ -456,7 +457,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_attach)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
CellularNetwork::AttachStatus stat = CellularNetwork::Detached;
ATHandler_stub::int_value = 1;
ATHandler_stub::bool_value = true;
@ -490,7 +491,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_detach)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
my_AT_CN cn(at);
my_AT_CN cn(at, *_dev);
EXPECT_TRUE(NSAPI_ERROR_OK == cn.detach());
@ -504,12 +505,12 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_access_technology)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.set_access_technology(CellularNetwork::RAT_UNKNOWN));
EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.set_access_technology(CellularNetwork::RAT_GSM_COMPACT));
my_AT_CN my_cn(at);
my_AT_CN my_cn(at, *_dev);
EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_access_technology(CellularNetwork::RAT_GSM_COMPACT));
}
@ -519,7 +520,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_scan_plmn)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
int c = -1;
CellularNetwork::operList_t ops;
ATHandler_stub::bool_value = false;
@ -567,7 +568,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_ciot_optimization_con
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_ciot_optimization_config(CellularNetwork::CIOT_OPT_NO_SUPPORT, CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE, NULL));
@ -581,7 +582,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_ciot_ue_optimization_
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
CellularNetwork::CIoT_Supported_Opt sup = CellularNetwork::CIOT_OPT_NO_SUPPORT;
CellularNetwork::CIoT_Preferred_UE_Opt pref = CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE;
ATHandler_stub::int_value = 1;
@ -606,7 +607,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_ciot_network_optimiza
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
CellularNetwork::CIoT_Supported_Opt sup = CellularNetwork::CIOT_OPT_NO_SUPPORT;
ATHandler_stub::int_value = 1;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
@ -620,7 +621,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_signal_quality)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
int rs = -1, ber = -1;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_signal_quality(rs, &ber));
@ -639,7 +640,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_3gpp_error)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::int_value = 8;
EXPECT_TRUE(8 == cn.get_3gpp_error());
}
@ -650,7 +651,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_operator_params)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
int format;
CellularNetwork::operator_t ops;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
@ -696,7 +697,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_operator_names)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
CellularNetwork::operator_names_list name_list;
ATHandler_stub::resp_info_true_counter = 0;
@ -731,7 +732,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_attach)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
network_cb_count = 0;
@ -744,7 +745,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_receive_period)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_receive_period(1, CellularNetwork::EDRXUTRAN_Iu_mode, 3));
@ -758,8 +759,11 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_packet_domain_event_r
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.set_packet_domain_event_reporting(true));
AT_CellularDevice_stub::supported_bool = true;
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_packet_domain_event_reporting(true));
EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_packet_domain_event_reporting(false));
@ -774,7 +778,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_is_active_context)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
AT_CellularNetwork cn(at, *_dev);
// No contexts
int active_contexts = -1;

View File

@ -9,6 +9,7 @@ set(unittest-includes ${unittest-includes}
../features/cellular/framework/common
../features/cellular/framework/AT
../features/frameworks/mbed-client-randlib/mbed-client-randlib
../features/netsocket/cellular
)
# Source files
@ -21,10 +22,15 @@ set(unittest-sources
set(unittest-test-sources
features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/EventQueue_stub.cpp
stubs/FileHandle_stub.cpp
stubs/us_ticker_stub.cpp
stubs/CellularDevice_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/CellularContext_stub.cpp
stubs/AT_CellularContext_stub.cpp
stubs/NetworkInterface_stub.cpp
stubs/NetworkInterfaceDefaults_stub.cpp
stubs/mbed_assert_stub.cpp
stubs/SocketAddress_stub.cpp
stubs/randLIB_stub.cpp

View File

@ -23,6 +23,7 @@
#include "AT_CellularSMS.h"
#include "FileHandle_stub.h"
#include "CellularLog.h"
#include "myCellularDevice.h"
using namespace mbed;
using namespace events;
@ -36,11 +37,17 @@ protected:
{
ATHandler_stub::return_given_size = false;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
_dev = new myCellularDevice(&_fh);
}
void TearDown()
{
delete _dev;
}
FileHandle_stub _fh;
AT_CellularDevice *_dev;
};
// *INDENT-ON*
@ -50,7 +57,7 @@ TEST_F(TestAT_CellularSMS, Create)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS *sms = new AT_CellularSMS(at);
AT_CellularSMS *sms = new AT_CellularSMS(at, *_dev);
EXPECT_TRUE(sms != NULL);
delete sms;
@ -69,7 +76,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_initialize)
ATHandler_stub::call_immediately = true;
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
EXPECT_EQ(NSAPI_ERROR_AUTH_FAILURE, sms.initialize(CellularSMS::CellularSMSMmodeText));
@ -89,7 +96,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_send_sms)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
EXPECT_EQ(NSAPI_ERROR_PARAMETER, sms.send_sms(NULL, "2", 1));
sms.initialize(CellularSMS::CellularSMSMmodeText);
@ -129,7 +136,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_get_sms)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
char buf[16];
char phone[21];
char stamp[21];
@ -174,7 +181,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_set_sms_callback)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
sms.set_sms_callback(NULL);
}
@ -184,7 +191,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_set_cpms)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == sms.set_cpms("2", "3", "4"));
}
@ -195,7 +202,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_set_csca)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == sms.set_csca("2", 1));
}
@ -206,7 +213,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_set_cscs)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == sms.set_cscs("2"));
}
@ -217,7 +224,7 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_delete_all_messages)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == sms.delete_all_messages());
}
@ -228,6 +235,6 @@ TEST_F(TestAT_CellularSMS, test_AT_CellularSMS_set_extra_sim_wait_time)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
AT_CellularSMS sms(at, *_dev);
sms.set_extra_sim_wait_time(56);
}

View File

@ -9,6 +9,7 @@ set(unittest-includes ${unittest-includes}
../features/cellular/framework/common
../features/cellular/framework/AT
../features/frameworks/mbed-client-randlib/mbed-client-randlib
../features/netsocket/cellular
)
# Source files
@ -20,7 +21,6 @@ set(unittest-sources
set(unittest-test-sources
features/cellular/framework/AT/at_cellularsms/at_cellularsmstest.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/EventQueue_stub.cpp
stubs/FileHandle_stub.cpp
stubs/CellularUtil_stub.cpp
@ -29,6 +29,13 @@ set(unittest-test-sources
stubs/ThisThread_stub.cpp
stubs/mbed_wait_api_stub.cpp
stubs/ConditionVariable_stub.cpp
stubs/CellularDevice_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/CellularContext_stub.cpp
stubs/AT_CellularContext_stub.cpp
stubs/AT_CellularNetwork_stub.cpp
stubs/NetworkInterface_stub.cpp
stubs/NetworkInterfaceDefaults_stub.cpp
stubs/Mutex_stub.cpp
)

View File

@ -25,6 +25,8 @@
#include "CellularLog.h"
#include "ATHandler_stub.h"
#include "SocketAddress.h"
#include "CellularDevice_stub.h"
#include "myCellularDevice.h"
using namespace mbed;
using namespace events;
@ -36,7 +38,7 @@ public:
nsapi_error_t create_error;
CellularSocket socket;
MyStack(ATHandler &atr, int cid, nsapi_ip_stack_t typ) : AT_CellularStack(atr, cid, typ)
MyStack(ATHandler &atr, int cid, nsapi_ip_stack_t typ, AT_CellularDevice &device) : AT_CellularStack(atr, cid, typ, device)
{
bool_value = false;
max_sock_value = 0;
@ -148,11 +150,16 @@ protected:
ATHandler_stub::ssize_value = 0;
ATHandler_stub::bool_value = false;
ATHandler_stub::read_string_value = NULL;
_dev = new myCellularDevice(&_fh);
}
void TearDown()
{
delete _dev;
}
FileHandle_stub _fh;
AT_CellularDevice *_dev;
};
// *INDENT-ON*
@ -162,7 +169,7 @@ TEST_F(TestAT_CellularStack, Create)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack *st = new MyStack(at, 0, IPV4_STACK);
MyStack *st = new MyStack(at, 0, IPV4_STACK, *_dev);
EXPECT_TRUE(st != NULL);
delete st;
@ -174,7 +181,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_get_ip_address)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
SocketAddress a;
EXPECT_EQ(st.get_ip_address(&a), NSAPI_ERROR_NO_ADDRESS);
EXPECT_EQ(a.get_ip_address(), nullptr);
@ -199,7 +206,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
st.bool_value = false;
EXPECT_EQ(st.socket_open(NULL, NSAPI_TCP), NSAPI_ERROR_UNSUPPORTED);
@ -208,7 +215,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
nsapi_socket_t sock = &st.socket;
EXPECT_EQ(st.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_NO_SOCKET);
MyStack st2(at, 0, IPV6_STACK);
MyStack st2(at, 0, IPV6_STACK, *_dev);
st2.bool_value = true;
st2.max_sock_value = 1;
sock = &st2.socket;
@ -221,7 +228,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
EXPECT_EQ(st.socket_close(&st.socket), NSAPI_ERROR_DEVICE_ERROR);
nsapi_socket_t sock = &st.socket;
@ -231,7 +238,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)
st.max_sock_value = 0;
EXPECT_EQ(st.socket_close(sock), NSAPI_ERROR_DEVICE_ERROR);
MyStack st2(at, 0, IPV6_STACK);
MyStack st2(at, 0, IPV6_STACK, *_dev);
st2.max_sock_value = 1;
st2.bool_value = true;
sock = &st2.socket;
@ -245,7 +252,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_bind)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
SocketAddress addr;
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_ALREADY;
EXPECT_EQ(st.socket_bind(NULL, addr), NSAPI_ERROR_NO_SOCKET);
@ -259,7 +266,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_listen)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
EXPECT_EQ(st.socket_listen(&st.socket, 4), NSAPI_ERROR_UNSUPPORTED);
}
@ -269,7 +276,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_connect)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
SocketAddress addr;
EXPECT_EQ(st.socket_connect(NULL, addr), NSAPI_ERROR_NO_SOCKET);
@ -282,7 +289,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_accept)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
nsapi_socket_t sock = &st.socket;
EXPECT_EQ(st.socket_accept(NULL, &sock), NSAPI_ERROR_UNSUPPORTED);
}
@ -293,7 +300,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_send)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
EXPECT_EQ(st.socket_send(NULL, "addr", 4), NSAPI_ERROR_NO_SOCKET);
EXPECT_EQ(st.socket_send(&st.socket, "addr", 4), NSAPI_ERROR_NO_CONNECTION);
@ -313,7 +320,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_sendto)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
SocketAddress addr("fc00::", 123);
EXPECT_EQ(st.socket_sendto(NULL, addr, "addr", 4), NSAPI_ERROR_NO_SOCKET);
@ -336,7 +343,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_recv)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
char table[4];
EXPECT_EQ(st.socket_recv(NULL, table, 4), NSAPI_ERROR_NO_SOCKET);
}
@ -347,7 +354,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_recvfrom)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
char table[4];
EXPECT_EQ(st.socket_recvfrom(NULL, NULL, table, 4), NSAPI_ERROR_NO_SOCKET);
@ -370,7 +377,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_attach)
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
MyStack st(at, 0, IPV6_STACK, *_dev);
st.socket_attach(NULL, NULL, NULL);
st.max_sock_value = 1;

View File

@ -9,6 +9,7 @@ set(unittest-includes ${unittest-includes}
../features/cellular/framework/common
../features/cellular/framework/AT
../features/frameworks/mbed-client-randlib/mbed-client-randlib
../features/netsocket/cellular
)
# Source files
@ -26,10 +27,16 @@ set(unittest-sources
set(unittest-test-sources
features/cellular/framework/AT/at_cellularstack/at_cellularstacktest.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/EventQueue_stub.cpp
stubs/FileHandle_stub.cpp
stubs/CellularUtil_stub.cpp
stubs/CellularContext_stub.cpp
stubs/AT_CellularContext_stub.cpp
stubs/AT_CellularNetwork_stub.cpp
stubs/NetworkInterfaceDefaults_stub.cpp
stubs/NetworkInterface_stub.cpp
stubs/CellularDevice_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/us_ticker_stub.cpp
stubs/NetworkStack_stub.cpp
stubs/mbed_assert_stub.cpp

View File

@ -385,8 +385,14 @@ TEST_F(TestATHandler, test_ATHandler_write_int)
at.write_int(2147483647);
//This is intentional for this test, so let's disable build time warning for next line
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverflow"
at.write_int(2147483647 + 1);
#pragma GCC diagnostic pop
// at.at_error(0, DeviceErrorType(0));
// at.write_int(4);
}

View File

@ -10,7 +10,7 @@ set(unittest-includes ${unittest-includes}
../features/cellular/framework/common
../features/cellular/framework/AT
../features/frameworks/mbed-client-randlib/mbed-client-randlib
)
# Source files
@ -21,7 +21,6 @@ set(unittest-sources
# Test files
set(unittest-test-sources
features/cellular/framework/AT/athandler/athandlertest.cpp
stubs/AT_CellularBase_stub.cpp
stubs/EventQueue_stub.cpp
stubs/FileHandle_stub.cpp
stubs/us_ticker_stub.cpp

View File

@ -33,8 +33,8 @@ set(unittest-test-sources
stubs/SerialBase_stub.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularNetwork_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/AT_CellularContext_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/Semaphore_stub.cpp
stubs/NetworkInterface_stub.cpp
stubs/NetworkInterfaceDefaults_stub.cpp

View File

@ -27,8 +27,8 @@ set(unittest-test-sources
stubs/SerialBase_stub.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularNetwork_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/AT_CellularContext_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/Semaphore_stub.cpp
stubs/NetworkInterface_stub.cpp
stubs/NetworkInterfaceDefaults_stub.cpp

View File

@ -27,7 +27,6 @@ set(unittest-test-sources
stubs/SerialBase_stub.cpp
stubs/ATHandler_stub.cpp
stubs/AT_CellularNetwork_stub.cpp
stubs/AT_CellularBase_stub.cpp
stubs/AT_CellularContext_stub.cpp
stubs/AT_CellularDevice_stub.cpp
stubs/Semaphore_stub.cpp

View File

@ -1,57 +0,0 @@
/*
* Copyright (c) , Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "nsapi_types.h"
#include "AT_CellularBase_stub.h"
#include "AT_CellularNetwork.h"
using namespace mbed;
ATHandler *AT_CellularBase_stub::handler_value = NULL;
ATHandler *AT_CellularBase_stub::handler_at_constructor_value = NULL;
device_err_t AT_CellularBase_stub::device_err_value;
bool AT_CellularBase_stub::supported_bool = true;
AT_CellularBase::AT_CellularBase(ATHandler &at) : _at(at)
{
AT_CellularBase_stub::handler_at_constructor_value = &_at;
}
ATHandler &AT_CellularBase::get_at_handler()
{
AT_CellularBase_stub::handler_value = &_at;
return _at;
}
device_err_t AT_CellularBase::get_device_error() const
{
return AT_CellularBase_stub::device_err_value;
}
intptr_t AT_CellularBase::get_property(CellularProperty key)
{
if (key == PROPERTY_C_GREG) {
return AT_CellularNetwork::RegistrationModeDisable;
} else if (key == PROPERTY_C_REG || key == PROPERTY_C_EREG) {
return AT_CellularNetwork::RegistrationModeEnable;
} else if (key == PROPERTY_AT_CGAUTH) {
return true;
} else if (key == PROPERTY_IPV4_PDP_TYPE) {
return true;
}
return AT_CellularBase_stub::supported_bool;
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (c) , Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "AT_CellularBase.h"
namespace AT_CellularBase_stub {
extern mbed::ATHandler *handler_value;
extern mbed::ATHandler *handler_at_constructor_value;
extern mbed::device_err_t device_err_value;
extern bool supported_bool;
}

View File

@ -20,7 +20,7 @@
using namespace mbed;
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req, bool nonip_req) :
AT_CellularBase(at), _is_connected(false),
_at(at), _is_connected(false),
_current_op(OP_INVALID), _fh(0), _cp_req(cp_req)
{
_stack = NULL;
@ -169,15 +169,15 @@ const char *AT_CellularContext::get_gateway()
return NULL;
}
AT_CellularBase::CellularProperty AT_CellularContext::pdp_type_t_to_cellular_property(pdp_type_t pdp_type)
AT_CellularDevice::CellularProperty AT_CellularContext::pdp_type_t_to_cellular_property(pdp_type_t pdp_type)
{
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_PDP_TYPE;
AT_CellularDevice::CellularProperty prop = AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE;
if (pdp_type == IPV6_PDP_TYPE) {
prop = PROPERTY_IPV6_PDP_TYPE;
prop = AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE;
} else if (pdp_type == IPV4V6_PDP_TYPE) {
prop = PROPERTY_IPV4V6_PDP_TYPE;
prop = AT_CellularDevice::PROPERTY_IPV4V6_PDP_TYPE;
} else if (pdp_type == NON_IP_PDP_TYPE) {
prop = PROPERTY_NON_IP_PDP_TYPE;
prop = AT_CellularDevice::PROPERTY_NON_IP_PDP_TYPE;
}
return prop;
@ -307,3 +307,8 @@ char *AT_CellularContext::get_interface_name(char *interface_name)
{
return NULL;
}
ATHandler &AT_CellularContext::get_at_handler()
{
return _at;
}

View File

@ -30,6 +30,7 @@ int AT_CellularDevice_stub::init_module_failure_count = 0;
int AT_CellularDevice_stub::set_pin_failure_count = 0;
int AT_CellularDevice_stub::get_sim_failure_count = 0;
bool AT_CellularDevice_stub::pin_needed = false;
bool AT_CellularDevice_stub::supported_bool = false;
AT_CellularDevice::AT_CellularDevice(FileHandle *fh) : CellularDevice(fh), _network(0), _sms(0),
_information(0), _context_list(0), _default_timeout(DEFAULT_AT_TIMEOUT), _modem_debug_on(false)
@ -83,7 +84,7 @@ CellularNetwork *AT_CellularDevice::open_network(FileHandle *fh)
_default_timeout,
"\r",
get_send_delay(),
_modem_debug_on));
_modem_debug_on), *this);
return _network;
}
@ -136,7 +137,7 @@ void AT_CellularDevice::delete_context(CellularContext *context)
AT_CellularNetwork *AT_CellularDevice::open_network_impl(ATHandler &at)
{
_network = new AT_CellularNetwork(at);
_network = new AT_CellularNetwork(at, *this);
return _network;
}
@ -271,3 +272,22 @@ nsapi_error_t AT_CellularDevice::set_baud_rate_impl(int baud_rate)
{
return NSAPI_ERROR_OK;
}
void AT_CellularDevice::set_cellular_properties(const intptr_t *property_array)
{
}
intptr_t AT_CellularDevice::get_property(CellularProperty key)
{
if (key == PROPERTY_C_GREG) {
return AT_CellularNetwork::RegistrationModeDisable;
} else if (key == PROPERTY_C_REG || key == PROPERTY_C_EREG) {
return AT_CellularNetwork::RegistrationModeEnable;
} else if (key == PROPERTY_AT_CGAUTH) {
return true;
} else if (key == PROPERTY_IPV4_PDP_TYPE) {
return true;
}
return AT_CellularDevice_stub::supported_bool;
}

View File

@ -18,6 +18,7 @@
#define AT_CELLULARDEVICE_STUB_H_
#include "AT_CellularDevice.h"
#include "ATHandler.h"
namespace AT_CellularDevice_stub {
extern int failure_count;
@ -26,6 +27,7 @@ extern int init_module_failure_count;
extern int set_pin_failure_count;
extern int get_sim_failure_count;
extern bool pin_needed;
extern bool supported_bool;
}

View File

@ -20,7 +20,7 @@
using namespace mbed;
AT_CellularInformation::AT_CellularInformation(ATHandler &at) : AT_CellularBase(at)
AT_CellularInformation::AT_CellularInformation(ATHandler &at, AT_CellularDevice &device) : _at(at), _device(device)
{
}
@ -57,3 +57,8 @@ nsapi_error_t AT_CellularInformation::get_iccid(char *buf, size_t buf_size)
{
return NSAPI_ERROR_OK;
}
ATHandler &AT_CellularInformation::get_at_handler()
{
return _at;
}

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) , Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "AT_CellularMultiplexer.h"
#include "CellularLog.h"
#include "nsapi_types.h"
using namespace mbed;
AT_CellularMultiplexer::AT_CellularMultiplexer(ATHandler &at) : AT_CellularBase(at)
{
}
AT_CellularMultiplexer::~AT_CellularMultiplexer()
{
}
nsapi_error_t AT_CellularMultiplexer::multiplexer_mode_start()
{
return 0;
}

View File

@ -32,7 +32,7 @@ int AT_CellularNetwork_stub::fail_counter = 0;
int AT_CellularNetwork_stub::set_registration_urc_fail_counter = 0;
int AT_CellularNetwork_stub::get_registration_params_fail_counter = 0;
AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(atHandler)
AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : _at(atHandler), _device(device)
{
}
@ -171,3 +171,8 @@ nsapi_error_t AT_CellularNetwork::clear()
{
return NSAPI_ERROR_OK;
}
ATHandler &AT_CellularNetwork::get_at_handler()
{
return _at;
}

View File

@ -34,8 +34,8 @@ const uint16_t SMS_MAX_8BIT_CONCATENATED_SINGLE_SMS_SIZE = 134;
const uint16_t SMS_MAX_GSM7_CONCATENATED_SINGLE_SMS_SIZE = 153;
AT_CellularSMS::AT_CellularSMS(ATHandler &at) : AT_CellularBase(at), _cb(0), _mode(CellularSMSMmodeText),
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1), _sms_info(NULL)
AT_CellularSMS::AT_CellularSMS(ATHandler &at, AT_CellularDevice &device) : _cb(0), _mode(CellularSMSMmodeText),
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1), _sms_info(NULL), _at(at), _device(device)
{
}
@ -189,3 +189,8 @@ bool AT_CellularSMS::create_time(const char *time_string, time_t *time)
return 0;
}
ATHandler &AT_CellularSMS::get_at_handler()
{
return _at;
}

View File

@ -22,7 +22,8 @@
using namespace mbed;
using namespace mbed_cellular_util;
AT_CellularStack::AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularBase(atHandler), _socket(NULL), _cid(cid), _stack_type(stack_type)
AT_CellularStack::AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
_socket(NULL), _cid(cid), _stack_type(stack_type), _at(atHandler), _device(device)
{
}

View File

@ -18,6 +18,7 @@
#define CELLULARDEVICE_STUB_H_
#include "CellularDevice.h"
#include "ATHandler.h"
namespace CellularDevice_stub {
extern int connect_counter;

View File

@ -17,7 +17,7 @@
#ifndef MY_CELLULARDEVICE_H_
#define MY_CELLULARDEVICE_H_
#include "CellularDevice.h"
#include "AT_CellularDevice.h"
#include "AT_CellularNetwork.h"
#include "FileHandle_stub.h"
#include "ATHandler_stub.h"
@ -33,9 +33,9 @@ class CellularInformation;
class CellularContext;
class FileHandle;
class myCellularDevice : public CellularDevice {
class myCellularDevice : public AT_CellularDevice {
public:
myCellularDevice(FileHandle *fh) : CellularDevice(fh), _context_list(0), _network(0) {}
myCellularDevice(FileHandle *fh) : AT_CellularDevice(fh), _context_list(0), _network(0) {}
virtual ~myCellularDevice()
{
delete _context_list;
@ -89,7 +89,7 @@ public:
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0, ",");
_network = new AT_CellularNetwork(at);
_network = new AT_CellularNetwork(at, *this);
return _network;
}
@ -198,6 +198,8 @@ public:
}
}
AT_CellularNetwork *_network;
AT_CellularContext *_context_list;
};

View File

@ -90,6 +90,8 @@ public:
*/
virtual ~CellularDevice();
public: //Virtual functions
/** Clear modem to a default initial state
*
* Clear persistent user data from the modem, such as PDP contexts.
@ -102,6 +104,39 @@ public:
*/
virtual nsapi_error_t clear();
/** Shutdown cellular device to minimum functionality.
*
* Actual functionality is modem specific, for example UART may is not be responsive without
* explicit wakeup signal (such as RTS) after shutdown.
*
* @remark You must call shutdown before power off to prepare the modem and to quit cellular network.
*
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t shutdown();
/** Get the linked list of CellularContext instances
*
* @return Pointer to first item in linked list
*/
virtual CellularContext *get_context_list() const;
/** Get event queue that can be chained to main event queue.
* @return event queue
*/
virtual events::EventQueue *get_queue();
protected: //Virtual functions
/** Cellular callback to be attached to Network and CellularStateMachine classes.
* CellularContext calls this when in PPP mode to provide network changes.
* This method will broadcast to every interested classes:
* CellularContext (might be many) and CellularStateMachine if available.
*/
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx = NULL);
public: //Pure virtual functions
/** Sets the modem up for powering on
* This is equivalent to plugging in the device, i.e., attaching power and serial port.
* In general, hard_power_on and soft_power_on provides a simple hardware abstraction layer
@ -219,6 +254,124 @@ public:
*/
virtual void delete_context(CellularContext *context) = 0;
/** Turn modem debug traces on
*
* @param on set true to enable debug traces
*/
virtual void modem_debug_on(bool on) = 0;
/** Initialize cellular device must be called right after the module is ready.
*
* For example, when multiple cellular modules are supported in a single driver this function
* detects and adapts to an actual module at runtime.
*
* @remark CellularStateMachine calls soft_power_on and init repeatedly when starting to connect
* until the modem responds.
*
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_NO_MEMORY on case of memory failure
* NSAPI_ERROR_UNSUPPORTED if current cellular module type is not detected
* NSAPI_ERROR_DEVICE_ERROR if model information could not be read
*
*/
virtual nsapi_error_t init() = 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 callback function to listen when device is ready.
*
* @param callback function to call on device ready, or NULL to remove callback.
*/
virtual void set_ready_cb(Callback<void()> callback) = 0;
/** Set power save mode
*
* @remark See 3GPP TS 27.007 PSM for details
*
* @param periodic_time in seconds to enable power save, or zero to disable
* @param active_time in seconds to wait before entering power save mode
*
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t set_power_save_mode(int periodic_time, int active_time = 0) = 0;
/** Get the current ATHandler instance in use for debug purposes etc.
* Once use has been finished call to release_at_handler() has to be made
*
* @return Pointer to the ATHandler in use
*/
virtual ATHandler *get_at_handler() = 0;
/** Release the ATHandler taken into use with get_at_handler()
*
* @param at_handler
* @return NSAPI_ERROR_OK on success, NSAPI_ERROR_PARAMETER on failure
*/
virtual nsapi_error_t release_at_handler(ATHandler *at_handler) = 0;
/** Sets cellular modem to given baud rate
*
* @param baud_rate
* @return NSAPI_ERROR_OK on success, NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t set_baud_rate(int baud_rate) = 0;
/** Create new CellularNetwork interface.
*
* @param fh file handle used in communication to modem. This can be, for example, UART handle. If null, then the default
* file handle is used.
* @return New instance of interface CellularNetwork.
*/
virtual CellularNetwork *open_network(FileHandle *fh = NULL) = 0;
#if MBED_CONF_CELLULAR_USE_SMS || defined(DOXYGEN_ONLY)
/** Create new CellularSMS interface.
*
* @param fh file handle used in communication to modem. This can be, for example, UART handle. If null, then the default
* file handle is used.
* @return New instance of interface CellularSMS.
*/
virtual CellularSMS *open_sms(FileHandle *fh = NULL) = 0;
/** Closes the opened CellularSMS by deleting the CellularSMS instance.
*/
virtual void close_sms() = 0;
#endif // MBED_CONF_CELLULAR_USE_SMS
/** Create new CellularInformation interface.
*
* @param fh file handle used in communication to modem. This can be, for example, UART handle. If null, then the default
* file handle is used.
* @return New instance of interface CellularInformation.
*/
virtual CellularInformation *open_information(FileHandle *fh = NULL) = 0;
/** Closes the opened CellularNetwork by deleting the CellularNetwork instance.
*/
virtual void close_network() = 0;
/** Closes the opened CellularInformation by deleting the CellularInformation instance.
*/
virtual void close_information() = 0;
/** Set the default response timeout.
*
* @remark CellularStateMachine timeouts for all states are also changed to `timeout`.
*
* @param timeout milliseconds to wait response from modem
*/
virtual void set_timeout(int timeout) = 0;
public: //Common functions
/** Stop the current operation. Operations: set_device_ready, set_sim_ready, register_to_network, attach_to_network
*
*/
@ -231,11 +384,6 @@ public:
*/
FileHandle &get_file_handle() const;
/** Get event queue that can be chained to main event queue.
* @return event queue
*/
virtual events::EventQueue *get_queue();
/** Set the pin code for SIM card
*
* @param sim_pin PIN for the SIM card
@ -307,53 +455,6 @@ public:
*/
void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb);
/** Create new CellularNetwork interface.
*
* @param fh file handle used in communication to modem. This can be, for example, UART handle. If null, then the default
* file handle is used.
* @return New instance of interface CellularNetwork.
*/
virtual CellularNetwork *open_network(FileHandle *fh = NULL) = 0;
#if MBED_CONF_CELLULAR_USE_SMS || defined(DOXYGEN_ONLY)
/** Create new CellularSMS interface.
*
* @param fh file handle used in communication to modem. This can be, for example, UART handle. If null, then the default
* file handle is used.
* @return New instance of interface CellularSMS.
*/
virtual CellularSMS *open_sms(FileHandle *fh = NULL) = 0;
/** Closes the opened CellularSMS by deleting the CellularSMS instance.
*/
virtual void close_sms() = 0;
#endif // MBED_CONF_CELLULAR_USE_SMS
/** Create new CellularInformation interface.
*
* @param fh file handle used in communication to modem. This can be, for example, UART handle. If null, then the default
* file handle is used.
* @return New instance of interface CellularInformation.
*/
virtual CellularInformation *open_information(FileHandle *fh = NULL) = 0;
/** Closes the opened CellularNetwork by deleting the CellularNetwork instance.
*/
virtual void close_network() = 0;
/** Closes the opened CellularInformation by deleting the CellularInformation instance.
*/
virtual void close_information() = 0;
/** Set the default response timeout.
*
* @remark CellularStateMachine timeouts for all states are also changed to `timeout`.
*
* @param timeout milliseconds to wait response from modem
*/
virtual void set_timeout(int timeout) = 0;
/** Set an array of timeouts to wait before CellularStateMachine retries after failure.
* To disable retry behavior completely use `set_retry_timeout_array(NULL, 0)`.
* CellularContext callback event `cell_callback_data_t.final_try` indicates true when all retries have failed.
@ -368,93 +469,7 @@ public:
*/
void set_retry_timeout_array(const uint16_t timeout[], int array_len);
/** Turn modem debug traces on
*
* @param on set true to enable debug traces
*/
virtual void modem_debug_on(bool on) = 0;
/** Initialize cellular device must be called right after the module is ready.
*
* For example, when multiple cellular modules are supported in a single driver this function
* detects and adapts to an actual module at runtime.
*
* @remark CellularStateMachine calls soft_power_on and init repeatedly when starting to connect
* until the modem responds.
*
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_NO_MEMORY on case of memory failure
* NSAPI_ERROR_UNSUPPORTED if current cellular module type is not detected
* NSAPI_ERROR_DEVICE_ERROR if model information could not be read
*
*/
virtual nsapi_error_t init() = 0;
/** Shutdown cellular device to minimum functionality.
*
* Actual functionality is modem specific, for example UART may is not be responsive without
* explicit wakeup signal (such as RTS) after shutdown.
*
* @remark You must call shutdown before power off to prepare the modem and to quit cellular network.
*
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t shutdown();
/** 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 callback function to listen when device is ready.
*
* @param callback function to call on device ready, or NULL to remove callback.
*/
virtual void set_ready_cb(Callback<void()> callback) = 0;
/** Set power save mode
*
* @remark See 3GPP TS 27.007 PSM for details
*
* @param periodic_time in seconds to enable power save, or zero to disable
* @param active_time in seconds to wait before entering power save mode
*
* @return NSAPI_ERROR_OK on success
* NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t set_power_save_mode(int periodic_time, int active_time = 0) = 0;
/** Get the linked list of CellularContext instances
*
* @return Pointer to first item in linked list
*/
virtual CellularContext *get_context_list() const;
/** Get the current ATHandler instance in use for debug purposes etc.
* Once use has been finished call to release_at_handler() has to be made
*
* @return Pointer to the ATHandler in use
*/
virtual ATHandler *get_at_handler() = 0;
/** Release the ATHandler taken into use with get_at_handler()
*
* @param at_handler
* @return NSAPI_ERROR_OK on success, NSAPI_ERROR_PARAMETER on failure
*/
virtual nsapi_error_t release_at_handler(ATHandler *at_handler) = 0;
/** Sets cellular modem to given baud rate
*
* @param baud_rate
* @return NSAPI_ERROR_OK on success, NSAPI_ERROR_DEVICE_ERROR on failure
*/
virtual nsapi_error_t set_baud_rate(int baud_rate) = 0;
protected:
protected: //Common functions
friend class AT_CellularNetwork;
friend class AT_CellularContext;
friend class CellularContext;
@ -468,13 +483,14 @@ protected:
*/
void get_retry_timeout_array(uint16_t *timeout, int &array_len) const;
/** Cellular callback to be attached to Network and CellularStateMachine classes.
* CellularContext calls this when in PPP mode to provide network changes.
* This method will broadcast to every interested classes:
* CellularContext (might be many) and CellularStateMachine if available.
*/
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr, CellularContext *ctx = NULL);
private: //Common functions
nsapi_error_t start_state_machine(CellularStateMachine::CellularState target_state);
nsapi_error_t create_state_machine();
void stm_callback(nsapi_event_t ev, intptr_t ptr);
protected: //Member variables
int _network_ref_count;
#if MBED_CONF_CELLULAR_USE_SMS
int _sms_ref_count;
@ -483,15 +499,15 @@ protected:
FileHandle *_fh;
events::EventQueue _queue;
CellularStateMachine *_state_machine;
private:
nsapi_error_t start_state_machine(CellularStateMachine::CellularState target_state);
nsapi_error_t create_state_machine();
private: //Member variables
CellularNetwork *_nw;
char _sim_pin[MAX_PIN_SIZE + 1];
char _plmn[MAX_PLMN_SIZE + 1];
PlatformMutex _mutex;
Callback<void(nsapi_event_t, intptr_t)> _status_cb;
const intptr_t *_property_array;
};
/**

View File

@ -1,56 +0,0 @@
/*
* Copyright (c) 2017, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "AT_CellularBase.h"
#include "CellularLog.h"
using namespace mbed;
AT_CellularBase::AT_CellularBase(ATHandler &at) : _at(at)
{
}
ATHandler &AT_CellularBase::get_at_handler()
{
return _at;
}
device_err_t AT_CellularBase::get_device_error() const
{
return _at.get_last_device_error();
}
const intptr_t *AT_CellularBase::_property_array = NULL;
void AT_CellularBase::set_cellular_properties(const intptr_t *property_array)
{
if (!property_array) {
tr_warning("trying to set an empty cellular property array");
return;
}
_property_array = property_array;
}
intptr_t AT_CellularBase::get_property(CellularProperty key)
{
if (_property_array) {
return _property_array[key];
} else {
return 0;
}
}

View File

@ -1,92 +0,0 @@
/*
* Copyright (c) 2017, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AT_CELLULAR_BASE_H_
#define AT_CELLULAR_BASE_H_
#include "ATHandler.h"
namespace mbed {
/**
* Class AT_CellularBase
*
* A base class for AT-classes.
*/
class AT_CellularBase {
public:
AT_CellularBase(ATHandler &at);
/** Getter for at handler. Common method for all AT-classes.
*
* @return reference to ATHandler
*/
ATHandler &get_at_handler();
/** Gets the device error that happened when using AT commands/responses. This is at error
* returned by the device. Returned CME/CMS errors can be found from 3gpp documents 27007 and 27005.
*
* @return at error (CME/CMS) while communicating with the device
*/
device_err_t get_device_error() const;
/* Supported features by the modem
*
* NOTE! These are used as index to feature table, so the only allowed modification to this is appending
* to the end (just before PROPERTY_MAX). Do not modify any of the existing fields.
*/
enum CellularProperty {
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4 and IPV6 simultaneously?
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
PROPERTY_MAX
};
/** Cellular module need to define an array of cellular properties which defines module supported property values.
*
* @param property_array array of module properties
*/
static void set_cellular_properties(const intptr_t *property_array);
/** Get value for the given key.
*
* @param key key for value to be fetched
* @return property value for the given key. Value type is defined in enum CellularProperty
*/
static intptr_t get_property(CellularProperty key);
protected:
static const intptr_t *_property_array;
ATHandler &_at;
};
} // namespace mbed
#endif /* AT_CELLULAR_BASE_H_ */

View File

@ -48,7 +48,7 @@ using namespace mbed;
using namespace rtos;
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req, bool nonip_req) :
AT_CellularBase(at), _current_op(OP_INVALID), _fh(0), _cp_req(cp_req), _is_connected(false)
_current_op(OP_INVALID), _fh(0), _cp_req(cp_req), _is_connected(false), _at(at)
{
tr_info("New CellularContext %s (%p)", apn ? apn : "", this);
_nonip_req = nonip_req;
@ -342,7 +342,7 @@ nsapi_error_t AT_CellularContext::do_user_authentication()
{
// if user has defined user name and password we need to call CGAUTH before activating or modifying context
if (_pwd && _uname) {
if (!get_property(PROPERTY_AT_CGAUTH)) {
if (!get_device()->get_property(AT_CellularDevice::PROPERTY_AT_CGAUTH)) {
return NSAPI_ERROR_UNSUPPORTED;
}
const bool stored_debug_state = _at.get_debug();
@ -360,15 +360,15 @@ nsapi_error_t AT_CellularContext::do_user_authentication()
return NSAPI_ERROR_OK;
}
AT_CellularBase::CellularProperty AT_CellularContext::pdp_type_t_to_cellular_property(pdp_type_t pdp_type)
AT_CellularDevice::CellularProperty AT_CellularContext::pdp_type_t_to_cellular_property(pdp_type_t pdp_type)
{
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_PDP_TYPE;
AT_CellularDevice::CellularProperty prop = AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE;
if (pdp_type == IPV6_PDP_TYPE) {
prop = PROPERTY_IPV6_PDP_TYPE;
prop = AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE;
} else if (pdp_type == IPV4V6_PDP_TYPE) {
prop = PROPERTY_IPV4V6_PDP_TYPE;
prop = AT_CellularDevice::PROPERTY_IPV4V6_PDP_TYPE;
} else if (pdp_type == NON_IP_PDP_TYPE) {
prop = PROPERTY_NON_IP_PDP_TYPE;
prop = AT_CellularDevice::PROPERTY_NON_IP_PDP_TYPE;
}
return prop;
@ -401,8 +401,9 @@ bool AT_CellularContext::get_context()
pdp_type_t pdp_type = string_to_pdp_type(pdp_type_from_context);
// Accept exact matching PDP context type or dual PDP context for modems that support both IPv4 and IPv6 stacks
if (get_property(pdp_type_t_to_cellular_property(pdp_type)) ||
((pdp_type == IPV4V6_PDP_TYPE && (get_property(PROPERTY_IPV4_PDP_TYPE) && get_property(PROPERTY_IPV6_PDP_TYPE))) && !_nonip_req)) {
if (get_device()->get_property(pdp_type_t_to_cellular_property(pdp_type)) ||
((pdp_type == IPV4V6_PDP_TYPE && (get_device()->get_property(AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE) &&
get_device()->get_property(AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE))) && !_nonip_req)) {
_pdp_type = pdp_type;
set_cid(cid);
}
@ -432,16 +433,18 @@ bool AT_CellularContext::set_new_context(int cid)
char pdp_type_str[8 + 1] = {0};
pdp_type_t pdp_type = IPV4_PDP_TYPE;
if (_nonip_req && _cp_in_use && get_property(PROPERTY_NON_IP_PDP_TYPE)) {
if (_nonip_req && _cp_in_use && get_device()->get_property(AT_CellularDevice::PROPERTY_NON_IP_PDP_TYPE)) {
strncpy(pdp_type_str, "Non-IP", sizeof(pdp_type_str));
pdp_type = NON_IP_PDP_TYPE;
} else if (get_property(PROPERTY_IPV4V6_PDP_TYPE) || (get_property(PROPERTY_IPV4_PDP_TYPE) && get_property(PROPERTY_IPV6_PDP_TYPE))) {
} else if (get_device()->get_property(AT_CellularDevice::PROPERTY_IPV4V6_PDP_TYPE) ||
(get_device()->get_property(AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE) &&
get_device()->get_property(AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE))) {
strncpy(pdp_type_str, "IPV4V6", sizeof(pdp_type_str));
pdp_type = IPV4V6_PDP_TYPE;
} else if (get_property(PROPERTY_IPV6_PDP_TYPE)) {
} else if (get_device()->get_property(AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE)) {
strncpy(pdp_type_str, "IPV6", sizeof(pdp_type_str));
pdp_type = IPV6_PDP_TYPE;
} else if (get_property(PROPERTY_IPV4_PDP_TYPE)) {
} else if (get_device()->get_property(AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE)) {
strncpy(pdp_type_str, "IP", sizeof(pdp_type_str));
pdp_type = IPV4_PDP_TYPE;
} else {
@ -615,7 +618,7 @@ nsapi_error_t AT_CellularContext::open_data_channel()
}
tr_info("CellularContext PPP connect");
if (get_property(PROPERTY_AT_CGDATA)) {
if (get_device()->get_property(AT_CellularDevice::PROPERTY_AT_CGDATA)) {
_at.cmd_start_stop("+CGDATA", "=\"PPP\",", "%d", _cid);
} else {
MBED_ASSERT(_cid >= 0 && _cid <= 99);
@ -1093,3 +1096,8 @@ void AT_CellularContext::set_cid(int cid)
static_cast<AT_CellularStack *>(_stack)->set_cid(_cid);
}
}
ATHandler &AT_CellularContext::get_at_handler()
{
return _at;
}

View File

@ -18,21 +18,20 @@
#define AT_CELLULARCONTEXT_H_
#include "CellularContext.h"
#include "AT_CellularBase.h"
#include "ATHandler.h"
#include "Semaphore.h"
#include "AT_CellularDevice.h"
const int MAX_APN_LENGTH = 63 + 1;
namespace mbed {
class AT_CellularDevice;
class AT_CellularContext : public CellularContext, public AT_CellularBase {
class AT_CellularContext : public CellularContext {
public:
AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn = 0, bool cp_req = false, bool nonip_req = false);
virtual ~AT_CellularContext();
// from CellularBase/NetworkInterface
// from CellularInterface/NetworkInterface
virtual nsapi_error_t set_blocking(bool blocking);
virtual NetworkStack *get_stack();
virtual nsapi_error_t get_ip_address(SocketAddress *address);
@ -43,7 +42,7 @@ public:
virtual nsapi_error_t disconnect();
virtual nsapi_connection_status_t get_connection_status() const;
virtual bool is_connected();
// from CellularBase
// from CellularInterface
virtual void set_plmn(const char *plmn);
virtual void set_sim_pin(const char *sim_pin);
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, const char *uname = 0,
@ -72,6 +71,8 @@ public:
virtual ControlPlane_netif *get_cp_netif();
AT_CellularDevice *get_device() const;
ATHandler &get_at_handler();
protected:
virtual void cellular_callback(nsapi_event_t ev, intptr_t ptr);
@ -104,7 +105,7 @@ protected:
virtual void set_disconnect();
virtual void deactivate_context();
virtual bool get_context();
AT_CellularBase::CellularProperty pdp_type_t_to_cellular_property(pdp_type_t pdp_type);
AT_CellularDevice::CellularProperty pdp_type_t_to_cellular_property(pdp_type_t pdp_type);
bool set_new_context(int cid);
private:
#if NSAPI_PPP_AVAILABLE
@ -134,6 +135,9 @@ protected:
// flag indicating if CP was requested to be setup
bool _cp_req;
bool _is_connected;
protected:
ATHandler &_at;
};
} // namespace mbed

View File

@ -52,7 +52,7 @@ AT_CellularDevice::AT_CellularDevice(FileHandle *fh) : CellularDevice(fh),
AT_CellularDevice::~AT_CellularDevice()
{
if (AT_CellularBase::get_property(AT_CellularBase::PROPERTY_AT_CGEREP)) {
if (get_property(PROPERTY_AT_CGEREP)) {
_at->set_urc_handler("+CGEV: NW DEACT", 0);
_at->set_urc_handler("+CGEV: ME DEACT", 0);
_at->set_urc_handler("+CGEV: NW PDN D", 0);
@ -93,7 +93,7 @@ void AT_CellularDevice::set_at_urcs_impl()
void AT_CellularDevice::set_at_urcs()
{
if (AT_CellularBase::get_property(AT_CellularBase::PROPERTY_AT_CGEREP)) {
if (get_property(PROPERTY_AT_CGEREP)) {
_at->set_urc_handler("+CGEV: NW DEACT", callback(this, &AT_CellularDevice::urc_nw_deact));
_at->set_urc_handler("+CGEV: ME DEACT", callback(this, &AT_CellularDevice::urc_nw_deact));
_at->set_urc_handler("+CGEV: NW PDN D", callback(this, &AT_CellularDevice::urc_pdn_deact));
@ -370,7 +370,7 @@ CellularInformation *AT_CellularDevice::open_information(FileHandle *fh)
AT_CellularNetwork *AT_CellularDevice::open_network_impl(ATHandler &at)
{
return new AT_CellularNetwork(at);
return new AT_CellularNetwork(at, *this);
}
#if MBED_CONF_CELLULAR_USE_SMS
@ -399,13 +399,13 @@ void AT_CellularDevice::close_sms()
AT_CellularSMS *AT_CellularDevice::open_sms_impl(ATHandler &at)
{
return new AT_CellularSMS(at);
return new AT_CellularSMS(at, *this);
}
#endif // MBED_CONF_CELLULAR_USE_SMS
AT_CellularInformation *AT_CellularDevice::open_information_impl(ATHandler &at)
{
return new AT_CellularInformation(at);
return new AT_CellularInformation(at, *this);
}
void AT_CellularDevice::close_network()
@ -671,3 +671,22 @@ nsapi_error_t AT_CellularDevice::set_baud_rate_impl(int baud_rate)
{
return _at->at_cmd_discard("+IPR", "=", "%d", baud_rate);
}
void AT_CellularDevice::set_cellular_properties(const intptr_t *property_array)
{
if (!property_array) {
tr_warning("trying to set an empty cellular property array");
return;
}
_property_array = property_array;
}
intptr_t AT_CellularDevice::get_property(CellularProperty key)
{
if (_property_array) {
return _property_array[key];
} else {
return 0;
}
}

View File

@ -35,6 +35,32 @@ class AT_CellularContext;
* Deleting/Closing of opened interfaces can be done only through this class.
*/
class AT_CellularDevice : public CellularDevice {
public:
/* Supported features by the modem
*
* NOTE! These are used as index to feature table, so the only allowed modification to this is appending
* to the end (just before PROPERTY_MAX). Do not modify any of the existing fields.
*/
enum CellularProperty {
PROPERTY_C_EREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_GREG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_C_REG, // AT_CellularNetwork::RegistrationMode. What support modem has for this registration type.
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4 and IPV6 simultaneously?
PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP?
PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP.
PROPERTY_MAX
};
public:
AT_CellularDevice(FileHandle *fh);
virtual ~AT_CellularDevice();
@ -142,6 +168,21 @@ public:
#endif // MBED_CONF_CELLULAR_USE_SMS
public:
/** Get value for the given key.
*
* @param key key for value to be fetched
* @return property value for the given key. Value type is defined in enum CellularProperty
*/
intptr_t get_property(CellularProperty key);
/** Cellular module need to define an array of cellular properties which defines module supported property values.
*
* @param property_array array of module properties
*/
void set_cellular_properties(const intptr_t *property_array);
public: //Member variables
AT_CellularNetwork *_network;
AT_CellularInformation *_information;
@ -165,6 +206,9 @@ protected:
private:
void urc_nw_deact();
void urc_pdn_deact();
private:
const intptr_t *_property_array;
};
} // namespace mbed

View File

@ -17,11 +17,12 @@
#include <stdio.h>
#include "AT_CellularDevice.h"
#include "AT_CellularInformation.h"
using namespace mbed;
AT_CellularInformation::AT_CellularInformation(ATHandler &at) : AT_CellularBase(at)
AT_CellularInformation::AT_CellularInformation(ATHandler &at, AT_CellularDevice &device) : _at(at), _device(device)
{
}
@ -54,7 +55,7 @@ nsapi_error_t AT_CellularInformation::get_serial_number(char *buf, size_t buf_si
return get_info("AT+CGSN", buf, buf_size);
}
if (!get_property(PROPERTY_AT_CGSN_WITH_TYPE)) {
if (!_device.get_property(AT_CellularDevice::PROPERTY_AT_CGSN_WITH_TYPE)) {
return NSAPI_ERROR_UNSUPPORTED;
}
@ -97,3 +98,8 @@ nsapi_error_t AT_CellularInformation::get_iccid(char *buf, size_t buf_size)
}
return _at.at_cmd_str("+CCID", "?", buf, buf_size);
}
ATHandler &AT_CellularInformation::get_at_handler()
{
return _at;
}

View File

@ -19,7 +19,8 @@
#define AT_CELLULAR_INFORMATION_H_
#include "CellularInformation.h"
#include "AT_CellularBase.h"
#include "ATHandler.h"
#include "AT_CellularDevice.h"
namespace mbed {
@ -28,9 +29,10 @@ namespace mbed {
*
* Class that provides information about cellular device.
*/
class AT_CellularInformation : public CellularInformation, public AT_CellularBase {
class AT_CellularInformation : public CellularInformation {
public:
AT_CellularInformation(ATHandler &atHandler);
AT_CellularInformation(ATHandler &at, AT_CellularDevice &device);
virtual ~AT_CellularInformation();
public:
@ -45,6 +47,8 @@ public:
virtual nsapi_error_t get_imsi(char *imsi, size_t buf_size);
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);
ATHandler &get_at_handler();
protected:
/** Request information text from cellular device
*
@ -54,6 +58,11 @@ protected:
* @return on success read character count, on failure negative error code
*/
nsapi_error_t get_info(const char *cmd, char *buf, size_t buf_size);
protected:
ATHandler &_at;
AT_CellularDevice &_device;
};
} // namespace mbed

View File

@ -20,6 +20,7 @@
#include "CellularUtil.h"
#include "CellularLog.h"
#include "CellularCommon.h"
#include "AT_CellularDevice.h"
using namespace std;
using namespace mbed_cellular_util;
@ -70,22 +71,22 @@ static const char *const rat_str[AT_CellularNetwork::RAT_MAX] = {
#endif
AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler) : AT_CellularBase(atHandler),
AT_CellularNetwork::AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) :
_connection_status_cb(NULL), _ciotopt_network_support_cb(NULL), _op_act(RAT_UNKNOWN),
_connect_status(NSAPI_STATUS_DISCONNECTED), _supported_network_opt(CIOT_OPT_MAX)
_connect_status(NSAPI_STATUS_DISCONNECTED), _supported_network_opt(CIOT_OPT_MAX),
_at(atHandler), _device(device)
{
_urc_funcs[C_EREG] = callback(this, &AT_CellularNetwork::urc_cereg);
_urc_funcs[C_GREG] = callback(this, &AT_CellularNetwork::urc_cgreg);
_urc_funcs[C_REG] = callback(this, &AT_CellularNetwork::urc_creg);
for (int type = 0; type < CellularNetwork::C_MAX; type++) {
if (get_property((AT_CellularBase::CellularProperty)type) != RegistrationModeDisable) {
if (_device.get_property((AT_CellularDevice::CellularProperty)type) != RegistrationModeDisable) {
_at.set_urc_handler(at_reg[type].urc_prefix, _urc_funcs[type]);
}
}
if (get_property(AT_CellularBase::PROPERTY_AT_CGEREP)) {
if (_device.get_property(AT_CellularDevice::PROPERTY_AT_CGEREP)) {
// additional urc to get better disconnect info for application. Not critical.
_at.set_urc_handler("+CGEV: NW DET", callback(this, &AT_CellularNetwork::urc_cgev));
_at.set_urc_handler("+CGEV: ME DET", callback(this, &AT_CellularNetwork::urc_cgev));
@ -99,12 +100,12 @@ AT_CellularNetwork::~AT_CellularNetwork()
{
(void)set_packet_domain_event_reporting(false);
for (int type = 0; type < CellularNetwork::C_MAX; type++) {
if (get_property((AT_CellularBase::CellularProperty)type) != RegistrationModeDisable) {
if (_device.get_property((AT_CellularDevice::CellularProperty)type) != RegistrationModeDisable) {
_at.set_urc_handler(at_reg[type].urc_prefix, 0);
}
}
if (get_property(AT_CellularBase::PROPERTY_AT_CGEREP)) {
if (_device.get_property(AT_CellularDevice::PROPERTY_AT_CGEREP)) {
_at.set_urc_handler("+CGEV: ME DET", 0);
_at.set_urc_handler("+CGEV: NW DET", 0);
}
@ -185,7 +186,7 @@ nsapi_error_t AT_CellularNetwork::set_registration_urc(RegistrationType type, bo
int index = (int)type;
MBED_ASSERT(index >= 0 && index < C_MAX);
RegistrationMode mode = (RegistrationMode)get_property((AT_CellularBase::CellularProperty)type);
RegistrationMode mode = (RegistrationMode)_device.get_property((AT_CellularDevice::CellularProperty)type);
if (mode == RegistrationModeDisable) {
return NSAPI_ERROR_UNSUPPORTED;
} else {
@ -544,7 +545,7 @@ nsapi_error_t AT_CellularNetwork::get_registration_params(RegistrationType type,
int i = (int)type;
MBED_ASSERT(i >= 0 && i < C_MAX);
if (!get_property((AT_CellularBase::CellularProperty)at_reg[i].type)) {
if (!_device.get_property((AT_CellularDevice::CellularProperty)at_reg[i].type)) {
return NSAPI_ERROR_UNSUPPORTED;
}
@ -625,7 +626,7 @@ nsapi_error_t AT_CellularNetwork::set_receive_period(int mode, EDRXAccessTechnol
nsapi_error_t AT_CellularNetwork::set_packet_domain_event_reporting(bool on)
{
if (!get_property(AT_CellularBase::PROPERTY_AT_CGEREP)) {
if (!_device.get_property(AT_CellularDevice::PROPERTY_AT_CGEREP)) {
return NSAPI_ERROR_UNSUPPORTED;
}
@ -683,10 +684,10 @@ nsapi_error_t AT_CellularNetwork::clear()
}
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN
char pdp_type_str[sizeof("IPV4V6")];
if (get_property(PROPERTY_IPV4V6_PDP_TYPE) ||
(get_property(PROPERTY_IPV4_PDP_TYPE) && get_property(PROPERTY_IPV6_PDP_TYPE))) {
if (_device.get_property(AT_CellularDevice::PROPERTY_IPV4V6_PDP_TYPE) ||
(_device.get_property(AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE) && _device.get_property(AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE))) {
strcpy(pdp_type_str, "IPV4V6");
} else if (get_property(PROPERTY_IPV6_PDP_TYPE)) {
} else if (_device.get_property(AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE)) {
strcpy(pdp_type_str, "IPV6");
} else {
strcpy(pdp_type_str, "IP");
@ -697,3 +698,8 @@ nsapi_error_t AT_CellularNetwork::clear()
return _at.unlock_return_error();
}
ATHandler &AT_CellularNetwork::get_at_handler()
{
return _at;
}

View File

@ -19,7 +19,8 @@
#define AT_CELLULAR_NETWORK_H_
#include "CellularNetwork.h"
#include "AT_CellularBase.h"
#include "ATHandler.h"
#include "AT_CellularDevice.h"
namespace mbed {
@ -34,11 +35,11 @@ namespace mbed {
*
* Class for attaching to a network and getting information from it.
*/
class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {
class AT_CellularNetwork : public CellularNetwork {
public:
AT_CellularNetwork(ATHandler &atHandler);
AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~AT_CellularNetwork();
// declare friend so it can access stack
friend class AT_CellularDevice;
@ -96,6 +97,9 @@ public: // CellularNetwork
virtual nsapi_error_t set_packet_domain_event_reporting(bool on);
public:
ATHandler &get_at_handler();
protected:
/** Sets access technology to be scanned. Modem specific implementation.
@ -145,6 +149,11 @@ protected:
registration_params_t _reg_params;
mbed::Callback<void()> _urc_funcs[C_MAX];
protected:
ATHandler &_at;
AT_CellularDevice &_device;
};
} // namespace mbed

View File

@ -177,8 +177,9 @@ static const unsigned char gsm_to_ascii[] = {
const int GSM_TO_ASCII_TABLE_SIZE = sizeof(gsm_to_ascii) / sizeof(gsm_to_ascii[0]);
AT_CellularSMS::AT_CellularSMS(ATHandler &at) : AT_CellularBase(at), _cb(0), _mode(CellularSMSMmodeText),
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1), _sms_info(NULL)
AT_CellularSMS::AT_CellularSMS(ATHandler &at, AT_CellularDevice &device) : _cb(0), _mode(CellularSMSMmodeText),
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1),
_sms_info(NULL), _at(at), _device(device)
{
}
@ -213,7 +214,7 @@ void AT_CellularSMS::cmti_urc()
nsapi_error_t AT_CellularSMS::set_cnmi()
{
if (!get_property(PROPERTY_AT_CNMI)) {
if (!_device.get_property(AT_CellularDevice::PROPERTY_AT_CNMI)) {
return NSAPI_ERROR_UNSUPPORTED;
}
@ -222,7 +223,7 @@ nsapi_error_t AT_CellularSMS::set_cnmi()
nsapi_error_t AT_CellularSMS::set_cmgf(int msg_format)
{
if (!get_property(PROPERTY_AT_CMGF)) {
if (!_device.get_property(AT_CellularDevice::PROPERTY_AT_CMGF)) {
return NSAPI_ERROR_UNSUPPORTED;
}
@ -231,7 +232,7 @@ nsapi_error_t AT_CellularSMS::set_cmgf(int msg_format)
nsapi_error_t AT_CellularSMS::set_csmp(int fo, int vp, int pid, int dcs)
{
if (!get_property(PROPERTY_AT_CSMP)) {
if (!_device.get_property(AT_CellularDevice::PROPERTY_AT_CSMP)) {
return NSAPI_ERROR_UNSUPPORTED;
}
@ -240,7 +241,7 @@ nsapi_error_t AT_CellularSMS::set_csmp(int fo, int vp, int pid, int dcs)
nsapi_error_t AT_CellularSMS::set_csdh(int show_header)
{
if (!get_property(PROPERTY_AT_CSDH)) {
if (!_device.get_property(AT_CellularDevice::PROPERTY_AT_CSDH)) {
return NSAPI_ERROR_UNSUPPORTED;
}
@ -1250,4 +1251,10 @@ uint16_t AT_CellularSMS::unpack_7_bit_gsm_to_str(const char *str, int len, char
return decodedCount;
}
ATHandler &AT_CellularSMS::get_at_handler()
{
return _at;
}
#endif //MBED_CONF_CELLULAR_USE_SMS

View File

@ -21,8 +21,9 @@
#if MBED_CONF_CELLULAR_USE_SMS
#include "CellularSMS.h"
#include "AT_CellularBase.h"
#include "ATHandler.h"
#include "Callback.h"
#include "AT_CellularDevice.h"
#include <time.h>
namespace mbed {
@ -32,10 +33,10 @@ namespace mbed {
*
* Class for SMS sending, reading and deleting.
*/
class AT_CellularSMS: public CellularSMS, public AT_CellularBase {
class AT_CellularSMS: public CellularSMS {
public:
AT_CellularSMS(ATHandler &atHandler);
AT_CellularSMS(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~AT_CellularSMS();
public:
@ -61,6 +62,9 @@ public:
virtual void set_extra_sim_wait_time(int sim_wait_time);
public:
ATHandler &get_at_handler();
private:
struct sms_info_t {
@ -165,6 +169,11 @@ private:
*/
uint16_t unpack_7_bit_gsm_to_str(const char *str, int len, char *buf, int padding_bits,
int msg_len);
private:
ATHandler &_at;
AT_CellularDevice &_device;
};
} // namespace mbed

View File

@ -19,11 +19,14 @@
#include "CellularUtil.h"
#include "CellularLog.h"
#include "ThisThread.h"
#include "AT_CellularDevice.h"
using namespace mbed_cellular_util;
using namespace mbed;
AT_CellularStack::AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type) : AT_CellularBase(at), _socket(NULL), _socket_count(0), _cid(cid), _stack_type(stack_type), _ip_ver_sendto(NSAPI_UNSPEC)
AT_CellularStack::AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
_socket(NULL), _socket_count(0), _cid(cid),
_stack_type(stack_type), _ip_ver_sendto(NSAPI_UNSPEC), _at(at), _device(device)
{
memset(_ip, 0, PDP_IPV6_SIZE);
}
@ -122,7 +125,7 @@ const char *AT_CellularStack::get_ip_address()
// Try to look for second address ONLY if modem has support for dual stack(can handle both IPv4 and IPv6 simultaneously).
// Otherwise assumption is that second address is not reliable, even if network provides one.
if ((get_property(PROPERTY_IPV4V6_PDP_TYPE) && (_at.read_string(_ip, PDP_IPV6_SIZE) != -1))) {
if ((_device.get_property(AT_CellularDevice::PROPERTY_IPV4V6_PDP_TYPE) && (_at.read_string(_ip, PDP_IPV6_SIZE) != -1))) {
convert_ipv6(_ip);
address.set_ip_address(_ip);
ipv6 = (address.get_ip_version() == NSAPI_IPv6);

View File

@ -18,9 +18,10 @@
#ifndef AT_CELLULAR_STACK_H_
#define AT_CELLULAR_STACK_H_
#include "AT_CellularBase.h"
#include "ATHandler.h"
#include "NetworkStack.h"
#include "PlatformMutex.h"
#include "AT_CellularDevice.h"
namespace mbed {
@ -35,10 +36,10 @@ namespace mbed {
*
* Implements NetworkStack and introduces interface for modem specific stack implementations.
*/
class AT_CellularStack : public NetworkStack, public AT_CellularBase {
class AT_CellularStack : public NetworkStack {
public:
AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type);
AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
virtual ~AT_CellularStack();
public: // NetworkStack
@ -232,6 +233,11 @@ private:
// mutex for write/read to a _socket array, needed when multiple threads may open sockets simultaneously
PlatformMutex _socket_mutex;
protected:
ATHandler &_at;
AT_CellularDevice &_device;
};
} // namespace mbed

View File

@ -3,8 +3,8 @@
namespace mbed {
AT_ControlPlane_netif::AT_ControlPlane_netif(ATHandler &at, int cid) : AT_CellularBase(at),
_cid(cid), _cb(NULL), _data(NULL), _recv_len(0)
AT_ControlPlane_netif::AT_ControlPlane_netif(ATHandler &at, int cid) :
_cid(cid), _cb(NULL), _data(NULL), _recv_len(0), _at(at)
{
_at.set_urc_handler("+CRTDCP:", mbed::Callback<void()>(this, &AT_ControlPlane_netif::urc_cp_recv));
}

View File

@ -1,10 +1,9 @@
#include "ControlPlane_netif.h"
#include "ATHandler.h"
#include "AT_CellularBase.h"
namespace mbed {
class AT_ControlPlane_netif: public ControlPlane_netif, public AT_CellularBase {
class AT_ControlPlane_netif: public ControlPlane_netif {
public:
AT_ControlPlane_netif(ATHandler &at, int cid);
virtual ~AT_ControlPlane_netif();
@ -37,6 +36,9 @@ private:
size_t _recv_len;
// Called on receiving URC: +CRTDCP
void urc_cp_recv();
protected:
ATHandler &_at;
};
} //mbed namespace

View File

@ -37,7 +37,8 @@ CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0),
#if MBED_CONF_CELLULAR_USE_SMS
_sms_ref_count(0),
#endif //MBED_CONF_CELLULAR_USE_SMS
_info_ref_count(0), _fh(fh), _queue(10 * EVENTS_EVENT_SIZE), _state_machine(0), _nw(0), _status_cb(0)
_info_ref_count(0), _fh(fh), _queue(10 * EVENTS_EVENT_SIZE), _state_machine(0),
_nw(0), _status_cb(0), _property_array(0)
{
MBED_ASSERT(fh);
set_sim_pin(NULL);
@ -258,4 +259,5 @@ nsapi_error_t CellularDevice::clear()
return NSAPI_ERROR_OK;
}
} // namespace mbed

View File

@ -40,7 +40,7 @@ AT_CellularContext *GEMALTO_CINTERION::create_context_impl(ATHandler &at, const
AT_CellularInformation *GEMALTO_CINTERION::open_information_impl(ATHandler &at)
{
if (_module == ModuleBGS2) {
return new GEMALTO_CINTERION_CellularInformation(at);
return new GEMALTO_CINTERION_CellularInformation(at, *this);
}
return AT_CellularDevice::open_information_impl(at);
}
@ -96,7 +96,7 @@ GEMALTO_CINTERION::Module GEMALTO_CINTERION::get_module()
void GEMALTO_CINTERION::init_module_bgs2()
{
// BGS2-W_ATC_V00.100
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable, // C_EREG
AT_CellularNetwork::RegistrationModeEnable, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -113,14 +113,14 @@ void GEMALTO_CINTERION::init_module_bgs2()
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
};
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
_module = ModuleBGS2;
}
void GEMALTO_CINTERION::init_module_els61()
{
// ELS61-E2_ATC_V01.000
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable, // C_EREG
AT_CellularNetwork::RegistrationModeEnable, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -133,14 +133,14 @@ void GEMALTO_CINTERION::init_module_els61()
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
};
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
_module = ModuleELS61;
}
void GEMALTO_CINTERION::init_module_ems31()
{
// EMS31-US_ATC_V4.9.5
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeDisable, // C_GREG
AT_CellularNetwork::RegistrationModeDisable, // C_REG
@ -153,14 +153,14 @@ void GEMALTO_CINTERION::init_module_ems31()
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
};
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
_module = ModuleEMS31;
}
void GEMALTO_CINTERION::init_module_ehs5e()
{
// EHS5-E
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable, // C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -171,7 +171,7 @@ void GEMALTO_CINTERION::init_module_ehs5e()
1, // PROPERTY_IPV6_STACK
0, // PROPERTY_IPV4V6_STACK
};
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
_module = ModuleEHS5E;
}

View File

@ -17,6 +17,7 @@
#include "GEMALTO_CINTERION_CellularContext.h"
#include "GEMALTO_CINTERION_CellularStack.h"
#include "CellularLog.h"
#include "CellularDevice.h"
namespace mbed {
@ -38,7 +39,7 @@ NetworkStack *GEMALTO_CINTERION_CellularContext::get_stack()
}
if (!_stack) {
_stack = new GEMALTO_CINTERION_CellularStack(_at, _apn, _uname, _pwd, _cid, (nsapi_ip_stack_t)_pdp_type);
_stack = new GEMALTO_CINTERION_CellularStack(get_at_handler(), _apn, _uname, _pwd, _cid, (nsapi_ip_stack_t)_pdp_type, *get_device());
}
return _stack;
}

View File

@ -19,7 +19,7 @@
namespace mbed {
GEMALTO_CINTERION_CellularInformation::GEMALTO_CINTERION_CellularInformation(ATHandler &at) : AT_CellularInformation(at)
GEMALTO_CINTERION_CellularInformation::GEMALTO_CINTERION_CellularInformation(ATHandler &at, AT_CellularDevice &device) : AT_CellularInformation(at, device)
{
}

View File

@ -24,7 +24,7 @@ namespace mbed {
class GEMALTO_CINTERION_CellularInformation: public AT_CellularInformation {
public:
GEMALTO_CINTERION_CellularInformation(ATHandler &at);
GEMALTO_CINTERION_CellularInformation(ATHandler &at, AT_CellularDevice &device);
public: // AT_CellularInformation
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);

View File

@ -33,8 +33,8 @@
using namespace mbed;
GEMALTO_CINTERION_CellularStack::GEMALTO_CINTERION_CellularStack(ATHandler &atHandler, const char *apn, const char *user, const char *password,
int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type), _apn(apn),
_user(user), _password(password)
int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device), _apn(apn), _user(user), _password(password)
{
}

View File

@ -24,7 +24,8 @@ namespace mbed {
class GEMALTO_CINTERION_CellularStack : public AT_CellularStack {
public:
GEMALTO_CINTERION_CellularStack(ATHandler &atHandler, const char *apn, const char *username, const char *password, int cid, nsapi_ip_stack_t stack_type);
GEMALTO_CINTERION_CellularStack(ATHandler &atHandler, const char *apn, const char *username,
const char *password, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
virtual ~GEMALTO_CINTERION_CellularStack();
protected:

View File

@ -21,7 +21,7 @@
using namespace mbed;
// by default all properties are supported
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -41,7 +41,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
#if MBED_CONF_GENERIC_AT3GPP_PROVIDE_DEFAULT

View File

@ -21,7 +21,7 @@
using namespace mbed;
using namespace events;
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeDisable, // C_REG
@ -41,12 +41,12 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
AT_CellularNetwork *SARA4_PPP::open_network_impl(ATHandler &at)
{
return new SARA4_PPP_CellularNetwork(at);
return new SARA4_PPP_CellularNetwork(at, *this);
}
#if MBED_CONF_SARA4_PPP_PROVIDE_DEFAULT

View File

@ -19,7 +19,7 @@
using namespace mbed;
SARA4_PPP_CellularNetwork::SARA4_PPP_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
SARA4_PPP_CellularNetwork::SARA4_PPP_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
{
}

View File

@ -24,7 +24,7 @@ namespace mbed {
class SARA4_PPP_CellularNetwork : public AT_CellularNetwork {
public:
SARA4_PPP_CellularNetwork(ATHandler &atHandler);
SARA4_PPP_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~SARA4_PPP_CellularNetwork();
protected:

View File

@ -28,7 +28,7 @@
using namespace events;
using namespace mbed;
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeDisable, // C_GREG
AT_CellularNetwork::RegistrationModeDisable, // C_REG
@ -48,7 +48,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
nsapi_error_t QUECTEL_BC95::get_sim_state(SimState &state)
@ -69,7 +69,7 @@ nsapi_error_t QUECTEL_BC95::get_sim_state(SimState &state)
AT_CellularNetwork *QUECTEL_BC95::open_network_impl(ATHandler &at)
{
return new QUECTEL_BC95_CellularNetwork(at);
return new QUECTEL_BC95_CellularNetwork(at, *this);
}
AT_CellularContext *QUECTEL_BC95::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
@ -79,7 +79,7 @@ AT_CellularContext *QUECTEL_BC95::create_context_impl(ATHandler &at, const char
AT_CellularInformation *QUECTEL_BC95::open_information_impl(ATHandler &at)
{
return new QUECTEL_BC95_CellularInformation(at);
return new QUECTEL_BC95_CellularInformation(at, *this);
}
nsapi_error_t QUECTEL_BC95::init()

View File

@ -38,7 +38,7 @@ NetworkStack *QUECTEL_BC95_CellularContext::get_stack()
}
if (!_stack) {
_stack = new QUECTEL_BC95_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type);
_stack = new QUECTEL_BC95_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type, *get_device());
}
return _stack;
}

View File

@ -18,7 +18,7 @@
namespace mbed {
QUECTEL_BC95_CellularInformation::QUECTEL_BC95_CellularInformation(ATHandler &at) : AT_CellularInformation(at)
QUECTEL_BC95_CellularInformation::QUECTEL_BC95_CellularInformation(ATHandler &at, AT_CellularDevice &device) : AT_CellularInformation(at, device)
{
}

View File

@ -23,7 +23,7 @@ namespace mbed {
class QUECTEL_BC95_CellularInformation : public AT_CellularInformation {
public:
QUECTEL_BC95_CellularInformation(ATHandler &at);
QUECTEL_BC95_CellularInformation(ATHandler &at, AT_CellularDevice &device);
virtual ~QUECTEL_BC95_CellularInformation();
public:

View File

@ -19,7 +19,7 @@
using namespace mbed;
QUECTEL_BC95_CellularNetwork::QUECTEL_BC95_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
QUECTEL_BC95_CellularNetwork::QUECTEL_BC95_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
{
_op_act = RAT_NB1;
}

View File

@ -24,7 +24,7 @@ namespace mbed {
class QUECTEL_BC95_CellularNetwork : public AT_CellularNetwork {
public:
QUECTEL_BC95_CellularNetwork(ATHandler &atHandler);
QUECTEL_BC95_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~QUECTEL_BC95_CellularNetwork();
protected:

View File

@ -24,7 +24,8 @@
using namespace mbed;
using namespace mbed_cellular_util;
QUECTEL_BC95_CellularStack::QUECTEL_BC95_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type)
QUECTEL_BC95_CellularStack::QUECTEL_BC95_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device)
{
_at.set_urc_handler("+NSONMI:", mbed::Callback<void()>(this, &QUECTEL_BC95_CellularStack::urc_nsonmi));
_at.set_urc_handler("+NSOCLI:", mbed::Callback<void()>(this, &QUECTEL_BC95_CellularStack::urc_nsocli));

View File

@ -26,7 +26,7 @@ namespace mbed {
class QUECTEL_BC95_CellularStack : public AT_CellularStack {
public:
QUECTEL_BC95_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type);
QUECTEL_BC95_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
virtual ~QUECTEL_BC95_CellularStack();
protected: // NetworkStack

View File

@ -45,7 +45,7 @@ using namespace rtos;
#define MBED_CONF_QUECTEL_BG96_POLARITY 1 // active high
#endif
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -69,7 +69,7 @@ QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh, PinName pwr, bool active_high, PinNam
_pwr(pwr, !_active_high),
_rst(rst, !_active_high)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
void QUECTEL_BG96::set_at_urcs_impl()
@ -79,7 +79,7 @@ void QUECTEL_BG96::set_at_urcs_impl()
AT_CellularNetwork *QUECTEL_BG96::open_network_impl(ATHandler &at)
{
return new QUECTEL_BG96_CellularNetwork(at);
return new QUECTEL_BG96_CellularNetwork(at, *this);
}
AT_CellularContext *QUECTEL_BG96::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
@ -89,7 +89,7 @@ AT_CellularContext *QUECTEL_BG96::create_context_impl(ATHandler &at, const char
AT_CellularInformation *QUECTEL_BG96::open_information_impl(ATHandler &at)
{
return new QUECTEL_BG96_CellularInformation(at);
return new QUECTEL_BG96_CellularInformation(at, *this);
}
void QUECTEL_BG96::set_ready_cb(Callback<void()> callback)

View File

@ -52,7 +52,7 @@ NetworkStack *QUECTEL_BG96_CellularContext::get_stack()
}
if (!_stack) {
_stack = new QUECTEL_BG96_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type);
_stack = new QUECTEL_BG96_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type, *get_device());
}
return _stack;

View File

@ -18,7 +18,7 @@
namespace mbed {
QUECTEL_BG96_CellularInformation::QUECTEL_BG96_CellularInformation(ATHandler &at) : AT_CellularInformation(at)
QUECTEL_BG96_CellularInformation::QUECTEL_BG96_CellularInformation(ATHandler &at, AT_CellularDevice &device) : AT_CellularInformation(at, device)
{
}

View File

@ -23,7 +23,7 @@ namespace mbed {
class QUECTEL_BG96_CellularInformation: public AT_CellularInformation {
public:
QUECTEL_BG96_CellularInformation(ATHandler &at);
QUECTEL_BG96_CellularInformation(ATHandler &at, AT_CellularDevice &device);
virtual ~QUECTEL_BG96_CellularInformation();
public: // AT_CellularInformation

View File

@ -21,7 +21,7 @@
using namespace mbed;
QUECTEL_BG96_CellularNetwork::QUECTEL_BG96_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
QUECTEL_BG96_CellularNetwork::QUECTEL_BG96_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
{
}

View File

@ -24,7 +24,7 @@ namespace mbed {
class QUECTEL_BG96_CellularNetwork : public AT_CellularNetwork {
public:
QUECTEL_BG96_CellularNetwork(ATHandler &atHandler);
QUECTEL_BG96_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~QUECTEL_BG96_CellularNetwork();
protected:

View File

@ -31,7 +31,8 @@ static const int sslctxID = 0;
using namespace mbed;
QUECTEL_BG96_CellularStack::QUECTEL_BG96_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type)
QUECTEL_BG96_CellularStack::QUECTEL_BG96_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device)
#ifdef MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
#if (MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES != 1)
#error Define cellular.offload-dns-queries to null or 1.

View File

@ -36,7 +36,7 @@ typedef enum {
class QUECTEL_BG96_CellularStack : public AT_CellularStack {
public:
QUECTEL_BG96_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type);
QUECTEL_BG96_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
virtual ~QUECTEL_BG96_CellularStack();
protected: // NetworkStack

View File

@ -46,7 +46,7 @@ using namespace events;
#define MBED_CONF_QUECTEL_EC2X_POLARITY 1 // active high
#endif
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -70,7 +70,7 @@ QUECTEL_EC2X::QUECTEL_EC2X(FileHandle *fh, PinName pwr, bool active_high, PinNam
_pwr_key(pwr, !_active_high),
_rst(rst, !_active_high)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
#if MBED_CONF_QUECTEL_EC2X_PROVIDE_DEFAULT

View File

@ -24,7 +24,7 @@
using namespace mbed;
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeDisable,// C_REG
@ -44,7 +44,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
nsapi_error_t QUECTEL_M26::get_sim_state(SimState &state)

View File

@ -28,7 +28,7 @@ QUECTEL_M26_CellularContext::QUECTEL_M26_CellularContext(ATHandler &at, Cellular
NetworkStack *QUECTEL_M26_CellularContext::get_stack()
{
if (!_stack) {
_stack = new QUECTEL_M26_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type);
_stack = new QUECTEL_M26_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type, *get_device());
}
return _stack;
}

View File

@ -19,7 +19,7 @@
using namespace mbed;
QUECTEL_M26_CellularInformation::QUECTEL_M26_CellularInformation(ATHandler &atHandler) : AT_CellularInformation(atHandler)
QUECTEL_M26_CellularInformation::QUECTEL_M26_CellularInformation(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularInformation(atHandler, device)
{
}

View File

@ -24,7 +24,7 @@ namespace mbed {
class QUECTEL_M26_CellularInformation : public AT_CellularInformation {
public:
QUECTEL_M26_CellularInformation(ATHandler &atHandler);
QUECTEL_M26_CellularInformation(ATHandler &atHandler, AT_CellularDevice &device);
public: //from CellularInformation
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);

View File

@ -24,7 +24,8 @@
using namespace mbed;
QUECTEL_M26_CellularStack::QUECTEL_M26_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type)
QUECTEL_M26_CellularStack::QUECTEL_M26_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device)
{
_at.set_urc_handler("+QIRDI:", Callback<void()>(this, &QUECTEL_M26_CellularStack::urc_qiurc));

View File

@ -29,7 +29,7 @@ namespace mbed {
class QUECTEL_M26_CellularStack : public AT_CellularStack {
public:
QUECTEL_M26_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type);
QUECTEL_M26_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
virtual ~QUECTEL_M26_CellularStack();
protected: // NetworkStack

View File

@ -27,7 +27,7 @@ using namespace events;
#define CONNECT_BUFFER_SIZE (1280 + 80 + 80) // AT response + sscanf format
#define CONNECT_TIMEOUT 8000
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -47,7 +47,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
AT_CellularContext *QUECTEL_UG96::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)

View File

@ -28,7 +28,7 @@
using namespace mbed;
using namespace events;
static const uint16_t retry_timeout[] = {1, 2, 4};
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC,// C_EREG
AT_CellularNetwork::RegistrationModeDisable,// C_GREG
AT_CellularNetwork::RegistrationModeDisable,// C_REG
@ -49,14 +49,14 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
RM1000_AT::RM1000_AT(FileHandle *fh) : AT_CellularDevice(fh)
{
tr_debug("RM1000_AT::RM1000_AT");
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
set_retry_timeout_array(retry_timeout, sizeof(retry_timeout) / sizeof(retry_timeout[0]));
}
AT_CellularNetwork *RM1000_AT::open_network_impl(ATHandler &at)
{
tr_debug("RM1000_AT::open_network_impl");
return new RM1000_AT_CellularNetwork(at);
return new RM1000_AT_CellularNetwork(at, *this);
}
AT_CellularContext *RM1000_AT::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)

View File

@ -45,7 +45,7 @@ NetworkStack *RM1000_AT_CellularContext::get_stack()
return NULL;
}
if (!_stack) {
_stack = new RM1000_AT_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type);
_stack = new RM1000_AT_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type, *get_device());
}
return _stack;

View File

@ -20,6 +20,7 @@
#include "CellularCommon.h"
#include "RM1000_AT_CellularNetwork.h"
#include "platform/mbed_wait_api.h"
#include "AT_CellularDevice.h"
#include "mbed-trace/mbed_trace.h"
#ifndef TRACE_GROUP
@ -37,7 +38,7 @@ void RM1000_AT_CellularNetwork::MODEM_FAULT_URC()
}
}
RM1000_AT_CellularNetwork::RM1000_AT_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
RM1000_AT_CellularNetwork::RM1000_AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
{
tr_debug("RM1000_AT_CellularNetwork::RM1000_B0_CellularNetwork");
_op_act = RAT_UNKNOWN;
@ -80,7 +81,7 @@ nsapi_error_t RM1000_AT_CellularNetwork::set_registration_urc(RegistrationType t
int index = (int)type;
MBED_ASSERT(index >= 0 && index < C_MAX);
RegistrationMode mode = (RegistrationMode)get_property((AT_CellularBase::CellularProperty)type);
RegistrationMode mode = (RegistrationMode)_device.get_property((AT_CellularDevice::CellularProperty)type);
if (mode == RegistrationModeDisable) {
return NSAPI_ERROR_UNSUPPORTED;
} else {

View File

@ -24,7 +24,7 @@ namespace mbed {
class RM1000_AT_CellularNetwork : public AT_CellularNetwork {
public:
RM1000_AT_CellularNetwork(ATHandler &atHandler);
RM1000_AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~RM1000_AT_CellularNetwork();
virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on);

View File

@ -27,7 +27,8 @@
using namespace mbed;
using namespace mbed_cellular_util;
RM1000_AT_CellularStack::RM1000_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type)
RM1000_AT_CellularStack::RM1000_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device)
{
tr_debug("RM1000_AT_CellularStack::RM1000_AT_CellularStack");

View File

@ -27,7 +27,7 @@ namespace mbed {
class RM1000_AT_CellularStack : public AT_CellularStack {
public:
RM1000_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type);
RM1000_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
virtual ~RM1000_AT_CellularStack();
virtual nsapi_error_t gethostbyname(const char *host,

View File

@ -21,7 +21,7 @@
using namespace mbed;
using namespace events;
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -41,7 +41,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
uint16_t TELIT_HE910::get_send_delay() const

View File

@ -41,7 +41,7 @@ using namespace events;
#define MBED_CONF_TELIT_ME910_POLARITY 1 // active high
#endif
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -67,7 +67,7 @@ TELIT_ME910::TELIT_ME910(FileHandle *fh, PinName pwr, bool active_high)
_active_high(active_high),
_pwr_key(pwr, !_active_high)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
AT_CellularContext *TELIT_ME910::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)

View File

@ -34,8 +34,8 @@ TELIT_ME910_CellularContext::~TELIT_ME910_CellularContext()
bool TELIT_ME910_CellularContext::get_context()
{
bool modem_supports_ipv6 = get_property(PROPERTY_IPV6_PDP_TYPE);
bool modem_supports_ipv4 = get_property(PROPERTY_IPV4_PDP_TYPE);
bool modem_supports_ipv6 = get_device()->get_property(AT_CellularDevice::PROPERTY_IPV6_PDP_TYPE);
bool modem_supports_ipv4 = get_device()->get_property(AT_CellularDevice::PROPERTY_IPV4_PDP_TYPE);
_at.cmd_start_stop("+CGDCONT", "?");
_at.resp_start("+CGDCONT:");
@ -62,7 +62,7 @@ bool TELIT_ME910_CellularContext::get_context()
pdp_type_t pdp_type = string_to_pdp_type(pdp_type_from_context);
// Accept exact matching PDP context type or dual PDP context for IPv4/IPv6 only modems
if (get_property(pdp_type_t_to_cellular_property(pdp_type)) ||
if (get_device()->get_property(pdp_type_t_to_cellular_property(pdp_type)) ||
((pdp_type == IPV4V6_PDP_TYPE && (modem_supports_ipv4 || modem_supports_ipv6)) && !_nonip_req)) {
_pdp_type = pdp_type;
_cid = cid;

View File

@ -21,7 +21,7 @@ using namespace mbed;
using namespace events;
#ifdef UBX_MDM_SARA_R41XM
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -39,7 +39,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_AT_CGEREP
};
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
@ -61,7 +61,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
1, // PROPERTY_AT_CGEREP
};
#else
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // C_EREG
0, // C_GREG
0, // C_REG
@ -82,12 +82,12 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
}
AT_CellularNetwork *UBLOX_AT::open_network_impl(ATHandler &at)
{
return new UBLOX_AT_CellularNetwork(at);
return new UBLOX_AT_CellularNetwork(at, *this);
}
AT_CellularContext *UBLOX_AT::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)

View File

@ -40,7 +40,7 @@ NetworkStack *UBLOX_AT_CellularContext::get_stack()
return NULL;
}
if (!_stack) {
_stack = new UBLOX_AT_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type);
_stack = new UBLOX_AT_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type, *get_device());
}
return _stack;

View File

@ -20,7 +20,7 @@
using namespace mbed;
UBLOX_AT_CellularNetwork::UBLOX_AT_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
UBLOX_AT_CellularNetwork::UBLOX_AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
{
_op_act = RAT_UNKNOWN;
}

View File

@ -28,7 +28,7 @@ namespace mbed {
class UBLOX_AT_CellularNetwork : public AT_CellularNetwork {
public:
UBLOX_AT_CellularNetwork(ATHandler &atHandler);
UBLOX_AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
virtual ~UBLOX_AT_CellularNetwork();
nsapi_error_t ubx_reboot();

View File

@ -21,7 +21,8 @@
using namespace mbed;
using namespace mbed_cellular_util;
UBLOX_AT_CellularStack::UBLOX_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type) : AT_CellularStack(atHandler, cid, stack_type)
UBLOX_AT_CellularStack::UBLOX_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device)
{
// URC handlers for sockets
_at.set_urc_handler("+UUSORD:", callback(this, &UBLOX_AT_CellularStack::UUSORD_URC));

View File

@ -27,7 +27,7 @@ namespace mbed {
class UBLOX_AT_CellularStack : public AT_CellularStack {
public:
UBLOX_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type);
UBLOX_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
virtual ~UBLOX_AT_CellularStack();
virtual const char *get_ip_address();

View File

@ -20,7 +20,7 @@
using namespace mbed;
using namespace events;
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeDisable, // C_GREG
AT_CellularNetwork::RegistrationModeDisable, // C_REG
@ -38,7 +38,7 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
UBLOX_N2XX::UBLOX_N2XX(FileHandle *fh): AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
set_cellular_properties(cellular_properties);
memset(simstr, 0, sizeof(simstr));
}
@ -66,7 +66,7 @@ AT_CellularContext *UBLOX_N2XX::create_context_impl(ATHandler &at, const char *a
#if MBED_CONF_CELLULAR_USE_SMS
AT_CellularSMS *UBLOX_N2XX::open_sms_impl(ATHandler &at)
{
return new UBLOX_N2XX_CellularSMS(at);
return new UBLOX_N2XX_CellularSMS(at, *this);
}
#endif // MBED_CONF_CELLULAR_USE_SMS

View File

@ -38,7 +38,7 @@ NetworkStack *UBLOX_N2XX_CellularContext::get_stack()
return NULL;
}
if (!_stack) {
_stack = new UBLOX_N2XX_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type);
_stack = new UBLOX_N2XX_CellularStack(_at, _cid, (nsapi_ip_stack_t)_pdp_type, *get_device());
}
return _stack;
}

Some files were not shown because too many files have changed in this diff Show More