The main application has several tasks that it needs to complete, such as the following:
- Instantiate the IotDevice object.
- Initialize the LEDs to Off.
- Create the socket connection.
- Initialize the scheduler.
Let's look at the code for each of these:
- First, instantiate the IotDevice object and initialize the LEDs, as follows:
Device = IotDevice()gpio_off(LED1)gpio_off(LED2)gpio_off(LED3)
- Next, we want to create the socket object and then connect to the socket server. We are going to use a socket server that is hosted on an Android device for our example, but it could easily be hosted on the web somewhere and we could then set up a relay for the socket server, an Android device, and our sensor node. The options are ...