mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Cellular: fixing unit test after refactor.
							parent
							
								
									ad2abbe887
								
							
						
					
					
						commit
						43e08a0adf
					
				| 
						 | 
				
			
			@ -117,6 +117,7 @@ set(unittest-includes-base
 | 
			
		|||
  "${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs/littlefs"
 | 
			
		||||
  "${PROJECT_SOURCE_DIR}/../features/cellular/framework/API"
 | 
			
		||||
  "${PROJECT_SOURCE_DIR}/../features/cellular/framework/AT"
 | 
			
		||||
  "${PROJECT_SOURCE_DIR}/../features/cellular/framework/device"
 | 
			
		||||
  "${PROJECT_SOURCE_DIR}/../features/cellular/framework"
 | 
			
		||||
  "${PROJECT_SOURCE_DIR}/../features/cellular/framework/common"
 | 
			
		||||
  "${PROJECT_SOURCE_DIR}/../features/lorawan"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,114 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 <string.h>
 | 
			
		||||
#include "AT_CellularContext.h"
 | 
			
		||||
#include "EventQueue.h"
 | 
			
		||||
#include "ATHandler.h"
 | 
			
		||||
#include "AT_CellularDevice.h"
 | 
			
		||||
#include "FileHandle_stub.h"
 | 
			
		||||
#include "CellularLog.h"
 | 
			
		||||
#include "ATHandler_stub.h"
 | 
			
		||||
#include "AT_CellularStack.h"
 | 
			
		||||
 | 
			
		||||
using namespace mbed;
 | 
			
		||||
using namespace events;
 | 
			
		||||
 | 
			
		||||
// AStyle ignored as the definition is not clear due to preprocessor usage
 | 
			
		||||
// *INDENT-OFF*
 | 
			
		||||
class TestAT_CellularContext : public testing::Test {
 | 
			
		||||
protected:
 | 
			
		||||
 | 
			
		||||
    void SetUp()
 | 
			
		||||
    {
 | 
			
		||||
        ATHandler_stub::int_count = kRead_int_table_size;
 | 
			
		||||
        ATHandler_stub::read_string_index = kRead_string_table_size;
 | 
			
		||||
        ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
 | 
			
		||||
        ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
        ATHandler_stub::int_value = -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void TearDown()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
// *INDENT-ON*
 | 
			
		||||
class my_stack : public AT_CellularStack {
 | 
			
		||||
public:
 | 
			
		||||
    my_stack(ATHandler &atHandler) : AT_CellularStack(atHandler, 1, IPV4_STACK) {}
 | 
			
		||||
    virtual int get_max_socket_count()
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
    virtual int get_max_packet_size()
 | 
			
		||||
    {
 | 
			
		||||
        return 200;
 | 
			
		||||
    }
 | 
			
		||||
    virtual bool is_protocol_supported(nsapi_protocol_t protocol)
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_error_t socket_close_impl(int sock_id)
 | 
			
		||||
    {
 | 
			
		||||
        return NSAPI_ERROR_OK;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_error_t create_socket_impl(CellularSocket *socket)
 | 
			
		||||
    {
 | 
			
		||||
        return NSAPI_ERROR_OK;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
 | 
			
		||||
                                                     const void *data, nsapi_size_t size)
 | 
			
		||||
    {
 | 
			
		||||
        return 100;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
 | 
			
		||||
                                                       void *buffer, nsapi_size_t size)
 | 
			
		||||
    {
 | 
			
		||||
        return 100;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class my_AT_CTX : public AT_CellularContext {
 | 
			
		||||
public:
 | 
			
		||||
    my_AT_CTX(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN,
 | 
			
		||||
            nsapi_ip_stack_t stack = DEFAULT_STACK) : AT_CellularContext(at, device, apn, stack) {}
 | 
			
		||||
    virtual ~my_AT_CTX() {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class my_AT_CTXIPV6 : public AT_CellularContext {
 | 
			
		||||
public:
 | 
			
		||||
    my_AT_CTXIPV6(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN,
 | 
			
		||||
            nsapi_ip_stack_t stack = DEFAULT_STACK) : AT_CellularContext(at, device, apn, stack) {}
 | 
			
		||||
    virtual ~my_AT_CTXIPV6() {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int network_cb_count;
 | 
			
		||||
static void network_cb(nsapi_event_t ev, intptr_t intptr)
 | 
			
		||||
{
 | 
			
		||||
    network_cb_count++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularContext, Create)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularContext *ctx = new AT_CellularContext(at, NULL);
 | 
			
		||||
    EXPECT_TRUE(ctx != NULL);
 | 
			
		||||
    delete ctx;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,35 @@
 | 
			
		|||
 | 
			
		||||
####################
 | 
			
		||||
# UNIT TESTS
 | 
			
		||||
####################
 | 
			
		||||
 | 
			
		||||
# Add test specific include paths
 | 
			
		||||
set(unittest-includes ${unittest-includes}
 | 
			
		||||
  features/cellular/framework/common/util
 | 
			
		||||
  ../features/cellular/framework/common
 | 
			
		||||
  ../features/cellular/framework/AT
 | 
			
		||||
  ../features/cellular/framework/device
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# Source files
 | 
			
		||||
set(unittest-sources
 | 
			
		||||
  ../features/cellular/framework/AT/AT_CellularContext.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# Test files
 | 
			
		||||
set(unittest-test-sources
 | 
			
		||||
  features/cellular/framework/AT/at_cellularcontext/at_cellularcontexttest.cpp
 | 
			
		||||
  stubs/ATHandler_stub.cpp
 | 
			
		||||
  stubs/AT_CellularBase_stub.cpp
 | 
			
		||||
  stubs/EventQueue_stub.cpp
 | 
			
		||||
  stubs/FileHandle_stub.cpp
 | 
			
		||||
  stubs/NetworkInterface_stub.cpp
 | 
			
		||||
  stubs/NetworkStack_stub.cpp
 | 
			
		||||
  stubs/us_ticker_stub.cpp
 | 
			
		||||
  stubs/mbed_assert_stub.c
 | 
			
		||||
  stubs/CellularDevice_stub.cpp
 | 
			
		||||
  stubs/CellularStateMachine_stub.cpp
 | 
			
		||||
  stubs/Semaphore_stub.cpp
 | 
			
		||||
  stubs/CellularUtil_stub.cpp
 | 
			
		||||
  stubs/equeue_stub.c
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -70,8 +70,12 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_network)
 | 
			
		|||
    AT_CellularDevice dev(que);
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(!dev.open_network(NULL));
 | 
			
		||||
    EXPECT_TRUE(dev.open_network(&fh1));
 | 
			
		||||
    CellularNetwork *nw = dev.open_network(NULL);
 | 
			
		||||
    CellularNetwork *nw1 = dev.open_network(&fh1);
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(nw);
 | 
			
		||||
    EXPECT_TRUE(nw1);
 | 
			
		||||
    EXPECT_TRUE(nw1 == nw);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sms)
 | 
			
		||||
| 
						 | 
				
			
			@ -80,8 +84,12 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sms)
 | 
			
		|||
    AT_CellularDevice dev(que);
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(!dev.open_sms(NULL));
 | 
			
		||||
    EXPECT_TRUE(dev.open_sms(&fh1));
 | 
			
		||||
    CellularSMS *sms = dev.open_sms(NULL);
 | 
			
		||||
    CellularSMS *sms1 = dev.open_sms(&fh1);
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(sms);
 | 
			
		||||
    EXPECT_TRUE(sms1);
 | 
			
		||||
    EXPECT_TRUE(sms1 == sms);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_power)
 | 
			
		||||
| 
						 | 
				
			
			@ -90,8 +98,12 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_power)
 | 
			
		|||
    AT_CellularDevice dev(que);
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(!dev.open_power(NULL));
 | 
			
		||||
    EXPECT_TRUE(dev.open_power(&fh1));
 | 
			
		||||
    CellularPower *pwr = dev.open_power(NULL);
 | 
			
		||||
    CellularPower *pwr1 = dev.open_power(&fh1);
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(pwr);
 | 
			
		||||
    EXPECT_TRUE(pwr1);
 | 
			
		||||
    EXPECT_TRUE(pwr1 == pwr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sim)
 | 
			
		||||
| 
						 | 
				
			
			@ -100,8 +112,12 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_sim)
 | 
			
		|||
    AT_CellularDevice dev(que);
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(! dev.open_sim(NULL));
 | 
			
		||||
    EXPECT_TRUE(dev.open_sim(&fh1));
 | 
			
		||||
    CellularSIM *sim =  dev.open_sim(NULL);
 | 
			
		||||
    CellularSIM *sim1 =  dev.open_sim(&fh1);
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(sim);
 | 
			
		||||
    EXPECT_TRUE(sim1);
 | 
			
		||||
    EXPECT_TRUE(sim1 == sim);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_information)
 | 
			
		||||
| 
						 | 
				
			
			@ -110,8 +126,12 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_information)
 | 
			
		|||
    AT_CellularDevice dev(que);
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(!dev.open_information(NULL));
 | 
			
		||||
    EXPECT_TRUE(dev.open_information(&fh1));
 | 
			
		||||
    CellularInformation *info = dev.open_information(NULL);
 | 
			
		||||
    CellularInformation *info1 = dev.open_information(&fh1);
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(info);
 | 
			
		||||
    EXPECT_TRUE(info1);
 | 
			
		||||
    EXPECT_TRUE(info1 == info);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_network)
 | 
			
		||||
| 
						 | 
				
			
			@ -249,21 +269,6 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_modem_debug_on)
 | 
			
		|||
    dev.close_sim();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_stack)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    AT_CellularDevice dev(que);
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
 | 
			
		||||
    NetworkStack *stack = dev.get_stack();
 | 
			
		||||
    EXPECT_TRUE(stack == NULL);
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(dev.open_network(&fh1));
 | 
			
		||||
 | 
			
		||||
    stack = dev.get_stack();
 | 
			
		||||
    EXPECT_TRUE(stack == NULL); // Not in PPP so also null but this is got from the network class
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_send_delay)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,10 @@ set(unittest-includes ${unittest-includes}
 | 
			
		|||
  features/cellular/framework/common/util
 | 
			
		||||
  ../features/cellular/framework/common
 | 
			
		||||
  ../features/cellular/framework/AT
 | 
			
		||||
  ../features/cellular/framework/device
 | 
			
		||||
  ../features/frameworks/mbed-client-randlib/mbed-client-randlib
 | 
			
		||||
  ../drivers
 | 
			
		||||
  ../hal
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# Source files
 | 
			
		||||
| 
						 | 
				
			
			@ -33,4 +36,16 @@ set(unittest-test-sources
 | 
			
		|||
  stubs/FileHandle_stub.cpp
 | 
			
		||||
  stubs/mbed_assert_stub.c
 | 
			
		||||
  stubs/CellularDevice_stub.cpp
 | 
			
		||||
  stubs/NetworkStack_stub.cpp
 | 
			
		||||
  stubs/AT_CellularContext_stub.cpp
 | 
			
		||||
  stubs/Semaphore_stub.cpp
 | 
			
		||||
  stubs/UARTSerial_stub.cpp
 | 
			
		||||
  stubs/SerialBase_stub.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# defines
 | 
			
		||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEVICE_SERIAL=1 -DDEVICE_INTERRUPTIN=1 -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN=NULL")
 | 
			
		||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMDMTXD=NC -DMDMRXD=NC -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200")
 | 
			
		||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEVICE_SERIAL=1 -DDEVICE_INTERRUPTIN=1 -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_PLMN=NULL -DMBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN=NULL")
 | 
			
		||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMDMTXD=NC -DMDMRXD=NC -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,54 +46,12 @@ protected:
 | 
			
		|||
    {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
// *INDENT-ON*
 | 
			
		||||
class my_stack : public AT_CellularStack {
 | 
			
		||||
public:
 | 
			
		||||
    my_stack(ATHandler &atHandler) : AT_CellularStack(atHandler, 1, IPV4_STACK) {}
 | 
			
		||||
    virtual int get_max_socket_count()
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
    virtual int get_max_packet_size()
 | 
			
		||||
    {
 | 
			
		||||
        return 200;
 | 
			
		||||
    }
 | 
			
		||||
    virtual bool is_protocol_supported(nsapi_protocol_t protocol)
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_error_t socket_close_impl(int sock_id)
 | 
			
		||||
    {
 | 
			
		||||
        return NSAPI_ERROR_OK;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_error_t create_socket_impl(CellularSocket *socket)
 | 
			
		||||
    {
 | 
			
		||||
        return NSAPI_ERROR_OK;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
 | 
			
		||||
                                                     const void *data, nsapi_size_t size)
 | 
			
		||||
    {
 | 
			
		||||
        return 100;
 | 
			
		||||
    }
 | 
			
		||||
    virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
 | 
			
		||||
                                                       void *buffer, nsapi_size_t size)
 | 
			
		||||
    {
 | 
			
		||||
        return 100;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class my_AT_CN : public AT_CellularNetwork {
 | 
			
		||||
public:
 | 
			
		||||
    my_AT_CN(ATHandler &atHandler) : AT_CellularNetwork(atHandler) {}
 | 
			
		||||
    virtual ~my_AT_CN() {}
 | 
			
		||||
    NetworkStack *get_stack()
 | 
			
		||||
    {
 | 
			
		||||
        if (!_stack) {
 | 
			
		||||
            return new my_stack(get_at_handler());
 | 
			
		||||
        } else {
 | 
			
		||||
            return _stack;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    virtual AT_CellularNetwork::RegistrationMode has_registration(RegistrationType reg_type)
 | 
			
		||||
    {
 | 
			
		||||
        if (reg_type == C_GREG) {
 | 
			
		||||
| 
						 | 
				
			
			@ -105,27 +63,12 @@ public:
 | 
			
		|||
    {
 | 
			
		||||
        return NSAPI_ERROR_OK;
 | 
			
		||||
    }
 | 
			
		||||
    virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack)
 | 
			
		||||
    {
 | 
			
		||||
        if (requested_stack == IPV4_STACK || requested_stack == DEFAULT_STACK) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class my_AT_CNipv6 : public AT_CellularNetwork {
 | 
			
		||||
public:
 | 
			
		||||
    my_AT_CNipv6(ATHandler &atHandler) : AT_CellularNetwork(atHandler) {}
 | 
			
		||||
    virtual ~my_AT_CNipv6() {}
 | 
			
		||||
    NetworkStack *get_stack()
 | 
			
		||||
    {
 | 
			
		||||
        if (!_stack) {
 | 
			
		||||
            return new my_stack(get_at_handler());
 | 
			
		||||
        } else {
 | 
			
		||||
            return _stack;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    virtual AT_CellularNetwork::RegistrationMode has_registration(RegistrationType reg_type)
 | 
			
		||||
    {
 | 
			
		||||
        if (reg_type == C_GREG) {
 | 
			
		||||
| 
						 | 
				
			
			@ -137,13 +80,6 @@ public:
 | 
			
		|||
    {
 | 
			
		||||
        return NSAPI_ERROR_OK;
 | 
			
		||||
    }
 | 
			
		||||
    virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack)
 | 
			
		||||
    {
 | 
			
		||||
        if (requested_stack == IPV6_STACK || requested_stack == DEFAULT_STACK) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int network_cb_count;
 | 
			
		||||
| 
						 | 
				
			
			@ -163,256 +99,6 @@ TEST_F(TestAT_CellularNetwork, Create)
 | 
			
		|||
    delete cn;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_init)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.init());
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_NO_MEMORY;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_NO_MEMORY == cn.init());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_credentials)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork *cnn = new AT_CellularNetwork(at);
 | 
			
		||||
    delete cnn;
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, NULL));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, NULL, NULL));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, NULL, "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, "user", NULL));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, "user"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", NULL));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", NULL, NULL));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", NULL, "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", "user", NULL));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", "user"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", "user", "passwd"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_activate_context)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    my_AT_CN my_cn(at);
 | 
			
		||||
    my_AT_CNipv6 my_cnipv6(at);
 | 
			
		||||
 | 
			
		||||
    // get_context return true and new context created. But now stack and so error.
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context return true and new context created, also do_user_authentication called with success.
 | 
			
		||||
    // But now stack and so error.
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context return true and new context created, also do_user_authentication called with failure.
 | 
			
		||||
    ATHandler_stub::resp_stop_success_count = 2;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == my_cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context return true and new context created, also do_user_authentication called with success.
 | 
			
		||||
    // Now there is stack.
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context return true and new context created, test delete context
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.activate_context());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives zero len, fails with no stack
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 1;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn reading fails
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 1;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"IPV6";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_NO_CONNECTION == cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn does not match, now other contexts so new one created
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 2;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"IP";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn match
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 2; // set to 2 so cgact will give that this context is active
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 2;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"IPV4V6";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_stack_type(IPV4_STACK));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("internet"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn match
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 2;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"IPV6";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.set_stack_type(IPV6_STACK));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.set_credentials("internet"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn match
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 2;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"IPV4V6";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_stack_type(DEFAULT_STACK));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("internet"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn match
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 2;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"IPV4V6";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.set_stack_type(DEFAULT_STACK));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.set_credentials("internet"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn match
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 2;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"IPV6";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.set_stack_type(DEFAULT_STACK));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.set_credentials("internet"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cnipv6.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn match
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::read_string_index = 2;
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"IP";
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_stack_type(DEFAULT_STACK));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("internet"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.activate_context());
 | 
			
		||||
 | 
			
		||||
    // get_context pdp type gives proper type, apn match. Test Delete the created context.
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 0;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    //ATHandler_stub::nsapi_error_ok_counter = 2;
 | 
			
		||||
    ATHandler_stub::resp_stop_success_count = 2;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials(NULL, NULL, NULL));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_NO_CONNECTION == my_cn.activate_context());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_connect)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    // no stack so will fail
 | 
			
		||||
    cn.attach(&network_cb);
 | 
			
		||||
    network_cb_count = 0;
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.connect("APN", "a", "b"));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_STATUS_DISCONNECTED == cn.get_connection_status());
 | 
			
		||||
    EXPECT_TRUE(network_cb_count == 2);
 | 
			
		||||
 | 
			
		||||
    network_cb_count = 0;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_NO_CONNECTION == cn.connect("APN"));
 | 
			
		||||
    EXPECT_TRUE(network_cb_count == 2);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_STATUS_DISCONNECTED == cn.get_connection_status());
 | 
			
		||||
 | 
			
		||||
    my_AT_CN my_cn(at);
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    cn.set_stack_type(IPV4_STACK);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.connect());
 | 
			
		||||
    EXPECT_TRUE(network_cb_count == 2);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_STATUS_GLOBAL_UP == my_cn.get_connection_status());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_disconnect)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.disconnect());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_stack)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    my_AT_CN my_cn(at);
 | 
			
		||||
    my_stack *mystack = (my_stack *)my_cn.get_stack();
 | 
			
		||||
    EXPECT_TRUE(mystack);
 | 
			
		||||
    delete mystack;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_registration)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
