1 00:00:00,540 --> 00:00:07,890 Now we need to declare an object of observe our library so we can access its functions, the constructor 2 00:00:07,890 --> 00:00:15,930 of the object to export what the server will be listening to as a parameter, since A-T is the default 3 00:00:15,930 --> 00:00:19,830 port for everything we request, we will use this value. 4 00:00:20,610 --> 00:00:24,900 And you can easily do that by writing this very simple line. 5 00:00:27,770 --> 00:00:30,390 Before the setup method, right observer, 6 00:00:33,440 --> 00:00:41,750 and it should be called observer server and at 80 years. 7 00:00:43,370 --> 00:00:52,450 So we have declared an object from the Observer with this port eighty four HCB request. 8 00:00:53,600 --> 00:01:01,820 Next, we declare that E.S.P 32 general-purpose input output pins to which lid's are connected and we 9 00:01:01,820 --> 00:01:03,740 are going to set their initial state. 10 00:01:06,220 --> 00:01:12,850 Now, to do that for the set up method, define an integer. 11 00:01:17,440 --> 00:01:18,640 And call it led. 12 00:01:19,640 --> 00:01:29,540 And one and we already know that we have connected the dots to PIN number two and five. 13 00:01:31,270 --> 00:01:39,460 So we would like to hear the same line will be written for and number five. 14 00:01:43,450 --> 00:01:44,410 For the second. 15 00:01:45,410 --> 00:01:45,830 Lyd. 16 00:01:47,610 --> 00:01:54,660 Now, let's give them initial value added one status. 17 00:01:56,760 --> 00:02:02,120 Turn it off low and something for little. 18 00:02:04,640 --> 00:02:05,450 Make it law. 19 00:02:06,470 --> 00:02:13,790 OK, now that we have furnished everything before the setup, we thought we will go back to our wireless 20 00:02:13,790 --> 00:02:15,480 network name and password. 21 00:02:16,700 --> 00:02:19,210 Let's move on to the set up function. 22 00:02:20,330 --> 00:02:25,780 We are going to configure our HTP request or server before actually running it. 23 00:02:26,150 --> 00:02:33,260 First of all, we open a serial connection for debugging purposes and we are going to set general-purpose 24 00:02:33,260 --> 00:02:41,400 input output ports to output because they are basically LEDs and we are going to control them as output. 25 00:02:42,260 --> 00:02:49,520 So inside the setup material to begin and use and moderate. 26 00:02:53,260 --> 00:03:03,190 Next, Pinewood just slightly on Arduino, and they are going to either take the print name Litvin one 27 00:03:04,600 --> 00:03:15,510 and make it out or something for the second pen and two, it will be treated as output. 28 00:03:16,240 --> 00:03:23,950 Then we are going to set up a soft access point to establish a Wi-Fi network by providing that as the 29 00:03:24,190 --> 00:03:31,720 password, IP address, IP subnet mask and IP getaway, which are basically this information that we 30 00:03:31,720 --> 00:03:35,500 provided or we added here to do that. 31 00:03:35,710 --> 00:03:40,870 What we need to do inside the setup method is write wi fi. 32 00:03:44,350 --> 00:03:45,880 That soft. 33 00:03:47,700 --> 00:04:01,680 AP And this will take two parameters, this as ID and the password then, right, Wi-Fi, the soft AP 34 00:04:01,680 --> 00:04:14,880 config, and it will take three parameters, the local IP gateway and the subnet. 35 00:04:17,810 --> 00:04:23,960 After that, you can add a delay to make sure that everything is stable. 36 00:04:26,320 --> 00:04:31,140 Now, that's it, let's verify to make sure that we don't have girls. 37 00:04:33,330 --> 00:04:40,520 I like verifying everyone and then to make sure that if there is an error, I can fix it when it happen. 38 00:04:42,390 --> 00:04:44,580 OK, Duncan Barling, we don't have any rules. 39 00:04:46,230 --> 00:04:53,700 Now we come to the most important part of this court in order to handle incoming ACTU requests, we 40 00:04:53,700 --> 00:04:59,470 need to specify which court to execute when a particular girl is hit. 41 00:05:00,390 --> 00:05:02,940 To do so, we use one method. 42 00:05:03,690 --> 00:05:05,570 This method takes two parameters. 43 00:05:05,730 --> 00:05:13,470 First one is a real path, and second one is dunam of function, which we want to execute. 44 00:05:13,860 --> 00:05:17,370 When that you are is hit, for example. 45 00:05:18,580 --> 00:05:24,640 Let's try to write one line and I'll explain it as we write it right server. 46 00:05:26,360 --> 00:05:27,990 Not on. 47 00:05:29,990 --> 00:05:36,800 Now, open to parentheses, the first parameter that will take. 48 00:05:38,420 --> 00:05:50,600 Is the slash and burn unit right, KUMAH, then why the method name that will take control when something 49 00:05:50,600 --> 00:05:50,900 happen? 50 00:05:53,850 --> 00:05:56,670 OK, now this line. 51 00:05:58,550 --> 00:06:05,810 When a server receives an estimate on the growth path, it will trigger the handle connect. 52 00:06:07,470 --> 00:06:12,420 Function, not that they are specified, is a relative path. 53 00:06:13,710 --> 00:06:16,320 Likewise, we can do the same for other are 54 00:06:19,200 --> 00:06:32,400 we can right here let one on and we can name the function led one on the same for other. 55 00:06:32,940 --> 00:06:39,600 Let's serve our own and we are going to write different values here. 56 00:06:40,050 --> 00:06:52,800 Slash led one off and handle led one of same for led to. 57 00:06:53,730 --> 00:06:59,190 We are going to change this to the two and same for here. 58 00:06:59,340 --> 00:07:05,300 Led to let to just to save time and to make sure that we don't care about writing. 59 00:07:05,320 --> 00:07:07,410 Now what will happen here. 60 00:07:07,740 --> 00:07:15,060 Whenever you write the IP address this one, let's say that you write in your browser, I will give 61 00:07:15,060 --> 00:07:18,870 you an example, 182 168 one zero by ten. 62 00:07:19,260 --> 00:07:21,320 And you write this slash. 63 00:07:21,870 --> 00:07:26,510 When they ask people to receive this request, it will run this method. 64 00:07:27,360 --> 00:07:32,400 Now, if you write, let one on, it will execute this method. 65 00:07:32,640 --> 00:07:37,620 And we are going to write this method methods in the loop section. 66 00:07:38,750 --> 00:07:44,990 But for now, this is what I need you to understand now, we haven't specified what the server should 67 00:07:44,990 --> 00:07:54,410 do if the client requests and you are other than the specified Web server on other Valdese, it should 68 00:07:54,410 --> 00:08:02,810 respond with an issue, be status 404 error, which has basically not found a page and a message for 69 00:08:02,810 --> 00:08:03,360 the user. 70 00:08:03,920 --> 00:08:16,790 We put this in a function as well, and we can easily do that by writing server that on not found, 71 00:08:16,790 --> 00:08:21,410 which is one of the functions that we can easily use here. 72 00:08:21,420 --> 00:08:23,840 You need to write the name of the function Quantic. 73 00:08:24,020 --> 00:08:25,450 It will take only one parameter. 74 00:08:26,540 --> 00:08:29,720 So not found. 75 00:08:30,770 --> 00:08:31,180 Okay. 76 00:08:35,290 --> 00:08:39,610 To start our server, we need to write server to begin. 77 00:08:42,250 --> 00:08:50,890 And don't take any parameters, and we can fight a line in the Syrian monitor to make sure that it will 78 00:08:50,890 --> 00:08:59,800 show us SERVERLESS has started, OK, FTB server has started. 79 00:09:02,660 --> 00:09:05,630 This is how to start yourself out once you finish the configuration. 80 00:09:05,660 --> 00:09:14,390 Now let's make a quick review of what we have done here and we initialised that soft access point mode 81 00:09:14,900 --> 00:09:23,060 and give it to parameters, the Wi-Fi network name and the password, and we give it the local IP getaway 82 00:09:23,060 --> 00:09:24,170 and subnet mask. 83 00:09:24,810 --> 00:09:27,910 Then we have the ability to make sure that everything is stable. 84 00:09:28,460 --> 00:09:30,620 After that, we wrote these lines. 85 00:09:32,800 --> 00:09:39,280 The third on will take two parameters, first parameter is they are allowed and the second parameter 86 00:09:39,280 --> 00:09:40,010 is the method. 87 00:09:40,420 --> 00:09:44,050 So when someone requests the you are this one. 88 00:09:45,360 --> 00:09:51,690 It will call the handle on Connect method, and when someone writes lit one, when someone calls this 89 00:09:51,690 --> 00:09:57,600 real, it will call this method and we are going to create these methods in the loop section. 90 00:09:59,350 --> 00:10:07,470 But what you need to know now is that you can add more Yarl's and more requests, and if someone until 91 00:10:07,490 --> 00:10:16,060 they are all that you haven't set here, you can direct him to handle not found a method on not found. 92 00:10:16,970 --> 00:10:25,340 Now, to solve the civil rights era that began, then serial doctorand line and to live this long and 93 00:10:25,340 --> 00:10:29,960 the ceremony or indicating that the civil war has started, let's verify. 94 00:10:36,280 --> 00:10:43,390 OK, now we have a problem which is handled, Internet was not declared, which means that this method 95 00:10:43,870 --> 00:10:47,550 was not yet declared and we haven't yet declared anything in the loop section. 96 00:10:47,560 --> 00:10:50,360 So this is an error that we can't ignore. 97 00:10:50,830 --> 00:10:55,660 And in the next lesson, we are going to start writing the code inside the loop section. 98 00:10:56,050 --> 00:10:57,160 And that's it for now. 99 00:10:57,190 --> 00:10:57,990 Thanks for watching. 100 00:10:58,000 --> 00:11:01,320 This is Asharaf from educational engineering team.