Right now, we have created the back end for our droid, even though this is very simple, we must go
through this simple example in order to understand the whole process.
Let us go to the Origin ID and let us start.
Well, this is going to be a little bit of a long program now.
Do you remember our connecting to Wi-Fi sketch?
You can go back to the connecting to Wi-Fi sketch lecture and download it and we can start at this exact
point.
Well, I want to start at this point because the Hello World for not MCU is actually just connecting
the Wi-Fi router we have now.
What do we need to add in order to connect to you?
There is a library that we need to install.
First, we need to go to Jewelz managed libraries and we need to make sure that that library is installed.
The lover is called Bob Sub Client, short for publish subscribe client, so we're going to search for
Bob so client know you'll find a lot of libraries when you do that.
I want you to scroll down and choose exactly this one.
It's called Bob Sub Client, nothing else.
As I said, there was a lot of support line tools.
There is a lot of them.
I just want you to choose this client, two point eight point zero, OK, and install this specific
version, OK?
After that, you will be able to add that library.
Now, we don't need this uplink anymore, so I'm going to replace this with Bob.
So blind and please watch for the capitalization, it should turn orange like that if the library was
found next.
We want to add the variable, which is the pointer to our server, so we have a const.
Char.
Pointer.
Executed server.
What what is the name of our server?
It's called the broker DOT.
Hive and cue.
Dot com.
OK, this is the name of the server that we are connecting to, and this is the name we have set up
in our DURET infrastructure.
OK, great.
What's next?
I want to create a wi fi claim to do that, we're just going to call wi fi client like this.
And I'm going to call it note MCU.
Client, OK.
This is very important in order to pass it to my next.
Thing, which is the amputee client, so we need Bob, so.
Client.
We're going to call the client.
And we are going to to it the following ambiguity server.
Which is this one, and I'm going to pursue it, deport no.
Remember the port no.
We're using for the high of MPU is one eight eight three.
I'm going to call something called Goldbeck.
And also, I need to pass the note MCU.
Now it's time to explain what the heck is going on here.
The first thing is I flightline it's very simple.
My wife, my client is the one that will connect you to your router.
Right.
So this so this is very simple.
It's just saying that, hey, Mignot, MCU is a client of Wi-Fi.
It means that I want the capabilities in order to connect this to Wi-Fi.
OK, so right now I don't mind not MCU into a Wi-Fi client next in order to create a client for ambiguity,
remember that security protocol is based on the client exchanging messages over topics.
So now I am saying, hey, I want my not MCU to be executed client.
And in order to do that, I need to initialize this client with certain parameters like, OK, you're
saying to me that this is my client.
What's the address of that server or the broker that I need to connect to?
Right.
The remember the topologies?
We had a user interface, we had a broker, and then we have sensors.
So now those sensors need to know which broker they are dealing with.
This is why I have my own server right here, which is a broker I've mq dot com.
OK, and you need to add the number.
So these two informations now are clear.
I'm going to skip this callback back for a second and I'm going to jump here.
You're going to say, OK, you're telling me this is an executed client and you're creating one and
you're connecting it to the server.
But through which Wi-Fi client you want to do that?
Well, since we are equipping our not MCU with Wi-Fi capabilities, we need to pass these Wi-Fi capabilities
in order to connect to the router in the first place.
Right.
So you can say that this is your router, you're connecting to it.
This is the server or the broker you're connecting to, and this is the port.
OK, if there is anything that is not clear here, please write to me in the Cairney and I will be really
glad to help you understand this concept further.
If there is some ambiguity in now, what is this callback?
Well, callback actually is a very, very important concept and nodes.
So it's not really related to not dread as it is related to the Noguez itself is event driven programming
language.
What does this mean?
It means that it can execute multiple stops at the same time without a lot of effort and programming.
Now, do you remember the original code?
We are executing line by line and we are always blocking the next instruction, right?
Let's say I am executing this.
Let's say this one takes one second, even though this is not correct, is just an example.
I cannot really jump to this unless this one is finished in execution and not.
Yes, it's not like that energy.
As you initiate the instruction, you let it go and you'll let it work and you can jump to the next
one.
Let's say you want to establish this wi fi, begin right here.
You can just initiated let it go and do its stuff in order to initialize the Wi-Fi and at the same time,
maybe to jump into this delay, see my point and advantage you if you just start things and you can
jump to the next instruction.
Now, here comes the role of the callback.
The goal back is what you initiated something to start doing some process.
Now, when it's done, it's going to give you a callback, like, hey, OK, I'm done.
This is the result of what I have been doing.
So it's sending you an event that, hey, I'm done, take the information and do with it whatever you
want.
So let's say I initiated this wi fi client and it's going to initialize some wi fi parameters.
Now, I will jump to the next instruction and this one is in the process.
Whenever this is done, even though I am still in the middle of this, I'm going to receive an event
saying, hey, this process is done and this is the result.
Do whatever you want with it.
I'm going to do some processing and then I'm going to go back here.
So there is a lot of multithreaded going on.
And Noguez, this is why it's a great, great programming language for observers, because our observer,
you wanted to do multiple stuff at the same time without the blocking other things.
Right.
This is why it's a really powerful language.
I really encourage you after finishing this course to go and just read a little bit about it and.
Like enforce yourself with this powerful programming language, especially if you want to go with Iot
and you want to do some Web server programming.
No, this is where the callback is going to take place.
Now, this is why they call like it is important.
You're saying you that something is going to subscribe to me.
I'm going to be doing some stuff.
I'm going to give a callback back in order to do something with the information I got, let's say,
in our case.
We have an on button we're going to press and on button.
OK.
And the gold is going to do whatever it wants.
When it's finished, it's going to give me a call back that.
OK, you have the on button.
What do you want to do with it?
This is why a call back is important in this case.