update version and few changes on android sense service

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

@ -249,8 +249,6 @@
<mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/repository/resources/scripts"/>
<mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/statistics"/>
<mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/repository/components/lib"/>
<!--Copy samples to distribution-->
@ -273,11 +271,21 @@
<fileset dir="src/scripts"/>
</copy>
<copy todir="target/wso2carbon-core-${carbon.kernel.version}/statistics"
<copy todir="target/wso2carbon-core-${carbon.kernel.version}/samples/statistics"
overwrite="true">
<fileset dir="src/statistics"/>
<fileset dir="src/statistics/carbonapps">
<exclude name="**/*.iml"/>
<exclude name="**/.DS_Store"/>
<exclude name="**/target/"/>
</fileset>
</copy>
<fileset dir="../samples">
<exclude name="**/*.iml"/>
<exclude name="**/.DS_Store"/>
<exclude name="**/target/"/>
</fileset>
<copy todir="target/wso2carbon-core-${carbon.kernel.version}/repository/components/lib">
<fileset dir="src/lib"/>
</copy>
@ -343,8 +351,8 @@
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/arduino/build.xml.disable"/>
<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/raspberrypi/build.xml"
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/raspberrypi/build.xml.disable"/>
<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml"
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml.disable"/>
<!--<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml"-->
<!--toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/virtual_firealarm/build.xml.disable"/>-->
<move file="target/wso2carbon-core-${carbon.kernel.version}/samples/sample_pom.xml"
toFile="target/wso2carbon-core-${carbon.kernel.version}/samples/pom.xml"
overwrite="true"/>

