Skip to content

Commit 76fe726

Browse files
authored
Merge pull request #9637 from u-blox/C030_N211_Cellular_Driver
Cellular: UBLOX_C030_N211 Cellular API's
2 parents 4c7fc65 + f19a412 commit 76fe726

28 files changed

+940
-32
lines changed

features/cellular/TESTS/api/cellular_sms/main.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,21 @@ static void test_sms_initialize_text_mode()
110110
static void test_sms_initialize_pdu_mode()
111111
{
112112
nsapi_error_t err = sms->initialize(CellularSMS::CellularSMSMmodePDU);
113-
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
114-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
113+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
114+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
115115
}
116116

117117
static void test_set_cscs()
118118
{
119119
nsapi_error_t err = sms->set_cscs("IRA");
120-
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
121-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
120+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
121+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
122122
err = sms->set_cscs("UCS2");
123-
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
124-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
123+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
124+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
125125
err = sms->set_cscs("GSM");
126-
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
127-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
126+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
127+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
128128
}
129129

130130
static void test_set_csca()
@@ -143,8 +143,8 @@ static void test_set_csca()
143143
static void test_set_cpms_me()
144144
{
145145
nsapi_error_t err = sms->set_cpms("ME", "ME", "ME");
146-
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
147-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
146+
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
147+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
148148
}
149149

150150
#ifdef MBED_CONF_APP_CELLULAR_PHONE_NUMBER

features/cellular/framework/AT/AT_CellularBase.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ class AT_CellularBase {
4949
PROPERTY_AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
5050
PROPERTY_AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
5151
PROPERTY_AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
52+
PROPERTY_AT_CNMI, // 0 = not supported, 1 = supported. New message (SMS) indication AT command
53+
PROPERTY_AT_CSMP, // 0 = not supported, 1 = supported. Set text mode AT command
54+
PROPERTY_AT_CMGF, // 0 = not supported, 1 = supported. Set preferred message format AT command
55+
PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command
5256
PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4?
5357
PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6?
5458
PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6?

features/cellular/framework/AT/AT_CellularSMS.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ void AT_CellularSMS::cmti_urc()
210210

211211
nsapi_error_t AT_CellularSMS::set_cnmi()
212212
{
213+
if (!get_property(PROPERTY_AT_CNMI)) {
214+
return NSAPI_ERROR_UNSUPPORTED;
215+
}
213216
_at.lock();
214217
_at.cmd_start("AT+CNMI=2,1");
215218
_at.cmd_stop_read_resp();
@@ -218,6 +221,9 @@ nsapi_error_t AT_CellularSMS::set_cnmi()
218221

219222
nsapi_error_t AT_CellularSMS::set_cmgf(int msg_format)
220223
{
224+
if (!get_property(PROPERTY_AT_CMGF)) {
225+
return NSAPI_ERROR_UNSUPPORTED;
226+
}
221227
_at.lock();
222228
_at.cmd_start("AT+CMGF=");
223229
_at.write_int(msg_format);
@@ -227,6 +233,9 @@ nsapi_error_t AT_CellularSMS::set_cmgf(int msg_format)
227233

228234
nsapi_error_t AT_CellularSMS::set_csmp(int fo, int vp, int pid, int dcs)
229235
{
236+
if (!get_property(PROPERTY_AT_CSMP)) {
237+
return NSAPI_ERROR_UNSUPPORTED;
238+
}
230239
_at.lock();
231240
_at.cmd_start("AT+CSMP=");
232241
_at.write_int(fo);
@@ -239,6 +248,9 @@ nsapi_error_t AT_CellularSMS::set_csmp(int fo, int vp, int pid, int dcs)
239248

240249
nsapi_error_t AT_CellularSMS::set_csdh(int show_header)
241250
{
251+
if (!get_property(PROPERTY_AT_CSDH)) {
252+
return NSAPI_ERROR_UNSUPPORTED;
253+
}
242254
_at.lock();
243255
_at.cmd_start("AT+CSDH=");
244256
_at.write_int(show_header);

features/cellular/framework/AT/AT_CellularStack.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
132132
tr_info("Socket %d open", index);
133133
// create local socket structure, socket on modem is created when app calls sendto/recvfrom
134134
_socket[index] = new CellularSocket;
135-
CellularSocket *psock;
136-
psock = _socket[index];
137-
memset(psock, 0, sizeof(CellularSocket));
135+
CellularSocket *psock = _socket[index];
138136
SocketAddress addr(0, get_dynamic_ip_port());
139137
psock->id = index;
140138
psock->localAddress = addr;

features/cellular/framework/common/CellularTargets.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ namespace mbed {
3232
#elif TARGET_MTB_MTS_DRAGONFLY
3333
#define CELLULAR_DEVICE TELIT_HE910
3434
#elif TARGET_UBLOX_C030
35-
#if defined(TARGET_UBLOX_C030_N211) || defined(TARGET_UBLOX_C030_R41XM)
35+
#if defined(TARGET_UBLOX_C030_R41XM)
3636
#define CELLULAR_DEVICE UBLOX_AT
37+
#elif defined(TARGET_UBLOX_C030_N211)
38+
#define CELLULAR_DEVICE UBLOX_N2XX
3739
#else
3840
#define CELLULAR_DEVICE UBLOX_PPP
3941
#endif

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ void GEMALTO_CINTERION::init_module_bgs2()
9999
0, // AT_CGSN_WITH_TYPE
100100
1, // AT_CGDATA
101101
1, // AT_CGAUTH
102+
1, // AT_CNMI
103+
1, // AT_CSMP
104+
1, // AT_CMGF
105+
1, // AT_CSDH
102106
1, // PROPERTY_IPV4_STACK
103107
0, // PROPERTY_IPV6_STACK
104108
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
2828
1, // AT_CGSN_WITH_TYPE
2929
1, // AT_CGDATA
3030
1, // AT_CGAUTH
31+
1, // AT_CNMI
32+
1, // AT_CSMP
33+
1, // AT_CMGF
34+
1, // AT_CSDH
3135
1, // PROPERTY_IPV4_STACK
3236
1, // PROPERTY_IPV6_STACK
3337
1, // PROPERTY_IPV4V6_STACK

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
2828
0, // AT_CGSN_WITH_TYPE
2929
0, // AT_CGDATA
3030
1, // AT_CGAUTH
31+
1, // AT_CNMI
32+
1, // AT_CSMP
33+
1, // AT_CMGF
34+
1, // AT_CSDH
3135
1, // PROPERTY_IPV4_STACK
3236
0, // PROPERTY_IPV6_STACK
3337
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3535
1, // AT_CGSN_WITH_TYPE
3636
1, // AT_CGDATA
3737
0, // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9
38+
1, // AT_CNMI
39+
1, // AT_CSMP
40+
1, // AT_CMGF
41+
1, // AT_CSDH
3842
1, // PROPERTY_IPV4_STACK
3943
0, // PROPERTY_IPV6_STACK
4044
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3737
0, // AT_CGSN_WITH_TYPE
3838
0, // AT_CGDATA
3939
1, // AT_CGAUTH
40+
1, // AT_CNMI
41+
1, // AT_CSMP
42+
1, // AT_CMGF
43+
1, // AT_CSDH
4044
1, // PROPERTY_IPV4_STACK
4145
0, // PROPERTY_IPV6_STACK
4246
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3131
0, // AT_CGSN_WITH_TYPE
3232
1, // AT_CGDATA
3333
0, // AT_CGAUTH
34+
1, // AT_CNMI
35+
1, // AT_CSMP
36+
1, // AT_CMGF
37+
1, // AT_CSDH
3438
1, // PROPERTY_IPV4_STACK
3539
0, // PROPERTY_IPV6_STACK
3640
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
3434
1, // AT_CGSN_WITH_TYPE
3535
1, // AT_CGDATA
3636
1, // AT_CGAUTH
37+
1, // AT_CNMI
38+
1, // AT_CSMP
39+
1, // AT_CMGF
40+
1, // AT_CSDH
3741
1, // PROPERTY_IPV4_STACK
3842
0, // PROPERTY_IPV6_STACK
3943
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
2828
0, // AT_CGSN_WITH_TYPE
2929
1, // AT_CGDATA
3030
0, // AT_CGAUTH
31+
1, // AT_CNMI
32+
1, // AT_CSMP
33+
1, // AT_CMGF
34+
1, // AT_CSDH
3135
1, // PROPERTY_IPV4_STACK
3236
0, // PROPERTY_IPV6_STACK
3337
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
2929
AT_CellularNetwork::RegistrationModeLAC, // C_REG
3030
0, // AT_CGSN_WITH_TYPE
3131
1, // AT_CGDATA
32-
1, // AT_CGAUTH,
32+
1, // AT_CGAUTH
33+
1, // AT_CNMI
34+
1, // AT_CSMP
35+
1, // AT_CMGF
36+
1, // AT_CSDH
3337
1, // PROPERTY_IPV4_STACK
3438
0, // PROPERTY_IPV6_STACK
3539
0, // PROPERTY_IPV4V6_STACK
@@ -42,6 +46,10 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
4246
1, // AT_CGSN_WITH_TYPE
4347
1, // AT_CGDATA
4448
1, // AT_CGAUTH
49+
1, // AT_CNMI
50+
1, // AT_CSMP
51+
1, // AT_CMGF
52+
1, // AT_CSDH
4553
1, // PROPERTY_IPV4_STACK
4654
0, // PROPERTY_IPV6_STACK
4755
0, // PROPERTY_IPV4V6_STACK

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
296296
_at.read_string(ipAddress, sizeof(ipAddress));
297297
port = _at.read_int();
298298
usorf_sz = _at.read_int();
299+
if (usorf_sz > size) {
300+
usorf_sz = size;
301+
}
302+
_at.read_bytes(&ch, 1);
303+
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
304+
_at.resp_stop();
299305

300306
// Must use what +USORF returns here as it may be less or more than we asked for
301307
if (usorf_sz > socket->pending_bytes) {
@@ -304,13 +310,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
304310
socket->pending_bytes -= usorf_sz;
305311
}
306312

307-
if (usorf_sz > size) {
308-
usorf_sz = size;
309-
}
310-
_at.read_bytes(&ch, 1);
311-
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
312-
_at.resp_stop();
313-
314313
if (usorf_sz > 0) {
315314
count += usorf_sz;
316315
size -= usorf_sz;
@@ -345,6 +344,12 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
345344
_at.resp_start("+USORD:");
346345
_at.skip_param(); // receiving socket id
347346
usorf_sz = _at.read_int();
347+
if (usorf_sz > size) {
348+
usorf_sz = size;
349+
}
350+
_at.read_bytes(&ch, 1);
351+
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
352+
_at.resp_stop();
348353

349354
// Must use what +USORD returns here as it may be less or more than we asked for
350355
if (usorf_sz > socket->pending_bytes) {
@@ -353,13 +358,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
353358
socket->pending_bytes -= usorf_sz;
354359
}
355360

356-
if (usorf_sz > size) {
357-
usorf_sz = size;
358-
}
359-
_at.read_bytes(&ch, 1);
360-
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
361-
_at.resp_stop();
362-
363361
if (usorf_sz > 0) {
364362
count += usorf_sz;
365363
size -= usorf_sz;

0 commit comments

Comments
 (0)