1 00:00:00,630 --> 00:00:04,260 Now, let's let's call a stop function. 2 00:00:05,370 --> 00:00:08,970 The first thing that we need to do is initial ICRA communication. 3 00:00:10,830 --> 00:00:15,240 Kasprzyk portrayed the same portrait and Alduin report. 4 00:00:16,860 --> 00:00:20,370 Then we need to set a time out for the serial communication. 5 00:00:24,400 --> 00:00:27,860 It will be 500 milliseconds, so half a second is enough. 6 00:00:28,570 --> 00:00:36,190 Then let's call the set up wi fi function, ensure that we have the right name. 7 00:00:37,840 --> 00:00:38,380 This is it. 8 00:00:38,380 --> 00:00:39,400 Set up Wi-Fi. 9 00:00:42,430 --> 00:00:54,070 After that, we need to call the client, the server to past the server parameters and will take them 10 00:00:54,090 --> 00:01:10,970 Kutty server link and impurity port as input, then we must call the function reconnect. 11 00:01:13,870 --> 00:01:15,970 Now let's verify our code. 12 00:01:19,540 --> 00:01:25,180 Great, we don't have any issues now we need to define a new function between the set up and look, 13 00:01:25,840 --> 00:01:27,130 let's call it publish. 14 00:01:27,310 --> 00:01:28,780 So we publish. 15 00:01:31,860 --> 00:01:35,220 Syrian thatta. 16 00:01:39,510 --> 00:01:41,460 Now, this function will take. 17 00:01:44,570 --> 00:01:47,000 Serial data as input. 18 00:01:50,970 --> 00:01:54,750 And after taking Syria, that has been bought at will. 19 00:01:57,190 --> 00:02:03,370 Make sure that then community server is connected using an if statement. 20 00:02:07,300 --> 00:02:11,800 No, inside that statement will right if client that connected. 21 00:02:19,240 --> 00:02:21,710 Now, it's not connected. 22 00:02:21,940 --> 00:02:30,280 Call that iConnect function to connect it now once it's connected. 23 00:02:31,210 --> 00:02:36,310 What we need to do is publish the data, so publish 24 00:02:39,190 --> 00:02:48,280 the publish will take the MQ Titi Serial Publish channel. 25 00:02:49,510 --> 00:03:00,210 As both and will also take the serial data from here, and this is already defined here. 26 00:03:03,270 --> 00:03:04,530 See our public channel. 27 00:03:06,140 --> 00:03:10,070 And you can change it to your own published chart. 28 00:03:10,610 --> 00:03:12,470 But for now, let's go back. 29 00:03:13,720 --> 00:03:19,870 OK, now plan to publish darkland will publish this. 30 00:03:21,200 --> 00:03:28,250 Serial data to this channel after making sure that the computer server is connected. 31 00:03:29,820 --> 00:03:32,920 Now, this is the removal from this function inside the world. 32 00:03:33,080 --> 00:03:37,980 We are going to call this function so inside the oilor we will ask. 33 00:03:39,800 --> 00:03:44,580 First, let's call a client that lub function. 34 00:03:47,450 --> 00:03:48,740 Now we will ask if. 35 00:03:51,670 --> 00:04:03,090 That cereal that available is more than zero or above zero, it means that we have incoming cereal data 36 00:04:03,670 --> 00:04:09,610 and in that case, if we have incoming cereal, that's what we need to do, is take the cereal that 37 00:04:09,610 --> 00:04:11,010 are installed and a variable. 38 00:04:11,020 --> 00:04:13,320 So we will define our character. 39 00:04:14,020 --> 00:04:15,040 Let's call it Mafa. 40 00:04:17,490 --> 00:04:18,080 Deathtoll. 41 00:04:20,060 --> 00:04:21,980 And you can make it. 42 00:04:25,030 --> 00:04:32,860 This will be an array of characters and its size will be 500, then you can change the decide whatever 43 00:04:33,400 --> 00:04:34,390 fits your needs. 44 00:04:35,440 --> 00:04:36,640 After doing this. 45 00:04:38,610 --> 00:04:48,600 We are going to use a function as a function called me, set the Killara function by name, said Koby's, 46 00:04:48,600 --> 00:04:55,320 the character to the first in characters of the string pointed by the array. 47 00:04:55,440 --> 00:04:57,560 Now I will write it down. 48 00:04:57,600 --> 00:04:58,920 Then I will explain to you. 49 00:04:58,920 --> 00:05:08,670 And while you are using it here, the first thing that you need to write here is me set inside it. 50 00:05:08,970 --> 00:05:13,110 It will take the buffer as input. 51 00:05:14,430 --> 00:05:26,910 And zero, then the buffer data of this size, which is 510 now, what this function will do is the 52 00:05:26,910 --> 00:05:27,300 following. 53 00:05:27,600 --> 00:05:29,800 The first thing, that buffer data. 54 00:05:30,300 --> 00:05:33,080 This is the pointer to the block of New Autofill. 55 00:05:33,240 --> 00:05:36,390 So we need to fill this block of limmer with data. 56 00:05:37,080 --> 00:05:42,780 Now, the second parameter, which is this number zero, this is the value to be set. 57 00:05:43,150 --> 00:05:49,500 The value is passed as integer, but the function fills the block of an order using the unsigned char 58 00:05:49,500 --> 00:05:50,760 conversion of the value. 59 00:05:52,230 --> 00:05:58,830 Now we come to the last variable or the last element, which is five hundred and ten, this is the number 60 00:05:58,830 --> 00:06:02,400 of bytes to be said to the value, which is basically the size of the early. 61 00:06:04,530 --> 00:06:11,940 And this function will return a pointer to the area where buffer data is told. 62 00:06:13,500 --> 00:06:20,220 Now we need to read the data until we see a new line, which is basically what we did, not our accord, 63 00:06:20,580 --> 00:06:25,690 we say we have sent data and at the end of each block of data, we are adding a new line. 64 00:06:26,220 --> 00:06:26,730 So. 65 00:06:26,860 --> 00:06:34,770 Right, serial the trade bites until. 66 00:06:37,710 --> 00:06:40,470 And here are going to other conditions. 67 00:06:41,460 --> 00:06:49,530 First thing is LaShun, which is a new line and the data that we will read will be stored here in the 68 00:06:49,530 --> 00:06:55,480 Buffalo data and the data size, let's make it 500. 69 00:06:55,620 --> 00:07:00,560 We already have an array with a size over 500, 510. 70 00:07:00,930 --> 00:07:04,530 So 500 is the same value to be inserted here. 71 00:07:04,890 --> 00:07:13,620 Usually you have to set a value that's below Baddeley size after this and then you need to publish this 72 00:07:13,620 --> 00:07:14,140 data. 73 00:07:14,580 --> 00:07:21,690 So bubblish serial data, this is the function that we defined here. 74 00:07:25,070 --> 00:07:31,110 And we'll take that that that we did receive as input, which is the above our data. 75 00:07:32,120 --> 00:07:41,210 So this function will read the incoming serial data and saw it here until a new line is, uh, sent 76 00:07:41,210 --> 00:07:42,730 from arguin to E.S.P. 77 00:07:43,220 --> 00:07:51,740 Then it will send the data to the published serial data function, which takes that that has input and 78 00:07:51,740 --> 00:07:55,190 this function and make sure that time Kutty server is connected. 79 00:07:55,790 --> 00:08:02,350 After making sure that it's connected, it will publish the data to the immediately serial channel. 80 00:08:02,990 --> 00:08:10,610 And as you can see it, this is the serial that which is the main function of our coding practice here. 81 00:08:10,780 --> 00:08:15,200 Now, again, what we have done here, let me zoom out. 82 00:08:18,250 --> 00:08:27,220 We have created defined some variables and we have used them Kutty Library, the wildfire library to 83 00:08:27,230 --> 00:08:33,160 set up fire to make sure that we are connecting or we are connected to our Wi-Fi network and we are 84 00:08:33,160 --> 00:08:33,760 online. 85 00:08:34,270 --> 00:08:41,080 That iConnect function is to make sure that we are connected to the computer server and we have the 86 00:08:41,080 --> 00:08:48,370 set up function where we have connect to Wi-Fi and to the computer server. 87 00:08:49,360 --> 00:08:56,020 Then we have the loop, which will make sure that we are all we have incoming serial data. 88 00:08:57,760 --> 00:09:04,030 And it will store the incoming signal that are inside this variable before that, which is basically 89 00:09:04,030 --> 00:09:11,160 an array of character and will send it to the publisher and data function, which is this one first, 90 00:09:11,500 --> 00:09:14,860 we will make sure that we are connected to the computer server. 91 00:09:15,340 --> 00:09:20,480 Then we will publish the data to this channel that we already find here. 92 00:09:21,700 --> 00:09:26,830 So this is our main coding practice for Legazpi 32. 93 00:09:27,530 --> 00:09:32,890 The next lesson, we are going to sort this out and make sure that it's working just fine. 94 00:09:33,520 --> 00:09:37,960 If you have any questions regarding any of these lines, please ask exactly what enabled. 95 00:09:38,350 --> 00:09:44,170 Now, just to make sure that we don't have any errors, let's verify our code one more time. 96 00:09:45,390 --> 00:09:51,900 OK, now we have an ear, as you can see, Cyril, that was not declared, it's here. 97 00:09:52,260 --> 00:09:55,770 So we have a spelling error. 98 00:09:56,100 --> 00:09:57,030 Verify again. 99 00:09:59,950 --> 00:10:02,090 Then combining without any errors. 100 00:10:02,380 --> 00:10:02,990 That's it. 101 00:10:03,280 --> 00:10:11,920 Now, we might have to change the values for our Wi-Fi network name and password and for the username 102 00:10:11,920 --> 00:10:18,100 and password and the channel or the server links depending on our needs. 103 00:10:18,160 --> 00:10:26,890 Now, if you are using your own API, you can simply send the serial data to your own API using Jason 104 00:10:26,890 --> 00:10:33,050 coding or any other method that fits your need, your needs. 105 00:10:33,070 --> 00:10:35,630 But for now, I'm using the computer to server. 106 00:10:35,660 --> 00:10:38,600 So this is the coding practice for this server. 107 00:10:39,040 --> 00:10:41,650 It's a very well known and widely used one. 108 00:10:42,100 --> 00:10:50,080 So I will change that Wi-Fi network values and the username and password values with mine. 109 00:10:50,380 --> 00:10:52,820 Then we will test this code out. 110 00:10:53,170 --> 00:10:57,430 Thanks for sharing with us on this asharaf from educational engineering team.