@@ -335,10 +335,6 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
335
335
nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl (CellularSocket *socket, const SocketAddress &address,
336
336
const void *data, nsapi_size_t size)
337
337
{
338
- if (size > BG96_MAX_SEND_SIZE) {
339
- return NSAPI_ERROR_PARAMETER;
340
- }
341
-
342
338
if (_ip_ver_sendto != address.get_ip_version ()) {
343
339
_ip_ver_sendto = address.get_ip_version ();
344
340
socket_close_impl (socket->id );
@@ -358,29 +354,59 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSoc
358
354
359
355
// Send
360
356
if (socket->proto == NSAPI_UDP) {
357
+ if (size > BG96_MAX_SEND_SIZE) {
358
+ return NSAPI_ERROR_PARAMETER;
359
+ }
361
360
char ipdot[NSAPI_IP_SIZE];
362
361
ip2dot (address, ipdot);
363
362
_at.cmd_start_stop (" +QISEND" , " =" , " %d%d%s%d" , socket->id , size,
364
363
ipdot, address.get_port ());
365
- } else {
366
- if (socket->tls_socket ) {
367
- _at.cmd_start_stop (" +QSSLSEND" , " =" , " %d%d" , socket->id , size);
368
- } else {
369
- _at.cmd_start_stop (" +QISEND" , " =" , " %d%d" , socket->id , size);
364
+ _at.resp_start (" >" );
365
+ _at.write_bytes ((uint8_t *)data, size);
366
+ _at.resp_start ();
367
+ _at.set_stop_tag (" \r\n " );
368
+ // Possible responses are SEND OK, SEND FAIL or ERROR.
369
+ char response[16 ];
370
+ response[0 ] = ' \0 ' ;
371
+ _at.read_string (response, sizeof (response));
372
+ _at.resp_stop ();
373
+ if (strcmp (response, " SEND OK" ) != 0 ) {
374
+ return NSAPI_ERROR_DEVICE_ERROR;
370
375
}
371
- }
376
+ } else {
377
+ const char *buf = (const char *)data;
378
+ nsapi_size_t blk = BG96_MAX_SEND_SIZE;
379
+ nsapi_size_t count = size;
372
380
373
- _at.resp_start (" >" );
374
- _at.write_bytes ((uint8_t *)data, size);
375
- _at.resp_start ();
376
- _at.set_stop_tag (" \r\n " );
377
- // Possible responses are SEND OK, SEND FAIL or ERROR.
378
- char response[16 ];
379
- response[0 ] = ' \0 ' ;
380
- _at.read_string (response, sizeof (response));
381
- _at.resp_stop ();
382
- if (strcmp (response, " SEND OK" ) != 0 ) {
383
- return NSAPI_ERROR_DEVICE_ERROR;
381
+ while (count > 0 ) {
382
+ if (count < blk) {
383
+ blk = count;
384
+ }
385
+
386
+ if (socket->tls_socket ) {
387
+ _at.cmd_start_stop (" +QSSLSEND" , " =" , " %d%d" , socket->id , blk);
388
+ }
389
+
390
+ else {
391
+ _at.cmd_start_stop (" +QISEND" , " =" , " %d%d" , socket->id , blk);
392
+ }
393
+
394
+ _at.resp_start (" >" );
395
+ _at.write_bytes ((uint8_t *)buf, blk);
396
+ _at.resp_start ();
397
+ _at.set_stop_tag (" \r\n " );
398
+ // Possible responses are SEND OK, SEND FAIL or ERROR.
399
+ char response[16 ];
400
+ response[0 ] = ' \0 ' ;
401
+ _at.read_string (response, sizeof (response));
402
+ _at.resp_stop ();
403
+ if (strcmp (response, " SEND OK" ) != 0 ) {
404
+ return NSAPI_ERROR_DEVICE_ERROR;
405
+ }
406
+
407
+ buf += blk;
408
+ count -= blk;
409
+ }
384
410
}
385
411
386
412
// Get the sent count after sending
0 commit comments