resolved errors on sample build and few changes on android service

merge-requests/1/head
ayyoob 9 years ago
parent e39ee91518
commit a0ee671515

@ -245,6 +245,8 @@
<!--Make samples directory for distribution-->
<mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/samples"/>
<mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/statistics"/>
<mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/repository/resources/sketches"/>
<mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/repository/resources/scripts"/>
@ -271,7 +273,7 @@
<fileset dir="src/scripts"/>
</copy>
<copy todir="target/wso2carbon-core-${carbon.kernel.version}/samples/statistics"
<copy todir="target/wso2carbon-core-${carbon.kernel.version}/statistics"
overwrite="true">
<fileset dir="src/statistics/carbonapps">
<exclude name="**/*.iml"/>

@ -61,6 +61,17 @@
<arg line="-c 'mvn clean install'" />
</exec>
</target>
<target name="build-android-agent">
<echo message="Downloading android agent source...." />
<exec dir="." executable="sh">
<arg line="-c 'svn checkout https://github.com/wso2-incubator/iot-server-agents/trunk/wso2_sense_agent --non-interactive --trust-server-cert'" />
</exec>
<echo message="building agent from source" />
<exec dir="wso2_sense_agent" executable="sh">
<arg line="-c 'mvn clean install'" />
</exec>
<copy file="wso2_sense_agent/app/build/outputs/apk/app-release-unsigned.apk" todir="sketch/android_sense.apk"/>
</target>
<target name="deploy" depends="create-db,build">
<copy toDir="${target.sketch.dir}/${sample_type}">
@ -79,6 +90,8 @@
</copy>
</target>
<target name="clean">
<delete file="${target.db.dir}/${data_source}.h2.db"/>
<delete dir="${target.sketch.dir}/${sample_type}"/>

@ -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;
}
}

@ -155,6 +155,16 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
<version>${smack.wso2.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
<version>${smackx.wso2.version}</version>
</dependency>
</dependencies>

Loading…
Cancel
Save