HTTP Connection ( GET / POST ), Example C# Code

2020. 1. 20. 11:49ESP/설정

1. AP

 

SSID = "Your SSID"

PASSWORD = "Your Password"

 

 

 

 

2. 접속서버

 

HOST = "my_test.com"

PORT NUMBER = 80

 

 

 

 

3. AT Commands

 

// set Station mode

AT+CWMODE=1     

 

// Lists available APs.                  

AT+CWLAP                     

 

// access to the internet        
AT+CWJAP="SSID","password"      

 

// Establishes TCP connection, UDP transmission or SSL connection

AT+CIPSTART="TCP","my_test.com",80

 

// Sends data when length of data is , or when \0 appears in the data

AT+AT+CIPSENDEX=93

 

// SEND DATA
POST /quiinc/event.php?id=S0000001&status=1 HTTP/1.0
Host: my_test.com
Connection: close

 

 

 

 

4. Exapmpe Code ( C# )

 

        private void Btn_esp_set_4_Click(object sender, RoutedEventArgs e)
        {            
            // Establishes TCP connection, UDP transmission or SSL connection
            AT+CIPSTART="TCP","my_test.com",80 

 

            Delay.MS(300);

 

            // POST
            str = "POST " + "/quiinc/event.php?id=S0000001&status=1" + " HTTP/1.0\r\n" +
                "Host: " + "my_test.com\r\n" +
                "Connection: close\r\n\r\n";

 

           // Sends data when length of data is , or when \0 appears in the data
            term.WriteCmd = "AT+CIPSENDEX=" + str.Length + "\r\n";

 

            Delay.MS(300);


            term.WriteCmd = str;
        }

 

 

 

5. Run