From a0ee671515195d5fd9f205809d6e0f8f12b892a6 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 25 Oct 2015 02:32:19 +0530 Subject: [PATCH] resolved errors on sample build and few changes on android service --- modules/distribution/pom.xml | 4 +- modules/samples/android_sense/build.xml | 13 +++ .../impl/AndroidSenseControllerService.java | 99 ++----------------- .../pom.xml | 10 ++ 4 files changed, 32 insertions(+), 94 deletions(-) diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml index 481e8af6..1ee51cb7 100644 --- a/modules/distribution/pom.xml +++ b/modules/distribution/pom.xml @@ -245,6 +245,8 @@ + + @@ -271,7 +273,7 @@ - diff --git a/modules/samples/android_sense/build.xml b/modules/samples/android_sense/build.xml index dcd93d1c..2224a67b 100644 --- a/modules/samples/android_sense/build.xml +++ b/modules/samples/android_sense/build.xml @@ -61,6 +61,17 @@ + + + + + + + + + + + @@ -79,6 +90,8 @@ + + diff --git a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java index 81dc7ebb..2e1c16b9 100644 --- a/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java +++ b/modules/samples/android_sense/src/org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/android/sense/service/impl/AndroidSenseControllerService.java @@ -1,12 +1,12 @@ /* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,6 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService; -import org.wso2.carbon.device.mgt.iot.common.exception.DeviceControllerException; -import org.wso2.carbon.device.mgt.iot.common.sensormgt.SensorDataManager; -import org.wso2.carbon.device.mgt.iot.common.sensormgt.SensorRecord; import org.wso2.carbon.device.mgt.iot.sample.android.sense.plugin.constants.AndroidSenseConstants; import org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl.util.DeviceJSON; import org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl.util.SensorJSON; @@ -71,11 +68,9 @@ public class AndroidSenseControllerService { switch (sensor.key){ case "light" : streamDef = LIGHT_STREAM_DEFINITION; payloadData = new Object[]{Float.parseFloat(sensor.value)}; - SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"light",sensor.value,sensor.time); break; case "battery" : streamDef = BATTERY_STREAM_DEFINITION; payloadData = new Object[]{Float.parseFloat(sensor.value)}; - SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"battery",sensor.value,sensor.time); break; case "GPS" : streamDef = GPS_STREAM_DEFINITION; String gpsValue =sensor.value; @@ -84,7 +79,6 @@ public class AndroidSenseControllerService { gpsValuesF[0] = Float.parseFloat(gpsValues[0]); gpsValuesF[1] = Float.parseFloat(gpsValues[0]); payloadData = gpsValuesF; - SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"gps",sensor.value,sensor.time); break; default : try { @@ -96,9 +90,10 @@ public class AndroidSenseControllerService { String valuesM[]=value.split(","); Float gValuesF[]= new Float[1]; gValuesF[0] = Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0]); - payloadData = gValuesF; - SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"magnetic",sensor.value,sensor.time); + }else if(androidSensorId==5){ + streamDef = LIGHT_STREAM_DEFINITION; + payloadData = new Object[]{Float.parseFloat(sensor.value)}; } }catch(NumberFormatException e){ continue; @@ -120,86 +115,4 @@ public class AndroidSenseControllerService { } - @Path("controller/readgps") - @GET - @Consumes("application/json") - @Produces("application/json") - public SensorRecord requestTemperature(@HeaderParam("owner") String owner, - @HeaderParam("deviceId") String deviceId, - @HeaderParam("protocol") String protocol, - @Context HttpServletResponse response) { - SensorRecord sensorRecord = null; - - try { - return SensorDataManager.getInstance().getSensorRecord(deviceId,"gps"); - } catch (DeviceControllerException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } - - - return sensorRecord; - } - - - @Path("controller/readlight") - @GET - @Consumes("application/json") - @Produces("application/json") - public SensorRecord readLight(@HeaderParam("owner") String owner, - @HeaderParam("deviceId") String deviceId, - @HeaderParam("protocol") String protocol, - @Context HttpServletResponse response) { - SensorRecord sensorRecord = null; - - try { - return SensorDataManager.getInstance().getSensorRecord(deviceId,"light"); - } catch (DeviceControllerException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } - - - return sensorRecord; - } - - @Path("controller/readmagnetic") - @GET - @Consumes("application/json") - @Produces("application/json") - public SensorRecord readMagnetic(@HeaderParam("owner") String owner, - @HeaderParam("deviceId") String deviceId, - @HeaderParam("protocol") String protocol, - @Context HttpServletResponse response) { - SensorRecord sensorRecord = null; - - try { - return SensorDataManager.getInstance().getSensorRecord(deviceId,"magnetic"); - } catch (DeviceControllerException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } - - - return sensorRecord; - } - - @Path("controller/readbattery") - @GET - @Consumes("application/json") - @Produces("application/json") - public SensorRecord readBattery(@HeaderParam("owner") String owner, - @HeaderParam("deviceId") String deviceId, - @HeaderParam("protocol") String protocol, - @Context HttpServletResponse response) { - SensorRecord sensorRecord = null; - - try { - return SensorDataManager.getInstance().getSensorRecord(deviceId,"battery"); - } catch (DeviceControllerException e) { - response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } - - - return sensorRecord; - } - - } diff --git a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml index 366b7526..b41c55ed 100644 --- a/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml +++ b/modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/pom.xml @@ -155,6 +155,16 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.analytics + + org.igniterealtime.smack.wso2 + smack + ${smack.wso2.version} + + + org.igniterealtime.smack.wso2 + smackx + ${smackx.wso2.version} +