Fixed conflicts

revert-dabc3590
mharindu 9 years ago
commit 36c88aee3c

@ -29,6 +29,8 @@ import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTrans
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException;
import org.wso2.carbon.iot.android.sense.constants.SenseConstants;
import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationData;
import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationDataReader;
import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorData;
import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData;
import org.wso2.carbon.iot.android.sense.speech.detector.util.ProcessWords;
@ -50,7 +52,6 @@ public class DataPublisherService extends Service {
private static String VALUE_TAG = "value";
public static Context context;
@Nullable
@Override
public IBinder onBind(Intent intent) {
@ -66,8 +67,9 @@ public class DataPublisherService extends Service {
public void run() {
try {
List<Event> events = new ArrayList<>();
//retreive sensor data.
//retrieve sensor data.
List<SensorData> sensorDataMap = SenseDataHolder.getSensorDataHolder();
if (!sensorDataMap.isEmpty()) {
for (SensorData sensorData : sensorDataMap) {
Event event = new Event();
event.setTimestamp(sensorData.getTimestamp());
@ -105,25 +107,31 @@ public class DataPublisherService extends Service {
break;
}
}
}
SenseDataHolder.resetSensorDataHolder();
//retreive batter data.
//retrieve batter data.
List<BatteryData> batteryDataMap = SenseDataHolder.getBatteryDataHolder();
if (!batteryDataMap.isEmpty()) {
for (BatteryData batteryData : batteryDataMap) {
Event event = new Event();
event.setTimestamp(batteryData.getTimestamp());
event.setBattery(batteryData.getLevel());
events.add(event);
}
}
SenseDataHolder.resetBatteryDataHolder();
//retreive location data.
//retrieve location data.
List<LocationData> locationDataMap = SenseDataHolder.getLocationDataHolder();
if (!locationDataMap.isEmpty()) {
for (LocationData locationData : locationDataMap) {
Event event = new Event();
event.setTimestamp(locationData.getTimeStamp());
event.setGps(new double[]{locationData.getLatitude(), locationData.getLongitude()});
events.add(event);
}
}
SenseDataHolder.resetLocationDataHolder();
//retrieve words
@ -158,12 +166,12 @@ public class DataPublisherService extends Service {
event.setDeviceId(deviceId);
jsonArray.put(new JSONObject().put("event", event.getEvent()));
}
MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context);
if (!mqttTransportHandler.isConnected()) {
mqttTransportHandler.connect();
}
String topic = LocalRegistry.getTenantDomain(context) + "/" + SenseConstants
.DEVICE_TYPE + "/" + deviceId + "/data";
String topic = LocalRegistry.getTenantDomain(context) + "/" + SenseConstants.DEVICE_TYPE + "/" + deviceId + "/data";
mqttTransportHandler.publishDeviceData(user, deviceId, jsonArray.toString(), topic);
}
} catch (JSONException e) {

@ -28,41 +28,60 @@ import java.util.concurrent.TimeUnit;
*/
public class LocationDataReader extends DataReader implements LocationListener {
protected LocationManager locationManager;
private Context mContext;
private final Context mContext;
LocationData gps;
// flag for GPS status
private boolean isGPSEnabled = false;
// flag for network status
private boolean isNetworkEnabled = false;
// flag for GPS status
private boolean canGetLocation = false;
//private boolean canGetLocation = false;
private static final String TAG = LocationDataReader.class.getName();
Location location; // location
double latitude; // latitude
double longitude; // longitude
// The minimum distance to change Updates in meters
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
// The minimum time between updates in milliseconds
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
public LocationDataReader(Context context) {
mContext = context;
this.mContext = context;
getLocation();
}
public Location getLocation() {
locationManager = (LocationManager) mContext.getSystemService(mContext.LOCATION_SERVICE);
try {
locationManager = (LocationManager) mContext
.getSystemService(mContext.LOCATION_SERVICE);
// getting GPS status
boolean isGPSEnabled = locationManager
isGPSEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
boolean isNetworkEnabled = locationManager
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
} else {
this.canGetLocation = true;
// First get location from Network Provider
if (isNetworkEnabled) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 0, 0, this);
// MIN_TIME_BW_UPDATES,
// MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("Network", "Network");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
@ -76,11 +95,10 @@ public class LocationDataReader extends DataReader implements LocationListener {
if (isGPSEnabled) {
if (location == null) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0, this);
//MIN_TIME_BW_UPDATES,
//MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d(TAG, "GPS Enabled");
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("GPS Enabled", "GPS Enabled");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
@ -92,6 +110,11 @@ public class LocationDataReader extends DataReader implements LocationListener {
}
}
}
} catch (Exception e) {
Log.e(TAG, "Failed to capture location data.");
}
return location;
}
@ -148,6 +171,7 @@ public class LocationDataReader extends DataReader implements LocationListener {
}
@Override
public void run() {
Log.d(TAG, "running -Location");
@ -156,7 +180,10 @@ public class LocationDataReader extends DataReader implements LocationListener {
double lat = getLatitude();
double longit = getLongitude();
if (lat != 0 && longit != 0) {
SenseDataHolder.getLocationDataHolder().add(new LocationData(getLatitude(), getLongitude()));
Log.d(TAG, "YYY " + getLatitude() + ", XXX " + getLongitude());
gps = new LocationData(getLatitude(), getLongitude());
SenseDataHolder.getLocationDataHolder().add(gps);
}
} catch (InterruptedException e) {
// Restore the interrupted status

@ -97,8 +97,8 @@ public class SensorDataReader extends DataReader implements SensorEventListener
@Override
public void run() {
Log.d(TAG, "running -sensorDataMap");
Vector<SensorData> sensorDatas = getSensorData();
for (SensorData data : sensorDatas) {
Vector<SensorData> sensorDetails = getSensorData();
for (SensorData data : sensorDetails) {
SenseDataHolder.getSensorDataHolder().add(data);
}
}

@ -17,9 +17,10 @@ import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationData;
import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorData;
import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData;
import org.wso2.carbon.iot.android.sense.speech.detector.util.WordData;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import android.util.Log;
/**
* This holds the sensor,battery and location data inmemory.
@ -31,6 +32,12 @@ public class SenseDataHolder {
private static List<LocationData> locationDataHolder;
private static List<WordData> wordDataHolder;
//LocationData gps;
private static final String TAG = SenseDataHolder.class.getName();
public static List<SensorData> getSensorDataHolder(){
if(sensorDataHolder == null){
sensorDataHolder = new CopyOnWriteArrayList<>();
@ -46,10 +53,14 @@ public class SenseDataHolder {
}
public static List<LocationData> getLocationDataHolder(){
if(locationDataHolder == null){
locationDataHolder = new CopyOnWriteArrayList<>();
}
return locationDataHolder;
}
public static List<WordData> getWordDataHolder(){

@ -24,7 +24,7 @@ import javax.ws.rs.QueryParam;
*/
public interface AndroidSenseManagerService {
@Path("/enrollment/devices/{device_id}")
@Path("/device/{device_id}/register")
@POST
AndroidConfiguration register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName);
}

@ -6,7 +6,7 @@ buildscript {
maven { url 'https://repo.eclipse.org/content/repositories/paho-releases/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

@ -1,6 +1,6 @@
#Fri Dec 11 10:25:01 IST 2015
#Wed May 11 14:40:10 IST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

@ -17,13 +17,14 @@
~ under the License.
-->
<project name="create-sample-sensor-capps" default="zip" basedir=".">
<project name="create-android-sense-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="target/carbonapps"/>
<property name="src-dir" value="src/main/resources/carbonapps"/>
<property name="Android_Sense_dir" value="Android_Sense"/>
<property name="Android_Sense_dir" value="androidsense"/>
<property name="Wordcounter_dir" value="word_count"/>
<target name="clean">
<delete dir="${target-dir}" />
@ -34,5 +35,8 @@
<zip destfile="${target-dir}/${Android_Sense_dir}.car">
<zipfileset dir="${src-dir}/${Android_Sense_dir}"/>
</zip>
<zip destfile="${target-dir}/${Wordcounter_dir}.car">
<zipfileset dir="${src-dir}/${Wordcounter_dir}"/>
</zip>
</target>
</project>

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you 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.
-->
<artifact name="EventExecution_AndroidSense" version="1.0.0" type="event/execution-plan" serverRole="DataAnalyticsServer">
<file>EventExecution_AndroidSense.siddhiql</file>
</artifact>

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you 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.
-->
<artifact name="EventPublisher_AndroidSense" version="1.0.0" type="event/publisher" serverRole="DataAnalyticsServer">
<file>EventPublisher_AndroidSense.xml</file>
</artifact>

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you 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.
-->
<artifacts>
<artifact name="AndroidSense_CAPP" version="1.0.0" type="carbon/application">
<dependency artifact="EventStream_AndroidSense" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="android_sense_mqtt" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="EventPublisher_AndroidSense" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="EventExecution_AndroidSense" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you 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.
-->
<artifact name="android_sense_execution" version="1.0.0" type="event/execution-plan" serverRole="DataAnalyticsServer">
<file>android_sense_execution.siddhiql</file>
</artifact>

@ -17,7 +17,7 @@
~ under the License.
-->
<eventPublisher name="EventPublisher_AndroidSense" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<eventPublisher name="android_sense_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="org.wso2.iot.android.sense" version="1.0.0"/>
<mapping customMapping="disable" type="wso2event"/>
<to eventAdapterType="iot-ui"/>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you 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.
-->
<artifact name="android_sense_publisher" version="1.0.0" type="event/publisher" serverRole="DataAnalyticsServer">
<file>android_sense_publisher.xml</file>
</artifact>

@ -17,12 +17,13 @@
~ under the License.
-->
<eventReceiver name="android_sense_mqtt" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<eventReceiver name="android_sense_receiver" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="oauth-mqtt">
<property name="topic">carbon.super/android_sense/+/data</property>
<property name="username">admin</property>
<property name="contentValidationParams">device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:2</property>
<property name="contentValidation">default</property>
<property name="contentValidatorParams">device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:2</property>
<property name="contentValidator">org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTContentValidator</property>
<property name="contentTransformer">default</property>
<property name="dcrUrl">https://localhost:${carbon.https.port}/dynamic-client-web/register</property>
<property name="url">tcp://${mqtt.broker.host}:${mqtt.broker.port}</property>
<property name="cleanSession">true</property>

@ -17,6 +17,6 @@
~ under the License.
-->
<artifact name="Eventreceiver_magnetic" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>EventReceiver_magnetic.xml</file>
<artifact name="android_sense_receiver" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>android_sense_receiver.xml</file>
</artifact>

@ -17,7 +17,7 @@
~ under the License.
-->
<artifact name="EventStream_AndroidSense" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<artifact name="android_sense_stream" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.iot.android.sense_1.0.0.json</file>
</artifact>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save