| 
						 | 
				
			
			@ -674,130 +360,6 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_detach)
 | 
			
		|||
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.detach());
 | 
			
		||||
 | 
			
		||||
    // connect so we can test callback in detach
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    cn.set_stack_type(IPV4_STACK);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.connect());
 | 
			
		||||
    EXPECT_TRUE(NSAPI_STATUS_GLOBAL_UP == cn.get_connection_status());
 | 
			
		||||
    // attach callback
 | 
			
		||||
    cn.attach(&network_cb);
 | 
			
		||||
    network_cb_count = 0;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.detach());
 | 
			
		||||
    EXPECT_TRUE(network_cb_count == 1);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_STATUS_DISCONNECTED == cn.get_connection_status());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_rate_control)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    int ur = -1;
 | 
			
		||||
    CellularNetwork::RateControlExceptionReports reports = CellularNetwork::NotAllowedToBeSent;
 | 
			
		||||
    CellularNetwork::RateControlUplinkTimeUnit timeUnit = CellularNetwork::Unrestricted;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_rate_control(reports, timeUnit, ur));
 | 
			
		||||
    EXPECT_TRUE(reports == CellularNetwork::NotAllowedToBeSent);
 | 
			
		||||
    EXPECT_TRUE(timeUnit == CellularNetwork::Unrestricted);
 | 
			
		||||
    EXPECT_TRUE(ur == -1);
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_rate_control(reports, timeUnit, ur));
 | 
			
		||||
    EXPECT_TRUE(reports == CellularNetwork::AllowedToBeSent);
 | 
			
		||||
    EXPECT_TRUE(timeUnit == CellularNetwork::Minute);
 | 
			
		||||
    EXPECT_TRUE(ur == 1);
 | 
			
		||||
 | 
			
		||||
    // test second if in get_rate_control
 | 
			
		||||
    reports = CellularNetwork::NotAllowedToBeSent;
 | 
			
		||||
    timeUnit = CellularNetwork::Unrestricted;
 | 
			
		||||
    ur = -1;
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::int_count = 1;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[0] = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_rate_control(reports, timeUnit, ur));
 | 
			
		||||
    EXPECT_TRUE(reports == CellularNetwork::NotAllowedToBeSent);
 | 
			
		||||
    EXPECT_TRUE(timeUnit == CellularNetwork::Unrestricted);
 | 
			
		||||
    EXPECT_TRUE(ur == -1);
 | 
			
		||||
 | 
			
		||||
    // test second if in get_rate_control
 | 
			
		||||
    ATHandler_stub::int_count = 2;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[0] = 1;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[1] = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_rate_control(reports, timeUnit, ur));
 | 
			
		||||
    EXPECT_TRUE(reports == CellularNetwork::AllowedToBeSent);
 | 
			
		||||
    EXPECT_TRUE(timeUnit == CellularNetwork::Unrestricted);
 | 
			
		||||
    EXPECT_TRUE(ur == -1);
 | 
			
		||||
 | 
			
		||||
    // test third if in get_rate_control
 | 
			
		||||
    ATHandler_stub::int_count = 3;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[0] = 3;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[1] = 1;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[2] = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_rate_control(reports, timeUnit, ur));
 | 
			
		||||
    EXPECT_TRUE(reports == CellularNetwork::AllowedToBeSent);
 | 
			
		||||
    EXPECT_TRUE(timeUnit == CellularNetwork::Day);
 | 
			
		||||
    EXPECT_TRUE(ur == -1);
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::int_count = 4;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[0] = 5;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[1] = 3;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[2] = 1;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[3] = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_rate_control(reports, timeUnit, ur));
 | 
			
		||||
    EXPECT_TRUE(reports == CellularNetwork::AllowedToBeSent);
 | 
			
		||||
    EXPECT_TRUE(timeUnit == CellularNetwork::Day);
 | 
			
		||||
    EXPECT_TRUE(ur == 5);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_apn_backoff_timer)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    int time = -1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_PARAMETER == cn.get_apn_backoff_timer(time));
 | 
			
		||||
    EXPECT_TRUE(time == -1);
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_PARAMETER == cn.get_apn_backoff_timer(time));
 | 
			
		||||
    EXPECT_TRUE(time == -1);
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 0;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    cn.set_credentials("internet", NULL, NULL);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_apn_backoff_timer(time));
 | 
			
		||||
    EXPECT_TRUE(time == -1);
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 0;
 | 
			
		||||
    ATHandler_stub::bool_value = true;
 | 
			
		||||
    ATHandler_stub::int_value = 55;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    cn.set_credentials("internet", NULL, NULL);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_apn_backoff_timer(time));
 | 
			
		||||
    EXPECT_TRUE(time == 55);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_ip_address)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    EXPECT_TRUE(!cn.get_ip_address());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_access_technology)
 | 
			
		||||
