@@ -48,6 +48,7 @@ extern TaskHandle_t xLTETaskHndl;
48
48
DECLARE PRIVATE DATA
49
49
******************************************************************************/
50
50
static char lteppp_trx_buffer [LTE_UART_BUFFER_SIZE ];
51
+ static char lteppp_queue_buffer [LTE_UART_BUFFER_SIZE ];
51
52
static uart_dev_t * lteppp_uart_reg ;
52
53
static QueueHandle_t xCmdQueue ;
53
54
static QueueHandle_t xRxQueue ;
@@ -68,6 +69,8 @@ static bool lteppp_enabled = false;
68
69
69
70
static bool ltepp_ppp_conn_up = false;
70
71
72
+ static bool lteppp_suspended = false;
73
+
71
74
/******************************************************************************
72
75
DECLARE PRIVATE FUNCTIONS
73
76
******************************************************************************/
@@ -288,6 +291,16 @@ bool ltepp_is_ppp_conn_up(void)
288
291
{
289
292
return ltepp_ppp_conn_up ;
290
293
}
294
+
295
+ void lteppp_suspend (void )
296
+ {
297
+ lteppp_suspended = true;
298
+ }
299
+
300
+ void lteppp_resume (void )
301
+ {
302
+ lteppp_suspended = false;
303
+ }
291
304
/******************************************************************************
292
305
DEFINE PRIVATE FUNCTIONS
293
306
******************************************************************************/
@@ -458,8 +471,28 @@ static bool lteppp_check_sim_present(void) {
458
471
// PPP output callback
459
472
static uint32_t lteppp_output_callback (ppp_pcb * pcb , u8_t * data , u32_t len , void * ctx ) {
460
473
LWIP_UNUSED_ARG (ctx );
461
- uint32_t tx_bytes = uart_write_bytes (LTE_UART_ID , (const char * )data , len );
462
- uart_wait_tx_done (LTE_UART_ID , LTE_TRX_WAIT_MS (len ) / portTICK_RATE_MS );
474
+ uint32_t tx_bytes ;
475
+ static uint32_t top = 0 ;
476
+ if (!lteppp_suspended ) {
477
+ if (top > 0 )
478
+ {
479
+ uart_write_bytes (LTE_UART_ID , (const char * )lteppp_queue_buffer , top + 1 );
480
+ uart_wait_tx_done (LTE_UART_ID , LTE_TRX_WAIT_MS (top + 1 ) / portTICK_RATE_MS );
481
+ top = 0 ;
482
+ }
483
+ tx_bytes = uart_write_bytes (LTE_UART_ID , (const char * )data , len );
484
+ uart_wait_tx_done (LTE_UART_ID , LTE_TRX_WAIT_MS (len ) / portTICK_RATE_MS );
485
+ }
486
+ else
487
+ {
488
+ memcpy (& (lteppp_queue_buffer [top ]), (const char * )data , len );
489
+ top += len ;
490
+ if (top > LTE_UART_BUFFER_SIZE )
491
+ {
492
+ top = LTE_UART_BUFFER_SIZE - 1 ;
493
+ }
494
+ return len ;
495
+ }
463
496
return tx_bytes ;
464
497
}
465
498
0 commit comments