@@ -80,7 +80,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
80
80
};
81
81
#endif
82
82
83
- UBLOX_AT::UBLOX_AT (FileHandle *fh) : AT_CellularDevice(fh)
83
+ UBLOX_AT::UBLOX_AT (FileHandle *fh) : AT_CellularDevice(fh), ubx_context( 0 )
84
84
{
85
85
set_cellular_properties (cellular_properties);
86
86
}
@@ -117,38 +117,36 @@ nsapi_error_t UBLOX_AT::init()
117
117
_at->lock ();
118
118
_at->flush ();
119
119
_at->at_cmd_discard (" " , " " );
120
-
121
- nsapi_error_t err = NSAPI_ERROR_OK;
120
+ int value = -1 ;
122
121
123
122
#ifdef UBX_MDM_SARA_G3XX
124
- err = _at->at_cmd_discard (" +CFUN" , " =0" );
125
-
126
- if (err == NSAPI_ERROR_OK) {
127
- _at->at_cmd_discard (" E0" , " " ); // echo off
128
- _at->at_cmd_discard (" +CMEE" , " =1" ); // verbose responses
129
- config_authentication_parameters ();
130
- err = _at->at_cmd_discard (" +CFUN" , " =1" ); // set full functionality
131
- }
123
+ value = 0 ;
132
124
#elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_R41XM)
133
- err = _at->at_cmd_discard (" +CFUN" , " =4" );
125
+ value = 4 ;
126
+ #else
127
+ _at->unlock ();
128
+ return NSAPI_ERROR_UNSUPPORTED;
129
+ #endif
130
+
131
+ nsapi_error_t err = _at->at_cmd_discard (" +CFUN" , " =" , " %d" , value);
132
+
134
133
if (err == NSAPI_ERROR_OK) {
135
134
_at->at_cmd_discard (" E0" , " " ); // echo off
136
135
_at->at_cmd_discard (" +CMEE" , " =1" ); // verbose responses
137
136
config_authentication_parameters ();
138
137
err = _at->at_cmd_discard (" +CFUN" , " =1" ); // set full functionality
139
138
}
140
- #else
141
- _at->unlock ();
142
- return NSAPI_ERROR_UNSUPPORTED;
143
- #endif
144
-
145
139
return _at->unlock_return_error ();
146
140
}
147
141
148
142
nsapi_error_t UBLOX_AT::config_authentication_parameters ()
149
143
{
150
144
char *config = NULL ;
151
145
nsapi_error_t err;
146
+ const char *apn;
147
+ const char *uname;
148
+ const char *pwd;
149
+ CellularContext::AuthenticationType auth = CellularContext::NOAUTH;
152
150
char imsi[MAX_IMSI_LENGTH + 1 ];
153
151
154
152
if (ubx_context->get_apn () == NULL ) {
@@ -162,9 +160,10 @@ nsapi_error_t UBLOX_AT::config_authentication_parameters()
162
160
apn = ubx_context->get_apn ();
163
161
pwd = ubx_context->get_pwd ();
164
162
uname = ubx_context->get_uname ();
165
- auth = ubx_context->get_auth ();
166
163
167
- auth = (*uname && *pwd) ? auth : CellularContext::NOAUTH;
164
+ if (*uname && *pwd) {
165
+ auth = ubx_context->get_auth ();
166
+ }
168
167
err = set_authentication_parameters (apn, uname, pwd, auth);
169
168
170
169
return err;
0 commit comments