need help with changing some code...

Hello guys
im new in arduino and i am trying to make some projects.
i use this tut :: ESP8266 Android App To Control Arduino Digital Pins and Toggle LEDs

now i want to use ESP8266 library for Arduino : GitHub - itead/ITEADLIB_Arduino_WeeESP8266: An easy-to-use Arduino ESP8266 library besed on AT firmware.

is there anyone can help me to change the normal code to codes using library?
i go this far

#include <doxygen.h>
#include "ESP8266.h"
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //moshakhas kardane pin haye LCD
SoftwareSerial mySerial(7, 8); // moshakhas kardane pin haye wifi
ESP8266 wifi(mySerial);

#define SSID        "Arsalan Wifi"  //UserName wifi
#define PASSWORD    "arsalan123"  //Password wifi

void setup() {
  lcd.begin(20, 4);     
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  digitalWrite(13,HIGH);
  String IP;
  Serial.print("setup begin\r\n");
  lcd.print("Connecting to Wifi");
  delay(3000);
  Serial.print("FW Version: ");
  
//  Serial.println(wifi.getVersion().c_str());
  
  
 
    if (wifi.setOprToStation()) {
        Serial.print("to station ok\r\n");

    } else {
        Serial.print("to station err\r\n");

    }

    if (wifi.joinAP(SSID, PASSWORD)) {
        Serial.print("Join AP success\r\n");
        Serial.print("IP: ");       
        Serial.println(wifi.getLocalIP().c_str());
        IP = wifi.getLocalIP().c_str();
        lcd.setCursor(0, 1);
        lcd.print("Join AP success");
        lcd.setCursor(0, 2);
        lcd.print("IP: "+IP);
    } else {
        Serial.print("Join AP failure\r\n");
        lcd.setCursor(0, 1);
        lcd.print("Join AP failure");
        lcd.setCursor(0, 2);
        lcd.print("Contact Administrator");
    }
     if (wifi.enableMUX()) {
        Serial.print("multiple ok\r\n");
    } else {
        Serial.print("multiple err\r\n");
    }
    if (wifi.startTCPServer(80)) {
        Serial.print("start tcp server ok\r\n");
        lcd.setCursor(0, 3);
        lcd.print("Server Ready");
    } else {
        Serial.print("start tcp server err\r\n");
        lcd.setCursor(0, 3);
        lcd.print("Server Setup Fail");
    }
    if (wifi.setTCPServerTimeout(10)) { 
        Serial.print("set tcp server timout 10 seconds\r\n");
    } else {
        Serial.print("set tcp server timout err\r\n");
    }
  
    
    Serial.print("setup end\r\n");

}

but i dont know how to change this part.

void loop()
{
  if(esp8266.available()) // check if the esp is sending a message 
  {
 
    
    if(esp8266.find("+IPD,"))
    {
     delay(1000); // wait for the serial buffer to fill up (read all the serial data)
     // get the connection id so that we can then disconnect
     int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns 
                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48
          
     esp8266.find("pin="); // advance cursor to "pin="
          
     int pinNumber = (esp8266.read()-48); // get first number i.e. if the pin 13 then the 1st number is 1
     int secondNumber = (esp8266.read()-48);
     if(secondNumber>=0 && secondNumber<=9)
     {
      pinNumber*=10;
      pinNumber +=secondNumber; // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number
     }
     
     digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin    
     
     // build string that is send back to device that is requesting pin toggle
     String content;
     content = "Pin ";
     content += pinNumber;
     content += " is ";
     
     if(digitalRead(pinNumber))
     {
       content += "ON";
     }
     else
     {
       content += "OFF";
     }
     
     sendHTTPResponse(connectionId,content);
     
     // make close command
     String closeCommand = "AT+CIPCLOSE="; 
     closeCommand+=connectionId; // append connection id
     closeCommand+="\r\n";
     
     sendCommand(closeCommand,1000,DEBUG); // close connection
    }
  }
}
 
/*
* Name: sendData
* Description: Function used to send data to ESP8266.
* Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no)
* Returns: The response from the esp8266 (if there is a reponse)
*/
String sendData(String command, const int timeout, boolean debug)
{
    String response = "";
    
    int dataSize = command.length();
    char data[dataSize];
    command.toCharArray(data,dataSize);
           
    esp8266.write(data,dataSize); // send the read character to the esp8266
    if(debug)
    {
      Serial.println("\r\n====== HTTP Response From Arduino ======");
      Serial.write(data,dataSize);
      Serial.println("\r\n========================================");
    }
    
    long int time = millis();
    
    while( (time+timeout) > millis())
    {
      while(esp8266.available())
      {
        
        // The esp has data so display its output to the serial window 
        char c = esp8266.read(); // read the next character.
        response+=c;
      }  
    }
    
    if(debug)
    {
      Serial.print(response);
    }
    
    return response;
}
 
