@@ -80,7 +80,7 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
8080};
8181#endif
8282
83- UBLOX_AT::UBLOX_AT (FileHandle *fh) : AT_CellularDevice(fh)
83+ UBLOX_AT::UBLOX_AT (FileHandle *fh) : AT_CellularDevice(fh), ubx_context( 0 )
8484{
8585 set_cellular_properties (cellular_properties);
8686}
@@ -117,38 +117,36 @@ nsapi_error_t UBLOX_AT::init()
117117 _at->lock ();
118118 _at->flush ();
119119 _at->at_cmd_discard (" " , " " );
120-
121- nsapi_error_t err = NSAPI_ERROR_OK;
120+ int value = -1 ;
122121
123122#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 ;
132124#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+
134133 if (err == NSAPI_ERROR_OK) {
135134 _at->at_cmd_discard (" E0" , " " ); // echo off
136135 _at->at_cmd_discard (" +CMEE" , " =1" ); // verbose responses
137136 config_authentication_parameters ();
138137 err = _at->at_cmd_discard (" +CFUN" , " =1" ); // set full functionality
139138 }
140- #else
141- _at->unlock ();
142- return NSAPI_ERROR_UNSUPPORTED;
143- #endif
144-
145139 return _at->unlock_return_error ();
146140}
147141
148142nsapi_error_t UBLOX_AT::config_authentication_parameters ()
149143{
150144 char *config = NULL ;
151145 nsapi_error_t err;
146+ const char *apn;
147+ const char *uname;
148+ const char *pwd;
149+ CellularContext::AuthenticationType auth = CellularContext::NOAUTH;
152150 char imsi[MAX_IMSI_LENGTH + 1 ];
153151
154152 if (ubx_context->get_apn () == NULL ) {
@@ -162,9 +160,10 @@ nsapi_error_t UBLOX_AT::config_authentication_parameters()
162160 apn = ubx_context->get_apn ();
163161 pwd = ubx_context->get_pwd ();
164162 uname = ubx_context->get_uname ();
165- auth = ubx_context->get_auth ();
166163
167- auth = (*uname && *pwd) ? auth : CellularContext::NOAUTH;
164+ if (*uname && *pwd) {
165+ auth = ubx_context->get_auth ();
166+ }
168167 err = set_authentication_parameters (apn, uname, pwd, auth);
169168
170169 return err;
0 commit comments