1
00:00:02,320 --> 00:00:08,410
Now that we are done with the first part of our code, let's move on and create a method so that we

2
00:00:08,410 --> 00:00:10,720
can connect to Wi-Fi networks easily.

3
00:00:11,980 --> 00:00:17,530
Let's limit the was set up by five.

4
00:00:22,940 --> 00:00:23,420
Now

5
00:00:26,240 --> 00:00:37,160
inside this method, just a delay of 20 milliseconds and serial the brand new line,

6
00:00:40,520 --> 00:00:45,710
let's bring something to tell you, though, that we are connecting to I from the that motor.

7
00:00:59,950 --> 00:01:01,360
OK, now.

8
00:01:03,170 --> 00:01:04,850
It's quite dynamic with the I fight.

9
00:01:09,900 --> 00:01:23,750
All right, it's a I thought that why I don't begin to start connecting to this, why is this I.D. and

10
00:01:23,750 --> 00:01:30,460
passport so it would take to qualify this ID and password?

11
00:01:30,470 --> 00:01:41,120
I will try to connect now, which are the line statement, if qualify

12
00:01:44,090 --> 00:01:44,960
the status.

13
00:01:48,150 --> 00:01:49,860
Is not connected,

14
00:01:54,270 --> 00:01:59,760
then we need to delay and try again.

15
00:02:09,190 --> 00:02:12,490
And while it's trying to connect, we need to train.

16
00:02:14,830 --> 00:02:16,210
OK, now.

17
00:02:18,780 --> 00:02:25,800
After this, after the wall, that wall keeps trying, we'll keep trying, connecting to the wife Typekit

18
00:02:25,800 --> 00:02:27,870
work, we need to add.

19
00:02:29,930 --> 00:02:33,710
Once it's connected, it will keep rolling this until it's connected.

20
00:02:34,280 --> 00:02:40,970
Now, once it's connected, we need to write Syria to the brand

21
00:02:43,580 --> 00:02:44,210
new line.

22
00:02:46,880 --> 00:02:47,840
No Wi-Fi

23
00:02:51,350 --> 00:02:52,400
is connected.

24
00:02:56,310 --> 00:02:58,530
And we can't even print the IP address.

25
00:03:14,340 --> 00:03:19,080
And to print it, we need to call a function called verify

26
00:03:21,870 --> 00:03:23,760
the local IP.

27
00:03:28,940 --> 00:03:35,390
This world will terror the IP address to our ISP, 32 bodies connected and will print it out on the

28
00:03:35,390 --> 00:03:35,960
sea that I'm on it.

29
00:03:36,320 --> 00:03:41,480
Now let's verify the code to make sure that everything is working just fine.

30
00:03:42,690 --> 00:03:43,070
OK.

31
00:03:45,060 --> 00:03:45,690
That's it.

32
00:03:46,280 --> 00:03:48,330
Now this is the first function.

33
00:03:49,050 --> 00:03:57,910
Now the second function is to reconnect, now void to connect.

34
00:04:02,070 --> 00:04:05,220
Now we will know until we are reconnected.

35
00:04:05,490 --> 00:04:08,260
So we'll add a wild statement.

36
00:04:09,660 --> 00:04:15,540
This is basically a function to make sure that we are connected to the NQT server.

37
00:04:15,780 --> 00:04:26,100
So while it's clear that connected

38
00:04:28,680 --> 00:04:31,260
is not true, we need to try.

39
00:04:35,350 --> 00:04:36,030
To reconnect.

40
00:04:37,490 --> 00:04:40,790
So let's try to the different.

41
00:04:44,820 --> 00:04:55,080
A typical thing to reconnect and your TV connection.

42
00:05:00,890 --> 00:05:04,730
OK, now the next line will be pliant.

43
00:05:08,790 --> 00:05:09,870
The publisher

44
00:05:14,610 --> 00:05:19,610
inside it will write out topic.

45
00:05:23,730 --> 00:05:24,190
That's right.

46
00:05:24,310 --> 00:05:26,630
Hello, world.

47
00:05:29,900 --> 00:05:36,740
Now, let's create a random client ID, string client I.D..

48
00:05:39,630 --> 00:05:48,780
Let's call it, yes, be 32 clients, and you cannot do anything

49
00:05:51,420 --> 00:05:57,960
after that, we kind of had client idea.

50
00:06:02,510 --> 00:06:05,690
B+ equal strength.

51
00:06:08,700 --> 00:06:11,940
And so this thing, we can add a random function.

52
00:06:16,380 --> 00:06:17,020
0X

53
00:06:19,770 --> 00:06:28,890
and for us now, we can make sure that takes over the time, and this will make sure that each side

54
00:06:28,890 --> 00:06:34,530
will have a new client ID that is unique because we are getting the value.

