Skip to content

Commit f9eef97

Browse files
author
Ari Parkkila
committed
Cellular Refactor get_send_delay() into CellularProperty
1 parent ceea992 commit f9eef97

File tree

24 files changed

+34
-58
lines changed

24 files changed

+34
-58
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,6 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_set_power_save_mode)
257257
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == dev.set_power_save_mode(0));
258258
}
259259

260-
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_send_delay)
261-
{
262-
FileHandle_stub fh1;
263-
AT_CellularDevice dev(&fh1);
264-
EXPECT_TRUE(0 == dev.get_send_delay());
265-
}
266-
267260
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_create_delete_context)
268261
{
269262
FileHandle_stub fh1;

UNITTESTS/features/cellular/framework/AT/at_cellularstack/at_cellularstacktest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,12 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
197197

198198
MyStack st(at, 0, IPV6_STACK, *_dev);
199199
AT_CellularDevice_stub::supported_bool = 0;
200+
AT_CellularDevice_stub::max_sock_value = 1;
200201
EXPECT_EQ(st.socket_open(NULL, NSAPI_TCP), NSAPI_ERROR_UNSUPPORTED);
201202

202203
AT_CellularDevice_stub::supported_bool = 1;
203-
AT_CellularDevice_stub::max_sock_value = 0;
204204
nsapi_socket_t sock = &st.socket;
205+
AT_CellularDevice_stub::max_sock_value = 0;
205206
EXPECT_EQ(st.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_NO_SOCKET);
206207

207208
MyStack st2(at, 0, IPV6_STACK, *_dev);
@@ -210,7 +211,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
210211
sock = &st2.socket;
211212
EXPECT_EQ(st2.socket_open(&sock, NSAPI_TCP), NSAPI_ERROR_OK);
212213

213-
AT_CellularDevice_stub::max_sock_value = 0;
214+
AT_CellularDevice_stub::max_sock_value = 1; // value must be the same as before the first open
214215
}
215216

216217
TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)

UNITTESTS/stubs/AT_CellularDevice_stub.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ AT_CellularDevice::~AT_CellularDevice()
4949

5050
ATHandler *AT_CellularDevice::get_at_handler(FileHandle *fileHandle)
5151
{
52-
return ATHandler::get_instance(fileHandle, _queue, _default_timeout, "\r", get_send_delay(), _modem_debug_on);
52+
return ATHandler::get_instance(fileHandle, _queue, _default_timeout, "\r", get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY), _modem_debug_on);
5353
}
5454

5555
ATHandler *AT_CellularDevice::get_at_handler()
@@ -88,7 +88,7 @@ CellularNetwork *AT_CellularDevice::open_network(FileHandle *fh)
8888
_queue,
8989
_default_timeout,
9090
"\r",
91-
get_send_delay(),
91+
get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY),
9292
_modem_debug_on), *this);
9393
return _network;
9494
}
@@ -164,11 +164,6 @@ void AT_CellularDevice::set_timeout(int timeout)
164164
_default_timeout = timeout;
165165
}
166166

167-
uint16_t AT_CellularDevice::get_send_delay() const
168-
{
169-
return 0;
170-
}
171-
172167
void AT_CellularDevice::modem_debug_on(bool on)
173168
{
174169
_modem_debug_on = on;

UNITTESTS/target_h/myCellularDevice.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ class myCellularDevice : public AT_CellularDevice {
115115

116116
virtual void set_timeout(int timeout) {}
117117

118-
virtual uint16_t get_send_delay() const
119-
{
120-
return 0;
121-
}
122-
123118
virtual void modem_debug_on(bool on) {}
124119

125120
virtual nsapi_error_t init()

features/cellular/framework/AT/AT_CellularDevice.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void AT_CellularDevice::setup_at_handler()
107107
{
108108
set_at_urcs();
109109

110-
_at->set_send_delay(get_send_delay());
110+
_at->set_send_delay(get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY));
111111
}
112112

113113
void AT_CellularDevice::urc_nw_deact()
@@ -188,7 +188,7 @@ ATHandler *AT_CellularDevice::get_at_handler(FileHandle *fileHandle)
188188
}
189189

