Smart Home IOT Project

Smart Home is the technology used to improve security and control your home using the variety of IOT sensors combined and working together to make the user’s life easier. This is the Singaporean Company project, This project uses the variety of technologies such as  Zwave communication, MQTT for sensors real-time communication, Alexa, Google Home, Door sensors, Multi Sensors, Motion Sensors, temperature sensors, Z-wave switch, temperature sensors and the list goes on and on…

My role as a sole IOS developer in a research and development team, I developed this project from start till the completion as an individual developer. I gained tremendous amount of knowledge on various aspects such as programming IOS, Swift, X-code, Objective-C, MQTT, Z – wave, API implementations, IOT components, Human Interface designs and many more

Some screenshots of the app I developed.

Connecting to MQTT in Swift & IOS

MQTT is a Message Queuing Telemetry Transport protocol, it is also called MQ Telemetry Transport. It is widely used in IOT (Internet of Things) to have a good connectivity between machine and machines (machine-to-machine M2M). It is designed to be  extremely lightweight to publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. It is widely used in different areas like sensor communications, satellite broker link, dialup connection, healthcare providers and home automations. It is extremely ideal for Mobile Application because of its light weight, low power usage and minimised data packets.. For more information about MQTT visit Here.

I recently had a chance to implement it to one of the smart home application i developed, Therefore i thought of sharing my experience relate  to development. I have implemented this Protocol to my IOS application using Swift programming language.

Instruction to implement MQTT

One of the MQTT library available for IOS is called Moscapsule Visit Here

Lets get started……………..

Add these two lines to your podfile

run the command pod install. Then close and open your .workspace file

Now you have the Moscapules added to you project, open your AppDelegate.swift file and ad the following codes. You can see the comments inside the code itself

Thats it, Its very simple to connect, Since you have implemented this code in you AppDelegate, You can start the connection from anywhere inside the application by calling

You can check connection and subscribe to topics

The best way to send to your view controllers is buy Broadcasting the received message in onMessageCallback . Here is how i have done it.

You can add a broadcast receiver to you ViewController so that you can receive this broadcast

Thats it, Its very simple. Hope this helps for someone.

If you have any Question or suggestions please leave it below in the comments section. Happy Coding 🙂 . Enjoy MQTT

 

Smart Home (IOT) Project

Smart Home project done for leading internet service provider in Singapore and Malaysia. Smart Home is a one among many solutions they provide to their customer. Smart home is a complete security solution which supports almost all Z-Wave sensors, IOT devices and many more smart home appliances. This product is also expected to go live with the integration of leading market voice assistant such as Alexa and Google echo voice assistance.

Responsibilities: IOS Developer

  • Requirement analysis and design architecture for mobile programming.
  • Select suitable technology and library such as MQTT for the feasible solution.
  • Design, develop the mobile application IOS platform
  • Collaborate with designing team to ensure best user experience

 Key Areas: #MQTT, #Signal-R, #Swift,  #XML, #Rest, #Json, #pushNotifications, #cocoapods

 

IOS implementing SignalR using Objective-C

For the past few weeks i been doing some research on SignalR in Objective C and i found very few resources available on the internet for implementing signlR in Objective-C. Therefore i thought of writing this tutorial, hoping it will help some developers one day.

In this tutorial i will explain you, how to  get connected to SingalR hub using IOS and Objective-C. This tutorial is not for beginners.

All Information about SignalR Objective-C library can be found in this Link.

Lets setup the environment first. flow the steps below

  1. First of all create a new IOS Objective C project.
  2. Close the project and navigate to the project directory Using Terminal.
  3. Create a new podfile and save the following code. (make sure to change your project name instead of signalRObjective2)
This will install required libraries such as AFNetworkingSocketRocket and as well as SignalR-ObjC

4. Now run the below command  in your terminal

pod install

. This will install all the required libraries and create a file with extension .xcworkspace in side your project folder.

5. Open the file yourproject.xcworkspace file

Now we got over environment setup , lets do the real coding to get connected to SignalR HUB.

In order to do a signal R communication, You need to understand three main factors in Signal R, They are explained below

  1. get connected – You must get connected to signalR Hub and keep the connection with out closing it.
  2. Subscribe to hub method – You must create a subscription to your hub method at the time of connection.
  3. Invoke hun method – You must invoke a hub method, when ever you want to send some message to the Hub and also receive the response through the subscribed method as explained before.

Now lets see how to implement it.

Connection

As you can see from the above code, you will have to tell the signalR hub URl and also the hub proxy name to the signalR-ObjectiveC library.

Then you need to subscribe to the Hub method as shown in the above code. serviceStatus is the hub method and it will return the response to testMethod which is in the client side.

Invoking a method in signalR hub is very simple as shown in the above code. And if you code dont have any parameters. Your invoke will be like this as shown below

That it. Over all Code will be as shown below

That is. If you have any problems are suggestions please be free to comment below, I will be happy to respond them.Thank you. Happy Coding 🙂