 Now, what we will do is to add another characteristic, which is of the type notify. So whenever you press the button on the nuclear, there will be some asynchronous data sent to the phone, and you will see the data in the bottom left corner on the screen inside the second characteristic. This is the goal for now. So let's go back to KUPA Max, and let's go again to the MyService, the definition of your own service, and let's add a second characteristic. So I go back to the pin and configuration, the middleware, the vPAN, and the tab is called MyService because I named it this way. I will add a second characteristic. Here it is. Again, we need to name it. So I will name it MyHaraNotify. Again, you can use the same name for the long and short. Here we need to modify the UUID because they need to be unique, and right now the UUID is the same. So just make any change you want. I will set the last byte to 1. The next change is... Yeah, we need to modify the property. We want it to be of type Notify. And this is it. We can regenerate the project and again make some modification in the code. So now comes the tricky part of the hands-on. What we need to do in the application behavior, when we press a button, we want to call a BLE stack API that writes to the characteristic. And when this happens, the BLE stack will send the notification to the phone. The trouble is that the BLE stack can process only single command at a time. In other words, the API is not re-entrant. So it's not a good idea to call it from an interrupt service routine, from example, from the X to interrupt. Instead, we need to create a task which runs in background that calls this API. And that's what we will do right now. We need to make three modifications in three separate files. They are the appconf header file, the appable.c and the custom underscore app.c. So in the appconf header file, we first define the function prototype, which in fact is the task that will be executed. Then on line 567, we define the name of the task. In my case, I call it cfg underscore task, my task. In the appable.c, in the line 257 and 258, you see we register the task and notice especially the last argument, which is the function pointer to my task. And then we set the task. Setting the task means the scheduler will execute it exactly, exactly once. Now let's look at the last file, the custom app.c and first look at the very bottom. You see that the task sets itself at the end of the function, which basically means the function will run in a while loop, but the scheduler is still able to run other tasks as well just by switching between them. The function body of my task is very simple. We simply check the stage of the GPIO that is connected to the button. If the button is pressed, we modify the data. So here you see the XOR operation. The result is that the data will toggle between zero and one and this data will be sent in the notification to the phone. And the function custom myhar notify, it's a function that calls the BListic API and updates the characteristic. There is one point to be careful. The name of the function actually depends on the name of the characteristic that you set in KUPA Max. So it might differ from one to another. So in my case, I called my characteristic myhar notify. If you named it something else, you might need to modify this function name as well. And you can locate the function in the same source file, the custom underscore app.c. So this is just one tricky point to be aware of. I will copy paste the code from the presentation. There's also another option. You can click on the icon of the file on the right and you can copy paste the whole source file. So it's up to you what you decide. I will use the copy from the presentation. So first thing is the appconf, which is in the include folder. So here online, 544. Again, in the user section, I will define the prototype of the function, which is my task. And don't forget to remove the line numbers. Then on the line 567, we define the name of the task. My case is a CFD task, my task. Then I go to the vpan folder, the app folder, and up ble.c and online 257. Here in the user section, I will first register the task. And then set it, which means the scheduler will run it exactly once. Then we go to the custom underscore app.c and define the function body, which in fact is the task itself. So online 85, I will copy paste the function body and remove the line numbers. Again, we check the state of the button. If it's pressed, we modify the data and we update the characteristic. And at the end of the task, we set it again. So let me check if I can compile without errors. I'll give you a little bit more time because this is probably the most difficult part of the whole session. And in the meantime, I will flash my nuclear with this firmware. Connect again, search the service and you will see there is an extra characteristic of type notify. And when we press a button, you will see the value will change from one to zero in the bottom left corner. So let me do that live as well. I'll connect again, see the service has now two characteristics. I enable the notification by pressing the notify in the top right. And now if I press the button, you see the value changes from one to zero. There is no debouncing. So in fact, you may see that the value changes two times on a single button press, but that's simple things to fix later on if you wish. And that's the end of the hands-on. So let's just summarize what we learned. We learned how to create the BLE project from scratch directly in KUPA Max. We learned which peripherals need to be enabled to integrate the Bluetooth middleware. We learned how to define your own BLE service and how to add your characteristics. We also learned how to process some of the events generated by BLE stack. And in the very last part, we learned how to safely call the BLE stack API. So thank you.