190190
return ATHandler::get_instance(fileHandle, _queue, _default_timeout,
191-
"\r", get_send_delay(), _modem_debug_on);
191+
"\r", get_property(AT_CellularDevice::PROPERTY_AT_SEND_DELAY), _modem_debug_on);
192192
}
193193

194194
ATHandler *AT_CellularDevice::get_at_handler()
@@ -445,11 +445,6 @@ void AT_CellularDevice::set_timeout(int timeout)
445445
}
446446
}
447447

448-
uint16_t AT_CellularDevice::get_send_delay() const
449-
{
450-
return 0;
451-
}
452-
453448
void AT_CellularDevice::modem_debug_on(bool on)
454449
{
455450
_modem_debug_on = on;

features/cellular/framework/AT/AT_CellularDevice.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class AT_CellularDevice : public CellularDevice {
6161
PROPERTY_SOCKET_COUNT, // The number of sockets of modem IP stack
6262
PROPERTY_IP_TCP, // 0 = not supported, 1 = supported. Modem IP stack has support for TCP
6363
PROPERTY_IP_UDP, // 0 = not supported, 1 = supported. Modem IP stack has support for TCP
64+
PROPERTY_AT_SEND_DELAY, // Sending delay between AT commands in ms
6465
PROPERTY_MAX
6566
};
6667

@@ -100,8 +101,6 @@ class AT_CellularDevice : public CellularDevice {
100101

101102
virtual void set_timeout(int timeout);
102103

103-
virtual uint16_t get_send_delay() const;
104-
105104
virtual void modem_debug_on(bool on);
106105

107106
virtual nsapi_error_t init();

features/cellular/framework/AT/AT_CellularStack.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ AT_CellularStack::~AT_CellularStack()
4747

4848
int AT_CellularStack::find_socket_index(nsapi_socket_t handle)
4949
{
50+
if (!_socket) {
51+
return -1;
52+
}
5053
for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
5154
if (_socket[i] == handle) {
5255
return i;
@@ -177,6 +180,7 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
177180

178181
if (!_socket) {
179182
if (_device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT) == 0) {
183+
_socket_mutex.unlock();
180184
return NSAPI_ERROR_NO_SOCKET;
181185
}
182186
if (socket_stack_init() != NSAPI_ERROR_OK) {

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
using namespace mbed;
2525
using namespace events;
2626

27-
const uint16_t RESPONSE_TO_SEND_DELAY = 100; // response-to-send delay in milliseconds at bit-rate over 9600
28-
2927
GEMALTO_CINTERION::Module GEMALTO_CINTERION::_module;
3028

3129
GEMALTO_CINTERION::GEMALTO_CINTERION(FileHandle *fh) : AT_CellularDevice(fh)
@@ -83,11 +81,6 @@ nsapi_error_t GEMALTO_CINTERION::init()
8381
return NSAPI_ERROR_OK;
8482
}
8583

86-
uint16_t GEMALTO_CINTERION::get_send_delay() const
87-
{
88-
return RESPONSE_TO_SEND_DELAY;
89-
}
90-
9184
GEMALTO_CINTERION::Module GEMALTO_CINTERION::get_module()
9285
{
9386
return _module;
@@ -116,6 +109,7 @@ void GEMALTO_CINTERION::init_module_bgs2()
116109
10, // PROPERTY_SOCKET_COUNT
117110
1, // PROPERTY_IP_TCP
118111
1, // PROPERTY_IP_UDP
112+
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
119113
};
120114
set_cellular_properties(cellular_properties);
121115
_module = ModuleBGS2;
@@ -144,6 +138,7 @@ void GEMALTO_CINTERION::init_module_els61()
144138
10, // PROPERTY_SOCKET_COUNT
145139
1, // PROPERTY_IP_TCP
146140
1, // PROPERTY_IP_UDP
141+
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
147142
};
148143
set_cellular_properties(cellular_properties);
149144
_module = ModuleELS61;
@@ -172,6 +167,7 @@ void GEMALTO_CINTERION::init_module_ems31()
172167
10, // PROPERTY_SOCKET_COUNT
173168
1, // PROPERTY_IP_TCP
174169
1, // PROPERTY_IP_UDP
170+
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
175171
};
176172
set_cellular_properties(cellular_properties);
177173
_module = ModuleEMS31;
@@ -200,6 +196,7 @@ void GEMALTO_CINTERION::init_module_ehs5e()
200196
10, // PROPERTY_SOCKET_COUNT
201197
1, // PROPERTY_IP_TCP
202198
1, // PROPERTY_IP_UDP
199+
100,// PROPERTY_AT_SEND_DELAY, if baud is below 9600 this must be longer
203200
};
204201
set_cellular_properties(cellular_properties);
205202
_module = ModuleEHS5E;

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class GEMALTO_CINTERION : public AT_CellularDevice {
5252
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
5353

5454
protected:
55-
virtual uint16_t get_send_delay() const;
5655
virtual nsapi_error_t init();
5756

5857
private:

features/cellular/framework/targets/GENERIC/GENERIC_AT3GPP/GENERIC_AT3GPP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4141
0, // PROPERTY_SOCKET_COUNT
4242
0, // PROPERTY_IP_TCP
4343
0, // PROPERTY_IP_UDP
44+
0, // PROPERTY_AT_SEND_DELAY
4445
};
4546

4647
GENERIC_AT3GPP::GENERIC_AT3GPP(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4141
0, // PROPERTY_SOCKET_COUNT
4242
0, // PROPERTY_IP_TCP
4343
0, // PROPERTY_IP_UDP
44+
0, // PROPERTY_AT_SEND_DELAY
4445
};
4546

4647
SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4848
7, // PROPERTY_SOCKET_COUNT
4949
1, // PROPERTY_IP_TCP
5050
1, // PROPERTY_IP_UDP
51+
0, // PROPERTY_AT_SEND_DELAY
5152
};
5253