55
00:06:36,030 --> 00:06:43,260
And we are adding it to that previous value so we can remove this number and which Typekit will be,

56
00:06:43,260 --> 00:06:44,670
the idea will be this.

57
00:06:46,520 --> 00:06:51,860
Plus, the last thing that comes out from this line now.

58
00:06:54,220 --> 00:07:00,700
Let's attempt to connect, but if statement, then else.

59
00:07:02,680 --> 00:07:13,540
Let's start with that statement now inside that statement, we need to ask if a client that connects

60
00:07:14,140 --> 00:07:22,900
function, which usually takes that client I.D. to this one does.

61
00:07:25,510 --> 00:07:32,560
Now they're going to use a function called C String, which basically converts the contents of a string

62
00:07:32,650 --> 00:07:39,490
as a C style, which is the one that we need for this if statement and to use it, we just need to write

63
00:07:39,490 --> 00:07:43,240
c underscore STR.

64
00:07:45,580 --> 00:07:59,110
Then we can add MQ 3T user, which is basically the user name for the server in Q T password.

65
00:08:08,420 --> 00:08:09,590
OK, last

66
00:08:12,170 --> 00:08:20,420
now, as you can see, it takes the Kinect function, takes three things the client I.D., the user

67
00:08:21,020 --> 00:08:30,200
and the password after that, if that statement is true, we can can print

68
00:08:32,990 --> 00:08:35,180
the word connected and Barcelona later.

69
00:08:35,630 --> 00:08:37,010
So brand new line.

70
00:08:44,210 --> 00:08:52,370
OK, now, once connected, we can publish an announcement by writing Client not publish

71
00:08:56,210 --> 00:08:57,770
inside that we can write.

72
00:09:00,080 --> 00:09:00,800
I see.

73
00:09:03,820 --> 00:09:04,630
Results.

74
00:09:08,470 --> 00:09:10,810
And yes, we first saw.

75
00:09:13,020 --> 00:09:15,960
Now that announcement will be.

76
00:09:18,090 --> 00:09:20,640
Hello, world.

77
00:09:23,810 --> 00:09:34,160
Now, otherwise, if this condition didn't hit, we need to go to the health department and inside it.

78
00:09:34,730 --> 00:09:36,110
We need to right field.

79
00:09:45,350 --> 00:09:54,650
And we can also add another line that says are equal and leave us space.

80
00:09:56,780 --> 00:10:07,220
We will print out the Lion State, so serial the trend line the state.

81
00:10:12,750 --> 00:10:13,230
Now.

82
00:10:14,700 --> 00:10:17,030
Let's make sure that we have everything correct.

83
00:10:17,510 --> 00:10:18,420
Battleground.

84
00:10:22,310 --> 00:10:26,840
The state function, OK, now, try again in five seconds.

85
00:10:39,070 --> 00:10:42,790
And we can add a delay of five or six seconds

86
00:10:46,300 --> 00:10:47,980
to give it time to try again.

87
00:10:48,760 --> 00:10:49,090
OK.

88
00:10:52,610 --> 00:10:53,270
That's it.

89
00:10:53,540 --> 00:10:59,260
This is the reconnect function for the NQT server.

90
00:10:59,630 --> 00:11:02,600
Now we can't have this call at the end.

91
00:11:02,960 --> 00:11:06,170
But for now, this is everything that we need.

92
00:11:06,170 --> 00:11:12,030
First, we need to make sure that the client is not connected if it's not connected.

93
00:11:12,050 --> 00:11:18,260
We need to know that we are attempting to connect and we need to set a Client ID.

94
00:11:19,220 --> 00:11:27,950
Now, if we have seen that Client I.D. MQ, the user name and password, it will connect.

95
00:11:28,640 --> 00:11:32,450
If there is any problem, there is no internet connection or any other problem.

96
00:11:32,870 --> 00:11:40,580
It will print failed to print the state of this client and to print that you should try again in a few

97
00:11:40,580 --> 00:11:47,510
seconds and will add a delay to make sure that you are signed after a good amount of time.

98
00:11:49,520 --> 00:11:51,680
Now we did verify our code.

99
00:11:53,280 --> 00:11:59,330
We only get OK, an error that plant idea is not defined because we have c small.

100
00:12:00,140 --> 00:12:01,370
So let's make it the capital.

101
00:12:05,800 --> 00:12:06,170
OK.

102
00:12:06,250 --> 00:12:08,500
Then compiling everything is correct.

103
00:12:09,130 --> 00:12:16,000
And the next lesson, we are going to start the setup up and loop function coding, but that's it for

104
00:12:16,000 --> 00:12:16,330
now.

105
00:12:17,230 --> 00:12:22,930
If you have any question, please ask in the Q&amp;A about this is Usha from educational engineering team.
