LinkControl is an automation application that can be used to control lights, dimmers, motors and other physical devices. This application is essentially a button processing application that needs to be paired with a server component that ultimately controls the physical devices. LinkControl downloads button definitions from the server application and when a button is pressed an identifier associated with the button is returned to the server indicating which button was pressed. With that information the server decides the appropriate next step. LinkControl has no knowledge of the overall process as it just handles button definitions and button presses. The server process could connect to a lighting controller such as one made by Lutron using telnet, or perhaps connect to a Z-Wave system through a WIFI/Z-Wave bridge. Other configurations are possible.
A definition of the client-server protocol used between the LinkControl application running on the iPhone/iPad and the server can be found in the following file:client-server-protocol.docx. ( if a logon dialog box pops up, just cancel out of it since there are no requirements to logon to read this document ).
A sample version of the Server code written in Python 2.7 is available in the file below. Running this file under Python should provide enough functionality to test out the basic operation of the client code running on an iPhone or iPad (LinkControl). Just set the server address and port number in LinkControl to match the server address and the port value in the python file. Download the sample Python server code from LinkControlServer.py.
There are three settings:
- Server Address: this can be either the IP address of the server or the name of the server.
- Server Port Number: the port number that the server process is using, programmed into the server process.
- Password: the password that the server process will accept and allow the client to connect. Again this is part of the server process programming. The sample python server provided above does not implement the password option so any value will do when communicating with that server.
The "Reset" switch on the settings view is used to disconnect the network connection and then reconnect it. It can be useful to use this switch when the connection to the server has been interrupted for some reason and a reconnect is required. The LinkControl client will attempt to reconnect automatically for a period of time, but by using this switch it will reconnect immediately.
LinkControl reconnects to the server and re-downloads the button definitions and the current state of each button whenever it becomes active. This includes the simple case of switching to another application on the iPhone and then switching back to LinkControl. At the switch back moment LinkControl contacts the server and re-establishes its connection, resulting in a fresh download of button information and button state information. LinkControl tries to show the same view that had been previously showing the last time it had an active connection to the server. Through this simple reconnection logic, the button states shown in LinkControl should be accurate.