Home | PODdevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | | About Us
 



Forward Logo (image)      

Mobile Phone Controlled PODdevices
A Tutorial Part 3 - Led Controller PODdevice Messages

by Matthew Ford 12th December 2010
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.

Led Controller PODdevice™ Messages
(Protocol for Operations Discovery)

Outline of the Tutorial

Part 1 – Introduction to PODdevices™

Part 2 – POD Mobile Phone Application

Part 3 – Led Controller PODdevice™ Messages

Part 4 – Coding the Led Controller PODdevice

Part 1 of the tutorial introduced PODdevices™ and the covered the specification of the operation discovery protocol. Part 2 of this tutorial covered the mobile phone PODapp. This part of the tutorial covers the messages the Led Controller will send and receive as a PODdevice. As a PODdevice, the Led Controller will advertise its functionality to the PODapp™ and let the user control the Led. For the Led Controller this functionality will include turning the Led on and off, fading the led on and fading it off, increasing and decreasing the brightness and two sub-menus, one to set specific levels, High, Med, Low and another to display the current level setting and led current.

Led Controller PODdevice™ Messages

The first step is to design the messages the Led Controller is going to use to advertise it functions. The messages will be tested against the Mobile Phone PODapp™ to see how they will appear to the user, before coding them in the Led Controller.

The PODdevice™ Main Menu

Start by connection the Mobile Phone PODapp™ to a terminal emulator on your PC (see Connecting the PODapp™ To TeraTerm ). On connection the PODapp™ automatically sends the getMainMenu message, {.}. The Led Controller PODdevice™ should respond to this with its main menu of functionality. In this case we will advertise the following navigation commands, fade on, brighter and one sub-menu. A place holder command d is also sent so we can update this naviagation menu later. (Note: The PC connection in the PODapp™ has 0 character timeout so the PODapp™ will wait indefinitely for you to enter your response. However when connecting to the real PODdevice, Led Controller needs to respond within its timeout settings. See the POD specification for details)

Following the POD specification we assign command characters to these menu items, o for on/off, f for fade up/down, u for up, d for down, l for Set Level sub-menu, a for Data submenu.
{^Led Control||m~menu|u~Brighter|d|f~Fade On}
Entering this message into the terminal window sends it to the MobilePhone PODapp. (Hint: type the message into notepad first, get it correct and then cut and paste it into the terminal window)



On receiving this main menu, the PODapp™ displays it.



The POD specification also allows for sending an optional menu title which has been done here. If the menu title is not sent by the PODdevice, the PODapp™ to should display something suitable. The PODapp™ provide in this tutorial will display the device name for the main menu title.

The Fade On/Off Command

When the user sends the Fade On command, the PODapp™ sends the message {f}. The Led Controller then should turn the Led on and send back a menu update that changes the Fade On display to Fade Off so the user can toggle the Led on and off using the same menu item. When the led is on the Darker display shown so the menu update also needs to be include the display text for the d command in the Led Controller's response.

Following the POD specification for menu updates, the Led Controller needs to send back display updates for the o and f commands.
{:|u~Brighter|d~Darker|f~Fade Off}



The PODapp™ now displays



The Up and Down Commands

Sending the Brighter or Darker menu items send the messages {u} and {d} respectively to the Led Controller to increase or decrease the led brightness and update the menu depending on whether or not the maximum brightness has been reached or the led has been turned off.

The Sub-Menu

The > menu item sends the message {m} and the Led Controller responds with the sub-menu.




The PODapp™ displays



This menu has two further sub-menus, Set Level and Data

The Set Level Menu

Choosing the Set Level item displays sends the message {l} to the PODdevice™ which responds with the menu
{.|1~Low|2~Medium|3~High|0~Off}



This menu message did not include a menu title and it was left to the PODapp™ to set something appropriate. This PODapp™ uses the display name of the command sent as the menu title, i.e Set Level ->




Low, Medium, High and Off Commands

Each of these menu items send the associated command when selected. That is Low sends {1}, Medium sends {2}, High send {3} and Off sends {0}. The Led Controller sets the corresponding led level and since there is no update needed for this menu, the Led Controller just sends back an empty command, {}, to let the PODapp™ know it has received and processed the command. For example

The PODapp™ has a refresh button that can be used to re-request the current menu

In this case it the PODapp™ resends {l} to re-request the Set Level sub-menu and the Led Controller responds with the Set Level menu as before.


The PODapp™ also has a <- Back button to go back to the previous menu. The PODapp™ does this by re-requesting the previous menu from the PODdevice. In this case to choosing <- Back sends {m} to the Led Controller to re-request the previous menu.

The Data Sub-Menu

Selecting the Data-> menu item sends {a} to the Led Controller which responds with the Data sub-menu. This menu contains two items Light Level and Led Current with associated commands v and i



The PODapp™ displays




The Light Level Command

Selecting Light Level sends the message, {v}, to the Led Controller. The Led Controller responds with a streaming raw data message {=} and then sends the present value of the level and the % setpoint.



The PODapp™ displays a streaming raw data screen with the data sent by the Led Controller.



The Led Controller can continue to send as much raw data as it likes, although the PODapp™ may need to discard old data to make room for the newer data.

The Led Current Command

Going back to the Data menu and selecting the Led Current menu item sends the message {i} and the Led Controller responds with the same streaming raw data message, {=}, but this time follows it with the % Led current reading.



Pressing Refresh re-sends the last command to the Led Controller and the Led Controller responds with the present Led Current reading.

That completes the commands that will be supported by the Led Controller PODdevice. The next section will cover the modifications needed to the existing Mobile Phone controlled Led Driver to make it a PODdevice™ that provides these functions.


PODdevice™ and PODapp™ are trade marks of Forward Computing and Control Pty. Ltd.


Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2012 Forward Computing and Control Pty. Ltd. ACN 003 669 994