Skip to content

Commit

Permalink
Cellular Refactor get_send_delay() into CellularProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
Ari Parkkila committed Jan 16, 2020
1 parent ceea992 commit b0e0487
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 56 deletions.
Expand Up @@ -257,13 +257,6 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_set_power_save_mode)
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == dev.set_power_save_mode(0));
}

TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_send_delay)
{
FileHandle_stub fh1;
AT_CellularDevice dev(&fh1);
EXPECT_TRUE(0 == dev.get_send_delay());
}

TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_create_delete_context)
{
FileHandle_stub fh1;
Expand Down
9 changes: 2 additions & 7 deletions UNITTESTS/stubs/AT_CellularDevice_stub.cpp
Expand Up @@ -49,7 +49,7 @@ AT_CellularDevice::~AT_CellularDevice()

ATHandler *AT_CellularDevice::get_at_handler(FileHandle *fileHandle)
{
return ATHandler::get_instance(fileHandle, _queue, _default_timeout, "\r", get_send_delay(), _modem_debug_on);
return ATHandler::get_instance(fileHandle, _queue, _default_timeout, "\r", get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY), _modem_debug_on);
}

ATHandler *AT_CellularDevice::get_at_handler()
Expand Down Expand Up @@ -88,7 +88,7 @@ CellularNetwork *AT_CellularDevice::open_network(FileHandle *fh)
_queue,
_default_timeout,
"\r",
get_send_delay(),
get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY),
_modem_debug_on), *this);
return _network;
}
Expand Down Expand Up @@ -164,11 +164,6 @@ void AT_CellularDevice::set_timeout(int timeout)
_default_timeout = timeout;
}

uint16_t AT_CellularDevice::get_send_delay() const
{
return 0;
}

void AT_CellularDevice::modem_debug_on(bool on)
{
_modem_debug_on = on;
Expand Down
5 changes: 0 additions & 5 deletions UNITTESTS/target_h/myCellularDevice.h
Expand Up @@ -115,11 +115,6 @@ class myCellularDevice : public AT_CellularDevice {

virtual void set_timeout(int timeout) {}

virtual uint16_t get_send_delay() const
{
return 0;
}

virtual void modem_debug_on(bool on) {}

virtual nsapi_error_t init()
Expand Down
9 changes: 2 additions & 7 deletions features/cellular/framework/AT/AT_CellularDevice.cpp
Expand Up @@ -107,7 +107,7 @@ void AT_CellularDevice::setup_at_handler()
{
set_at_urcs();

_at->set_send_delay(get_send_delay());
_at->set_send_delay(get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY));
}

void AT_CellularDevice::urc_nw_deact()
Expand Down Expand Up @@ -188,7 +188,7 @@ ATHandler *AT_CellularDevice::get_at_handler(FileHandle *fileHandle)
}

return ATHandler::get_instance(fileHandle, _queue, _default_timeout,
"\r", get_send_delay(), _modem_debug_on);
"\r", get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY), _modem_debug_on);
}

ATHandler *AT_CellularDevice::get_at_handler()
Expand Down Expand Up @@ -445,11 +445,6 @@ void AT_CellularDevice::set_timeout(int timeout)
}
}

uint16_t AT_CellularDevice::get_send_delay() const
{
return 0;
}

void AT_CellularDevice::modem_debug_on(bool on)
{
_modem_debug_on = on;
Expand Down
3 changes: 1 addition & 2 deletions features/cellular/framework/AT/AT_CellularDevice.h
Expand Up @@ -61,6 +61,7 @@ class AT_CellularDevice : public CellularDevice {
PROPERTY_SOCKET_COUNT, // The number of sockets of modem IP stack
PROPERTY_IP_TCP, // 0 = not supported, 1 = supported. Modem IP stack has support for TCP
PROPERTY_IP_UDP, // 0 = not supported, 1 = supported. Modem IP stack has support for TCP
PROPERTY_AT_SEND_DELAY, // Sending delay between AT commands in ms
PROPERTY_MAX
};

Expand Down Expand Up @@ -100,8 +101,6 @@ class AT_CellularDevice : public CellularDevice {

virtual void set_timeout(int timeout);

virtual uint16_t get_send_delay() const;

virtual void modem_debug_on(bool on);

virtual nsapi_error_t init();
Expand Down
Expand Up @@ -24,8 +24,6 @@
using namespace mbed;
using namespace events;

const uint16_t RESPONSE_TO_SEND_DELAY = 100; // response-to-send delay in milliseconds at bit-rate over 9600

GEMALTO_CINTERION::Module GEMALTO_CINTERION::_module;

GEMALTO_CINTERION::GEMALTO_CINTERION(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down Expand Up @@ -83,11 +81,6 @@ nsapi_error_t GEMALTO_CINTERION::init()
return NSAPI_ERROR_OK;
}

uint16_t GEMALTO_CINTERION::get_send_delay() const
{
return RESPONSE_TO_SEND_DELAY;
}

GEMALTO_CINTERION::Module GEMALTO_CINTERION::get_module()
{
return _module;
Expand Down Expand Up @@ -116,6 +109,7 @@ void GEMALTO_CINTERION::init_module_bgs2()
10, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
};
set_cellular_properties(cellular_properties);
_module = ModuleBGS2;
Expand Down Expand Up @@ -144,6 +138,7 @@ void GEMALTO_CINTERION::init_module_els61()
10, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
};
set_cellular_properties(cellular_properties);
_module = ModuleELS61;
Expand Down Expand Up @@ -172,6 +167,7 @@ void GEMALTO_CINTERION::init_module_ems31()
10, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
};
set_cellular_properties(cellular_properties);
_module = ModuleEMS31;
Expand Down Expand Up @@ -200,6 +196,7 @@ void GEMALTO_CINTERION::init_module_ehs5e()
10, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
};
set_cellular_properties(cellular_properties);
_module = ModuleEHS5E;
Expand Down
Expand Up @@ -52,7 +52,6 @@ class GEMALTO_CINTERION : public AT_CellularDevice {
virtual AT_CellularInformation *open_information_impl(ATHandler &at);

protected:
virtual uint16_t get_send_delay() const;
virtual nsapi_error_t init();

private:
Expand Down
Expand Up @@ -41,6 +41,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Expand Up @@ -41,6 +41,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Expand Up @@ -48,6 +48,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
7, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Expand Up @@ -62,9 +62,10 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
1, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP,
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
12, // PROPERTY_SOCKET_COUNT
12, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh, PinName pwr, bool active_high, PinName rst)
Expand Down
Expand Up @@ -66,6 +66,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

