Thales IoT Developer Community
Terminal GPIO Demo
Showcase, July 7, 2017 - 12:19pm, 6358 views
Cinterion EHS6 Terminals - GPIO demo
Terminal GPIO usage and set-up showcase
AT Command parsing via SMS
Cell based location via SMS
Module hardware and network status via SMS
Download File src.zip
(zip | 56.21 KB)
Download File 2017_07_03_Terminal_GPIO_Demo.pdf
(pdf | 934.84 KB)
Customer query:
I have a Project with an EHS6 USB Terminal which should be configured via a Java MIDlet.
It is an Alarm system which has 3 outputs which react to 3 different sensors and
are connected via the GPIOS of the terminal.
My task is to respond to which one of the sensors the terminal is sending an SMS.
EXAMPLE:
Sensor_1 GPIO12: Alert_01;
Sensor_2 GPIO13: Alert_02;
Sensor_3 GPIO14: Alert_03;
My question would be, how do I have to change the Java code so that the MIDlet 3 different GPIOS
with 3 different SMS messages can process?
You can copy, duplicate and modify the basic ButtonHandler.java file to create three buttons ButtonA, ButtonB etc...
Modify which GPIO to monitor:
public static String gpioPin = gpioPin11;
// Actual GPIO to use
In the class ExternalDevice.java method "start()" you can link to the three ButtonHandlers A,B and C:
// Allows Button Handler to tell us about a "button down" event on the Concept board
if (buttonListenerA == null) {
buttonListenerA = new ExternalDeviceButtonHandlerListenerA();
if (buttonListenerA != null) {
ButtonHandlerA.getInstance().addButtonListener(buttonListenerA);
}
}...
Of course, to take actions you'll need to make three ExternalDeviceButtonHandlerListeners too...
// ------------------------------------------------------------- //
class ExternalDeviceButtonHandlerListenerA implements InPortListener {
final boolean DEBUG = false;
public void ExternalDeviceButtonHandlerListenerA() {
}
public void portValueChanged(int changedInPortValue) {
if (DEBUG) {System.out.println("[ExternalDeviceButtonHandlerListenerA]: " + changedInPortValue);}
if (changedInPortValue == ButtonHandler.BUTTON_DOWN_ON) {
ExternalDevice.alarmStateA = ButtonHandler.BUTTON_DOWN_ON;
SubscriptionHandler.getInstance().sendAdhocBroadcastToAllSubscribersBySMS("Alarm_A", SmsHandler.CLASS1);
}
if (changedInPortValue == ButtonHandler.BUTTON_UP_OFF) {
ExternalDevice.alarmStateA = ButtonHandler.BUTTON_UP_OFF;
SubscriptionHandler.getInstance().sendAdhocBroadcastToAllSubscribersBySMS("Disarm_A", SmsHandler.CLASS1);
}
}
}
// ------------------------------------------------------------- //