Serial port transmission and interrupt reception of esp8266-SDK

I recently started experimenting with the ESP8266 module, primarily for communication between two ESP8266 devices. The main goal was to configure one as an Access Point (AP) and the other as a Station (STA), enabling them to communicate over a wireless network. Since the module comes with factory firmware, I mainly used a serial port debugging tool to send AT commands and configure the necessary settings. **Basic Configuration of ESP8266 and Serial Communication** **AP Mode (Server): The steps are as follows:** 1. Set the ESP8266 to AP mode using the command `AT+CWMODE=2`. If it was previously configured, you can reset it to factory settings with `AT+RESTORE`. 2. Configure the AP's SSID and password using `AT+CWSAP="ssid","pwd","chl","ecn"`. 3. Restart the module with `AT+RST`. 4. Enable multiple connections by setting `AT+CIPMUX=1`. 5. Start a TCP server on port 5000 using `AT+CIPSERVER=1,5000`. 6. Check the local IP address with `AT+CIFSR` to help the client connect later. 7. Send data using `AT+CIPSEND="link.ID", "length"` once a client connects. **STA Mode (Client): The steps are as follows:** 1. Switch to STA mode with `AT+CWMODE=1`. 2. Restart the module with `AT+RST`. 3. Connect to the AP using `AT+CWJAP="ssid","pwd"`. 4. Establish a TCP connection with `AT+CIPSTART="type","remote IP","remote port"`. Once connected, you can send data using `AT+CIPSEND`. 5. Set the transmission mode with `AT+CIPMODE=1`. 6. Send data using `AT+CIPSEND`. Here’s an example of the AP sending data to the STA via the serial port. Before sending each message, you must use `AT+CIPSEND="link.ID", "length"`. In the image, two messages were sent, resulting in 16 bytes total. For the STA sending data to the AP, since it's in transparent mode, you only need to send `AT+CIPSEND` once. No further commands are needed after that. In the image, three consecutive `AT+CIPSEND` commands were issued along with the message "Hello". **ESP8266 SDK Serial Interrupt Reception and Transmission** **1. Transmission** To start, initialize the serial port using `uart_init(115200, 115200);`, which sets the baud rate for UART0 and UART1. You can then use `uart0_tx_buffer(uint8 *buf, uint16 len)` to send data through UART0. Alternatively, you can use `os_printf()` to print messages, but be cautious if you're using UART1. If you want to redirect `os_printf()` output to UART1, you can change the default output using `Os_install_putc1((void *)uart1_write_char);`. **2. Reception** In the serial initialization function `uart_init()`, there is a task created for receiving data: `system_os_task(uart_recvTask, uart_recvTaskPrio, uart_recvTaskQueue, uart_recvTaskQueueLen);`. This task listens for incoming data on UART0. The serial port is configured with `uart_config(UART0);`, and an interrupt handler is attached using `ETS_UART_INTR_ATTACH(uart0_rx_intr_handler, &(UartDev.rcv_buff));`. Inside the interrupt handler, the system checks for various flags. When the receive FIFO timeout occurs (`UART_RXFIFO_TOUT_INT_ST`), it sends a message to the `uart_recvTask` via `system_os_post()`. In the `uart_recvTask` function, the received data is processed. If buffer mode is enabled, it uses `uart_rx_buff_enq()` to enqueue the data. Otherwise, it reads the FIFO directly, processes each byte, and sends it back using `uart_tx_one_char(UART0, d_tmp)`. You can modify this code to store the received data in a buffer instead of immediately echoing it, allowing for custom processing or storage.

Xenon Lamp Aging Test Chamber

Xenon Lamp Aging Test Chamber,Xenon Lamp Aging Light Tester,Photovoltaic Module Test Box,Xenon Lamp Aging Testing Machine

Wuxi Juxingyao Trading Co., Ltd , https://www.juxingyao.com