From 5d0f0c9a42880025fb55b7e0f863b54bca3a384b Mon Sep 17 00:00:00 2001 From: Shabir Mohamed Date: Sun, 11 Oct 2015 15:37:03 +0530 Subject: [PATCH] small corrections with firealarm sample --- modules/samples/firealarm/build.xml | 2 +- .../samples/firealarm/sketch/startservice.sh | 34 ++++++++++++++++++- .../service/impl/FireAlarmManagerService.java | 12 ------- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/modules/samples/firealarm/build.xml b/modules/samples/firealarm/build.xml index 2680e19d..92dafa81 100644 --- a/modules/samples/firealarm/build.xml +++ b/modules/samples/firealarm/build.xml @@ -33,7 +33,7 @@ ${data_source} - The datasource used for Arduino database + The datasource used for Firealarm database jdbc/${data_source} diff --git a/modules/samples/firealarm/sketch/startservice.sh b/modules/samples/firealarm/sketch/startservice.sh index 7019a368..b324e9d0 100644 --- a/modules/samples/firealarm/sketch/startservice.sh +++ b/modules/samples/firealarm/sketch/startservice.sh @@ -2,13 +2,45 @@ echo "----------------------------------------------------------------" echo "| WSO2 IOT Sample " -echo "| RaspiAlarm " +echo "| Virtual RaspiAlarm " echo "| ---------------- " echo "| ....initializing startup-script " echo "----------------------------------------------------------------" unzip firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar.zip + +while true; do + read -p "What is the network-interface of your PC that the Agent should use (find from ifconfig. ex: wlan0,en0,eth0..) > " interface + + if [ $interface -eq $interface 2>/dev/null ] + then + echo "Setting the network-interface to " $interface + sed s/^network-interface=.*/network-interface=$interface/ deviceConfig.properties > myTmp + mv -f myTmp deviceConfig.properties + rm myTmp + break; + else + echo "Please select an appropriate interface from those which are listed on ifconfig." + fi +done + +while true; do + read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-IoT-Server (ex: '60' indicates 1 minute) > " interval + + if [ $interval -eq $interval 2>/dev/null ] + then + echo "Setting data-push interval to " $interval " seconds." + sed s/^push-interval=.*/push-interval=$interval/ deviceConfig.properties > myTmp + mv -f myTmp deviceConfig.properties + rm myTmp + break; + else + echo "Input needs to be an integer indicating the number seconds between successive data-pushes." + fi +done + + java -jar firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar diff --git a/modules/samples/firealarm/src/org.wso2.carbon.device.mgt.iot.sample.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/firealarm/service/impl/FireAlarmManagerService.java b/modules/samples/firealarm/src/org.wso2.carbon.device.mgt.iot.sample.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/firealarm/service/impl/FireAlarmManagerService.java index 35dc4601..5ce29421 100644 --- a/modules/samples/firealarm/src/org.wso2.carbon.device.mgt.iot.sample.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/firealarm/service/impl/FireAlarmManagerService.java +++ b/modules/samples/firealarm/src/org.wso2.carbon.device.mgt.iot.sample.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/firealarm/service/impl/FireAlarmManagerService.java @@ -51,10 +51,7 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; import java.util.List; -import java.util.Properties; import java.util.UUID; //@Path("/FireAlarmDeviceManager") @@ -303,15 +300,6 @@ public class FireAlarmManagerService { String accessToken = accessTokenInfo.getAccess_token(); String refreshToken = accessTokenInfo.getRefresh_token(); //adding registering data -// -// -// Properties props = System.getProperties(); -// Enumeration e = props.propertyNames(); -// -// while (e.hasMoreElements()) { -// String key = (String) e.nextElement(); -// log.info(key + " -- " + props.getProperty(key)); -// } XmppAccount newXmppAccount = new XmppAccount(); newXmppAccount.setAccountName(owner + "_" + deviceId);