@@ -92,7 +92,7 @@ static bool lte_uart_break_evt = false;
9292 ******************************************************************************/
9393static void TASK_LTE (void * pvParameters );
9494static void TASK_UART_EVT (void * pvParameters );
95- static bool lteppp_send_at_cmd_exp (const char * cmd , uint32_t timeout , const char * expected_rsp , void * data_rem , size_t len );
95+ static bool lteppp_send_at_cmd_exp (const char * cmd , uint32_t timeout , const char * expected_rsp , void * data_rem , size_t len , bool expect_continuation );
9696static bool lteppp_send_at_cmd (const char * cmd , uint32_t timeout );
9797static bool lteppp_check_sim_present (void );
9898static void lteppp_status_cb (ppp_pcb * pcb , int err_code , void * ctx );
@@ -236,7 +236,9 @@ void lteppp_disconnect(void) {
236236
237237void lteppp_send_at_command (lte_task_cmd_data_t * cmd , lte_task_rsp_data_t * rsp ) {
238238 xQueueSend (xCmdQueue , (void * )cmd , (TickType_t )portMAX_DELAY );
239- xQueueReceive (xRxQueue , rsp , (TickType_t )portMAX_DELAY );
239+
240+ if (!cmd -> expect_continuation )
241+ xQueueReceive (xRxQueue , rsp , (TickType_t )portMAX_DELAY );
240242}
241243
242244bool lteppp_wait_at_rsp (const char * expected_rsp , uint32_t timeout , bool from_mp , void * data_rem ) {
@@ -529,8 +531,10 @@ static void TASK_LTE (void *pvParameters) {
529531 xSemaphoreGive (xLTESem );
530532 state = lteppp_get_state ();
531533 if (xQueueReceive (xCmdQueue , lteppp_trx_buffer , 0 )) {
532- lteppp_send_at_cmd_exp (lte_task_cmd -> data , lte_task_cmd -> timeout , NULL , & (lte_task_rsp -> data_remaining ), lte_task_cmd -> dataLen );
533- xQueueSend (xRxQueue , (void * )lte_task_rsp , (TickType_t )portMAX_DELAY );
534+ bool expect_continuation = lte_task_cmd -> expect_continuation ;
535+ lteppp_send_at_cmd_exp (lte_task_cmd -> data , lte_task_cmd -> timeout , NULL , & (lte_task_rsp -> data_remaining ), lte_task_cmd -> dataLen , lte_task_cmd -> expect_continuation );
536+ if (!expect_continuation )
537+ xQueueSend (xRxQueue , (void * )lte_task_rsp , (TickType_t )portMAX_DELAY );
534538 }
535539 else if (state == E_LTE_PPP && lte_uart_break_evt )
536540 {
@@ -616,7 +620,7 @@ static void TASK_UART_EVT (void *pvParameters)
616620}
617621
618622
619- static bool lteppp_send_at_cmd_exp (const char * cmd , uint32_t timeout , const char * expected_rsp , void * data_rem , size_t len ) {
623+ static bool lteppp_send_at_cmd_exp (const char * cmd , uint32_t timeout , const char * expected_rsp , void * data_rem , size_t len , bool expect_continuation ) {
620624
621625 if (strstr (cmd , "Pycom_Dummy" ) != NULL )
622626 {
@@ -657,22 +661,34 @@ static bool lteppp_send_at_cmd_exp (const char *cmd, uint32_t timeout, const cha
657661 }
658662#endif
659663 // flush the rx buffer first
660- uart_flush (LTE_UART_ID );
664+ if (!expect_continuation || (len >= 2 && cmd [0 ] == 'A' && cmd [1 ] == 'T' )) // starts with AT
665+ {
666+ uart_flush (LTE_UART_ID );
667+ }
661668 // uart_read_bytes(LTE_UART_ID, (uint8_t *)tmp_buf, sizeof(tmp_buf), 5 / portTICK_RATE_MS);
662669 // then send the command
663670 uart_write_bytes (LTE_UART_ID , cmd , cmd_len );
664- if (strcmp (cmd , "+++" )) {
665- uart_write_bytes (LTE_UART_ID , "\r" , 1 );
671+
672+ if (expect_continuation )
673+ {
674+ return true;
666675 }
667- uart_wait_tx_done (LTE_UART_ID , LTE_TRX_WAIT_MS (cmd_len ) / portTICK_RATE_MS );
668- vTaskDelay (2 / portTICK_RATE_MS );
676+ else {
677+ if (strcmp (cmd , "+++" ))
678+ {
679+ uart_write_bytes (LTE_UART_ID , "\r" , 1 );
680+ }
669681
670- return lteppp_wait_at_rsp (expected_rsp , timeout , false, data_rem );
682+ uart_wait_tx_done (LTE_UART_ID , LTE_TRX_WAIT_MS (cmd_len ) / portTICK_RATE_MS );
683+ vTaskDelay (2 / portTICK_RATE_MS );
684+
685+ return lteppp_wait_at_rsp (expected_rsp , timeout , false, data_rem );
686+ }
671687 }
672688}
673689
674690static bool lteppp_send_at_cmd (const char * cmd , uint32_t timeout ) {
675- return lteppp_send_at_cmd_exp (cmd , timeout , LTE_OK_RSP , NULL , strlen (cmd ) );
691+ return lteppp_send_at_cmd_exp (cmd , timeout , LTE_OK_RSP , NULL , strlen (cmd ), false );
676692}
677693
678694static bool lteppp_check_sim_present (void ) {
0 commit comments