Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit c887d32

Browse files
author
iwahdan88
committed
esp32/lteppp: added suspen/resume functinality to lteppp
1 parent 0650a29 commit c887d32

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

esp32/lte/lteppp.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern TaskHandle_t xLTETaskHndl;
4848
DECLARE PRIVATE DATA
4949
******************************************************************************/
5050
static char lteppp_trx_buffer[LTE_UART_BUFFER_SIZE];
51+
static char lteppp_queue_buffer[LTE_UART_BUFFER_SIZE];
5152
static uart_dev_t* lteppp_uart_reg;
5253
static QueueHandle_t xCmdQueue;
5354
static QueueHandle_t xRxQueue;
@@ -68,6 +69,8 @@ static bool lteppp_enabled = false;
6869

6970
static bool ltepp_ppp_conn_up = false;
7071

72+
static bool lteppp_suspended = false;
73+
7174
/******************************************************************************
7275
DECLARE PRIVATE FUNCTIONS
7376
******************************************************************************/
@@ -288,6 +291,16 @@ bool ltepp_is_ppp_conn_up(void)
288291
{
289292
return ltepp_ppp_conn_up;
290293
}
294+
295+
void lteppp_suspend(void)
296+
{
297+
lteppp_suspended = true;
298+
}
299+
300+
void lteppp_resume(void)
301+
{
302+
lteppp_suspended = false;
303+
}
291304
/******************************************************************************
292305
DEFINE PRIVATE FUNCTIONS
293306
******************************************************************************/
@@ -458,8 +471,28 @@ static bool lteppp_check_sim_present(void) {
458471
// PPP output callback
459472
static uint32_t lteppp_output_callback(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx) {
460473
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+
}
463496
return tx_bytes;
464497
}
465498

esp32/lte/lteppp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,8 @@ extern void connect_lte_uart (void);
103103

104104
extern bool ltepp_is_ppp_conn_up(void);
105105

106+
extern void lteppp_suspend(void);
107+
108+
extern void lteppp_resume(void);
109+
106110
#endif // _LTEPPP_H_

esp32/mods/modlte.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ STATIC mp_obj_t lte_suspend(mp_obj_t self_in) {
695695
}
696696
lte_check_init();
697697
if (lteppp_get_state() == E_LTE_PPP) {
698+
lteppp_suspend();
698699
//printf("Pausing ppp...\n");
699700
lte_pause_ppp();
700701
//printf("Pausing ppp done...\n");
@@ -808,6 +809,7 @@ STATIC mp_obj_t lte_resume(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t
808809

809810
if (lte_push_at_command_ext("ATO", LTE_RX_TIMEOUT_MAX_MS, LTE_CONNECT_RSP)) {
810811
lteppp_connect();
812+
lteppp_resume();
811813
lteppp_set_state(E_LTE_PPP);
812814
vTaskDelay(1500);
813815
} else {

0 commit comments

Comments
 (0)