5354
QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
6262
1, // PROPERTY_NON_IP_PDP_TYPE
6363
1, // PROPERTY_AT_CGEREP,
6464
1, // PROPERTY_AT_COPS_FALLBACK_AUTO
65-
12, // PROPERTY_SOCKET_COUNT
65+
12, // PROPERTY_SOCKET_COUNT
6666
1, // PROPERTY_IP_TCP
6767
1, // PROPERTY_IP_UDP
68+
0, // PROPERTY_AT_SEND_DELAY
6869
};
6970

7071
QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh, PinName pwr, bool active_high, PinName rst)

features/cellular/framework/targets/QUECTEL/EC2X/QUECTEL_EC2X.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
6666
0, // PROPERTY_SOCKET_COUNT
6767
0, // PROPERTY_IP_TCP
6868
0, // PROPERTY_IP_UDP
69+
0, // PROPERTY_AT_SEND_DELAY
6970
};
7071

7172
QUECTEL_EC2X::QUECTEL_EC2X(FileHandle *fh, PinName pwr, bool active_high, PinName rst)

features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4444
6, // PROPERTY_SOCKET_COUNT
4545
1, // PROPERTY_IP_TCP
4646
1, // PROPERTY_IP_UDP
47+
0, // PROPERTY_AT_SEND_DELAY
4748
};
4849

4950
QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4646
0, // PROPERTY_SOCKET_COUNT
4747
0, // PROPERTY_IP_TCP
4848
0, // PROPERTY_IP_UDP
49+
0, // PROPERTY_AT_SEND_DELAY
4950
};
5051

5152
QUECTEL_UG96::QUECTEL_UG96(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/RiotMicro/AT/RM1000_AT.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4848
7, // PROPERTY_SOCKET_COUNT
4949
1, // PROPERTY_IP_TCP
5050
1, // PROPERTY_IP_UDP
51+
0, // PROPERTY_AT_SEND_DELAY
5152
};
5253

5354
RM1000_AT::RM1000_AT(FileHandle *fh) : AT_CellularDevice(fh)

