resolved errors on sample build and few changes on android service

application-manager-new
ayyoob 9 years ago
parent e39ee91518
commit a0ee671515

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

@ -61,6 +61,17 @@
<arg line="-c 'mvn clean install'" /> <arg line="-c 'mvn clean install'" />
</exec> </exec>
</target> </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"> <target name="deploy" depends="create-db,build">
<copy toDir="${target.sketch.dir}/${sample_type}"> <copy toDir="${target.sketch.dir}/${sample_type}">
@ -79,6 +90,8 @@
</copy> </copy>
</target> </target>
<target name="clean"> <target name="clean">
<delete file="${target.db.dir}/${data_source}.h2.db"/> <delete file="${target.db.dir}/${data_source}.h2.db"/>
<delete dir="${target.sketch.dir}/${sample_type}"/> <delete dir="${target.sketch.dir}/${sample_type}"/>

@ -20,9 +20,6 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService; 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.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.DeviceJSON;
import org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl.util.SensorJSON; import org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl.util.SensorJSON;
@ -71,11 +68,9 @@ public class AndroidSenseControllerService {
switch (sensor.key){ switch (sensor.key){
case "light" : streamDef = LIGHT_STREAM_DEFINITION; case "light" : streamDef = LIGHT_STREAM_DEFINITION;
payloadData = new Object[]{Float.parseFloat(sensor.value)}; payloadData = new Object[]{Float.parseFloat(sensor.value)};
SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"light",sensor.value,sensor.time);
break; break;
case "battery" : streamDef = BATTERY_STREAM_DEFINITION; case "battery" : streamDef = BATTERY_STREAM_DEFINITION;
payloadData = new Object[]{Float.parseFloat(sensor.value)}; payloadData = new Object[]{Float.parseFloat(sensor.value)};
SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"battery",sensor.value,sensor.time);
break; break;
case "GPS" : streamDef = GPS_STREAM_DEFINITION; case "GPS" : streamDef = GPS_STREAM_DEFINITION;
String gpsValue =sensor.value; String gpsValue =sensor.value;
@ -84,7 +79,6 @@ public class AndroidSenseControllerService {
gpsValuesF[0] = Float.parseFloat(gpsValues[0]); gpsValuesF[0] = Float.parseFloat(gpsValues[0]);
gpsValuesF[1] = Float.parseFloat(gpsValues[0]); gpsValuesF[1] = Float.parseFloat(gpsValues[0]);
payloadData = gpsValuesF; payloadData = gpsValuesF;
SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"gps",sensor.value,sensor.time);
break; break;
default : default :
try { try {
@ -96,9 +90,10 @@ public class AndroidSenseControllerService {
String valuesM[]=value.split(","); String valuesM[]=value.split(",");
Float gValuesF[]= new Float[1]; Float gValuesF[]= new Float[1];
gValuesF[0] = Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0]); gValuesF[0] = Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0]);
payloadData = gValuesF; 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){ }catch(NumberFormatException e){
continue; 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> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId> <artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
</dependency> </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> </dependencies>

Loading…
Cancel
Save