| 
						 | 
				
			
			@ -896,103 +458,12 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_ciot_optimization_con
 | 
			
		|||
    pref = CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE;
 | 
			
		||||
    ATHandler_stub::int_value = 1;
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
 | 
			
		||||
    ATHandler_stub::nsapi_error_ok_counter = 0;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_ciot_optimization_config(sup, pref));
 | 
			
		||||
    EXPECT_TRUE(sup == CellularNetwork::SUPPORTED_UE_OPT_NO_SUPPORT);
 | 
			
		||||
    EXPECT_TRUE(pref == CellularNetwork::PREFERRED_UE_OPT_NO_PREFERENCE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_stack_type)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_PARAMETER == cn.set_stack_type(IPV4_STACK));
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_stack_type(DEFAULT_STACK));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_stack_type)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    EXPECT_TRUE(DEFAULT_STACK == cn.get_stack_type());
 | 
			
		||||
 | 
			
		||||
    my_AT_CN my_cn(at);
 | 
			
		||||
    EXPECT_TRUE(DEFAULT_STACK == my_cn.get_stack_type());
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_stack_type(IPV4_STACK));
 | 
			
		||||
    EXPECT_TRUE(DEFAULT_STACK == my_cn.get_stack_type());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_pdpcontext_params)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    CellularNetwork::pdpContextList_t list;
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_pdpcontext_params(list));
 | 
			
		||||
 | 
			
		||||
    // don't got to while loop
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 0;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_pdpcontext_params(list));
 | 
			
		||||
    EXPECT_TRUE(NULL == list.get_head());
 | 
			
		||||
 | 
			
		||||
    // go to while loop and check values
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::resp_info_true_counter = 1;
 | 
			
		||||
    ATHandler_stub::int_count = 9;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[8] = 1;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[7] = 2;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[6] = 3;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[5] = 4;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[4] = 5;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[3] = 6;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[2] = 7;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[1] = 8;
 | 
			
		||||
    ATHandler_stub::int_valid_count_table[0] = 9;
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::read_string_index = 7;
 | 
			
		||||
    ATHandler_stub::read_string_table[6] = (char *)"internet";
 | 
			
		||||
    ATHandler_stub::read_string_table[5] = (char *)"1.2.3.4.5.6.7.8.9.10.11.112.13.14.15.16.1.2.3.44.55.6.7.8.9.10.11.12.13.14.15.16";
 | 
			
		||||
    ATHandler_stub::read_string_table[4] = (char *)"23.33.44.1.2.3.55.123.225.34.11.1.0.0.123.234";
 | 
			
		||||
    ATHandler_stub::read_string_table[3] = (char *)"1.2.3.4";
 | 
			
		||||
    ATHandler_stub::read_string_table[2] = (char *)"0.255.0.255";
 | 
			
		||||
    ATHandler_stub::read_string_table[1] = (char *)"25.66.77.88";
 | 
			
		||||
    ATHandler_stub::read_string_table[0] = (char *)"004.003.002.001";
 | 
			
		||||
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_pdpcontext_params(list));
 | 
			
		||||
    CellularNetwork::pdpcontext_params_t *params = list.get_head();
 | 
			
		||||
    EXPECT_TRUE(params != NULL);
 | 
			
		||||
    EXPECT_TRUE(params->next == NULL);
 | 
			
		||||
    EXPECT_TRUE(params->cid == 1);
 | 
			
		||||
    EXPECT_TRUE(params->bearer_id == 2);
 | 
			
		||||
    EXPECT_TRUE(params->im_signalling_flag == 3);
 | 
			
		||||
    EXPECT_TRUE(params->lipa_indication == 4);
 | 
			
		||||
    EXPECT_TRUE(params->ipv4_mtu == 5);
 | 
			
		||||
    EXPECT_TRUE(params->wlan_offload == 6);
 | 
			
		||||
    EXPECT_TRUE(params->local_addr_ind == 7);
 | 
			
		||||
    EXPECT_TRUE(params->non_ip_mtu == 8);
 | 
			
		||||
    EXPECT_TRUE(params->serving_plmn_rate_control_value == 9);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->apn, "internet") == 0);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->local_addr, "102:304:506:708:90A:B70:D0E:F10") == 0);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->local_subnet_mask, "102:32C:3706:708:90A:B0C:D0E:F10") == 0);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->gateway_addr, "1721:2C01:203:377B:E122:B01:000:7BEA") == 0);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->dns_primary_addr, "1.2.3.4") == 0);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->dns_secondary_addr, "0.255.0.255") == 0);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->p_cscf_prim_addr, "25.66.77.88") == 0);
 | 
			
		||||
    EXPECT_TRUE(strcmp(params->p_cscf_sec_addr, "004.003.002.001") == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_extended_signal_quality)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