features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,14 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4141
0, // PROPERTY_SOCKET_COUNT
4242
0, // PROPERTY_IP_TCP
4343
0, // PROPERTY_IP_UDP
44+
20, // PROPERTY_AT_SEND_DELAY
4445
};
4546

4647
TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
4748
{
4849
set_cellular_properties(cellular_properties);
4950
}
5051

51-
uint16_t TELIT_HE910::get_send_delay() const
52-
{
53-
return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
54-
}
55-
5652
nsapi_error_t TELIT_HE910::init()
5753
{
5854
nsapi_error_t err = AT_CellularDevice::init();

features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,13 @@
2929

3030
#include "AT_CellularDevice.h"
3131

32-
//the delay between sending AT commands
33-
#define DEFAULT_DELAY_BETWEEN_AT_COMMANDS 20
34-
3532
namespace mbed {
3633

3734
class TELIT_HE910 : public AT_CellularDevice {
3835
public:
3936
TELIT_HE910(FileHandle *fh);
4037

4138
protected: // AT_CellularDevice
42-
virtual uint16_t get_send_delay() const;
4339
virtual nsapi_error_t init();
4440
};
4541
} // namespace mbed

features/cellular/framework/targets/TELIT/ME910/TELIT_ME910.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
6262
0, // PROPERTY_SOCKET_COUNT
6363
0, // PROPERTY_IP_TCP
6464
0, // PROPERTY_IP_UDP
65+
20, // PROPERTY_AT_SEND_DELAY
6566
};
6667

67-
//the delay between sending AT commands
68-
static const uint16_t DEFAULT_DELAY_BETWEEN_AT_COMMANDS = 20;
69-
7068
TELIT_ME910::TELIT_ME910(FileHandle *fh, PinName pwr, bool active_high)
7169
: AT_CellularDevice(fh),
7270
_active_high(active_high),
@@ -80,12 +78,6 @@ AT_CellularContext *TELIT_ME910::create_context_impl(ATHandler &at, const char *
8078
return new TELIT_ME910_CellularContext(at, this, apn, cp_req, nonip_req);
8179
}
8280

83-
84-
uint16_t TELIT_ME910::get_send_delay() const
85-
{
86-
return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
87-
}
88-
8981
nsapi_error_t TELIT_ME910::init()
9082
{
9183
nsapi_error_t err = AT_CellularDevice::init();

features/cellular/framework/targets/TELIT/ME910/TELIT_ME910.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class TELIT_ME910 : public AT_CellularDevice {
4141
TELIT_ME910(FileHandle *fh, PinName pwr, bool active_high);
4242

4343
protected: // AT_CellularDevice
44-
virtual uint16_t get_send_delay() const;
4544
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
4645
virtual nsapi_error_t init();
4746
virtual nsapi_error_t hard_power_on();

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4141
7, // PROPERTY_SOCKET_COUNT
4242
1, // PROPERTY_IP_TCP
4343
1, // PROPERTY_IP_UDP
44+
0, // PROPERTY_AT_SEND_DELAY
4445
};
4546
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
4647
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
@@ -67,6 +68,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
6768
7, // PROPERTY_SOCKET_COUNT
6869
1, // PROPERTY_IP_TCP
6970
1, // PROPERTY_IP_UDP
71+
0, // PROPERTY_AT_SEND_DELAY
7072
};
7173
#else
7274
static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
@@ -89,6 +91,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
8991
0, // PROPERTY_SOCKET_COUNT
9092
0, // PROPERTY_IP_TCP
9193
0, // PROPERTY_IP_UDP
94+
0, // PROPERTY_AT_SEND_DELAY
9295
};
9396
#endif
9497

features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
4040
7, // PROPERTY_SOCKET_COUNT
4141
0, // PROPERTY_IP_TCP
4242
1, // PROPERTY_IP_UDP
43+
0, // PROPERTY_AT_SEND_DELAY
4344
};
4445

4546
UBLOX_N2XX::UBLOX_N2XX(FileHandle *fh): AT_CellularDevice(fh)

0 commit comments

Comments
 (0)