Home > other >  Solving ESP8266 as the client cannot connect to the server
Solving ESP8266 as the client cannot connect to the server

Time:09-17

Can connect to the router, but can't connect to the server, try various way, or no, please, help, the following code
 int main (void) 
{
U8 t=0;
U8 temperature;
U8 humidity;
U8 * p;
Int buf [5].

Delay_init ();//delay function to initialize the
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//set the interrupt priority 2:2 and grouped into group a preemption priority, two response priorities
Uart_init (115200);//initialize serial port 115200
Usart3_init (115200);//initialize serial port 3
Usmart_dev. Init (72);//initialize USMART
DHT11_Init ();//DHT11 initialization
ESP8266_STA ();//set to client mode


While (1)
{


The hills u3_printf (" love the sea ");

}

}

 void ESP8266_STA (void) 

{
Const u8 * wifista_ssid="KELIVE"; No.//router SSID
Const u8 * wifista_encryption="wpawpa2_psk";//wpa/connected aes encryption
Const u8 * wifista_password="we157631";//connect password
Const u8 * wifista_severip="192.168.1.100";//server IP
Const u8 * wifista_severport="8080";//port
Const u8 * wifista_severxylx="TCP";//protocol type

U8 * p;
Delay_init ();//delay function to initialize the
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//set the interrupt priority 2:2 and grouped into group a preemption priority, two response priorities
Uart_init (115200);//initialize serial port 115200
Usmart_dev. Init (72);//initialize USMART
Usart3_init (115200);//initialize serial port 3





While (atk_8266_send_cmd (" AT ", "OK," 20))//check if the WIFI module online
{
Atk_8266_quit_trans ();//exit passthrough
Atk_8266_send_cmd (" AT + CIPMODE=0 ", "OK", 200);//close the passthrough mode
}

Atk_8266_send_cmd (" ATE0 ", "OK," 20);//close the echo
//ATK - ESP8266 module Settings
Atk_8266_send_cmd (" AT + CWMODE=1 ", "OK," 50);//set the WIFI STA mode
Atk_8266_send_cmd (" AT + RST ", "OK," 20);
delay_ms(1000);//delay 3 s waiting for the resumption of success
delay_ms(1000);
delay_ms(1000);
delay_ms(1000);
//set to connect to the WIFI network name/encryption/password
Sprintf (p (char *), "AT + CWJAP=" % s \ "and " % s \ "", wifista_ssid, wifista_password);//set wireless parameters: the ssid and password
Atk_8266_send_cmd (p, "OK", 300);//connection target routers, and obtain IP
Atk_8266_send_cmd (" AT + CIPMUX=0 ", "OK," 20);//0: single connection, more than 1: connection
Sprintf (p (char *), "AT + CIPSTART=" TCP \ "and " % s \ "% s", wifista_severip, wifista_severport);
While (atk_8266_send_cmd (200) p, "OK,");
Atk_8266_send_cmd (" AT + CIPMODE=1 ", "OK", 200);
Atk_8266_send_cmd (" AT + CIPSEND ", "OK," 20);

}

CodePudding user response:

Turn off the computer firewall

CodePudding user response:

Upstairs right, should be the server's firewall do bad things

CodePudding user response:

ESP8266_STA itself is a powerful MCU, but also use the AT commands to control, so cough up
  • Related