QUECTEL_EC2X::QUECTEL_EC2X(FileHandle *fh, PinName pwr, bool active_high, PinName rst)
Expand Down
Expand Up @@ -44,6 +44,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
6, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Expand Up @@ -46,6 +46,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Expand Up @@ -48,6 +48,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
7, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

RM1000_AT::RM1000_AT(FileHandle *fh) : AT_CellularDevice(fh)
Expand Down
Expand Up @@ -41,18 +41,14 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
20, // PROPERTY_AT_SEND_DELAY
};

TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
{
set_cellular_properties(cellular_properties);
}

uint16_t TELIT_HE910::get_send_delay() const
{
return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
}

nsapi_error_t TELIT_HE910::init()
{
nsapi_error_t err = AT_CellularDevice::init();
Expand Down
4 changes: 0 additions & 4 deletions features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.h
Expand Up @@ -29,17 +29,13 @@

#include "AT_CellularDevice.h"

//the delay between sending AT commands
#define DEFAULT_DELAY_BETWEEN_AT_COMMANDS 20

namespace mbed {

class TELIT_HE910 : public AT_CellularDevice {
public:
TELIT_HE910(FileHandle *fh);

protected: // AT_CellularDevice
virtual uint16_t get_send_delay() const;
virtual nsapi_error_t init();
};
} // namespace mbed
Expand Down
10 changes: 1 addition & 9 deletions features/cellular/framework/targets/TELIT/ME910/TELIT_ME910.cpp
Expand Up @@ -62,11 +62,9 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
20, // PROPERTY_AT_SEND_DELAY
};

//the delay between sending AT commands
static const uint16_t DEFAULT_DELAY_BETWEEN_AT_COMMANDS = 20;

TELIT_ME910::TELIT_ME910(FileHandle *fh, PinName pwr, bool active_high)
: AT_CellularDevice(fh),
_active_high(active_high),
Expand All @@ -80,12 +78,6 @@ AT_CellularContext *TELIT_ME910::create_context_impl(ATHandler &at, const char *
return new TELIT_ME910_CellularContext(at, this, apn, cp_req, nonip_req);
}


uint16_t TELIT_ME910::get_send_delay() const
{
return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
}

nsapi_error_t TELIT_ME910::init()
{
nsapi_error_t err = AT_CellularDevice::init();
Expand Down
Expand Up @@ -41,7 +41,6 @@ class TELIT_ME910 : public AT_CellularDevice {
TELIT_ME910(FileHandle *fh, PinName pwr, bool active_high);

protected: // AT_CellularDevice
virtual uint16_t get_send_delay() const;
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
virtual nsapi_error_t init();
virtual nsapi_error_t hard_power_on();
Expand Down
3 changes: 3 additions & 0 deletions features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp
Expand Up @@ -41,6 +41,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
7, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
Expand All @@ -67,6 +68,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
7, // PROPERTY_SOCKET_COUNT
1, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};
#else
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
Expand All @@ -89,6 +91,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};
#endif

Expand Down
Expand Up @@ -40,6 +40,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
7, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
1, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};

UBLOX_N2XX::UBLOX_N2XX(FileHandle *fh): AT_CellularDevice(fh)
Expand Down
3 changes: 3 additions & 0 deletions features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp
Expand Up @@ -42,6 +42,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
Expand All @@ -68,6 +69,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};
#else
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
Expand All @@ -90,6 +92,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
0, // PROPERTY_SOCKET_COUNT
0, // PROPERTY_IP_TCP
0, // PROPERTY_IP_UDP
0, // PROPERTY_AT_SEND_DELAY
};
#endif

Expand Down

0 comments on commit b0e0487

Please sign in to comment.