Merge pull request #116 from charithag/IoTS-1.0.0-M1

Add configs for analytics
Ruwan 9 years ago
commit 520234eb41

@ -171,6 +171,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

@ -18,6 +18,8 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.device.DeviceType;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService;
@ -29,18 +31,11 @@ import org.wso2.carbon.device.mgt.iot.DeviceManagement;
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants;
import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.DeviceJSON;
import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.SensorJSON;
import org.wso2.carbon.device.mgt.iot.apimgt.AccessTokenInfo;
import org.wso2.carbon.device.mgt.iot.apimgt.TokenClient;
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppAccount;
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig;
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppServerClient;
import org.wso2.carbon.device.mgt.iot.exception.AccessTokenException;
import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException;
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager;
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord;
import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
import org.wso2.carbon.device.mgt.iot.util.ZipUtil;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.apimgt.annotations.device.feature.Feature;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
@ -48,34 +43,33 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.UUID;
@DeviceType( value = "android_sense" )
@API( name="android_sense", version="1.0.0", context="/android_sense")
public class AndroidSenseService {
private static final String ACCELEROMETER_STREAM_DEFINITION = "org.wso2.iot.devices.accelerometer";
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";
private static final String ACCELEROMETER_STREAM_DEFINITION = "org.wso2.iot.devices.accelerometer";
private static final String GRAVITY_STREAM_DEFINITION = "org.wso2.iot.devices.gravity";
private static final String GYROSCOPE_STREAM_DEFINITION = "org.wso2.iot.devices.gyroscope";
private static final String LIGHT_STREAM_DEFINITION = "org.wso2.iot.devices.light";
private static final String MAGNETIC_STREAM_DEFINITION = "org.wso2.iot.devices.magnetic";
private static final String PRESSURE_STREAM_DEFINITION = "org.wso2.iot.devices.pressure";
private static final String GRAVITY_STREAM_DEFINITION = "org.wso2.iot.devices.gravity";
private static final String ROTATION_STREAM_DEFINITION = "org.wso2.iot.devices.rotation";
private static final String PROXIMITY_STREAM_DEFINITION = "org.wso2.iot.devices.proximity";
private static final String ROTATION_STREAM_DEFINITION = "org.wso2.iot.devices.rotation";
private static final String SENSOR_ACCELEROMETER = "accelerometer";
private static final String SENSOR_GYROSCOPE = "gyroscope";
private static final String SENSOR_PRESSURE = "pressure";
private static final String SENSOR_BATTERY = "battery";
private static final String SENSOR_GPS = "gps";
private static final String SENSOR_GRAVITY = "gravity";
private static final String SENSOR_ROTATION = "rotation";
private static final String SENSOR_GYROSCOPE = "gyroscope";
private static final String SENSOR_LIGHT = "light";
private static final String SENSOR_GPS = "gps";
private static final String SENSOR_PROXIMITY = "proximity";
private static final String SENSOR_BATTERY = "battery";
private static final String SENSOR_MAGNETIC = "magnetic";
private static final String SENSOR_PRESSURE = "pressure";
private static final String SENSOR_PROXIMITY = "proximity";
private static final String SENSOR_ROTATION = "rotation";
private static Log log = LogFactory.getLog(AndroidSenseService.class);
//TODO; replace this tenant domain
@ -361,6 +355,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readlight", name = "Light", description = "Read Light data from the device", type = "monitor")
public SensorRecord readLight(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -380,6 +375,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readbattery", name = "Battery", description = "Read Battery data from the device", type = "monitor")
public SensorRecord readBattery(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -399,6 +395,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readgps", name = "gps", description = "Read GPS data from the device", type = "monitor")
public SensorRecord readGPS(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -418,6 +415,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readmagnetic", name = "Magnetic", description = "Read Magnetic data from the device", type = "monitor")
public SensorRecord readMagnetic(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -437,6 +435,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readaccelerometer", name = "Accelerometer", description = "Read Accelerometer data from the device", type = "monitor")
public SensorRecord readAccelerometer(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -456,6 +455,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readrotation", name = "Rotation", description = "Read Rotational Vector data from the device", type = "monitor")
public SensorRecord readRotation(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -475,6 +475,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readproximity", name = "Proximity", description = "Read Proximity data from the device", type = "monitor")
public SensorRecord readProximity(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -494,6 +495,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readgyroscope", name = "Gyroscope", description = "Read Gyroscope data from the device", type = "monitor")
public SensorRecord readGyroscope(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -513,6 +515,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readpressure", name = "Pressure", description = "Read Pressure data from the device", type = "monitor")
public SensorRecord readPressure(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -532,6 +535,7 @@ public class AndroidSenseService {
@GET
@Consumes("application/json")
@Produces("application/json")
@Feature(code = "readgravity", name = "Gravity", description = "Read Gravity data from the device", type = "monitor")
public SensorRecord readGravity(
@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {

@ -29,34 +29,34 @@
<!--</context-param>-->
<!--publish to apim-->
<!--<context-param>-->
<!--<param-name>managed-api-enabled</param-name>-->
<!--<param-value>true</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>managed-api-owner</param-name>-->
<!--<param-value>admin</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>managed-api-name</param-name>-->
<!--<param-value>android_sense</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>managed-api-endpoint</param-name>-->
<!--<param-value>http://localhost:9763/android_sense</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>managed-api-version</param-name>-->
<!--<param-value>1.0.0</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>managed-api-context</param-name>-->
<!--<param-value>/android_sense</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>managed-api-isSecured</param-name>-->
<!--<param-value>true</param-value>-->
<!--</context-param>-->
<context-param>
<param-name>managed-api-enabled</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
<context-param>
<param-name>managed-api-name</param-name>
<param-value>android_sense</param-value>
</context-param>
<context-param>
<param-name>managed-api-endpoint</param-name>
<param-value>http://localhost:9763/android_sense</param-value>
</context-param>
<context-param>
<param-name>managed-api-version</param-name>
<param-value>1.0.0</param-value>
</context-param>
<context-param>
<param-name>managed-api-context</param-name>
<param-value>/android_sense</param-value>
</context-param>
<context-param>
<param-name>managed-api-isSecured</param-name>
<param-value>true</param-value>
</context-param>
<!-- Below configuration is used to redirect http requests to https -->
<!--<security-constraint>-->

@ -0,0 +1,120 @@
{
"deviceType": {
"label": "Android Sense",
"category": "iot"
},
"analyticStreams": [
{
"name": "Accelerometer",
"table": "DEVICE_ACCELEROMETER_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"ACCELEROMETER", "label":"Accelerometer", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "Battery",
"table": "DEVICE_BATTERY_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"BATTERY", "label":"Battery Level", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "GPS",
"table": "DEVICE_GPS_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.google-map",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"time"}},
{"column": {"name":"LATITUDE", "label":"Latitude", "ui-mapping":"lat"}},
{"column": {"name":"LONGITUDE", "label":"Longitude", "ui-mapping":"lat"}}
]
}
},
{
"name": "Gravity",
"table": "DEVICE_GRAVITY_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"GRAVITY", "label":"Gravity", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "Gyroscope",
"table": "DEVICE_GYROSCOPE_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"GYROSCOPE", "label":"Gyroscope", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "Light",
"table": "DEVICE_LIGHT_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"LIGHT", "label":"Light", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "Magnetic",
"table": "DEVICE_MAGNETIC_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"MAGNETIC", "label":"Magnetic", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "Pressure",
"table": "DEVICE_PRESSURE_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"PRESSURE", "label":"Pressure", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "Proximity",
"table": "DEVICE_PROXIMITY_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.bar-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"PROXIMITY", "label":"Proximity", "ui-mapping":"y-axis"}}
]
}
},
{
"name": "Rotation",
"table": "DEVICE_ROTATION_SUMMARY",
"ui_unit": "cdmf.unit.analytics.line-chart",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"ROTATION", "label":"Rotation", "ui-mapping":"y-axis"}}
]
}
}
]
}

@ -1,4 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="EventReceiver_temperature" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.iot.devices.temperature" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventreceiver_temperature" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_temperature.xml</file>
</artifact>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstore_temperature" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
<file>org_wso2_iot_devices_temperature.xml</file>
</artifact>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<EventStoreConfiguration>
<Source>
<StreamId>org.wso2.iot.devices.temperature:1.0.0</StreamId>
</Source>
<RecordStoreName>EVENT_STORE</RecordStoreName>
<TableSchema>
<ColumnDefinition>
<Name>meta_owner</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceType</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceId</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_time</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>LONG</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>temperature</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
</TableSchema>
</EventStoreConfiguration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstream_temperature" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.temperature_1.0.0.json</file>
</artifact>

@ -0,0 +1,20 @@
{
"name": "org.wso2.iot.devices.temperature",
"version": "1.0.0",
"nickName": "Temperature Data",
"description": "Temperature data received from the Device",
"metaData": [
{"name":"owner","type":"STRING"},
{"name":"deviceType","type":"STRING"},
{"name":"deviceId","type":"STRING"},
{"name":"time","type":"LONG"}
],
"payloadData": [
{
"name": "temperature","type": "FLOAT"
}
]
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Script>
CREATE TEMPORARY TABLE DeviceTemperatureData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_TEMPERATURE");
CREATE TEMPORARY TABLE DeviceTemperatureSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_TEMPERATURE_SUMMARY", schema "temperature FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceTemperatureSummaryData select temperature, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceTemperatureData group by temperature, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script>
<CronExpression>0 * * * * ?</CronExpression>
</Analytics>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
<file>Temperature_Sensor_Script.xml</file>
</artifact>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifacts>
<artifact name="IoTServer_Sensors_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="create-sample-sensor-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="../org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/carbonapps"/>
<property name="Temperature_Sensor_dir" value="Temperature_Sensor"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<mkdir dir="${target-dir}"/>
<zip destfile="${target-dir}/${Temperature_Sensor_dir}.car">
<zipfileset dir="${Temperature_Sensor_dir}"/>
</zip>
</target>
</project>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
# Copyright (c) 2015, 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.
# See the License for the specific language governing permissions and
# limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-mgt-iot-arduino-feature</artifactId>
<version>1.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.arduino.analytics</artifactId>
<name>WSO2 Carbon - IoT Server Arduino Analytics capp</name>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<ant antfile="build.xml" target="zip"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,20 @@
{
"deviceType": {
"label": "Arduino",
"category": "iot",
"downloadAgentUri": "manager/device/arduino/download",
},
"analyticStreams": [
{
"name": "Temperature",
"table": "DEVICE_TEMPERATURE_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"ACCELEROMETER", "label":"Accelerometer", "ui-mapping":"y-axis"}}
]
}
}
]
}

@ -1,8 +0,0 @@
{
"deviceType": {
"label": "Arduino",
"category": "iot",
"downloadAgentUri": "manager/device/arduino/download",
"downloadAgentLinkGenUri" : "manager/device/arduino/generate_link"
}
}

@ -1,6 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/devicetype-conf/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/configs/,target:${installFolder}/../../conf/devicetype-conf/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\

@ -36,6 +36,7 @@
<modules>
<module>org.wso2.carbon.device.mgt.iot.arduino.feature</module>
</modules>
<module>org.wso2.carbon.device.mgt.iot.arduino.analytics</module>
</modules>
</project>

@ -1,4 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.digitaldisplay_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\

@ -1,8 +0,0 @@
{
"deviceType": {
"label": "Drone Analyzer",
"category": "iot",
"downloadAgentUri": "manager/device/drone_analyzer/download",
"downloadAgentLinkGenUri" : "manager/device/drone_analyzer/generate_link"
}
}

@ -1,6 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/devicetype-conf/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/configs/,target:${installFolder}/../../conf/devicetype-conf/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.droneanalyzer_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="EventReceiver_temperature" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.iot.devices.temperature" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventreceiver_temperature" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_temperature.xml</file>
</artifact>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstore_temperature" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
<file>org_wso2_iot_devices_temperature.xml</file>
</artifact>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<EventStoreConfiguration>
<Source>
<StreamId>org.wso2.iot.devices.temperature:1.0.0</StreamId>
</Source>
<RecordStoreName>EVENT_STORE</RecordStoreName>
<TableSchema>
<ColumnDefinition>
<Name>meta_owner</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceType</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_deviceId</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>STRING</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>meta_time</Name>
<EnableIndexing>true</EnableIndexing>
<IsPrimaryKey>true</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>LONG</Type>
</ColumnDefinition>
<ColumnDefinition>
<Name>temperature</Name>
<EnableIndexing>false</EnableIndexing>
<IsPrimaryKey>false</IsPrimaryKey>
<EnableScoreParam>false</EnableScoreParam>
<Type>FLOAT</Type>
</ColumnDefinition>
</TableSchema>
</EventStoreConfiguration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventstream_temperature" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.devices.temperature_1.0.0.json</file>
</artifact>

@ -0,0 +1,20 @@
{
"name": "org.wso2.iot.devices.temperature",
"version": "1.0.0",
"nickName": "Temperature Data",
"description": "Temperature data received from the Device",
"metaData": [
{"name":"owner","type":"STRING"},
{"name":"deviceType","type":"STRING"},
{"name":"deviceId","type":"STRING"},
{"name":"time","type":"LONG"}
],
"payloadData": [
{
"name": "temperature","type": "FLOAT"
}
]
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Script>
CREATE TEMPORARY TABLE DeviceTemperatureData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_TEMPERATURE");
CREATE TEMPORARY TABLE DeviceTemperatureSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_TEMPERATURE_SUMMARY", schema "temperature FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
insert overwrite table DeviceTemperatureSummaryData select temperature, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceTemperatureData group by temperature, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
</Script>
<CronExpression>0 * * * * ?</CronExpression>
</Analytics>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
<file>Temperature_Sensor_Script.xml</file>
</artifact>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifacts>
<artifact name="IoTServer_Sensors_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="Eventstream_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventstore_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Eventreceiver_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="create-sample-sensor-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="../org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/carbonapps"/>
<property name="Temperature_Sensor_dir" value="Temperature_Sensor"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<mkdir dir="${target-dir}"/>
<zip destfile="${target-dir}/${Temperature_Sensor_dir}.car">
<zipfileset dir="${Temperature_Sensor_dir}"/>
</zip>
</target>
</project>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
# Copyright (c) 2015, 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.
# See the License for the specific language governing permissions and
# limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-mgt-iot-raspberrypi-feature</artifactId>
<version>1.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.raspberrypi.analytics</artifactId>
<name>WSO2 Carbon - IoT Server Raspberry Pi Analytics capp</name>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<ant antfile="build.xml" target="zip"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,19 @@
{
"deviceType": {
"label": "RaspberryPi",
"category": "iot"
},
"analyticStreams": [
{
"name": "Temperature",
"table": "DEVICE_TEMPERATURE_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"TEMPERATURE", "label":"Temperature", "ui-mapping":"y-axis"}}
]
}
}
]
}

@ -1,8 +0,0 @@
{
"deviceType": {
"label": "RaspberryPi",
"category": "iot",
"downloadAgentUri": "manager/device/raspberrypi/download",
"downloadAgentLinkGenUri" : "manager/device/raspberrypi/generate_link"
}
}

@ -1,6 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/devicetype-conf/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/configs/,target:${installFolder}/../../conf/devicetype-conf/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\

@ -36,6 +36,7 @@
<modules>
<module>org.wso2.carbon.device.mgt.iot.raspberrypi.feature</module>
<module>org.wso2.carbon.device.mgt.iot.raspberrypi.analytics</module>
</modules>
</project>

@ -0,0 +1,21 @@
{
"deviceType": {
"label": "Virtual Firealarm",
"category": "iot",
"downloadAgentUri": "manager/device/virtual_firealarm/download",
"downloadAgentLinkGenUri": "manager/device/virtual_firealarm/generate_link"
},
"analyticStreams": [
{
"name": "Temperature",
"table": "DEVICE_TEMPERATURE_SUMMARY",
"ui_unit": {
"name": "cdmf.unit.analytics.line-chart",
"data":[
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}},
{"column": {"name":"TEMPERATURE", "label":"Temperature", "ui-mapping":"y-axis"}}
]
}
}
]
}

@ -1,8 +0,0 @@
{
"deviceType": {
"label": "Virtual Firealarm",
"category": "iot",
"downloadAgentUri": "manager/device/virtual_firealarm/download",
"downloadAgentLinkGenUri" : "manager/device/virtual_firealarm/generate_link"
}
}

@ -1,6 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/devicetype-conf/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/configs/,target:${installFolder}/../../conf/devicetype-conf/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\

@ -1,4 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\

@ -1,4 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\

Loading…
Cancel
Save