/*
* Name: sendHTTPResponse
* Description: Function that sends HTTP 200, HTML UTF-8 response
*/
void sendHTTPResponse(int connectionId, String content)
{
     
     // build HTTP response
     String httpResponse;
     String httpHeader;
     // HTTP Header
     httpHeader = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n"; 
     httpHeader += "Content-Length: ";
     httpHeader += content.length();
     httpHeader += "\r\n";
     httpHeader +="Connection: close\r\n\r\n";
     httpResponse = httpHeader + content + " "; // There is a bug in this code: the last character of "content" is not sent, I cheated by adding this extra space
     sendCIPData(connectionId,httpResponse);
}
 
/*
* Name: sendCIPDATA
* Description: sends a CIPSEND=<connectionId>,<data> command
*
*/
void sendCIPData(int connectionId, String data)
{
   String cipSend = "AT+CIPSEND=";
   cipSend += connectionId;
   cipSend += ",";
   cipSend +=data.length();
   cipSend +="\r\n";
   sendCommand(cipSend,1000,DEBUG);
   sendData(data,1000,DEBUG);
}
 
/*
* Name: sendCommand
* Description: Function used to send data to ESP8266.
* Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no)
* Returns: The response from the esp8266 (if there is a reponse)
*/
String sendCommand(String command, const int timeout, boolean debug)
{
    String response = "";
           
    esp8266.print(command); // send the read character to the esp8266
    
    long int time = millis();
    
    while( (time+timeout) > millis())
    {
      while(esp8266.available())
      {
        
        // The esp has data so display its output to the serial window 
        char c = esp8266.read(); // read the next character.
        response+=c;
      }  
    }
    
    if(debug)
    {
      Serial.print(response);
    }
    
    return response;
}

sorry for my bad english,
anyone can help me please? :confused:

but i dont know how to change this part.

Change it to do what?

PaulS:
Change it to do what?

change it buy library codes. cuz when i use library for ESP8622 these codes wont work . so i want them using library code.

change it buy library codes

Buy them from where?

when i use library for ESP8622 these codes wont work .

The code does something. You haven't explained what it does. You want the code to do something. Presumably, what you want it to do is not the same as what it currently does. I haven't a clue what you want it to do.

PaulS:
Buy them from where?
The code does something. You haven't explained what it does. You want the code to do something. Presumably, what you want it to do is not the same as what it currently does. I haven't a clue what you want it to do.

i mean by * missspell. change it by library codes.

the code exactly do what i want, but i download the library folder and if i want to use library files i have to change them, for example :

sendCommand("AT+RST\r\n",2000,DEBUG); // reset module
  sendCommand("AT+CWMODE=1\r\n",1000,DEBUG); // configure as access point
  sendCommand("AT+CWJAP=\"Arsalan Wifi\",\"123arsalan\"\r\n",3000,DEBUG);
  delay(10000);
  sendCommand("AT+CIFSR\r\n",1000,DEBUG); // get ip address
  sendCommand("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
  sendCommand("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80

this codes reset madule , configure as access point , connect to wifi modem, get ip, configure for multiple connections, turn server on port 80

now i install library folder and i have to change them like this :

#define SSID        "Arsalan Wifi"  //UserName wifi
#define PASSWORD    "arsalan123"  //Password wifi
if (wifi.setOprToStation()) {
        Serial.print("to station ok\r\n");

    } else {
        Serial.print("to station err\r\n");

    }

    if (wifi.joinAP(SSID, PASSWORD)) {
        Serial.print("Join AP success\r\n");
        Serial.print("IP: ");       
        Serial.println(wifi.getLocalIP().c_str());
    } else {
        Serial.print("Join AP failure\r\n");
        lcd.setCursor(0, 1);
    }
     if (wifi.enableMUX()) {
        Serial.print("multiple ok\r\n");
    } else {
        Serial.print("multiple err\r\n");
    }
    if (wifi.startTCPServer(80)) {
        Serial.print("start tcp server ok\r\n");
    } else {
        Serial.print("start tcp server err\r\n");
    }
    if (wifi.setTCPServerTimeout(10)) { 
        Serial.print("set tcp server timout 10 seconds\r\n");
    } else {
        Serial.print("set tcp server timout err\r\n");
    }
  
    
    Serial.print("setup end\r\n");

it doese the same , but using library, now i want the rest of the codes using library, i hope u can understand me.

anyone? please?

The lines of code you want to change are for sending ASCII commands to an ESP8266 with AT-firmware.
When you use Arduino-core for ESP you make the same operations differently.

Example:
Instead of writing

sendCommand("AT+CWJAP=\"Arsalan Wifi\",\"123arsalan\"\r\n",3000,DEBUG);

You might write

WiFi.begin("Arsalan Wifi", "123arsalan");

Look at the examples for ESP for ideas on how to do.