From 971185decfbc096fa281510617161d6c21ac476e Mon Sep 17 00:00:00 2001 From: Chatura Dilan Date: Thu, 30 Jun 2016 15:59:40 +0530 Subject: [PATCH] fixes for android sense client --- .../app/build.gradle | 8 + .../app/src/main/AndroidManifest.xml | 6 + .../sense/beacon/BeaconDetactorService.java | 13 +- .../bmonitor/BeaconMonitoringActivity.java | 121 +++++++++++ .../bmonitor/BluetoothLeDeviceStore.java | 193 +++++++++++++++++ .../sense/bmonitor/BluetoothLeScanner.java | 65 ++++++ .../sense/bmonitor/BluetoothUtils.java | 60 ++++++ .../sense/bmonitor/CsvWriterHelper.java | 43 ++++ .../sense/bmonitor/LeDeviceListAdapter.java | 154 +++++++++++++ .../android/sense/bmonitor/TimeFormatter.java | 35 +++ .../sense/bmonitor/UtcDateFormatter.java | 74 +++++++ .../realtimeviewer/ActivitySelectSensor.java | 3 +- .../iot/android/sense/siddhi/dto/BLE.java | 55 ----- .../core/SidhdhiQueryExecutor.java | 136 ------------ .../wrapper/SidhdhiWrapper.java | 59 ----- .../sense/siddhi/reader/BLEReader.java | 71 ------ .../app/src/main/res/drawable/beacon_red.png | Bin 0 -> 19250 bytes .../res/layout/activity_beacon_monitoring.xml | 34 +++ .../src/main/res/layout/list_item_device.xml | 203 ++++++++++++++++++ .../app/src/main/res/values/strings.xml | 71 ++++++ 20 files changed, 1080 insertions(+), 324 deletions(-) create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java delete mode 100755 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/dto/BLE.java delete mode 100755 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/core/SidhdhiQueryExecutor.java delete mode 100755 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/wrapper/SidhdhiWrapper.java delete mode 100755 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/reader/BLEReader.java create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon_red.png create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_beacon_monitoring.xml create mode 100644 components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle index 3c6c7507fe..bf9860dba5 100755 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle @@ -11,6 +11,12 @@ android { versionName "1.0" } + repositories { + maven { + url "https://dl.bintray.com/alt236/maven" + } + } + buildTypes { release { minifyEnabled false @@ -53,5 +59,7 @@ dependencies { compile 'com.netflix.feign:feign-jaxrs:8.16.0' compile 'com.netflix.feign:feign-jackson:8.16.0' compile 'org.altbeacon:android-beacon-library:2.8.1' + compile 'uk.co.alt236:easycursor-android:1.0.0' + compile 'uk.co.alt236:bluetooth-le-library-android:1.0.0' } diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml index d1857e4364..7ba9b334cc 100755 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml @@ -78,6 +78,12 @@ android:label="Beacon Monitor" android:theme="@style/AppTheme.NoActionBar" > + + + diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java index c3c66a52ba..61e84c6809 100755 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java @@ -45,20 +45,29 @@ public class BeaconDetactorService extends Service implements BeaconConsumer { @Override public int onStartCommand(Intent intent, int flags, int startId) { + + new Thread(){ + @Override + public void run() { + iBeaconManager.bind(BeaconDetactorService.this); + } + }.start(); + + return START_STICKY; } @Override public void onCreate() { super.onCreate(); - iBeaconManager.bind(this); + final Handler handler = new Handler(); final Runnable runnable = new Runnable() { @Override public void run() { - stopSelf(); + //stopSelf(); } }; handler.postDelayed(runnable, 10000); diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java new file mode 100644 index 0000000000..23785db26a --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java @@ -0,0 +1,121 @@ +/* + * + * Copyright (c) 2016, 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. + */ + +package org.wso2.carbon.iot.android.sense.bmonitor; + +import android.annotation.TargetApi; +import android.app.Activity; +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.widget.ListView; + +import java.util.HashMap; +import java.util.Map; + +import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R; +import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice; +import uk.co.alt236.easycursor.objectcursor.EasyObjectCursor; + +public class BeaconMonitoringActivity extends AppCompatActivity { + + private BluetoothLeScanner mScanner; + private BluetoothUtils mBluetoothUtils; + private LeDeviceListAdapter mLeDeviceListAdapter; + private BluetoothLeDeviceStore mDeviceStore; + + protected ListView mList; + + public static final int MINIMUM_DISTANCE = -70; + + public static Map itemMap; + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_beacon_monitoring); + + itemMap = new HashMap(); + itemMap.put("DC:5F:BD:68:88:D5", "Noodles"); + itemMap.put("EF:0F:50:D5:BA:A1", "Vegetables"); + itemMap.put("FA:F2:CF:84:C2:F7", "Oil"); + + mList = (ListView) this.findViewById(android.R.id.list); + + mDeviceStore = new BluetoothLeDeviceStore(); + mBluetoothUtils = new BluetoothUtils(this); + mScanner = new BluetoothLeScanner(mLeScanCallback, mBluetoothUtils); + startScan(); + } + + private final BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { + @Override + public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) { + final BluetoothLeDevice deviceLe = new BluetoothLeDevice(device, rssi, scanRecord, System.currentTimeMillis()); + if(deviceLe!= null && deviceLe.getName()!= null && !deviceLe.getName().equals("Unknown Device")){ + mDeviceStore.addDevice(deviceLe); + + if(deviceLe.getRssi() > MINIMUM_DISTANCE){ + Object[] objects = new Object[4]; + objects[0] = deviceLe.getName(); + objects[1] = deviceLe.getAddress(); + objects[2] = deviceLe.getRssi(); + objects[3] = itemMap.get(device.getAddress()); + + new SendToSiddi().execute(objects); + } + + + final EasyObjectCursor c = mDeviceStore.getDeviceCursor(); + runOnUiThread(new Runnable() { + @Override + public void run() { + mLeDeviceListAdapter.swapCursor(c); + } + }); + } + } + }; + + private void startScan() { + + mLeDeviceListAdapter = new LeDeviceListAdapter(this, mDeviceStore.getDeviceCursor()); + mList.setAdapter(mLeDeviceListAdapter); + + final boolean mIsBluetoothOn = mBluetoothUtils.isBluetoothOn(); + final boolean mIsBluetoothLePresent = mBluetoothUtils.isBluetoothLeSupported(); + mBluetoothUtils.askUserToEnableBluetoothIfNeeded(); + if (mIsBluetoothOn && mIsBluetoothLePresent) { + mScanner.scanLeDevice(-1, true); + invalidateOptionsMenu(); + } + } + + + public class SendToSiddi extends AsyncTask{ + + @Override + protected Void doInBackground(Object... objects) { + + return null; + } + } +} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java new file mode 100644 index 0000000000..1411575013 --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java @@ -0,0 +1,193 @@ +/* + * + * Copyright (c) 2016, 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. + */ + +package org.wso2.carbon.iot.android.sense.bmonitor; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice; +import uk.co.alt236.bluetoothlelib.device.beacon.BeaconType; +import uk.co.alt236.bluetoothlelib.device.beacon.BeaconUtils; +import uk.co.alt236.bluetoothlelib.device.beacon.ibeacon.IBeaconDevice; +import uk.co.alt236.bluetoothlelib.util.ByteUtils; +import uk.co.alt236.easycursor.objectcursor.EasyObjectCursor; + +public class BluetoothLeDeviceStore { + private final Map mDeviceMap; + + + public BluetoothLeDeviceStore() { + mDeviceMap = new HashMap<>(); + } + + public void addDevice(final BluetoothLeDevice device) { + if (mDeviceMap.containsKey(device.getAddress())) { + mDeviceMap.get(device.getAddress()).updateRssiReading(device.getTimestamp(), device.getRssi()); + } else { + mDeviceMap.put(device.getAddress(), device); + } + } + + public void clear() { + mDeviceMap.clear(); + } + + public EasyObjectCursor getDeviceCursor() { + return new EasyObjectCursor<>( + BluetoothLeDevice.class, + getDeviceList(), + "address"); + } + + public List getDeviceList() { + final List methodResult = new ArrayList<>(mDeviceMap.values()); + + Collections.sort(methodResult, new Comparator() { + + @Override + public int compare(final BluetoothLeDevice arg0, final BluetoothLeDevice arg1) { + return arg0.getAddress().compareToIgnoreCase(arg1.getAddress()); + } + }); + + return methodResult; + } + + private String getListAsCsv() { + final List list = getDeviceList(); + final StringBuilder sb = new StringBuilder(); + sb.append(CsvWriterHelper.addStuff("mac")); + sb.append(CsvWriterHelper.addStuff("name")); + sb.append(CsvWriterHelper.addStuff("firstTimestamp")); + sb.append(CsvWriterHelper.addStuff("firstRssi")); + sb.append(CsvWriterHelper.addStuff("currentTimestamp")); + sb.append(CsvWriterHelper.addStuff("currentRssi")); + sb.append(CsvWriterHelper.addStuff("adRecord")); + sb.append(CsvWriterHelper.addStuff("iBeacon")); + sb.append(CsvWriterHelper.addStuff("uuid")); + sb.append(CsvWriterHelper.addStuff("major")); + sb.append(CsvWriterHelper.addStuff("minor")); + sb.append(CsvWriterHelper.addStuff("txPower")); + sb.append(CsvWriterHelper.addStuff("distance")); + sb.append(CsvWriterHelper.addStuff("accuracy")); + sb.append('\n'); + + for (final BluetoothLeDevice device : list) { + sb.append(CsvWriterHelper.addStuff(device.getAddress())); + sb.append(CsvWriterHelper.addStuff(device.getName())); + sb.append(CsvWriterHelper.addStuff(TimeFormatter.getIsoDateTime(device.getFirstTimestamp()))); + sb.append(CsvWriterHelper.addStuff(device.getFirstRssi())); + sb.append(CsvWriterHelper.addStuff(TimeFormatter.getIsoDateTime(device.getTimestamp()))); + sb.append(CsvWriterHelper.addStuff(device.getRssi())); + sb.append(CsvWriterHelper.addStuff(ByteUtils.byteArrayToHexString(device.getScanRecord()))); + final boolean isIBeacon = BeaconUtils.getBeaconType(device) == BeaconType.IBEACON; + final String uuid; + final String minor; + final String major; + final String txPower; + final String distance; + final String accuracy; + + if (isIBeacon) { + final IBeaconDevice beacon = new IBeaconDevice(device); + uuid = String.valueOf(beacon.getUUID()); + minor = String.valueOf(beacon.getMinor()); + major = String.valueOf(beacon.getMajor()); + txPower = String.valueOf(beacon.getCalibratedTxPower()); + distance = beacon.getDistanceDescriptor().toString().toLowerCase(Locale.US); + accuracy = String.valueOf(beacon.getAccuracy()); + } else { + uuid = ""; + minor = ""; + major = ""; + txPower = ""; + distance = ""; + accuracy = ""; + } + + sb.append(CsvWriterHelper.addStuff(isIBeacon)); + sb.append(CsvWriterHelper.addStuff(uuid)); + sb.append(CsvWriterHelper.addStuff(minor)); + sb.append(CsvWriterHelper.addStuff(major)); + sb.append(CsvWriterHelper.addStuff(txPower)); + sb.append(CsvWriterHelper.addStuff(distance)); + sb.append(CsvWriterHelper.addStuff(accuracy)); + + sb.append('\n'); + } + + return sb.toString(); + } + + public void shareDataAsEmail(final Context context) { + final long timeInMillis = System.currentTimeMillis(); + + final String to = null; + final String subject = ""; + + final String message = ""; + + final Intent i = new Intent(Intent.ACTION_SEND); + i.setType("plain/text"); + try { + final File outputDir = context.getCacheDir(); + final File outputFile = File.createTempFile("bluetooth_le_" + timeInMillis, ".csv", outputDir); + outputFile.setReadable(true, false); + generateFile(outputFile, getListAsCsv()); + i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(outputFile)); + i.putExtra(Intent.EXTRA_EMAIL, new String[]{to}); + i.putExtra(Intent.EXTRA_SUBJECT, subject); + i.putExtra(Intent.EXTRA_TEXT, message); + context.startActivity(Intent.createChooser(i, "Email Subject")); + + } catch (final IOException e) { + e.printStackTrace(); + } + } + + private static FileWriter generateFile(final File file, final String contents) { + FileWriter writer = null; + try { + writer = new FileWriter(file); + writer.append(contents); + writer.flush(); + + } catch (final IOException e) { + e.printStackTrace(); + } finally { + try { + writer.close(); + } catch (final IOException e) { + e.printStackTrace(); + } + } + return writer; + } +} \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java new file mode 100644 index 0000000000..a132d53eec --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java @@ -0,0 +1,65 @@ +/* + * + * Copyright (c) 2016, 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. + */ + +package org.wso2.carbon.iot.android.sense.bmonitor; + +import android.bluetooth.BluetoothAdapter; +import android.os.Handler; +import android.util.Log; + +public class BluetoothLeScanner { + private final Handler mHandler; + private final BluetoothAdapter.LeScanCallback mLeScanCallback; + private final BluetoothUtils mBluetoothUtils; + private boolean mScanning; + + public BluetoothLeScanner(final BluetoothAdapter.LeScanCallback leScanCallback, final BluetoothUtils bluetoothUtils) { + mHandler = new Handler(); + mLeScanCallback = leScanCallback; + mBluetoothUtils = bluetoothUtils; + } + + public boolean isScanning() { + return mScanning; + } + + public void scanLeDevice(final int duration, final boolean enable) { + if (enable) { + if (mScanning) { + return; + } + Log.d("TAG", "~ Starting Scan"); + // Stops scanning after a pre-defined scan period. + if (duration > 0) { + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + Log.d("TAG", "~ Stopping Scan (timeout)"); + mScanning = false; + mBluetoothUtils.getBluetoothAdapter().stopLeScan(mLeScanCallback); + } + }, duration); + } + mScanning = true; + mBluetoothUtils.getBluetoothAdapter().startLeScan(mLeScanCallback); + } else { + Log.d("TAG", "~ Stopping Scan"); + mScanning = false; + mBluetoothUtils.getBluetoothAdapter().stopLeScan(mLeScanCallback); + } + } +} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java new file mode 100644 index 0000000000..5e664793c7 --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java @@ -0,0 +1,60 @@ +/* + * + * Copyright (c) 2016, 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. + */ + +package org.wso2.carbon.iot.android.sense.bmonitor; + +import android.app.Activity; +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothManager; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; + +public final class BluetoothUtils { + public final static int REQUEST_ENABLE_BT = 2001; + private final Activity mActivity; + private final BluetoothAdapter mBluetoothAdapter; + + public BluetoothUtils(final Activity activity) { + mActivity = activity; + final BluetoothManager btManager = (BluetoothManager) mActivity.getSystemService(Context.BLUETOOTH_SERVICE); + mBluetoothAdapter = btManager.getAdapter(); + } + + public void askUserToEnableBluetoothIfNeeded() { + if (isBluetoothLeSupported() && (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled())) { + final Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); + mActivity.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); + } + } + + public BluetoothAdapter getBluetoothAdapter() { + return mBluetoothAdapter; + } + + public boolean isBluetoothLeSupported() { + return mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); + } + + public boolean isBluetoothOn() { + if (mBluetoothAdapter == null) { + return false; + } else { + return mBluetoothAdapter.isEnabled(); + } + } +} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java new file mode 100644 index 0000000000..6c10210a27 --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2016, 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. + */ + +package org.wso2.carbon.iot.android.sense.bmonitor; + +public class CsvWriterHelper { + private static final String QUOTE = "\""; + + public static String addStuff(final Integer text) { + return QUOTE + text + QUOTE + ","; + } + + public static String addStuff(final Long text) { + return QUOTE + text + QUOTE + ","; + } + + public static String addStuff(final boolean value) { + return QUOTE + value + QUOTE + ","; + } + + public static String addStuff(String text) { + if (text == null) { + text = ""; + } + text = text.replace(QUOTE, "'"); + + return QUOTE + text.trim() + QUOTE + ","; + } +} \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java new file mode 100644 index 0000000000..da4370b893 --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java @@ -0,0 +1,154 @@ +/* + * + * Copyright (c) 2016, 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. + */ + +package org.wso2.carbon.iot.android.sense.bmonitor; + +import android.app.Activity; +import android.support.v4.widget.SimpleCursorAdapter; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.text.DecimalFormat; + +import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R; +import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice; +import uk.co.alt236.bluetoothlelib.device.beacon.BeaconType; +import uk.co.alt236.bluetoothlelib.device.beacon.BeaconUtils; +import uk.co.alt236.bluetoothlelib.device.beacon.ibeacon.IBeaconDevice; +import uk.co.alt236.easycursor.objectcursor.EasyObjectCursor; + +public class LeDeviceListAdapter extends SimpleCursorAdapter { + private final LayoutInflater mInflator; + private final Activity mActivity; + + public static final DecimalFormat DOUBLE_TWO_DIGIT_ACCURACY = new DecimalFormat("#.##"); + public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; + + public LeDeviceListAdapter(final Activity activity, final EasyObjectCursor cursor) { + super(activity, R.layout.list_item_device, cursor, new String[0], new int[0], 0); + mInflator = activity.getLayoutInflater(); + mActivity = activity; + } + + @SuppressWarnings("unchecked") + @Override + public EasyObjectCursor getCursor() { + return ((EasyObjectCursor) super.getCursor()); + } + + @Override + public BluetoothLeDevice getItem(final int i) { + return getCursor().getItem(i); + } + + @Override + public long getItemId(final int i) { + return i; + } + + @Override + public View getView(final int i, View view, final ViewGroup viewGroup) { + final ViewHolder viewHolder; + // General ListView optimization code. + if (view == null) { + view = mInflator.inflate(R.layout.list_item_device, null); + viewHolder = new ViewHolder(); + viewHolder.deviceAddress = (TextView) view.findViewById(R.id.device_address); + viewHolder.deviceName = (TextView) view.findViewById(R.id.device_name); + viewHolder.deviceRssi = (TextView) view.findViewById(R.id.device_rssi); + viewHolder.deviceIcon = (ImageView) view.findViewById(R.id.device_icon); + viewHolder.deviceLastUpdated = (TextView) view.findViewById(R.id.device_last_update); + viewHolder.ibeaconMajor = (TextView) view.findViewById(R.id.ibeacon_major); + viewHolder.ibeaconMinor = (TextView) view.findViewById(R.id.ibeacon_minor); + viewHolder.ibeaconDistance = (TextView) view.findViewById(R.id.ibeacon_distance); + viewHolder.ibeaconUUID = (TextView) view.findViewById(R.id.ibeacon_uuid); + viewHolder.ibeaconTxPower = (TextView) view.findViewById(R.id.ibeacon_tx_power); + viewHolder.ibeaconSection = view.findViewById(R.id.ibeacon_section); + viewHolder.ibeaconDistanceDescriptor = (TextView) view.findViewById(R.id.ibeacon_distance_descriptor); + view.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) view.getTag(); + } + + final BluetoothLeDevice device = getCursor().getItem(i); + final String deviceName = device.getName(); + + final double rssi = device.getRssi(); + + if (deviceName != null && deviceName.length() > 0) { + viewHolder.deviceName.setText(deviceName + " (" + BeaconMonitoringActivity.itemMap.get(device.getAddress()) + ")"); + } else { + viewHolder.deviceName.setText(R.string.unknown_device); + } + + + if (BeaconUtils.getBeaconType(device) == BeaconType.IBEACON) { + final IBeaconDevice iBeacon = new IBeaconDevice(device); + final String accuracy = DOUBLE_TWO_DIGIT_ACCURACY.format(iBeacon.getAccuracy()); + + viewHolder.deviceIcon.setImageResource(R.drawable.beacon); + viewHolder.ibeaconSection.setVisibility(View.VISIBLE); + viewHolder.ibeaconMajor.setText(String.valueOf(iBeacon.getMajor())); + viewHolder.ibeaconMinor.setText(String.valueOf(iBeacon.getMinor())); + viewHolder.ibeaconTxPower.setText(String.valueOf(iBeacon.getCalibratedTxPower())); + viewHolder.ibeaconUUID.setText(iBeacon.getUUID()); + viewHolder.ibeaconDistance.setText( + mActivity.getString(R.string.formatter_meters, accuracy)); + viewHolder.ibeaconDistanceDescriptor.setText(iBeacon.getDistanceDescriptor().toString()); + } else { + if(device.getRssi() > BeaconMonitoringActivity.MINIMUM_DISTANCE){ + viewHolder.deviceIcon.setImageResource(R.drawable.beacon_red); + }else{ + viewHolder.deviceIcon.setImageResource(R.drawable.beacon); + } + + viewHolder.ibeaconSection.setVisibility(View.GONE); + } + + + final String rssiString = + mActivity.getString(R.string.formatter_db, String.valueOf(rssi)); + final String runningAverageRssiString = + mActivity.getString(R.string.formatter_db, String.valueOf(device.getRunningAverageRssi())); + + viewHolder.deviceLastUpdated.setText( + android.text.format.DateFormat.format( + TIME_FORMAT, new java.util.Date(device.getTimestamp()))); + viewHolder.deviceAddress.setText(device.getAddress()); + viewHolder.deviceRssi.setText(rssiString + " / " + runningAverageRssiString); + return view; + } + + static class ViewHolder { + TextView deviceName; + TextView deviceAddress; + TextView deviceRssi; + TextView ibeaconUUID; + TextView ibeaconMajor; + TextView ibeaconMinor; + TextView ibeaconTxPower; + TextView ibeaconDistance; + TextView ibeaconDistanceDescriptor; + TextView deviceLastUpdated; + View ibeaconSection; + ImageView deviceIcon; + } + +} \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java new file mode 100644 index 0000000000..340a0211b1 --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2016, 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. + */ + +package org.wso2.carbon.iot.android.sense.bmonitor; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class TimeFormatter { + private final static String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS zzz"; + private final static SimpleDateFormat ISO_FORMATTER = new UtcDateFormatter(ISO_FORMAT, Locale.US); + + public static String getIsoDateTime(final Date date) { + return ISO_FORMATTER.format(date); + } + + public static String getIsoDateTime(final long millis) { + return getIsoDateTime(new Date(millis)); + } +} \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java new file mode 100644 index 0000000000..bb3f527590 --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java @@ -0,0 +1,74 @@ +/** + * **************************************************************************** + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + *

+ * GenieConnect Ltd. ("COMPANY") CONFIDENTIAL + * Unpublished Copyright (c) 2010-2013 GenieConnect Ltd., All Rights Reserved. + *

+ * NOTICE: + * All information contained herein is, and remains the property of COMPANY. + * The intellectual and technical concepts contained herein are proprietary to + * COMPANY and may be covered by U.S. and Foreign Patents, patents in process, and + * are protected by trade secret or copyright law. Dissemination of this + * information or reproduction of this material is strictly forbidden unless prior + * written permission is obtained from COMPANY. Access to the source code + * contained herein is hereby forbidden to anyone except current COMPANY employees, + * managers or contractors who have executed Confidentiality and Non-disclosure + * agreements explicitly covering such access. + *

+ * The copyright notice above does not evidence any actual or intended publication + * or disclosure of this source code, which includes information that is + * confidential and/or proprietary, and is a trade secret, of COMPANY. + *

+ * ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE, OR PUBLIC + * DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN + * CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE LAWS + * AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE CODE + * AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS TO REPRODUCE, + * DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR SELL ANYTHING + * THAT IT MAY DESCRIBE, IN WHOLE OR IN PART. + * **************************************************************************** + */ +package org.wso2.carbon.iot.android.sense.bmonitor; + +import android.annotation.SuppressLint; + +import java.text.DateFormatSymbols; +import java.util.Locale; +import java.util.TimeZone; + +public class UtcDateFormatter extends java.text.SimpleDateFormat { + private static final long serialVersionUID = 1L; + + private static final String TIME_ZONE_STRING = "UTC"; + private static final TimeZone TIME_ZONE_UTC = TimeZone.getTimeZone(TIME_ZONE_STRING); + + @SuppressLint("SimpleDateFormat") + public UtcDateFormatter(final String template) { + super(template); + super.setTimeZone(TIME_ZONE_UTC); + } + + @SuppressLint("SimpleDateFormat") + public UtcDateFormatter(final String template, final DateFormatSymbols symbols) { + super(template, symbols); + super.setTimeZone(TIME_ZONE_UTC); + } + + public UtcDateFormatter(final String template, final Locale locale) { + super(template, locale); + super.setTimeZone(TIME_ZONE_UTC); + } + + /* + * This function will throw an UnsupportedOperationException. + * You are not be able to change the TimeZone of this object + * + * (non-Javadoc) + * @see java.text.DateFormat#setTimeZone(java.util.TimeZone) + */ + @Override + public void setTimeZone(final TimeZone timezone) { + throw new UnsupportedOperationException("This SimpleDateFormat can only be in " + TIME_ZONE_STRING); + } +} \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java index fe6c4b0933..f8d658f69d 100755 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java @@ -38,6 +38,7 @@ import android.widget.Toast; import android.app.AlertDialog; import android.content.DialogInterface; import org.wso2.carbon.iot.android.sense.RegisterActivity; +import org.wso2.carbon.iot.android.sense.bmonitor.BeaconMonitoringActivity; import org.wso2.carbon.iot.android.sense.data.publisher.DataPublisherReceiver; import org.wso2.carbon.iot.android.sense.data.publisher.DataPublisherService; import org.wso2.carbon.iot.android.sense.event.SenseScheduleReceiver; @@ -146,7 +147,7 @@ public class ActivitySelectSensor extends AppCompatActivity fbtnBeaconMonitor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(getApplicationContext(), MonitoringActivity.class); + Intent intent = new Intent(getApplicationContext(), BeaconMonitoringActivity.class); startActivity(intent); diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/dto/BLE.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/dto/BLE.java deleted file mode 100755 index 0dec7d2ad7..0000000000 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/dto/BLE.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -package org.wso2.carbon.iot.android.sense.siddhi.dto; - -public class BLE { - int id; - long timeStamp; - String location; - - public BLE(int id, String location){ - this.id = id; - this.location = location; - timeStamp = System.currentTimeMillis(); - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public long getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(long timeStamp) { - this.timeStamp = timeStamp; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } -} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/core/SidhdhiQueryExecutor.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/core/SidhdhiQueryExecutor.java deleted file mode 100755 index 6496a40bc6..0000000000 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/core/SidhdhiQueryExecutor.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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. - */ - -package org.wso2.carbon.iot.android.sense.siddhi.eventprocessor.core; - -import org.wso2.carbon.iot.android.sense.siddhi.dto.BLE; -import org.wso2.carbon.iot.android.sense.siddhi.eventprocessor.wrapper.SidhdhiWrapper; -import org.wso2.siddhi.core.SiddhiManager; -import org.wso2.siddhi.core.event.Event; -import org.wso2.siddhi.core.stream.input.InputHandler; -import org.wso2.siddhi.core.ExecutionPlanRuntime; -import org.wso2.siddhi.core.stream.output.StreamCallback; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - - -public class SidhdhiQueryExecutor implements Runnable { - - protected String query = null; - private static SiddhiManager siddhiManager = new SiddhiManager(); - private static final int INTERVAL = 3000; - - public volatile Thread sidhdiThread; - private ReadWriteLock rwlock = new ReentrantReadWriteLock(); - - //TODO have another array initialized so that a list of callbacks can be stored, String[] callbackList - public SidhdhiQueryExecutor(String query){ - this.query = query; - } - - public void run(){ - //TODO the array of callbacks needs to be passed to invoke - //TODO what is retruned should be a map of callbacks and outputs - ExecutionPlan executionPlan = new ExecutionPlan().invoke(); - - Thread thisThread = Thread.currentThread(); - - while (sidhdiThread == thisThread) { - InputHandler inputHandler = executionPlan.getInputHandler(); - - //Sending events to Siddhi - try { - List bleReadings = read(); - for(BLE ble : bleReadings){ - System.out.println("Publishing data..."); - inputHandler.send(new Object[]{ble.getId(), ble.getTimeStamp(), ble.getLocation()}); - } - - thisThread.sleep(INTERVAL); - } catch (InterruptedException e) { - e.printStackTrace(); - break; - } - } - } - - public List read() - { - List bleData; - rwlock.readLock().lock(); - try { - //TODO Reading BLE VALUES - bleData = SidhdhiWrapper.getBleData(); - } finally { - rwlock.readLock().unlock(); - } - return bleData; - } - - public void stop(){ - sidhdiThread = null; - } - - public void start(){ - sidhdiThread = new Thread(this); - sidhdiThread.start(); - } - - private class ExecutionPlan { - - private InputHandler inputHandler; - - public InputHandler getInputHandler() { - return inputHandler; - } - - //TODO should expect an array of callbacks - public ExecutionPlan invoke() { - - //Generating runtime - ExecutionPlanRuntime runtime = siddhiManager.createExecutionPlanRuntime(query); - - - - //TODO logic needs to be revised so that array of callbacks are processed - runtime.addCallback("dataOut", new StreamCallback() { - @Override - public void receive(Event[] events) { - System.out.println("Location Match event initiated."); - if (events.length > 0) { - //TODO Configure Event here! - System.out.println("Firing location match event..."); - } - } - }); - - - //Retrieving InputHandler to push events into Siddhi - inputHandler = runtime.getInputHandler("dataIn"); - - //Starting event processing - runtime.start(); - System.out.println("Execution Plan Started!"); - return this; - } - } - -} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/wrapper/SidhdhiWrapper.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/wrapper/SidhdhiWrapper.java deleted file mode 100755 index e6db9c6a9e..0000000000 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/eventprocessor/wrapper/SidhdhiWrapper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -package org.wso2.carbon.iot.android.sense.siddhi.eventprocessor.wrapper; - -import org.wso2.carbon.iot.android.sense.siddhi.dto.BLE; -import org.wso2.carbon.iot.android.sense.siddhi.eventprocessor.core.SidhdhiQueryExecutor; -import org.wso2.carbon.iot.android.sense.siddhi.reader.BLEReader; - -import java.util.List; -import java.util.Map; - - -public class SidhdhiWrapper { - - private static List bleData; - - public static List getBleData() { - return bleData; - } - - public static void setBleData(List bleData) { - SidhdhiWrapper.bleData = bleData; - } - - public static void main(String args[]){ - String query = "@Import('iot.sample.input:1.0.0')\n" + - "define stream dataIn (id int, timestamp long, location string);\n" + - "\n" + - "@Export('iot.sample.output:1.0.0')\n" + - "define stream dataOut (action string, timestamp long);\n" + - "\n" + - "from every e1=dataIn[location=='loc_1'] -> e2=dataIn[location=='loc_2'] -> e3=dataIn[location=='loc_3']\n" + - "select 'x' as action, e3.timestamp\n" + - "insert into dataOut;"; - - BLEReader blEReader = new BLEReader(); - blEReader.start(); - - SidhdhiQueryExecutor queryExecutor = new SidhdhiQueryExecutor(query); - queryExecutor.start(); - } - -} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/reader/BLEReader.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/reader/BLEReader.java deleted file mode 100755 index 36fb195f8a..0000000000 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/siddhi/reader/BLEReader.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ - -package org.wso2.carbon.iot.android.sense.siddhi.reader; - -import org.wso2.carbon.iot.android.sense.siddhi.dto.BLE; -import org.wso2.carbon.iot.android.sense.siddhi.eventprocessor.wrapper.SidhdhiWrapper; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -public class BLEReader implements Runnable{ - - private ReadWriteLock rwlock = new ReentrantReadWriteLock(); - List bleData = new ArrayList(); - public volatile Thread bleReader; - private static final int INTERVAL = 2000; - - public void run(){ - Thread thisThread = Thread.currentThread(); - while (bleReader == thisThread) { - write(); - try { - thisThread.sleep(INTERVAL); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - public void stop(){ - bleReader = null; - } - - public void start(){ - bleReader = new Thread(this); - bleReader.start(); - } - - public void write() - { - rwlock.writeLock().lock(); - try { - bleData.add(new BLE(123, "loc_1")); - bleData.add(new BLE(123, "loc_2")); - bleData.add(new BLE(123, "loc_3")); - SidhdhiWrapper.setBleData(bleData); - } finally { - rwlock.writeLock().unlock(); - } - } -} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon_red.png b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon_red.png new file mode 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8w+I4jBJJ*Ku;3dLW5Moke3Sm06UNb3 zclyOq)FrA9p&oX8C6CEDomTS!HZic2J<78auzOkK1sI=l4$ZAavep)}BeiFYp7dKr zkFhX1jwb4akLRd~Y|q^)m@5EZM-tisA-e@Mm~x=O*qmwq0>}WI$o}-c_Z`)?v_iE| z;93!gcy9E;RE9EbiH;jjQh1?Rf)~0e=^*vEsm}I|3`ho&R6t>1_8JRTNwhPpG?~|O z!%x1vz4Tk0T`IXCg6|#k1ffULFNuPs?12QG&2?N&SZQBZTi87X*uKw)q;;u zheRK-UNQl~lJeDlu=cT9Zw0A3$fO7p0EZ-(-DQR`)Lh<7SEkh&+->a9>naA8S>Xj3 z9LLbGN}$>t&u~Ph7%c#Mx_DH<%!EzTApvz8H1sOJktl$HKpnr7nLB?Ff->s0+ZTH+ zz)IC9Qt#v-BvM8LE66!K4!?=33Lfm_l%4fOanbL}4FkXtaQHlLePfS + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml new file mode 100644 index 0000000000..46cd6c0ee9 --- /dev/null +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml index a335b9272f..62002d6055 100755 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml @@ -11,4 +11,75 @@ Hello blank fragment + + + + This is a sample application using the Bluetooth LE Library.\n\nGithub: https://github.com/alt236/Bluetooth-LE-Library---Android\n\nCopyright: Alexandros Schillings + Device Info + iBeacon Data + Raw Ad Records + RSSI Info + Scan Record + Advertisement: + As Array: + As String: + Bluetooth LE: + Bluetooth: + Bonding State: + Company ID: + Data: + Desc: + Device address: + Device Class: + Major Class: + Services: + Device Name: + Distance: + First RSSI: + First Timestamp: + Last RSSI: + Last Timestamp: + MAC: + Major: + Minor: + RSSI: + Running Average RSSI: + State: + TX Power: + UUID: + Updated: + Descriptor: + + + Connected + Disconnected + Invalid Device Data! + No data + Not supported + Off + On + Supported + unknown + Unknown characteristic + Unknown device + Unknown service + No known services + + %sm + %sdb + Items: %s + + + About + Connect + Disconnect + Scan + Stop + Share + + + Bluetooth LE Scan Results (%s) + Bluetooth LE Device GATT Results (%s, %s) + Please find attached the scan results. + Please select your email client: