Closed sushant-ht closed 3 years ago
Code you are showing is not library specific.
i modified lwgsm_ll_esp32.c
`/**
/*
/ Define TAG for log messages /
/ Defines ESP uart number to use / #define GSM_UART_NUM UART_NUM_1
static QueueHandle_t gsm_uart_queue;
static uint8_t initialized = 0;
char* uart_buffer[LWGSM_USART_DMA_RX_BUFF_SIZE];
/**
\return Number of bytes sent / static size_t send_data(const void data, size_t len) {
/ Implement send function here / if (len) {
printf("GSMUART][%s][%d]\n", (const char*) data, len);
len = uart_write_bytes(GSM_UART_NUM, (const char) "AT\r", 3); //uart_wait_tx_done(GSM_UART_NUM, portMAX_DELAY); ESP_LOG_BUFFER_HEXDUMP(">", data, len, ESP_LOG_DEBUG); } return len; / Return number of bytes actually sent to AT port */ }
static void uart_event_task(void *pvParameters) { uart_event_t event; size_t buffer_len;
printf("uart event started");
for(;;) { //Waiting for UART event. if(xQueueReceive(gsm_uart_queue, (void * )&event, (portTickType)portMAX_DELAY)) {
#if 1
printf("uart[%d] event:", GSM_UART_NUM);
#endif
switch(event.type) {
case UART_DATA:
printf("[GSMUART DATA]: %d", event.size);
uart_get_buffered_data_len(GSM_UART_NUM, &buffer_len);
buffer_len = uart_read_bytes(GSM_UART_NUM, (void*) uart_buffer, buffer_len, portMAX_DELAY);
ESP_LOG_BUFFER_HEXDUMP("<", uart_buffer, buffer_len, ESP_LOG_DEBUG);
if (buffer_len) {
#if LWGSM_CFG_INPUT_USE_PROCESS
lwgsm_input_process(uart_buffer, buffer_len);
#else
lwgsm_input(uart_buffer, buffer_len);
#endif
}
break;
case UART_FIFO_OVF:
ESP_LOGW(TAG, "UART_FIFO_OVF");
uart_flush_input(GSM_UART_NUM);
xQueueReset(gsm_uart_queue);
break;
case UART_BUFFER_FULL:
ESP_LOGW(TAG, "UART_BUFFER_FULL");
uart_flush_input(GSM_UART_NUM);
xQueueReset(gsm_uart_queue);
break;
default:
break;
}
}
} vTaskDelete(NULL); } /**
\brief Configure UART using DMA for receive in double buffer mode and IDLE line detection */ static void configure_uart(uint32_t baudrate) { uart_config_t uart_config = { .baud_rate = baudrate, .data_bits = UART_DATA_8_BITS, .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, //.source_clk = UART_SCLK_REF_TICK, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE };
printf("GSMUART Baudrate %d\n", baudrate); printf("GSMUART port %u\n", GSM_UART_NUM);
// uart_intr_config_t uart_int1 = { // .intr_enable_mask = UART_RXFIFO_TOUT_INT_ENA_M | UART_TX_DONE_INT_ENA_M | UART_RXFIFO_FULL_INT_ST_M |UART_TXFIFO_EMPTY_INT_ST_M, /!< UART interrupt enable mask, choose from UART_XXXX_INT_ENA_M under UART_INT_ENA_REG(i), connect with bit-or operator/ // .rx_timeout_thresh = 4 , /!< UART timeout interrupt threshold (unit: time of sending one byte)/ // .txfifo_empty_intr_thresh = UART_TXFIFO_EMPTY_INT_CLR_M, /!< UART TX empty interrupt threshold./ // .rxfifo_full_thresh = UART_RXFIFO_FULL_INT_CLR_M, // };
// ESP_ERROR_CHECK(uart_intr_config(GSM_UART_NUM, &uart_int1) );
ESP_ERROR_CHECK(uart_param_config(GSM_UART_NUM, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(GSM_UART_NUM, 26, 25, 0, 0));
ESP_ERROR_CHECK(uart_driver_install(GSM_UART_NUM, LWGSM_USART_DMA_RX_BUFF_SIZE 2, LWGSM_USART_DMA_RX_BUFF_SIZE 2, 20, &gsm_uart_queue, 0));
} /**
\return lwgsmOK on success, member of \ref lwgsmr_t enumeration otherwise / lwgsmr_t lwgsm_ll_init(lwgsm_ll_t ll) {
/ Step 1: Configure memory for dynamic allocations / static uint8_t memory[0x10000]; / Create memory for dynamic allocations with specific size /
/*
/ Step 2: Set AT port send function to use when we have data to transmit / if (!initialized) { ll->send_fn = send_data; / Set callback function to send data / }
/ Step 3: Configure AT port to be able to send/receive data to/from GSM device / configure_uart(ll->uart.baudrate); / Initialize UART for communication / xTaskCreate(uart_event_task, "uart_lwgsm_task0", 4096, NULL, 5, NULL); initialized = 1; return lwgsmOK; }
/**
\return \ref lwgsmOK on success, member of \ref lwgsmr_t enumeration otherwise / lwgsmr_t lwgsm_ll_deinit(lwgsm_ll_t ll) {
ESP_ERROR_CHECK(uart_driver_delete(GSM_UART_NUM)); initialized = 0; / Clear initialized flag / return lwgsmOK; }
`
i have modified UART_event example from esp32 idf and it works well, i am atleast getting AT response here code and log snippet
` /* Configure parameters of an UART driver,
communication pins and install the driver */ uart_config_t uart_config = { .baud_rate = 115200, .data_bits = UART_DATA_8_BITS, .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE }; uart_param_config(EX_UART_NUM, &uart_config);
esp_log_level_set(TAG, ESP_LOG_INFO); uart_set_pin(EX_UART_NUM, 26, 25, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(EX_UART_NUM, BUF_SIZE 2, BUF_SIZE 2, 20, &uart0_queue, 0);`
`[0;32mI (15771) scan: [Command]: AT [0m [0;32mI (15771) scan: uart[1] event:[0m [0;32mI (15771) scan: [UART DATA]: 9[0m [0;32mI (15771) scan: [IN DATA] AT
OK
[0m`
It was solved It was my mistake as RESET line stayed LOW.
i am trying to use lwgsm library with esp32 and sim7600e, and i am facing problem, i get
i have changed following steps in Library
/ Defines ESP uart number to use /
define GSM_UART_NUM UART_NUM_1
ESP_ERROR_CHECK(uart_set_pin(GSM_UART_NUM, 26, 25, 0, 0));
i had written an uart routine to check AT command with same UART setting i do get AT response from modem. i have insert a debug line in uart events routine, this line is never invoked