App Development: IoT - MQTT Connects Mobile App & IoT Devices

Download App Development: IoT - MQTT Connects Mobile App & IoT Devices

Post on 21-Jan-2018

54 views

Category:

Technology

6 download

TRANSCRIPT

1. MQTT Connects IoT Devices & Mobile App Marvin Heng Twitter : @hmheng Blog : http://hmheng.pinsland.com Github: https://github.com/hmheng 2. Pre-requisites Created a Xamarin mobile app 3. Mobile App that Connects IoT Device via MQTT 1. First, we need to create a Xamarin Cross Platform Mobile App. Dont have one yet? Click to learn how to create one! 4. Mobile App that Connects IoT Device via MQTT 2. Secondly, we need to add a NuGet Packages - MQTTnet, right click Solution in the Solution Explorer -> Manage NuGet Packages for Solution 2b 2a 5. Mobile App that Connects IoT Device via MQTT 3. Lets search MQTTnet and install it to all the projects. 3b3a 3c 6. Mobile App that Connects IoT Device via MQTT 4. Now, we need to add some components to MainPage.xaml as specified below. 4b4a 4c 4 7. Mobile App that Connects IoT Device via MQTT 5. After that, click the code behind MainPage.xaml.cs and add the following usings. 4b4a 4c 8. Mobile App that Connects IoT Device via MQTT 6. Now, replace the constructor as below and declare a mqttClient. 4b4a 4c 9. Mobile App that Connects IoT Device via MQTT 7. Create an Async function for handling BtnConnects click event with the following code. 4b4a 4c 10. Mobile App that Connects IoT Device via MQTT 8. Create an Async function to send the message to MQTT Broker/Server when BtnSend is being clicked. 4b4a 4c 11. Mobile App that Connects IoT Device via MQTT 9. Create an Async function for handling connected event when MqttClient is successfully connected with MQTT Server. 4b4a 4c 12. Mobile App that Connects IoT Device via MQTT 10. Lastly, lets create a function to handle the message it received from Broker. 4b4a 4c 13. Mobile App that Connects IoT Device via MQTT 11. Finally, lets compile and run it on your mobile device. Your MQTT Broker should be able to receive the message for the topic it subscribed to. Desktop MQTT Broker Click to Get Source Code for Testing 14. Awesome! Your Mobile App is Now Able to Connect IoT Devices via the Most Popular Protocol - MQTT 15. MQTT Connects IoT Devices & Mobile App Marvin Heng Twitter : @hmheng Blog : http://hmheng.pinsland.com Github: https://github.com/hmheng

Recommended

View more >