Specifications

AVIDdirector-M2M Technical Reference Guide
February 5, 2009 ©AVIDwireless 2004-2009 All Rights Reserved Page 36 of 55
Appendix 4 Sample M2Mlet for Simulation Board
This is the Demo M2Mlet that is used with the AVIDdirector-M2M Simulation board. The Simulation board has the
following port assignments:
Pin M2MXML
Address
Function
1 TTL1.AIN Potentiometer provides 0 to +5V reading (0 to 4095)
2 TTL2.AOUT Light bulb glows in proportion to value of 0 to 63
3 TTL3.DOUT Green LED 1=Turn LED on
4 TTL4.DOUT Red LED 1=Turn LED on
5 TTL5.DIN Push Button 1=Push button is pressed
6 TTL6.DIN Toggle switch, 1=towards connector, 0=rear of board.
The M2Mlet performs these functions:
§ Initializes the TTL1 to TTL6 ports to their specific function.
§ TTL1 (the potentiometer) is set to the value must change by +/-30 units before a new reading is set to the
M2MXML portal, and a reading is sent no more than once every 10 seconds
§ Changing the potentiometer will be converted to a level to send to the light bulb, which is a driven by a
transistor. Potentiometer readings from 0 to 4095 are converted to Analog output values of 0 to 63
§ TTL3 and TTL4 LEDs correspond to the TTL5 and TTL6 switches.
§ TTL5 switch is set to only send a reading to the portal when pressed. Releasing the button does not send a
reading
§ TTL6 toggle switch will send a reading whenever it is switched.
§ The M2MApp.ini configuration propertyM2MLET.DEMO_ENABLED is used to enable or disable the M2Mlet. If
the property is set to false or no, then the M2Mlet is not initialized during start(). If this is set, such as by
using the SetConfiguration command, then the M2Mlet is initialized and started running. The method
processSetConfigurationItem handles dynamically enabling or disabling the M2Mlet. Setting
M2MLET.DEMO_ENABLED to false allows disabling the demonstration M2Mlet without requiring the user to
connect to the debug / console port and manually editing the M2MApp.ini file.
package com.avidwireless.AVIDdirector;
// get the AVIDdirector specific classes
import com.avidwireless.AVIDdirector.AVIDdirectorApp;
import com.avidwireless.AVIDdirector.M2Mlet;
import com.avidwireless.AVIDdirector.M2M_IO;
import com.avidwireless.AVIDdirector.iodevice.*;
import com.avidwireless.AVIDdirector.IllegalHardwareAddressException;
import com.avidwireless.AVIDdirector.InvalidHardwareOperationException;
import com.avidwireless.AVIDdirector.AvidUtil;
import com.avidwireless.AVIDdirector.Logger;
// the M2M-XML command types
import com.sensorlogic.messages.M2MXML_Messages;
import com.sensorlogic.messages.TelemetryMessage;
import com.sensorlogic.messages.PerceptRequest;
import com.sensorlogic.messages.Response;
// standard Java classes
import javax.comm.SerialPort;
import javax.comm.CommPortIdentifier;
import javax.comm.NoSuchPortException;
import javax.comm.PortInUseException;
import javax.comm.UnsupportedCommOperationException;
import java.io.OutputStream;