mirror of https://github.com/ARMmbed/mbed-os.git
Cellular Refactor get_send_delay() into CellularProperty
parent
ceea992b40
commit
f9eef97ead
|
@ -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;
|
||||
|
|
|
@ -197,11 +197,12 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
|
|||
|
||||
MyStack st(at, 0, IPV6_STACK, *_dev);
|
||||
AT_CellularDevice_stub::supported_bool = 0;
|
||||
AT_CellularDevice_stub::max_sock_value = 1;
|
||||
EXPECT_EQ(st.socket_open(NULL, NSAPI_TCP), NSAPI_ERROR_UNSUPPORTED);
|
||||
|
||||
AT_CellularDevice_stub::supported_bool = 1;
|
||||
AT_CellularDevice_stub::max_sock_value = 0;
|
||||
nsapi_socket_t sock = &st.socket;
|
||||
AT_CellularDevice_stub::max_sock_value = 0;
|
||||
EXPECT_EQ(st.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_NO_SOCKET);
|
||||
|
||||
MyStack st2(at, 0, IPV6_STACK, *_dev);
|
||||
|
@ -210,7 +211,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
|
|||
sock = &st2.socket;
|
||||
EXPECT_EQ(st2.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_OK);
|
||||
|
||||
AT_CellularDevice_stub::max_sock_value = 0;
|
||||
AT_CellularDevice_stub::max_sock_value = 1; // value must be the same as before the first open
|
||||
}
|
||||
|
||||
TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)
|
||||
|
|
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -115,11 +115,6 @@ public:
|
|||
|
||||
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()
|
||||
|
|
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
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
|
||||
};
|
||||
|
||||
|
@ -100,8 +101,6 @@ public:
|
|||
|
||||
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();
|
||||
|
|
|
@ -47,6 +47,9 @@ AT_CellularStack::~AT_CellularStack()
|
|||
|
||||
int AT_CellularStack::find_socket_index(nsapi_socket_t handle)
|
||||
{
|
||||
if (!_socket) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
|
||||
if (_socket[i] == handle) {
|
||||
return i;
|
||||
|
@ -177,6 +180,7 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
|
|||
|
||||
if (!_socket) {
|
||||
if (_device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT) == 0) {
|
||||
_socket_mutex.unlock();
|
||||
return NSAPI_ERROR_NO_SOCKET;
|
||||
}
|
||||
if (socket_stack_init() != NSAPI_ERROR_OK) {
|
||||
|
|
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
|
|
@ -52,7 +52,6 @@ protected: // AT_CellularDevice
|
|||
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
|
||||
|
||||
protected:
|
||||
virtual uint16_t get_send_delay() const;
|
||||
virtual nsapi_error_t init();
|
||||
|
||||
private:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -65,6 +65,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
|
|||
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
20, // PROPERTY_AT_SEND_DELAY
|
||||
};
|
||||
|
||||
TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
|
||||
|
@ -48,11 +49,6 @@ 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();
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
|
||||
#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 {
|
||||
|
@ -39,7 +36,6 @@ public:
|
|||
TELIT_HE910(FileHandle *fh);
|
||||
|
||||
protected: // AT_CellularDevice
|
||||
virtual uint16_t get_send_delay() const;
|
||||
virtual nsapi_error_t init();
|
||||
};
|
||||
} // namespace mbed
|
||||
|
|
|
@ -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),
|
||||
|
@ -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();
|
||||
|
|
|
@ -41,7 +41,6 @@ public:
|
|||
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();
|
||||
|
|
|
@ -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] = {
|
||||
|
@ -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] = {
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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] = {
|
||||
|
@ -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] = {
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue