Skip to content

Commit 2f5706b

Browse files
author
Wajahat Abbas
committed
remove target dependency in ublox cellular APIs
1 parent 28a0e3c commit 2f5706b

File tree

7 files changed

+52
-36
lines changed

7 files changed

+52
-36
lines changed

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,36 @@
2020
using namespace mbed;
2121
using namespace events;
2222

23-
#ifdef TARGET_UBLOX_C030_R41XM
23+
#ifdef UBX_MDM_SARA_R41XM
2424
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
2525
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
2626
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
2727
AT_CellularNetwork::RegistrationModeLAC, // C_REG
2828
0, // AT_CGSN_WITH_TYPE
29-
1, // AT_CGDATA
30-
1, // AT_CGAUTH
29+
0, // AT_CGDATA
30+
0, // AT_CGAUTH
3131
1, // AT_CNMI
3232
1, // AT_CSMP
3333
1, // AT_CMGF
34-
1, // AT_CSDH
34+
0, // AT_CSDH
3535
1, // PROPERTY_IPV4_STACK
3636
0, // PROPERTY_IPV6_STACK
3737
0, // PROPERTY_IPV4V6_STACK
3838
0, // PROPERTY_NON_IP_PDP_TYPE
3939
1, // PROPERTY_AT_CGEREP
4040
};
41-
#else
41+
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
4242
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
4343
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
4444
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
4545
AT_CellularNetwork::RegistrationModeLAC, // C_REG
46+
#ifdef UBX_MDM_SARA_G3XX
47+
0, // AT_CGSN_WITH_TYPE
48+
#else
4649
1, // AT_CGSN_WITH_TYPE
50+
#endif
4751
1, // AT_CGDATA
48-
1, // AT_CGAUTH
52+
0, // AT_CGAUTH
4953
1, // AT_CNMI
5054
1, // AT_CSMP
5155
1, // AT_CMGF
@@ -56,6 +60,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
5660
0, // PROPERTY_NON_IP_PDP_TYPE
5761
1, // PROPERTY_AT_CGEREP
5862
};
63+
#else
64+
#error This modem is currently not supported.
5965
#endif
6066

6167
UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh)
@@ -98,7 +104,7 @@ nsapi_error_t UBLOX_AT::init()
98104

99105
nsapi_error_t err = NSAPI_ERROR_OK;
100106

101-
#ifdef TARGET_UBLOX_C027
107+
#ifdef UBX_MDM_SARA_G3XX
102108
err = _at->at_cmd_discard("+CFUN", "=0");
103109

104110
if (err == NSAPI_ERROR_OK) {
@@ -107,14 +113,16 @@ nsapi_error_t UBLOX_AT::init()
107113
config_authentication_parameters();
108114
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
109115
}
110-
#else
116+
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_R41XM)
111117
err = _at->at_cmd_discard("+CFUN", "=4");
112118
if (err == NSAPI_ERROR_OK) {
113119
_at->at_cmd_discard("E0", ""); // echo off
114120
_at->at_cmd_discard("+CMEE", "=1"); // verbose responses
115121
config_authentication_parameters();
116122
err = _at->at_cmd_discard("+CFUN", "=1"); // set full functionality
117123
}
124+
#else
125+
#error This modem is currently not supported.
118126
#endif
119127

120128
return _at->unlock_return_error();
@@ -155,7 +163,7 @@ nsapi_error_t UBLOX_AT::set_authentication_parameters(const char *apn,
155163
nsapi_error_t err = _at->at_cmd_discard("+CGDCONT", "=", "%d%s%s", 1, "IP", apn);
156164

157165
if (err == NSAPI_ERROR_OK) {
158-
#ifdef TARGET_UBLOX_C030_R41XM
166+
#ifdef UBX_MDM_SARA_R41XM
159167
if (modem_security == CellularContext::CHAP) {
160168
err = _at->at_cmd_discard("+UAUTHREQ", "=", "%d%d%s%s", 1, modem_security, password, username);
161169
} else if (modem_security == CellularContext::NOAUTH) {

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "UBLOX_AT_CellularStack.h"
1919
#include "APN_db.h"
2020
#include "CellularLog.h"
21-
2221
#include "rtos/ThisThread.h"
2322

2423
namespace mbed {
@@ -53,13 +52,13 @@ void UBLOX_AT_CellularContext::do_connect()
5352
_cb_data.error = NSAPI_ERROR_NO_CONNECTION;
5453

5554
// Attempt to establish a connection
56-
#ifndef TARGET_UBLOX_C030_R41XM
55+
#ifndef UBX_MDM_SARA_R41XM
5756
_cb_data.error = define_context();
58-
#elif TARGET_UBLOX_C030_R410M
57+
#elif UBX_MDM_SARA_R410M
5958
_is_context_active = true;
6059
_is_context_activated = true;
6160
_cb_data.error = NSAPI_ERROR_OK;
62-
#elif TARGET_UBLOX_C030_R412M
61+
#elif UBX_MDM_SARA_R412M
6362
CellularNetwork::RadioAccessTechnology rat = read_radio_technology();
6463
if (rat == CellularNetwork::RadioAccessTechnology::RAT_EGPRS) {
6564
if (!_is_context_active) {
@@ -100,7 +99,7 @@ void UBLOX_AT_CellularContext::do_connect()
10099
}
101100
}
102101

103-
#ifndef TARGET_UBLOX_C030_R41XM
102+
#ifndef UBX_MDM_SARA_R41XM
104103
nsapi_error_t UBLOX_AT_CellularContext::define_context()
105104
{
106105
bool success = false;
@@ -234,7 +233,7 @@ int UBLOX_AT_CellularContext::nsapi_security_to_modem_security(AuthenticationTyp
234233
case CHAP:
235234
modem_security = 2;
236235
break;
237-
#ifndef TARGET_UBLOX_C030_R41XM
236+
#ifndef UBX_MDM_SARA_R41XM
238237
case AUTOMATIC:
239238
modem_security = 3;
240239
break;
@@ -309,7 +308,7 @@ CellularContext::AuthenticationType UBLOX_AT_CellularContext::get_auth()
309308
return _authentication_type;
310309
}
311310

312-
#ifdef TARGET_UBLOX_C030_R412M
311+
#ifdef UBX_MDM_SARA_R412M
313312
CellularNetwork::RadioAccessTechnology UBLOX_AT_CellularContext::read_radio_technology()
314313
{
315314
int act;
@@ -343,6 +342,6 @@ CellularNetwork::RadioAccessTechnology UBLOX_AT_CellularContext::read_radio_tech
343342

344343
return rat;
345344
}
346-
#endif // #ifdef TARGET_UBLOX_C030_R412M
345+
#endif // #ifdef UBX_MDM_SARA_R412M
347346

348347
} /* namespace mbed */

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class UBLOX_AT_CellularContext: public AT_CellularContext {
4545
/** Get the next set of credentials from the database.
4646
*/
4747
void get_next_credentials(char **config);
48-
#ifdef TARGET_UBLOX_C030_R412M
48+
#ifdef UBX_MDM_SARA_R412M
4949
CellularNetwork::RadioAccessTechnology read_radio_technology(void);
5050
#endif
5151
protected:
@@ -55,7 +55,7 @@ class UBLOX_AT_CellularContext: public AT_CellularContext {
5555
*
5656
* @return True if successful, otherwise false.
5757
*/
58-
#ifndef TARGET_UBLOX_C030_R41XM
58+
#ifndef UBX_MDM_SARA_R41XM
5959
nsapi_error_t define_context();
6060
#endif
6161

@@ -79,7 +79,7 @@ class UBLOX_AT_CellularContext: public AT_CellularContext {
7979
* CHAP or AUTOMATIC).
8080
* @return True if successful, otherwise false.
8181
*/
82-
#ifndef TARGET_UBLOX_C030_R41XM
82+
#ifndef UBX_MDM_SARA_R41XM
8383
bool activate_profile(const char *apn, const char *username, const char *password, AuthenticationType auth);
8484
#endif
8585

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
#include "UBLOX_AT_CellularNetwork.h"
19-
2019
#include "rtos/ThisThread.h"
2120

2221
using namespace mbed;
@@ -47,11 +46,11 @@ nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTe
4746
_at.lock();
4847
switch (opRat) {
4948
case RAT_EGPRS:
50-
#if defined (TARGET_UBLOX_C030_R412M)
49+
#if defined (UBX_MDM_SARA_R412M)
5150
_at.at_cmd_discard("+URAT", "=", "%d%d", 9, 8);
5251
break;
5352
#endif
54-
#if defined(TARGET_UBLOX_C030_U201)
53+
#if defined(UBX_MDM_SARA_U201)
5554
case RAT_GSM:
5655
_at.at_cmd_discard("+URAT", "=", "%d%d", 0, 0);
5756
break;
@@ -61,7 +60,7 @@ nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTe
6160
case RAT_HSDPA_HSUPA:
6261
_at.at_cmd_discard("+URAT", "=", "%d%d", 2, 2);
6362
break;
64-
#elif defined(TARGET_UBLOX_C030_R41XM)
63+
#elif defined(UBX_MDM_SARA_R41XM)
6564
case RAT_CATM1:
6665
_at.at_cmd_discard("+URAT", "=", "%d%d", 7, 8);
6766
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ nsapi_error_t UBLOX_AT_CellularStack::gethostbyname(const char *host, SocketAddr
451451
} else {
452452
// This interrogation can sometimes take longer than the usual 8 seconds
453453
_at.cmd_start_stop("+UDNSRN", "=0,", "%s", host);
454-
#ifdef TARGET_UBLOX_C030_R41XM
454+
#ifdef UBX_MDM_SARA_R41XM
455455
_at.set_at_timeout(70000);
456456
#else
457457
_at.set_at_timeout(120000);

features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,36 @@
2121
using namespace mbed;
2222
using namespace events;
2323

24-
#ifdef TARGET_UBLOX_C027
24+
#ifdef UBX_MDM_SARA_R41XM
2525
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
2626
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
2727
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
2828
AT_CellularNetwork::RegistrationModeLAC, // C_REG
2929
0, // AT_CGSN_WITH_TYPE
30-
1, // AT_CGDATA
31-
1, // AT_CGAUTH
30+
0, // AT_CGDATA
31+
0, // AT_CGAUTH
3232
1, // AT_CNMI
3333
1, // AT_CSMP
3434
1, // AT_CMGF
35-
1, // AT_CSDH
35+
0, // AT_CSDH
3636
1, // PROPERTY_IPV4_STACK
3737
0, // PROPERTY_IPV6_STACK
3838
0, // PROPERTY_IPV4V6_STACK
3939
0, // PROPERTY_NON_IP_PDP_TYPE
4040
1, // PROPERTY_AT_CGEREP
4141
};
42-
#else
42+
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
4343
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
4444
AT_CellularNetwork::RegistrationModeDisable,// C_EREG
4545
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
4646
AT_CellularNetwork::RegistrationModeLAC, // C_REG
47+
#ifdef UBX_MDM_SARA_G3XX
48+
0, // AT_CGSN_WITH_TYPE
49+
#else
4750
1, // AT_CGSN_WITH_TYPE
51+
#endif
4852
1, // AT_CGDATA
49-
1, // AT_CGAUTH
53+
0, // AT_CGAUTH
5054
1, // AT_CNMI
5155
1, // AT_CSMP
5256
1, // AT_CMGF
@@ -57,6 +61,8 @@ static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
5761
0, // PROPERTY_NON_IP_PDP_TYPE
5862
1, // PROPERTY_AT_CGEREP
5963
};
64+
#else
65+
#error This modem is currently not supported.
6066
#endif
6167

6268
UBLOX_PPP::UBLOX_PPP(FileHandle *fh) : AT_CellularDevice(fh)

targets/targets.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@
707707
"macro_name": "MODEM_ON_BOARD_UART"
708708
}
709709
},
710-
"macros": ["TARGET_LPC1768"],
710+
"macros": ["TARGET_LPC1768", "UBX_MDM_SARA_G3XX", "UBX_MDM_SARA_G350"],
711711
"inherits": ["LPCTarget"],
712712
"device_has": [
713713
"USTICKER",
@@ -4873,23 +4873,27 @@
48734873
"UBLOX_C030_U201": {
48744874
"inherits": ["UBLOX_C030"],
48754875
"components_add": ["SD", "FLASHIAP"],
4876-
"release_versions": ["5"]
4876+
"release_versions": ["5"],
4877+
"macros_add": ["UBX_MDM_SARA_U2XX", "UBX_MDM_SARA_U201"]
48774878
},
48784879
"UBLOX_C030_N211": {
48794880
"inherits": ["UBLOX_C030"],
4880-
"release_versions": ["5"]
4881+
"release_versions": ["5"],
4882+
"macros_add": ["UBX_MDM_SARA_N2XX", "UBX_MDM_SARA_N211"]
48814883
},
48824884
"UBLOX_C030_R41XM": {
48834885
"inherits": ["UBLOX_C030"],
48844886
"release_versions": ["5"]
48854887
},
48864888
"UBLOX_C030_R410M": {
48874889
"inherits": ["UBLOX_C030_R41XM"],
4888-
"release_versions": ["5"]
4890+
"release_versions": ["5"],
4891+
"macros_add": ["UBX_MDM_SARA_R41XM", "UBX_MDM_SARA_R410M"]
48894892
},
48904893
"UBLOX_C030_R412M": {
48914894
"inherits": ["UBLOX_C030_R41XM"],
4892-
"release_versions": ["5"]
4895+
"release_versions": ["5"],
4896+
"macros_add": ["UBX_MDM_SARA_R41XM", "UBX_MDM_SARA_R412M"]
48934897
},
48944898
"NZ32_SC151": {
48954899
"inherits": ["FAMILY_STM32"],

0 commit comments

Comments
 (0)