Now we need to declare an object of observe our library so we can access its functions, the constructor
of the object to export what the server will be listening to as a parameter, since A-T is the default
port for everything we request, we will use this value.
And you can easily do that by writing this very simple line.
Before the setup method, right observer,
and it should be called observer server and at 80 years.
So we have declared an object from the Observer with this port eighty four HCB request.
Next, we declare that E.S.P 32 general-purpose input output pins to which lid's are connected and we
are going to set their initial state.
Now, to do that for the set up method, define an integer.
And call it led.
And one and we already know that we have connected the dots to PIN number two and five.
So we would like to hear the same line will be written for and number five.
For the second.
Lyd.
Now, let's give them initial value added one status.
Turn it off low and something for little.
Make it law.
OK, now that we have furnished everything before the setup, we thought we will go back to our wireless
network name and password.
Let's move on to the set up function.
We are going to configure our HTP request or server before actually running it.
First of all, we open a serial connection for debugging purposes and we are going to set general-purpose
input output ports to output because they are basically LEDs and we are going to control them as output.
So inside the setup material to begin and use and moderate.
Next, Pinewood just slightly on Arduino, and they are going to either take the print name Litvin one
and make it out or something for the second pen and two, it will be treated as output.
Then we are going to set up a soft access point to establish a Wi-Fi network by providing that as the
password, IP address, IP subnet mask and IP getaway, which are basically this information that we
provided or we added here to do that.
What we need to do inside the setup method is write wi fi.
That soft.
AP And this will take two parameters, this as ID and the password then, right, Wi-Fi, the soft AP
config, and it will take three parameters, the local IP gateway and the subnet.
After that, you can add a delay to make sure that everything is stable.
Now, that's it, let's verify to make sure that we don't have girls.
I like verifying everyone and then to make sure that if there is an error, I can fix it when it happen.
OK, Duncan Barling, we don't have any rules.
Now we come to the most important part of this court in order to handle incoming ACTU requests, we
need to specify which court to execute when a particular girl is hit.
To do so, we use one method.
This method takes two parameters.
First one is a real path, and second one is dunam of function, which we want to execute.
When that you are is hit, for example.
Let's try to write one line and I'll explain it as we write it right server.
Not on.
Now, open to parentheses, the first parameter that will take.
Is the slash and burn unit right, KUMAH, then why the method name that will take control when something
happen?
OK, now this line.
When a server receives an estimate on the growth path, it will trigger the handle connect.
Function, not that they are specified, is a relative path.
Likewise, we can do the same for other are
we can right here let one on and we can name the function led one on the same for other.
Let's serve our own and we are going to write different values here.
Slash led one off and handle led one of same for led to.
We are going to change this to the two and same for here.
Led to let to just to save time and to make sure that we don't care about writing.
Now what will happen here.
Whenever you write the IP address this one, let's say that you write in your browser, I will give
you an example, 182 168 one zero by ten.
And you write this slash.
When they ask people to receive this request, it will run this method.
Now, if you write, let one on, it will execute this method.
And we are going to write this method methods in the loop section.
But for now, this is what I need you to understand now, we haven't specified what the server should
do if the client requests and you are other than the specified Web server on other Valdese, it should
respond with an issue, be status 404 error, which has basically not found a page and a message for
the user.
We put this in a function as well, and we can easily do that by writing server that on not found,
which is one of the functions that we can easily use here.
You need to write the name of the function Quantic.
It will take only one parameter.
So not found.
Okay.
To start our server, we need to write server to begin.
And don't take any parameters, and we can fight a line in the Syrian monitor to make sure that it will
show us SERVERLESS has started, OK, FTB server has started.
This is how to start yourself out once you finish the configuration.
Now let's make a quick review of what we have done here and we initialised that soft access point mode
and give it to parameters, the Wi-Fi network name and the password, and we give it the local IP getaway
and subnet mask.
Then we have the ability to make sure that everything is stable.
After that, we wrote these lines.
The third on will take two parameters, first parameter is they are allowed and the second parameter
is the method.
So when someone requests the you are this one.
It will call the handle on Connect method, and when someone writes lit one, when someone calls this
real, it will call this method and we are going to create these methods in the loop section.
But what you need to know now is that you can add more Yarl's and more requests, and if someone until
they are all that you haven't set here, you can direct him to handle not found a method on not found.
Now, to solve the civil rights era that began, then serial doctorand line and to live this long and
the ceremony or indicating that the civil war has started, let's verify.
OK, now we have a problem which is handled, Internet was not declared, which means that this method
was not yet declared and we haven't yet declared anything in the loop section.
So this is an error that we can't ignore.
And in the next lesson, we are going to start writing the code inside the loop section.
And that's it for now.
Thanks for watching.
This is Asharaf from educational engineering team.