@@ -370,10 +370,6 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
370
370
nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl (CellularSocket *socket, const SocketAddress &address,
371
371
const void *data, nsapi_size_t size)
372
372
{
373
- if (size > BG96_MAX_SEND_SIZE) {
374
- return NSAPI_ERROR_PARAMETER;
375
- }
376
-
377
373
if (_ip_ver_sendto != address.get_ip_version ()) {
378
374
_ip_ver_sendto = address.get_ip_version ();
379
375
socket_close_impl (socket->id );
@@ -393,29 +389,59 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSoc
393
389
394
390
// Send
395
391
if (socket->proto == NSAPI_UDP) {
392
+ if (size > BG96_MAX_SEND_SIZE) {
393
+ return NSAPI_ERROR_PARAMETER;
394
+ }
396
395
char ipdot[NSAPI_IP_SIZE];
397
396
ip2dot (address, ipdot);
398
397
_at.cmd_start_stop (" +QISEND" , " =" , " %d%d%s%d" , socket->id , size,
399
398
ipdot, address.get_port ());
400
- } else {
401
- if (socket->tls_socket ) {
402
- _at.cmd_start_stop (" +QSSLSEND" , " =" , " %d%d" , socket->id , size);
403
- } else {
404
- _at.cmd_start_stop (" +QISEND" , " =" , " %d%d" , socket->id , size);
399
+ _at.resp_start (" >" );
400
+ _at.write_bytes ((uint8_t *)data, size);
401
+ _at.resp_start ();
402
+ _at.set_stop_tag (" \r\n " );
403
+ // Possible responses are SEND OK, SEND FAIL or ERROR.
404
+ char response[16 ];
405
+ response[0 ] = ' \0 ' ;
406
+ _at.read_string (response, sizeof (response));
407
+ _at.resp_stop ();
408
+ if (strcmp (response, " SEND OK" ) != 0 ) {
409
+ return NSAPI_ERROR_DEVICE_ERROR;
405
410
}
406
- }
411
+ } else {
412
+ const char *buf = (const char *)data;
413
+ nsapi_size_t blk = BG96_MAX_SEND_SIZE;
414
+ nsapi_size_t count = size;
407
415
408
- _at.resp_start (" >" );
409
- _at.write_bytes ((uint8_t *)data, size);
410
- _at.resp_start ();
411
- _at.set_stop_tag (" \r\n " );
412
- // Possible responses are SEND OK, SEND FAIL or ERROR.
413
- char response[16 ];
414
- response[0 ] = ' \0 ' ;
415
- _at.read_string (response, sizeof (response));
416
- _at.resp_stop ();
417
- if (strcmp (response, " SEND OK" ) != 0 ) {
418
- return NSAPI_ERROR_DEVICE_ERROR;
416
+ while (count > 0 ) {
417
+ if (count < blk) {
418
+ blk = count;
419
+ }
420
+
421
+ if (socket->tls_socket ) {
422
+ _at.cmd_start_stop (" +QSSLSEND" , " =" , " %d%d" , socket->id , blk);
423
+ }
424
+
425
+ else {
426
+ _at.cmd_start_stop (" +QISEND" , " =" , " %d%d" , socket->id , blk);
427
+ }
428
+
429
+ _at.resp_start (" >" );
430
+ _at.write_bytes ((uint8_t *)buf, blk);
431
+ _at.resp_start ();
432
+ _at.set_stop_tag (" \r\n " );
433
+ // Possible responses are SEND OK, SEND FAIL or ERROR.
434
+ char response[16 ];
435
+ response[0 ] = ' \0 ' ;
436
+ _at.read_string (response, sizeof (response));
437
+ _at.resp_stop ();
438
+ if (strcmp (response, " SEND OK" ) != 0 ) {
439
+ return NSAPI_ERROR_DEVICE_ERROR;
440
+ }
441
+
442
+ buf += blk;
443
+ count -= blk;
444
+ }
419
445
}
420
446
421
447
// Get the sent count after sending
0 commit comments