@ -100,9 +100,15 @@
<featureArtifacts>
<!--<featureArtifactDef>-->
<!--org.wso2.carbon:org.wso2.carbon.core.feature:${carbon.kernel.version}-->
<!--</featureArtifactDef>-->
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.core.feature:${carbon.kernel.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.core.runtime.feature:${carbon.kernel.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.core.ui.feature:${carbon.kernel.version}
</featureArtifactDef>
<!--Device Cloud Features -->
@ -713,10 +719,18 @@
<deleteOldProfileFiles>true</deleteOldProfileFiles>
<features>
<!--<feature>-->
<!--<id>org.wso2.carbon.core.feature.group</id>-->
<!--<version>${carbon.kernel.version}</version>-->
<!--</feature>-->
<feature>
<id>org.wso2.carbon.core.feature.group</id>
<version>${carbon.kernel.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.core.runtime.feature.group</id>
<version>${carbon.kernel.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.core.ui.feature.group</id>
<version>${carbon.kernel.version}</version>
</feature>
<!-- IoT Features -->
<feature>

@ -83,6 +83,21 @@
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
</dependencies>

@ -17,12 +17,23 @@
package org.wso2.carbon.device.mgt.iot.sample.android.sense.service.impl;
import org.apache.commons.logging.Log;
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;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@ -32,6 +43,10 @@ public class AndroidSenseControllerService {
private static Log log = LogFactory.getLog(AndroidSenseControllerService.class);
@Context //injected response proxy supporting multiple thread
private HttpServletResponse response;
private static final String BATTERY_STREAM_DEFINITION = "org.wso2.iot.devices.battery";
private static final String LIGHT_STREAM_DEFINITION = "org.wso2.iot.devices.light";
private static final String GPS_STREAM_DEFINITION = "org.wso2.iot.devices.gps";
private static final String MAGNETIC_STREAM_DEFINITION = "org.wso2.iot.devices.magnetic";
/* Service to push all the sensor data collected by the Android
Called by the Android device */
@ -41,29 +56,150 @@ public class AndroidSenseControllerService {
public void pushSensorData(final DeviceJSON dataMsg, @Context HttpServletResponse response) {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain("carbon.super", true);
DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx.getOSGiService(
DeviceAnalyticsService.class, null);
String temperature = dataMsg.owner; //TEMP
log.info("Recieved Sensor Data Values: " + temperature);
SensorJSON[] sensorData = dataMsg.values;
String streamDef = null;
Object payloadData[] = null;
if (log.isDebugEnabled()) {
log.debug("Recieved Temperature Data Value: " + temperature + " degrees C");
}
//try {
boolean result = false;
// result=DeviceController.pushBamData(dataMsg.owner, AndroidSenseConstants.DEVICE_TYPE,
// dataMsg.deviceId,
// System.currentTimeMillis(), "DeviceData",
// temperature, "TEMPERATURE");
for(SensorJSON sensor: sensorData){
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;
String gpsValues[]=gpsValue.split(",");
Float gpsValuesF[]= new Float[2];
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 {
int androidSensorId = Integer.parseInt(sensor.key);
if(androidSensorId==2){
streamDef = MAGNETIC_STREAM_DEFINITION;
String value =sensor.value;
String valuesM[]=value.split(",");
Float gValuesF[]= new Float[1];
gValuesF[0] = Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0])*Float.parseFloat(valuesM[0]);
if (!result) {
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
payloadData = gValuesF;
SensorDataManager.getInstance().setSensorRecord(dataMsg.deviceId,"magnetic",sensor.value,sensor.time);
}
}catch(NumberFormatException e){
continue;
}
}
//return result;
// } catch (UnauthorizedException e) {
// response.setStatus(HttpStatus.SC_UNAUTHORIZED);
//
// }
Object metdaData[] = {dataMsg.owner, AndroidSenseConstants.DEVICE_TYPE, dataMsg.deviceId, sensor.time};
if(streamDef!=null && payloadData!=null && payloadData.length > 0) {
try {
deviceAnalyticsService.publishEvent(streamDef, "1.0.0",
metdaData, new Object[0], payloadData);
} catch (DataPublisherConfigurationException e) {
response.setStatus(Response.Status.UNSUPPORTED_MEDIA_TYPE.getStatusCode());
}
}
}
}
@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;
}
}

@ -92,6 +92,64 @@
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<exclusions>
<exclusion>
<groupId>org.bouncycastle.wso2</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.api</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.queuing</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.base</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</exclusion>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
<exclusion>
<groupId>commons-fileupload.wso2</groupId>
<artifactId>commons-fileupload</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.equinox</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>

@ -824,7 +824,7 @@
<!--Carbon kernel versions-->
<carbon.kernel.version>4.4.2</carbon.kernel.version>
<carbon.kernel.version.range>[4.4.1, 4.5.0)</carbon.kernel.version.range>
<carbon.kernel.version.range>[4.4.2, 4.5.0)</carbon.kernel.version.range>
<carbon.platform.version>4.4.2</carbon.platform.version>
<!--Carbon p2 version-->
@ -873,7 +873,7 @@
<javax.ws.rs.version>1.1.1</javax.ws.rs.version>
<!-- Carbon Commons -->
<carbon.commons.version>4.4.7</carbon.commons.version>
<carbon.commons.version>4.4.8</carbon.commons.version>
<!-- Carbon Deployment -->
<carbon.deployment.version>4.5.2</carbon.deployment.version>
@ -886,7 +886,7 @@
<!-- Carbon Registry -->
<carbon.registry.version>4.4.8</carbon.registry.version>
<carbon.registry.package.import.version.range>[4.4.1, 4.5.0)</carbon.registry.package.import.version.range>
<carbon.registry.package.import.version.range>[4.4.8, 4.5.0)</carbon.registry.package.import.version.range>
<!-- Carbon Governance -->
<carbon.governance.version>4.5.8</carbon.governance.version>
@ -899,7 +899,7 @@
<carbon.iot.device.mgt.version>1.0.0-SNAPSHOT</carbon.iot.device.mgt.version>
<!-- carbon mediation -->
<carbon.mediation.version>4.4.10</carbon.mediation.version>
<carbon.mediation.version>4.4.11-SNAPSHOT</carbon.mediation.version>
<!-- API Management -->
<carbon.api.mgt.version>4.3.0-SNAPSHOT</carbon.api.mgt.version>
@ -918,10 +918,10 @@
<!--DAS-->
<carbon.analytics.version>1.0.4-SNAPSHOT</carbon.analytics.version>
<carbon.analytics.common.version>5.0.5-SNAPSHOT</carbon.analytics.common.version>
<carbon.analytics.common.version>5.0.5</carbon.analytics.common.version>
<cipher.tool.version>1.0.0-wso2v3</cipher.tool.version>
<shindig.version>1.0.0</shindig.version>
<carbon.event-processing.version>2.0.7</carbon.event-processing.version>
<carbon.event-processing.version>2.0.8</carbon.event-processing.version>
<carbon.data.version>4.3.2</carbon.data.version>

Loading…
Cancel
Save