I recently started playing the ESP8266 module, which is mainly used for communication between two ESP8266s. The main reason is to configure two ESP8266 into AP mode (server) and STA mode (client). Through the configuration to make it communicate, since the firmware has been configured at the factory, we mainly use the serial port debugging assistant to configure some commands required by the AT command.
Basic configuration of ESP8266 and serial communication AP mode (server): The steps are as follows1, AP mode settings (command: AT + CWMODE = 2); / / If previously set, this time you want to reconfigure, you can use the command: "AT + RESTORE" to restore the factory settings.
2. Configure the AP parameters of ESP8266 (instruction: AT+CWSAP=“ssidâ€, “pwdâ€, “chlâ€, “ecnâ€);
3. Restart (command: AT+RST);
4, set up multiple connections, open the TCP server (command: AT + CIPMUX = 1);
5, establish a TCP Server (command: AT + CIPSERVER = 1, 5000);
6, query the local IP address (for the convenience of the latter client connection) (command: AT + CIFSR);
7, send the data (after the completion of the above 6 steps, do not write the instruction, because there is no client access) (command: AT + CIPSEND = "link.ID", "length")
STA mode (client): The steps are as follows1, STA mode settings (command: AT + CWMODE = 1);
2. Restart (command: AT+RST);
3. Connect to the AP (command: AT+CWJAP=“ssidâ€, “pwdâ€);
4, establish a TCP connection (command: AT + CIPSTART = "type", "remote IP", "remote port"); (after the execution of the instruction, you can configure the send data command on the server: AT + CIPSEND)
5, set the transmission mode (command: AT + CIPMODE = 1);
6, send data (command: AT + CIPSEND);
The following is an example of an AP (server) sending information to a STA (client) through a serial port (every message is sent before sending a message: AT+CIPSEND=“link.IDâ€, “lengthâ€)
(On the left is the client on the right side of the server) (sent twice in the picture, so there are 16 8)
The following is an example of the STA (client) sending information to the AP (server) through the serial port (because it is set to transparent mode, it only needs to send an instruction once: AT+CIPSEND, and no need to input the command after sending the message later.)
(On the left is the client on the right side of the server) (three consecutive "AT+CIPSEND" and "Hello")
esp8266-SDK serial interrupt reception and transmission 1, the transmissionCall uart_init (115200, 115200); initialize the serial port, the baud rate is set to 115200. The previous one is to set the baud rate of uart0, the latter is the setting, the baud rate of uart
Then you can use uart0_tx_buffer(uint8 *buf, uint16 len) to send data from uart0, and you can also use os_printf() function to send data, but you need to pay attention to if you are using serial port 1
I want to use os_printf() to modify
Os_printf This interface is printed by default from UART 0. Uart_init in IOT_Demo can set the baud rate, where
Os_install_putc1((void *)uart1_write_char) Change os_printf to print from UART 1
2, receivingEnter the serial port initialization function uart_init, you can see the following function
System_os_task(uart_recvTask, uart_recvTaskPrio, uart_recvTaskQueue, uart_recvTaskQueueLen);
This function is to create a task, which is to use the receiving data of serial port 0, for example.
Uart_config(UART0);
This is the configuration serial port register, in this there is a callback function that sets the serial port.
ETS_UART_INTR_ATTACH(uart0_rx_intr_handler, &(UartDev.rcv_buff));
The serial port callback function uart0_rx_intr_handler is set with ETS_UART_INTR_ATTACH
There are various interrupt flag judgments in uart0_rx_intr_handler, and the normal situation will enter UART_RXFIFO_TOUT_INT_ST, that is, the time to stop the transmission exceeds the set trick.
Limit, then call system_os_post to send a message to the task uart_recvTask created in the initialization function uart_init, and then look at uart_recvTask(os_event_t *events)
LOCAL void ICACHE_FLASH_ATTR ///////
uart_recvTask(os_event_t *events)
{
If(events-》sig == 0){
#if UART_BUFF_EN
Uart_rx_buff_enq();
#else
Uint8 fifo_len = (READ_PERI_REG(UART_STATUS(UART0))》UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT;
Uint8 d_tmp = 0;
Uint8 idx=0;
For(idx=0;idx"fifo_len;idx++) {
D_tmp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF;
Uart_tx_one_char(UART0, d_tmp);
}
WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
Uart_rx_intr_enable(UART0);
#endif
}else if(events-》sig == 1){
#if UART_BUFF_EN
//already move uart buffer output to uart empty interrupt
//tx_start_uart_buffer(UART0);
#else
#endif
}
}
In this case, the received data is sent through uart_tx_one_char(UART0, d_tmp); one by one, if we want to process
The data you receive yourself can be processed by putting it in the buffer.
Electrode sheets can be divided into different electrode sheets according to different standards, for example: self-adhesive electrode sheets, if according to the material can be divided into 1. PET self-adhesive electrode sheet 2 silicone self-adhesive electrode sheet, 3 silicone self-adhesive electrode sheet 4, others Button self-adhesive electrode sheet; silica gel electrode sheet can be divided into water-absorbing electrode sheet, heating electrode sheet, conductive electrode sheet and so on according to the purpose. In addition to the electrode pads, there are electrode wires and related physiotherapy products related to them.
Conductive Sheet,Conductive Plastic Sheet,Thermal Conductive Sheet,Conductive Rubber Sheet
Original Electronics Technology (Suzhou) Co., Ltd. , https://www.original-te.com