| 
						 | 
				
			
			@ -1132,8 +603,6 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_attach)
 | 
			
		|||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    network_cb_count = 0;
 | 
			
		||||
    cn.attach(&network_cb);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.connect());
 | 
			
		||||
    EXPECT_TRUE(network_cb_count == 2); // check that attached callback was called twice
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_get_connection_status)
 | 
			
		||||
| 
						 | 
				
			
			@ -1147,32 +616,6 @@ TEST_F(TestAT_CellularNetwork, test_get_connection_status)
 | 
			
		|||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    network_cb_count = 0;
 | 
			
		||||
    cn.attach(&network_cb);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_UNSUPPORTED == cn.connect());
 | 
			
		||||
    EXPECT_TRUE(network_cb_count == 2); // check that attached callback was called twice
 | 
			
		||||
    EXPECT_TRUE(NSAPI_STATUS_DISCONNECTED == cn.get_connection_status());
 | 
			
		||||
 | 
			
		||||
    my_AT_CN my_cn(at);
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    ATHandler_stub::bool_value = false;
 | 
			
		||||
    cn.set_stack_type(IPV4_STACK);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.connect());
 | 
			
		||||
    EXPECT_TRUE(network_cb_count == 2);
 | 
			
		||||
    EXPECT_TRUE(NSAPI_STATUS_GLOBAL_UP == my_cn.get_connection_status());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(TestAT_CellularNetwork, test_set_blocking)
 | 
			
		||||
{
 | 
			
		||||
    EventQueue que;
 | 
			
		||||
    FileHandle_stub fh1;
 | 
			
		||||
    ATHandler at(&fh1, que, 0, ",");
 | 
			
		||||
 | 
			
		||||
    AT_CellularNetwork cn(at);
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_blocking(false));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_blocking(true));
 | 
			
		||||
 | 
			
		||||
    ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_blocking(false));
 | 
			
		||||
    EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_blocking(true));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,6 @@ set(unittest-includes ${unittest-includes}
 | 
			
		|||
# Source files
 | 
			
		||||
set(unittest-sources
 | 
			
		||||
  ../features/cellular/framework/AT/AT_CellularNetwork.cpp
 | 
			
		||||
  ../features/cellular/framework/AT/AT_CellularStack.cpp
 | 
			
		||||
  ../features/cellular/framework/common/CellularUtil.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -25,8 +24,6 @@ set(unittest-test-sources
 | 
			
		|||
  stubs/AT_CellularBase_stub.cpp
 | 
			
		||||
  stubs/EventQueue_stub.cpp
 | 
			
		||||
  stubs/FileHandle_stub.cpp
 | 
			
		||||
  stubs/NetworkInterface_stub.cpp
 | 
			
		||||
  stubs/NetworkStack_stub.cpp
 | 
			
		||||
  stubs/us_ticker_stub.cpp
 | 
			
		||||
  stubs/mbed_assert_stub.c
 | 
			
		||||
  stubs/SocketAddress_stub.cpp
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,204 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 "AT_CellularContext.h"
 | 
			
		||||
 | 
			
		||||
using namespace mbed;
 | 
			
		||||
 | 
			
		||||
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, nsapi_ip_stack_t stack) :
 | 
			
		||||
        AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
 | 
			
		||||
        _current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
 | 
			
		||||
{
 | 
			
		||||
    _stack = NULL;
 | 
			
		||||
    _ip_stack_type = DEFAULT_STACK;
 | 
			
		||||
    _authentication_type = CellularContext::CHAP;
 | 
			
		||||
    _connect_status = NSAPI_STATUS_DISCONNECTED;
 | 
			
		||||
    _is_context_active = false;
 | 
			
		||||
    _is_context_activated = false;
 | 
			
		||||
    _apn = apn;
 | 
			
		||||
    _uname = MBED_CONF_NSAPI_DEFAULT_CELLULAR_USERNAME;
 | 
			
		||||
    _pwd = MBED_CONF_NSAPI_DEFAULT_CELLULAR_PASSWORD;
 | 
			
		||||
    _status_cb = NULL;
 | 
			
		||||
    _cid = -1;
 | 
			
		||||
    _new_context_set = false;
 | 
			
		||||
    _next = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
AT_CellularContext::~AT_CellularContext()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularContext::set_file_handle(FileHandle *fh)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::connect()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::set_device_ready()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::set_sim_ready()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::register_to_network()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::attach_to_network()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::check_operation(nsapi_error_t err, ContextOperation op)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t AT_CellularContext::get_timeout_for_operation(ContextOperation op) const
 | 
			
		||||
{
 | 
			
		||||
    uint32_t timeout = 10 * 60 * 1000; // default timeout is 10 minutes as registration and attach may take time
 | 
			
		||||
    return timeout;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AT_CellularContext::is_connected()
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
NetworkStack *AT_CellularContext::get_stack()
 | 
			
		||||
{
 | 
			
		||||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *AT_CellularContext::get_ip_address()
 | 
			
		||||
{
 | 
			
		||||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularContext::attach(Callback<void(nsapi_event_t, intptr_t)> status_cb)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::set_blocking(bool blocking)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularContext::set_apn_credentials(const char *uname, const char *pwd,
 | 
			
		||||
            CellularContext::AuthenticationType type) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularContext::set_apn_credentials(const char* apn, const char *uname, const char *pwd,
 | 
			
		||||
            CellularContext::AuthenticationType type)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AT_CellularContext::stack_type_supported(nsapi_ip_stack_t stack_type)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_ip_stack_t AT_CellularContext::get_stack_type()
 | 
			
		||||
{
 | 
			
		||||
    return IPV4V6_STACK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_ip_stack_t AT_CellularContext::string_to_stack_type(const char *pdp_type)
 | 
			
		||||
{
 | 
			
		||||
    return IPV4V6_STACK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PDP Context handling
 | 
			
		||||
nsapi_error_t AT_CellularContext::delete_current_context()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::do_user_authentication()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AT_CellularContext::get_context()
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AT_CellularContext::set_new_context(int cid)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::do_activate_context()
 | 
			
		||||
{
 | 
			
		||||
   return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularContext::do_connect()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if NSAPI_PPP_AVAILABLE
 | 
			
		||||
nsapi_error_t AT_CellularContext::open_data_channel()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularContext::ppp_status_cb(nsapi_event_t ev, intptr_t ptr)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif //#if NSAPI_PPP_AVAILABLE
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::disconnect()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::get_apn_backoff_timer(int &backoff_timer)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::get_rate_control(
 | 
			
		||||
    CellularContext::RateControlExceptionReports &reports,
 | 
			
		||||
    CellularContext::RateControlUplinkTimeUnit &timeUnit, int &uplinkRate)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularContext::get_pdpcontext_params(pdpContextList_t ¶ms_list)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Called by CellularDevice for network and cellular device changes
 | 
			
		||||
void AT_CellularContext::cellular_callback(nsapi_event_t ev, intptr_t ptr)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularContext::call_network_cb(nsapi_connection_status_t status)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -33,49 +33,6 @@ AT_CellularNetwork::~AT_CellularNetwork()
 | 
			
		|||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::init()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
 | 
			
		||||
                                                  const char *username, const char *password)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
 | 
			
		||||
                                                  AuthenticationType type, const char *username, const char *password)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::connect(const char *apn,
 | 
			
		||||
                                          const char *username, const char *password)
 | 
			
		||||
{
 | 
			
		||||
    return connect();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::connect()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::activate_context()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::open_data_channel()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::disconnect()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularNetwork::attach(Callback<void(nsapi_event_t, intptr_t)> status_cb)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -85,16 +42,6 @@ nsapi_connection_status_t AT_CellularNetwork::get_connection_status() const
 | 
			
		|||
    return NSAPI_STATUS_LOCAL_UP;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::set_blocking(bool blocking)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_ip_stack_t AT_CellularNetwork::string_to_stack_type(const char *pdp_type)
 | 
			
		||||
{
 | 
			
		||||
    return IPV4_STACK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::set_registration_urc(RegistrationType type, bool urc_on)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +73,7 @@ AT_CellularNetwork::RegistrationMode AT_CellularNetwork::has_registration(Regist
 | 
			
		|||
    return RegistrationModeDisable;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::set_attach(int timeout)
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::set_attach()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -141,36 +88,6 @@ nsapi_error_t AT_CellularNetwork::detach()
 | 
			
		|||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::get_apn_backoff_timer(int &backoffTime)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
NetworkStack *AT_CellularNetwork::get_stack()
 | 
			
		||||
{
 | 
			
		||||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *AT_CellularNetwork::get_ip_address()
 | 
			
		||||
{
 | 
			
		||||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::set_stack_type(nsapi_ip_stack_t stack_type)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_ip_stack_t AT_CellularNetwork::get_stack_type()
 | 
			
		||||
{
 | 
			
		||||
    return IPV4_STACK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AT_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AT_CellularNetwork::urc_no_carrier()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -203,19 +120,6 @@ nsapi_error_t AT_CellularNetwork::get_ciot_optimization_config(Supported_UE_Opt
 | 
			
		|||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::get_rate_control(
 | 
			
		||||
    CellularNetwork::RateControlExceptionReports &reports,
 | 
			
		||||
    CellularNetwork::RateControlUplinkTimeUnit &timeUnit, int &uplinkRate)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::get_pdpcontext_params(pdpContextList_t ¶ms_list)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
| 
						 | 
				
			
			@ -241,10 +145,7 @@ nsapi_error_t AT_CellularNetwork::get_operator_names(operator_names_list &op_nam
 | 
			
		|||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t AT_CellularNetwork::do_user_authentication()
 | 
			
		||||
bool AT_CellularNetwork::is_active_context()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,13 +27,45 @@ MBED_WEAK CellularDevice *CellularDevice::get_default_instance()
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
CellularDevice::CellularDevice() : _network_ref_count(0), _sms_ref_count(0), _power_ref_count(0), _sim_ref_count(0),
 | 
			
		||||
    _info_ref_count(0)
 | 
			
		||||
        _info_ref_count(0), _fh(0), _error(0), _state_machine(0), _nw(0)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CellularDevice::~CellularDevice()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
events::EventQueue *CellularDevice::get_queue() const
 | 
			
		||||
{
 | 
			
		||||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CellularContext *CellularDevice::get_context_list() const
 | 
			
		||||
{
 | 
			
		||||
    return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t CellularDevice::set_device_ready()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t CellularDevice::set_sim_ready()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t CellularDevice::register_to_network()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t CellularDevice::attach_to_network()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,66 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 "CellularStateMachine.h"
 | 
			
		||||
#include "CellularDevice.h"
 | 
			
		||||
 | 
			
		||||
namespace mbed {
 | 
			
		||||
 | 
			
		||||
CellularStateMachine::CellularStateMachine(CellularDevice &device, events::EventQueue &queue) :
 | 
			
		||||
        _cellularDevice(device), _queue(queue)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CellularStateMachine::~CellularStateMachine()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CellularStateMachine::stop()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CellularStateMachine::set_sim_pin(const char *sim_pin)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CellularStateMachine::set_plmn(const char *plmn)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t CellularStateMachine::run_to_state(CellularStateMachine::CellularState state)
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool CellularStateMachine::get_current_status(CellularStateMachine::CellularState ¤t_state, CellularStateMachine::CellularState &target_state)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nsapi_error_t CellularStateMachine::start_dispatch()
 | 
			
		||||
{
 | 
			
		||||
    return NSAPI_ERROR_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CellularStateMachine::set_cellular_callback(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,80 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 "SerialBase.h"
 | 
			
		||||
 | 
			
		||||
namespace mbed {
 | 
			
		||||
 | 
			
		||||
SerialBase::SerialBase(PinName tx, PinName rx, int baud)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SerialBase::~SerialBase()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SerialBase::baud(int baudrate)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SerialBase::format(int bits, Parity parity, int stop_bits)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SerialBase::readable()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int SerialBase::writeable()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SerialBase::attach(Callback<void()> func, IrqType type)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SerialBase::_irq_handler(uint32_t id, SerialIrq irq_type)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SerialBase::_base_getc()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SerialBase::_base_putc(int c)
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SerialBase::send_break()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SerialBase::lock()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SerialBase:: unlock()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,127 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 "UARTSerial.h"
 | 
			
		||||
 | 
			
		||||
namespace mbed {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
UARTSerial::UARTSerial(PinName tx, PinName rx, int baud) : SerialBase(tx, rx, baud)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
UARTSerial::~UARTSerial()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ssize_t UARTSerial::read(void *buffer, size_t length)
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ssize_t UARTSerial::write(const void *buffer, size_t length)
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
off_t UARTSerial::seek(off_t offset, int whence)
 | 
			
		||||
{
 | 
			
		||||
    return -ESPIPE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int UARTSerial::close()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::dcd_irq()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::set_baud(int baud)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::set_data_carrier_detect(PinName dcd_pin, bool active_high)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::set_format(int bits, Parity parity, int stop_bits)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int UARTSerial::isatty()
 | 
			
		||||
{
 | 
			
		||||
    return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int UARTSerial::sync()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::sigio(Callback<void()> func)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ssize_t UARTSerial::write_unbuffered(const char *buf_ptr, size_t length)
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool UARTSerial::hup() const
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::wake()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
short UARTSerial::poll(short events) const
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::lock()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::unlock()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::api_lock(void)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::api_unlock(void)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::rx_irq(void)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::tx_irq(void)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UARTSerial::wait_ms(uint32_t millisec)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +25,14 @@
 | 
			
		|||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct gpio_irq_s {
 | 
			
		||||
    uint32_t ch;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct serial_s {
 | 
			
		||||
    int x;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#include "gpio_object.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,7 @@
 | 
			
		|||
#include "CellularLog.h"
 | 
			
		||||
#include "ATHandler.h"
 | 
			
		||||
#include "UARTSerial.h"
 | 
			
		||||
#include "FileHandle.h"
 | 
			
		||||
 | 
			
		||||
using namespace events;
 | 
			
		||||
using namespace mbed;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue