@@ -144,16 +144,11 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_close_impl(int sock_id)
144
144
145
145
_at.set_at_timeout (FAILURE_TIMEOUT);
146
146
147
- _at.cmd_start (" AT^SISC=" );
148
- _at.write_int (sock_id);
149
- _at.cmd_stop_read_resp ();
147
+ _at.at_cmd_discard (" ^SISC" , " =" , " %d" , sock_id);
150
148
151
149
_at.clear_error (); // clear SISS even though SISC fails
152
- _at.cmd_start (" AT^SISS=" );
153
- _at.write_int (sock_id);
154
- _at.write_string (" srvType" );
155
- _at.write_string (" none" );
156
- _at.cmd_stop_read_resp ();
150
+
151
+ _at.at_cmd_discard (" ^SISS" , " =" , " %d%s%s" , sock_id, " srvType" , " none" );
157
152
158
153
_at.restore_at_timeout ();
159
154
@@ -170,8 +165,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
170
165
int internet_service_id = find_socket_index (socket);
171
166
bool foundSrvType = false ;
172
167
bool foundConIdType = false ;
173
- _at.cmd_start (" AT^SISS?" );
174
- _at.cmd_stop ();
168
+ _at.cmd_start_stop (" ^SISS" , " ?" );
175
169
_at.resp_start (" ^SISS:" );
176
170
/*
177
171
* Profile is a list of tag-value map:
@@ -211,19 +205,11 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
211
205
_at.resp_stop ();
212
206
213
207
if (!foundSrvType) {
214
- _at.cmd_start (" AT^SISS=" );
215
- _at.write_int (internet_service_id);
216
- _at.write_string (" srvType" );
217
- _at.write_string (" Socket" );
218
- _at.cmd_stop_read_resp ();
208
+ _at.at_cmd_discard (" ^SISS" , " =" , " %d%s%s" , internet_service_id, " srvType" , " Socket" );
219
209
}
220
210
221
211
if (!foundConIdType) {
222
- _at.cmd_start (" AT^SISS=" );
223
- _at.write_int (internet_service_id);
224
- _at.write_string (" conId" );
225
- _at.write_int (connection_profile_id);
226
- _at.cmd_stop_read_resp ();
212
+ _at.at_cmd_discard (" ^SISS" , " =" , " %d%s%d" , internet_service_id, " conId" , connection_profile_id);
227
213
}
228
214
229
215
// host address (IPv4) and local+remote port is needed only for BGS2 which does not support UDP server socket
@@ -249,9 +235,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
249
235
_at.write_string (sock_addr);
250
236
_at.cmd_stop_read_resp ();
251
237
252
- _at.cmd_start (" AT^SISO=" );
253
- _at.write_int (internet_service_id);
254
- _at.cmd_stop_read_resp ();
238
+ _at.at_cmd_discard (" ^SISO" , " =" , " %d" , internet_service_id);
255
239
256
240
if (_at.get_last_error ()) {
257
241
tr_error (" Socket %d open failed!" , socket->id );
@@ -337,13 +321,8 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_sendto_impl(Cellul
337
321
}
338
322
339
323
_at.set_at_timeout (FAILURE_TIMEOUT);
340
- _at.cmd_start (" AT^SISW=" );
341
- _at.write_int (socket->id );
342
- _at.write_int (size);
343
324
344
325
if (GEMALTO_CINTERION::get_module () != GEMALTO_CINTERION::ModuleBGS2) {
345
- _at.write_int (0 );
346
-
347
326
// UDP requires Udp_RemClient
348
327
if (socket->proto == NSAPI_UDP) {
349
328
char socket_address[NSAPI_IPv6_SIZE + sizeof (" []:12345" ) - 1 + 1 ];
@@ -352,12 +331,14 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_sendto_impl(Cellul
352
331
} else {
353
332
std::sprintf (socket_address, " [%s]:%u" , address.get_ip_address (), address.get_port ());
354
333
}
355
- _at.write_string (socket_address);
334
+ _at.cmd_start_stop (" ^SISW" , " =" , " %d%d%d%s" , socket->id , size, 0 , socket_address);
335
+ } else {
336
+ _at.cmd_start_stop (" ^SISW" , " =" , " %d%d%d" , socket->id , size, 0 );
356
337
}
338
+ } else {
339
+ _at.cmd_start_stop (" ^SISW" , " =" , " %d%d" , socket->id , size);
357
340
}
358
341
359
- _at.cmd_stop ();
360
-
361
342
sisw_retry:
362
343
_at.resp_start (" ^SISW:" );
363
344
if (!_at.info_resp ()) {
@@ -418,10 +399,7 @@ nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(Cell
418
399
size = UDP_PACKET_SIZE;
419
400
}
420
401
421
- _at.cmd_start (" AT^SISR=" );
422
- _at.write_int (socket->id );
423
- _at.write_int (size);
424
- _at.cmd_stop ();
402
+ _at.cmd_start_stop (" ^SISR" , " =" , " %d%d" , socket->id , size);
425
403
426
404
sisr_retry:
427
405
_at.resp_start (" ^SISR:" );
@@ -516,8 +494,8 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::create_connection_profile(int con
516
494
517
495
char conParamType[sizeof (" GPRS0" ) + 1 ];
518
496
std::sprintf (conParamType, " GPRS%d" , (_stack_type == IPV4_STACK) ? 0 : 6 );
519
- _at. cmd_start ( " AT^SICS? " );
520
- _at.cmd_stop ( );
497
+
498
+ _at.cmd_start_stop ( " ^SICS " , " ? " );
521
499
bool found_connection = false ;
522
500
_at.resp_start (" ^SICS:" );
523
501
while (_at.info_resp ()) {
@@ -543,46 +521,25 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::create_connection_profile(int con
543
521
544
522
// connection profile is bound to a PDP context and it can not be changed
545
523
if (!found_connection) {
546
- _at.cmd_start (" AT^SICS=" );
547
- _at.write_int (connection_profile_id);
548
- _at.write_string (" conType" );
549
- _at.write_string (conParamType);
550
- _at.cmd_stop_read_resp ();
524
+ _at.at_cmd_discard (" ^SICS" , " =" , " %d%s%s" , connection_profile_id, " conType" , conParamType);
551
525
552
526
if (_apn && strlen (_apn) > 0 ) {
553
- _at.cmd_start (" AT^SICS=" );
554
- _at.write_int (connection_profile_id);
555
- _at.write_string (" apn" );
556
- _at.write_string (_apn);
557
- _at.cmd_stop_read_resp ();
527
+ _at.at_cmd_discard (" ^SICS" , " =" , " %d%s%s" , connection_profile_id, " apn" , _apn);
558
528
}
559
529
560
530
if (_user && strlen (_user) > 0 ) {
561
- _at.cmd_start (" AT^SICS=" );
562
- _at.write_int (connection_profile_id);
563
- _at.write_string (" user" );
564
- _at.write_string (_user);
565
- _at.cmd_stop_read_resp ();
531
+ _at.at_cmd_discard (" ^SICS" , " =" , " %d%s%s" , connection_profile_id, " user" , _user);
566
532
}
567
533
568
534
if (_password && strlen (_password) > 0 ) {
569
- _at.cmd_start (" AT^SICS=" );
570
- _at.write_int (connection_profile_id);
571
- _at.write_string (" passwd" );
572
- _at.write_string (_password);
573
- _at.cmd_stop_read_resp ();
535
+ _at.at_cmd_discard (" ^SICS" , " =" , " %d%s%s" , connection_profile_id, " passwd" , _password);
574
536
}
575
537
576
538
// set maximum inactivity timeout
577
- _at.cmd_start (" AT^SICS=" );
578
- _at.write_int (connection_profile_id);
579
- _at.write_string (" inactTO" );
580
- _at.write_int (0xffff ); // 2^16-1
581
- _at.cmd_stop_read_resp ();
539
+ _at.at_cmd_discard (" ^SICS" , " =" , " %d%s%d" , connection_profile_id, " inactTO" , 0xffff );
582
540
583
541
// use URC mode ON
584
- _at.cmd_start (" AT^SCFG=\" Tcp/withURCs\" ,\" on\" " );
585
- _at.cmd_stop_read_resp ();
542
+ _at.at_cmd_discard (" ^SCFG" , " =" , " %s%s" , " Tcp/withURCs" , " on" );
586
543
}
587
544
588
545
tr_debug (" Cinterion profile %d, %s (err %d)" , connection_profile_id, (_stack_type == IPV4_STACK) ? " IPv4" : " IPv6" , _at.get_last_error ());
@@ -598,15 +555,10 @@ void GEMALTO_CINTERION_CellularStack::close_connection_profile(int connection_pr
598
555
// To clear connection profile need to detach from packet data.
599
556
// After detach modem sends PDP disconnected event to network class,
600
557
// which propagates network disconnected to upper layer to start reconnecting.
601
- _at.cmd_start (" AT+CGATT=0" );
602
- _at.cmd_stop_read_resp ();
558
+ _at.at_cmd_discard (" +CGATT" , " =0" );
603
559
_at.clear_error ();
604
560
605
- _at.cmd_start (" AT^SICS=" );
606
- _at.write_int (connection_profile_id);
607
- _at.write_string (" conType" );
608
- _at.write_string (" none" );
609
- _at.cmd_stop_read_resp ();
561
+ _at.at_cmd_discard (" ^SICS" , " =" , " %d%s%s" , connection_profile_id, " conType" , " none" );
610
562
611
563
_at.clear_error ();
612
564
}
0 commit comments