Skip to content

Commit 7af118f

Browse files
pennamfacchinm
authored andcommitted
GEMALTO_CINTERION_CellularContext: add return value to enable_access_technology()
1 parent 81478e0 commit 7af118f

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

connectivity/cellular/include/cellular/framework/AT/AT_CellularContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class AT_CellularContext : public CellularContext {
109109
* @return NIDD context text, e.g. Non-IP or NONIP
110110
*/
111111
virtual const char *get_nonip_context_type_str();
112-
virtual void enable_access_technology();
112+
virtual nsapi_error_t enable_access_technology();
113113
virtual void set_cid(int cid);
114114

115115
private:

connectivity/cellular/source/framework/AT/AT_CellularContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ bool AT_CellularContext::set_new_context(int cid)
443443
return success;
444444
}
445445

446-
void AT_CellularContext::enable_access_technology()
446+
nsapi_error_t AT_CellularContext::enable_access_technology()
447447
{
448-
enable_access_technology();
448+
return enable_access_technology();
449449
}
450450

451451
nsapi_error_t AT_CellularContext::do_activate_context()

connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,30 +148,35 @@ NetworkStack *GEMALTO_CINTERION_CellularContext::get_stack()
148148
}
149149
#endif // NSAPI_PPP_AVAILABLE
150150

151-
void GEMALTO_CINTERION_CellularContext::enable_access_technology()
151+
nsapi_error_t GEMALTO_CINTERION_CellularContext::enable_access_technology()
152152
{
153-
char *buffer = new char [8];
154-
memset(buffer, 0, 8);
155-
sprintf(buffer,"%08X", _band);
153+
nsapi_error_t error = NSAPI_ERROR_OK;
154+
char buffer[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
155+
156+
snprintf(buffer, 9, "%08X", _band);
156157
switch (_rat)
157158
{
158159
case CATM1:
159-
_at.at_cmd_discard("^SXRAT", "=","%d", _rat);
160-
_at.at_cmd_discard("^SCFG", "=","%s%s", "Radio/Band/CatM",buffer);
160+
error = _at.at_cmd_discard("^SCFG", "=","%s%s", "Radio/Band/CatM", buffer);
161161
break;
162162

163163
case CATNB:
164-
_at.at_cmd_discard("^SXRAT", "=","%d", _rat);
165-
_at.at_cmd_discard("^SCFG", "=","%s%s", "Radio/Band/CatNB",buffer);
164+
error = _at.at_cmd_discard("^SCFG", "=","%s%s", "Radio/Band/CatNB", buffer);
166165
break;
167166

168167
default:
169168
break;
170169
}
170+
if (error != NSAPI_ERROR_OK) {
171+
return error;
172+
}
171173

172-
_at.at_cmd_discard("^SCFG", "=", "%s%s", "Tcp/withURCs", "on");
173-
free(buffer);
174+
error = _at.at_cmd_discard("^SXRAT", "=","%d", _rat);
175+
if (error != NSAPI_ERROR_OK) {
176+
return error;
177+
}
174178

179+
return _at.at_cmd_discard("^SCFG", "=", "%s%s", "Tcp/withURCs", "on");
175180
}
176181

177182
} /* namespace mbed */

connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class GEMALTO_CINTERION_CellularContext: public AT_CellularContext {
3434
virtual NetworkStack *get_stack();
3535
#endif // NSAPI_PPP_AVAILABLE
3636
virtual nsapi_error_t do_user_authentication();
37-
virtual void enable_access_technology();
37+
virtual nsapi_error_t enable_access_technology();
3838
};
3939

4040
} /* namespace mbed */

0 commit comments

Comments
 (0)