Creating APRS-X Repository. Mostly a template of classes and working BLE service with packet dump available.
Creating APRS-X Repository. Mostly a template of classes and working BLE service with packet dump available.

--- /dev/null
+++ b/AndroidManifest.xml
@@ -1,1 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"

+    package="com.dryerzinia.aprs_x"

+    android:versionCode="1"

+    android:versionName="1.0" >

+

+    <uses-sdk

+        android:minSdkVersion="18"

+        android:targetSdkVersion="21" />

 
+    <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
+
+    <uses-permission android:name="android.permission.BLUETOOTH"/>
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+

+    <application

+        android:allowBackup="true"

+        android:icon="@drawable/ic_launcher"

+        android:label="@string/app_name"

+        android:theme="@style/AppTheme" >

+        <activity

+            android:name="com.dryerzinia.aprs_x.ui.MainActivity"

+            android:label="@string/app_name" >

+            <intent-filter>

+                <action android:name="android.intent.action.MAIN" />

+

+                <category android:name="android.intent.category.LAUNCHER" />

+            </intent-filter>

+        </activity>
+
+        <activity android:name="com.dryerzinia.aprs_x.test.DeviceScanActivity" />
+        <activity android:name="com.dryerzinia.aprs_x.test.DeviceControlActivity"/>
+        <service android:name="com.dryerzinia.aprs_x.services.BluetoothLeService" android:enabled="true"/>

+
+    </application>

+

+</manifest>

+

 Binary files /dev/null and b/libs/android-support-v4.jar differ
--- /dev/null
+++ b/project.properties
@@ -1,1 +1,15 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
+# Project target.
+target=android-19
+

 Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ
--- /dev/null
+++ b/res/drawable-hdpi/whiteprogress.xml
@@ -1,1 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+<item android:id="@android:id/background">
+    <shape>
+        <solid
+                android:color="@android:color/transparent" />
+    </shape>
+</item>
 
+<item
+    android:id="@android:id/progress">
+    <clip>
+        <shape>
+            <solid
+                android:color="@android:color/white" />
+        </shape>
+    </clip>
+</item>
+
+</layer-list>

 Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ
 Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ
 Binary files /dev/null and b/res/drawable-xxhdpi/ic_launcher.png differ
--- /dev/null
+++ b/res/layout/actionbar_indeterminate_progress.xml
@@ -1,1 +1,24 @@
+<!--
+  Copyright 2013 Google Inc.
 
+  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.
+  -->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             android:layout_height="wrap_content"
+             android:layout_width="56dp"
+             android:minWidth="56dp">
+    <ProgressBar android:layout_width="32dp"
+                 android:layout_height="32dp"
+                 android:layout_gravity="center"/>
+</FrameLayout>
+

--- /dev/null
+++ b/res/layout/activity_main.xml
@@ -1,1 +1,24 @@
-
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"

+    android:id="@+id/drawer_layout"

+    android:layout_width="match_parent"

+    android:layout_height="match_parent" >

+

+    <!-- The main content view -->

+

+    <FrameLayout

+        android:id="@+id/frame_layout_main"

+        android:layout_width="match_parent"

+        android:layout_height="match_parent" />

+    <!-- The navigation drawer -->

+

+    <ListView

+        android:id="@+id/list_view_navigation_drawer"

+        android:layout_width="240dp"

+        android:layout_height="match_parent"

+        android:layout_gravity="start"

+        android:background="#111"

+        android:choiceMode="singleChoice"

+        android:divider="@android:color/transparent"

+        android:dividerHeight="0dp" />

+

+</android.support.v4.widget.DrawerLayout>

--- /dev/null
+++ b/res/layout/conversation_fragment_layout.xml
@@ -1,1 +1,30 @@
-
+<?xml version="1.0" encoding="utf-8"?>

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

+    android:layout_width="match_parent"

+    android:layout_height="match_parent" >

+

+    <ListView

+        android:id="@+id/list_view_messages"

+        android:layout_width="match_parent"

+        android:layout_height="wrap_content"

+        android:layout_alignParentTop="true" >

+    </ListView>

+

+    <RelativeLayout

+        android:id="@+id/relative_layout_send_message"

+        android:layout_width="match_parent"

+        android:layout_height="wrap_content"

+        android:layout_centerHorizontal="true" >

+

+        <EditText

+            android:id="@+id/edit_text_send_message"

+            android:layout_width="wrap_content"

+            android:layout_height="wrap_content" />

+

+        <ImageButton

+            android:id="@+id/image_button_send_message"

+            android:layout_width="match_parent"

+            android:layout_height="wrap_content" />

+    </RelativeLayout>

+

+</RelativeLayout>

--- /dev/null
+++ b/res/layout/gatt_services_characteristics.xml
@@ -1,1 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
 
+     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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="3dp">
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_margin="1dp">
+        <TextView android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:text="@string/label_device_address"
+                  android:textSize="16sp"/>
+        <Space android:layout_width="5dp"
+               android:layout_height="wrap_content"/>
+        <TextView android:id="@+id/device_address"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textSize="16sp"/>
+    </LinearLayout>
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_margin="1dp">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/label_state"
+            android:textSize="16sp" />
+
+        <Space android:layout_width="5dp"
+               android:layout_height="wrap_content"/>
+        <TextView android:id="@+id/connection_state"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:text="@string/disconnected"
+                  android:textSize="16sp"/>
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" >
+
+        <TextView
+            android:id="@+id/volume_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/volume" />
+
+        <Space android:layout_width="5dp"
+               android:layout_height="wrap_content"/>
+
+        <ProgressBar
+            android:id="@+id/volume_bar"
+            style="?android:attr/progressBarStyleHorizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:max="125"
+            android:progressDrawable="@drawable/whiteprogress" />
+
+    </LinearLayout>
+
+    <ListView android:id="@+id/packet_list"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"/>
+</LinearLayout>

--- /dev/null
+++ b/res/layout/listitem_device.xml
@@ -1,1 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
 
+     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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content">
+    <TextView android:id="@+id/device_name"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textSize="24dp"/>
+    <TextView android:id="@+id/device_address"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textSize="12dp"/>
+</LinearLayout>

--- /dev/null
+++ b/res/layout/map_fragment_layout.xml
@@ -1,1 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

+    android:layout_width="match_parent"

+    android:layout_height="match_parent" >

+    

+

+</RelativeLayout>

 

--- /dev/null
+++ b/res/layout/new_conversation_fragment_layout.xml
@@ -1,1 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>

+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

+    android:layout_width="match_parent"

+    android:layout_height="match_parent"

+    android:orientation="vertical" >

+    

+

+</LinearLayout>

 

--- /dev/null
+++ b/res/layout/packet_list_item.xml
@@ -1,1 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2006 The Android Open Source Project
 
+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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/packet_list_item"
+    android:textSize="12sp"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:textAppearance="?android:attr/textAppearanceListItemSmall"
+    android:gravity="center_vertical"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:minHeight="?android:attr/listPreferredItemHeightSmall"
+/>

--- /dev/null
+++ b/res/layout/whiteprogress.xml
@@ -1,1 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+<item android:id="@android:id/background">
+    <shape>
+        <solid
+                android:color="@android:color/transparent" />
+    </shape>
+</item>
 
+<item
+    android:id="@android:id/progress">
+    <clip>
+        <shape>
+            <solid
+                android:color="@android:color/white" />
+        </shape>
+    </clip>
+</item>
+
+</layer-list>

--- /dev/null
+++ b/res/menu/ble_scan.xml
@@ -1,1 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/menu_refresh"
+          android:checkable="false"
+          android:title="@string/menu_refresh"
+          android:orderInCategory="1"
+          android:showAsAction="ifRoom"/>
+    <item android:id="@+id/menu_scan"
+          android:title="@string/menu_scan"
+          android:orderInCategory="100"
+          android:showAsAction="ifRoom|withText"/>
+    <item android:id="@+id/menu_stop"
+          android:title="@string/menu_stop"
+          android:orderInCategory="101"
+          android:showAsAction="ifRoom|withText"/>
+</menu>
 

--- /dev/null
+++ b/res/menu/gatt_services.xml
@@ -1,1 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
 
+     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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/menu_refresh"
+          android:checkable="false"
+          android:orderInCategory="1"
+          android:showAsAction="ifRoom"/>
+    <item android:id="@+id/menu_connect"
+          android:title="@string/menu_connect"
+          android:orderInCategory="100"
+          android:showAsAction="ifRoom|withText"/>
+    <item android:id="@+id/menu_disconnect"
+          android:title="@string/menu_disconnect"
+          android:orderInCategory="101"
+          android:showAsAction="ifRoom|withText"/>
+</menu>
+

file:b/res/menu/main.xml (new)
--- /dev/null
+++ b/res/menu/main.xml
@@ -1,1 +1,17 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"

+    xmlns:tools="http://schemas.android.com/tools"

+    tools:context="com.dryerzinia.aprs_x.MainActivity" >

+

+    <item

+        android:id="@+id/action_settings"

+        android:orderInCategory="100"

+        android:showAsAction="never"

+        android:title="@string/action_settings"/>

+

+    <item android:id="@+id/ble_scan"

+          android:orderInCategory="1"

+          android:showAsAction="never"

+          android:title="@string/menu_ble_scan"/>

+    

+</menu>

 

--- /dev/null
+++ b/res/values-v11/styles.xml
@@ -1,1 +1,12 @@
+<resources>

+

+    <!--

+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.

+    -->

+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">

+        <!-- API 11 theme customizations can go here. -->

+    </style>

+

+</resources>

 

--- /dev/null
+++ b/res/values-v14/styles.xml
@@ -1,1 +1,13 @@
+<resources>

+

+    <!--

+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.

+    -->

+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">

+        <!-- API 14 theme customizations can go here. -->

+    </style>

+

+</resources>

 

--- /dev/null
+++ b/res/values-w820dp/dimens.xml
@@ -1,1 +1,11 @@
+<resources>

+

+    <!--

+         Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).

+    -->

+    <dimen name="activity_horizontal_margin">64dp</dimen>

+

+</resources>

 

--- /dev/null
+++ b/res/values/color.xml
@@ -1,1 +1,11 @@
-
+<?xml version="1.0" encoding="utf-8"?>

+<resources>

+

+    <color name="purple_mild">#9b98fe</color>

+    <color name="orange_mild">#ffa873</color>

+    <color name="orange_strong">#fe9800</color>

+    <color name="purple_strong">#bc79be</color>

+    <color name="beige_mild">#f8fbdb</color>

+    <color name="black">#000000</color>

+

+</resources>

--- /dev/null
+++ b/res/values/dimens.xml
@@ -1,1 +1,24 @@
+<resources>

+

+    <!-- Default screen margins, per the Android Design guidelines. -->

+    <dimen name="activity_horizontal_margin">16dp</dimen>

+    <dimen name="activity_vertical_margin">16dp</dimen>

+    

+    <!-- Google metrics and grids guidelines, taken from: http://developer.android.com/design/style/metrics-grids.html-->

+    <dimen name="single_item_height">48dp</dimen>

+    <dimen name="single_item_height_.5">24dp</dimen>

+    <dimen name="single_item_height_1.5">72dp</dimen>

+    <dimen name="single_item_height_2">96dp</dimen>

+    

+    <dimen name="single_item_vertical_padding">4dp</dimen>

+    <dimen name="single_item_vertical_padding_.5">2dp</dimen>

+    <dimen name="single_item_vertical_padding_1.5">6dp</dimen>

+    <dimen name="single_item_vertical_padding_2">8dp</dimen>

+

+    <dimen name="single_item_horizontal_padding">8dp</dimen>

+    <dimen name="single_item_horizontal_padding_.5">4dp</dimen>

+    <dimen name="single_item_horizontal_padding_1.5">12dp</dimen>

+    <dimen name="single_item_horizontal_padding_2">16dp</dimen>

+

+</resources>

 

--- /dev/null
+++ b/res/values/strings.xml
@@ -1,1 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>

+

+    <string name="app_name">APRS-X</string>

+    <string name="hello_world">Hello world!</string>

+    <string name="action_settings">Settings</string>

 
+    <string name="ble_not_supported">BLE is not supported</string>
+    <string name="label_data">Data:</string>
+    <string name="volume">Volume:</string>
+    <string name="label_device_address">Device address:</string>
+    <string name="label_state">State:</string>
+    <string name="no_data">No data</string>
+    <string name="connected">Connected</string>
+    <string name="disconnected">Disconnected</string>
+    <string name="title_devices">BLE Device Scan</string>
+    <string name="error_bluetooth_not_supported">Bluetooth not supported.</string>
+
+    <string name="unknown_device">Unknown device</string>
+    <string name="unknown_characteristic">Unknown characteristic</string>
+    <string name="unknown_service">Unknown service</string>
+
+    <string name="menu_ble_scan">BLE Scan</string>
+    
+    <string name="menu_connect">Connect</string>
+    <string name="menu_disconnect">Disconnect</string>
+    <string name="menu_scan">Scan</string>
+    <string name="menu_stop">Stop</string>
+    <string name="menu_refresh">Refresh</string>
+

+</resources>

+

--- /dev/null
+++ b/res/values/styles.xml
@@ -1,1 +1,21 @@
+<resources>

+

+    <!--

+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.

+    -->

+    <style name="AppBaseTheme" parent="android:Theme.Light">

+        <!--

+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.

+        -->

+    </style>

+

+    <!-- Application theme. -->

+    <style name="AppTheme" parent="AppBaseTheme">

+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->

+    </style>

+

+</resources>

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/data_model/CommThread.java
@@ -1,1 +1,50 @@
+package com.dryerzinia.aprs_x.data_model;

+

+import java.util.ArrayList;

+

+public class CommThread {

+

+	private String commThreadID;

+	private ArrayList<String> participantAddresses, commMessageIDs;

+

+	public CommThread() {

+		participantAddresses = new ArrayList<String>();

+		commMessageIDs = new ArrayList<String>();

+	}

+

+	/**

+	 * Generates a UUID from the participantAddresses (so that we can check and

+	 * see if a CommThread already exists with that set of participants)

+	 */

+	public void generateCommThreadID() {

+		// TODO this should generate a UUID from the participantAddresses.

+	}

+

+	public String getCommThreadID() {

+		return commThreadID;

+	}

+

+	public void setCommThreadID(String commThreadID) {

+		this.commThreadID = commThreadID;

+	}

+

+	public ArrayList<String> getParticipantAddresses() {

+		return participantAddresses;

+	}

+

+	// TODO we need to sort this list in (alphabetical?) order so that when we generate a UUID

+	// for a set of addresses, it will always be the same.

+	public void setParticipantAddresses(ArrayList<String> participantAddresses) {

+		this.participantAddresses = participantAddresses;

+		generateCommThreadID();

+	}

+

+	public ArrayList<String> getCommMessageIDs() {

+		return commMessageIDs;

+	}

+

+	public void setCommMessageIDs(ArrayList<String> commMessageIDs) {

+		this.commMessageIDs = commMessageIDs;

+	}

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/data_model/XContact.java
@@ -1,1 +1,29 @@
+package com.dryerzinia.aprs_x.data_model;

+

+public class XContact {

+

+	private String address;

+	private String commonName;

+

+	public XContact() {

+

+	}

+

+	public String getAddress() {

+		return address;

+	}

+

+	public void setAddress(String address) {

+		this.address = address;

+	}

+

+	public String getCommonName() {

+		return commonName;

+	}

+

+	public void setCommonName(String commonName) {

+		this.commonName = commonName;

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/data_model/XMessage.java
@@ -1,1 +1,70 @@
+package com.dryerzinia.aprs_x.data_model;

+

+public class XMessage {

+

+	private String messageID, destAddress, sentAddress, message, timestamp;

+	private long lat, lon;

+

+	public XMessage() {

+

+	}

+

+	public String getMessageID() {

+		return messageID;

+	}

+

+	//TODO this should be a UUID.

+	public void setMessageID(String messageID) {

+		this.messageID = messageID;

+	}

+

+	public String getDestAddress() {

+		return destAddress;

+	}

+

+	public void setDestAddress(String destAddress) {

+		this.destAddress = destAddress;

+	}

+

+	public String getSentAddress() {

+		return sentAddress;

+	}

+

+	public void setSentAddress(String sentAddress) {

+		this.sentAddress = sentAddress;

+	}

+

+	public String getMessage() {

+		return message;

+	}

+

+	public void setMessage(String message) {

+		this.message = message;

+	}

+

+	public String getTimestamp() {

+		return timestamp;

+	}

+

+	public void setTimestamp(String timestamp) {

+		this.timestamp = timestamp;

+	}

+

+	public long getLat() {

+		return lat;

+	}

+

+	public void setLat(long lat) {

+		this.lat = lat;

+	}

+

+	public long getLon() {

+		return lon;

+	}

+

+	public void setLon(long lon) {

+		this.lon = lon;

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/DatabaseConstants.java
@@ -1,1 +1,39 @@
+package com.dryerzinia.aprs_x.db;

+

+import com.dryerzinia.aprs_x.db.DatabaseContract.PacketMasterTableSchema;

+

+public class DatabaseConstants {

+

+	/*

+	 * SQLite data types.

+	 */

+	public static final String SQLITE_TEXT_TYPE = " TEXT";

+	public static final String SQLITE_REAL_TYPE = " REAL";

+	public static final String SQLITE_INTEGER_TYPE = " INTEGER";

+	public static final String SQLITE_INTEGER_PRIMARY_KEY_TYPE = " INTEGER PRIMARY KEY";

+	public static final String SQLITE_BLOB_TYPE = " BLOB";

+	public static final String DELIM_COMMA = ",";

+

+	public static final String SQL_CREATE_TABLE = "CREATE TABLE ";

+	public static final String SQL_DROP_TABLE_IF_EXISTS = "DROP TABLE IF EXISTS ";

+

+	/*

+	 * Create table statements.

+	 */

+	public static final String CREATE_PACKET_MASTER_TABLE = SQL_CREATE_TABLE + PacketMasterTableSchema.TABLE_NAME + " (" + PacketMasterTableSchema._ID

+			+ SQLITE_INTEGER_PRIMARY_KEY_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_UUID + SQLITE_TEXT_TYPE + DELIM_COMMA

+			+ PacketMasterTableSchema.COLUMN_NAME_SOURCE_ADDRESS + SQLITE_TEXT_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_DESTINATION_ADDRESS

+			+ SQLITE_TEXT_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_PACKET_TYPE + SQLITE_TEXT_TYPE + DELIM_COMMA

+			+ PacketMasterTableSchema.COLUMN_NAME_PACKET_DATA_ID + SQLITE_TEXT_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_RAW_DATA + SQLITE_BLOB_TYPE

+			+ DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_REPEATER_ADDRESS_1 + SQLITE_TEXT_TYPE + DELIM_COMMA

+			+ PacketMasterTableSchema.COLUMN_NAME_REPEATER_ADDRESS_2 + SQLITE_TEXT_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_REPEATER_ADDRESS_3

+			+ SQLITE_TEXT_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_REPEATER_ADDRESS_4 + SQLITE_TEXT_TYPE + DELIM_COMMA

+			+ PacketMasterTableSchema.COLUMN_NAME_REPEATER_ADDRESS_5 + SQLITE_TEXT_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_REPEATER_ADDRESS_6

+			+ SQLITE_TEXT_TYPE + DELIM_COMMA + PacketMasterTableSchema.COLUMN_NAME_REPEATER_ADDRESS_7 + SQLITE_TEXT_TYPE + " )";

+

+	/*

+	 * Drop table statements.

+	 */

+	public static final String DROP_PACKET_MASTER_TABLE = SQL_DROP_TABLE_IF_EXISTS + PacketMasterTableSchema.TABLE_NAME;

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/DatabaseContract.java
@@ -1,1 +1,87 @@
+package com.dryerzinia.aprs_x.db;

+

+import android.provider.BaseColumns;

+

+/**

+ * Contains static abstract inner classes that define the schemas for the

+ * individual tables in the database.

+ */

+public final class DatabaseContract {

+

+	private DatabaseContract() {

+

+	}

+

+	public static abstract class PacketMasterTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "packet_master";

+		public static final String COLUMN_NAME_UUID = "uuid";

+		public static final String COLUMN_NAME_SOURCE_ADDRESS = "source_address";

+		public static final String COLUMN_NAME_DESTINATION_ADDRESS = "destination_address";

+		public static final String COLUMN_NAME_PACKET_TYPE = "packet_type";

+		public static final String COLUMN_NAME_PACKET_DATA_ID = "packet_data_id";

+		public static final String COLUMN_NAME_RAW_DATA = "raw_data";

+		public static final String COLUMN_NAME_REPEATER_ADDRESS_1 = "repeater_address_1";

+		public static final String COLUMN_NAME_REPEATER_ADDRESS_2 = "repeater_address_2";

+		public static final String COLUMN_NAME_REPEATER_ADDRESS_3 = "repeater_address_3";

+		public static final String COLUMN_NAME_REPEATER_ADDRESS_4 = "repeater_address_4";

+		public static final String COLUMN_NAME_REPEATER_ADDRESS_5 = "repeater_address_5";

+		public static final String COLUMN_NAME_REPEATER_ADDRESS_6 = "repeater_address_6";

+		public static final String COLUMN_NAME_REPEATER_ADDRESS_7 = "repeater_address_7";

+	}

+

+	public static abstract class OldMicETableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "old_mic_e";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class CurrentMicETableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "current_mic_e";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class PositionWithTimestampTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "position_with_timestamping";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class PositionWithTimestampNoMessagingTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "position_with_timestamping_no_messaging";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class PositionWithoutTimestampableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "position_without_timestamp";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class PositionWithoutTimestampNoMessagingTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "position_without_timestamp_no_messaging";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class AprsStatusTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "aprs_status";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class WeatherReportTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "weather_report";

+		public static final String COLUMN_NAME_UUID = "uuid";

+	}

+

+	public static abstract class ContactsTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "contacts";

+		public static final String COLUMN_NAME_UUID = "uuid";

+		public static final String COLUMN_NAME_LAST_SEEN_TIMESTAMP = "last_seen_timestamp";

+		public static final String COLUMN_NAME_CONTACT_NAME = "contact_name";

+		public static final String COLUMN_NAME_SYSTEM_ID = "system_id";

+	}

+

+	public static abstract class ConversationsTableSchema implements BaseColumns {

+		public static final String TABLE_NAME = "conversations";

+		public static final String COLUMN_NAME_PEER_ADDRESS = "peer_address";

+		public static final String COLUMN_NAME_LAST_RECEIVED_MESSAGE_TIMESTAMP = "last_message_received_timestamp";

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/DatabaseHelper.java
@@ -1,1 +1,28 @@
+package com.dryerzinia.aprs_x.db;

+

+import android.content.Context;

+import android.database.sqlite.SQLiteDatabase;

+import android.database.sqlite.SQLiteDatabase.CursorFactory;

+import android.database.sqlite.SQLiteOpenHelper;

+

+public class DatabaseHelper extends SQLiteOpenHelper {

+

+	public static final String DATABASE_NAME = "aprsx.db";

+	public static final int DATABASE_VERSION = 1;

+

+	public DatabaseHelper(Context context) {

+		super(context, DATABASE_NAME, null, DATABASE_VERSION);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

+

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/DatabaseManager.java
@@ -1,1 +1,37 @@
+package com.dryerzinia.aprs_x.db;

+

+import android.app.Activity;

+

+public class DatabaseManager {

+

+	private Activity mActivity;

+

+	private DatabaseHelper dbHelper;

+

+	private DatabaseManager() {

+

+	}

+

+	private static class SingletonHolder {

+		private static final DatabaseManager INSTANCE = new DatabaseManager();

+	}

+

+	public static DatabaseManager getInstance() {

+		return SingletonHolder.INSTANCE;

+	}

+

+	public void initialize(Activity activity) {

+		this.mActivity = activity;

+		this.setDbHelper(new DatabaseHelper(mActivity));

+	}

+

+	public DatabaseHelper getDbHelper() {

+		return dbHelper;

+	}

+

+	public void setDbHelper(DatabaseHelper dbHelper) {

+		this.dbHelper = dbHelper;

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/AprsStatusTable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class AprsStatusTable extends Table {

+

+	public AprsStatusTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/ContactsTable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class ContactsTable extends Table {

+

+	public ContactsTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/ConversationTable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class ConversationTable extends Table {

+

+	public ConversationTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/CurrentMicETable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class CurrentMicETable extends Table {

+

+	public CurrentMicETable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/OldMicETable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class OldMicETable extends Table {

+

+	public OldMicETable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/PacketMasterTable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class PacketMasterTable extends Table {

+

+	public PacketMasterTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/PositionWithTimestampNoMessagingTable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class PositionWithTimestampNoMessagingTable extends Table {

+

+	public PositionWithTimestampNoMessagingTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/PositionWithTimestampTable.java
@@ -1,1 +1,23 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class PositionWithTimestampTable extends Table{

+

+	public PositionWithTimestampTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/PositionWithoutTimestampNoMessaging.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class PositionWithoutTimestampNoMessaging extends Table {

+

+	public PositionWithoutTimestampNoMessaging(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/PositionWithoutTimestampTable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class PositionWithoutTimestampTable extends Table {

+

+	public PositionWithoutTimestampTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/Table.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public abstract class Table {

+	private String createStatement, dropTableStatement;

+

+	public Table(String createStatement, String dropTableStatement) {

+		this.createStatement = createStatement;

+		this.dropTableStatement = dropTableStatement;

+	}

+

+	public void onCreate(SQLiteDatabase db) {

+		db.execSQL(createStatement);

+	}

+

+	public void onUpgrade(SQLiteDatabase db) {

+		db.execSQL(dropTableStatement);

+		onCreate(db);

+	}

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/db/table/WeatherReportTable.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.db.table;

+

+import android.database.sqlite.SQLiteDatabase;

+

+public class WeatherReportTable extends Table {

+

+	public WeatherReportTable(String createStatement, String dropTableStatement) {

+		super(createStatement, dropTableStatement);

+	}

+

+	@Override

+	public void onCreate(SQLiteDatabase db) {

+		super.onCreate(db);

+	}

+

+	@Override

+	public void onUpgrade(SQLiteDatabase db) {

+		super.onUpgrade(db);

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/services/BluetoothLeService.java
@@ -1,1 +1,402 @@
-
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.dryerzinia.aprs_x.services;
+
+import android.app.Service;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothGattCallback;
+import android.bluetooth.BluetoothGattCharacteristic;
+import android.bluetooth.BluetoothGattDescriptor;
+import android.bluetooth.BluetoothGattService;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.BluetoothProfile;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+import android.util.Log;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Service for managing connection and data communication with a GATT server hosted on a
+ * given Bluetooth LE device.
+ */
+public class BluetoothLeService extends Service {
+    private final static String TAG = BluetoothLeService.class.getSimpleName();
+
+    private BluetoothManager mBluetoothManager;
+    private BluetoothAdapter mBluetoothAdapter;
+    private String mBluetoothDeviceAddress;
+    private BluetoothGatt mBluetoothGatt;
+    private int mConnectionState = STATE_DISCONNECTED;
+
+    private int packetTotalLength = 0;
+    private int packetCurrentLength = 256;
+    private byte[] packetData = new byte[256];
+
+    private static final int STATE_DISCONNECTED = 0;
+    private static final int STATE_CONNECTING = 1;
+    private static final int STATE_CONNECTED = 2;
+
+    public final static String ACTION_GATT_CONNECTED =
+            "com.example.bluetooth.le.ACTION_GATT_CONNECTED";
+    public final static String ACTION_GATT_DISCONNECTED =
+            "com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
+    public final static String ACTION_GATT_SERVICES_DISCOVERED =
+            "com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
+    public final static String ACTION_DATA_AVAILABLE =
+            "com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
+    public final static String EXTRA_DATA =
+            "com.example.bluetooth.le.EXTRA_DATA";
+    public final static String BLE_TNC_PACKET_DATA =
+            "com.example.bluetooth.le.BLE_TNC_PACKET_DATA";
+    public final static String BLE_TNC_VOLUME =
+            "com.example.bluetooth.le.BLE_TNC_VOLUME";
+
+    public final static UUID UUID_BLE_TNC_PACKET_DATA =
+            UUID.fromString("00002221-0000-1000-8000-00805f9b34fb");
+
+    // Implements callback methods for GATT events that the app cares about.  For example,
+    // connection change and services discovered.
+    private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
+        @Override
+        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
+            String intentAction;
+            if (newState == BluetoothProfile.STATE_CONNECTED) {
+                intentAction = ACTION_GATT_CONNECTED;
+                mConnectionState = STATE_CONNECTED;
+                broadcastUpdate(intentAction);
+                Log.i(TAG, "Connected to GATT server.");
+                // Attempts to discover services after successful connection.
+                Log.i(TAG, "Attempting to start service discovery:" +
+                        mBluetoothGatt.discoverServices());
+
+            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
+                intentAction = ACTION_GATT_DISCONNECTED;
+                mConnectionState = STATE_DISCONNECTED;
+                Log.i(TAG, "Disconnected from GATT server.");
+                broadcastUpdate(intentAction);
+            }
+        }
+
+        @Override
+        public void onServicesDiscovered(BluetoothGatt gatt, int status) {
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
+            } else {
+                Log.e(TAG, "onServicesDiscovered received: " + status);
+            }
+        }
+
+        @Override
+        public void onCharacteristicRead(BluetoothGatt gatt,
+                                         BluetoothGattCharacteristic characteristic,
+                                         int status) {
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
+            }
+        }
+
+        @Override
+        public void onDescriptorRead(BluetoothGatt gatt,
+        								BluetoothGattDescriptor descriptor,
+        								int status) {
+
+        }
+
+        @Override
+        public void onDescriptorWrite(BluetoothGatt gatt,
+        								BluetoothGattDescriptor descriptor,
+        								int status) {
+
+        }
+
+        @Override
+        public void onCharacteristicChanged(BluetoothGatt gatt,
+                                            BluetoothGattCharacteristic characteristic) {
+            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
+        }
+    };
+
+    private void broadcastUpdate(final String action) {
+        final Intent intent = new Intent(action);
+        sendBroadcast(intent);
+    }
+
+    private void broadcastUpdate(final String action,
+                                 final BluetoothGattCharacteristic characteristic) {
+
+        Log.d(TAG, "Update");
+        if (UUID_BLE_TNC_PACKET_DATA.equals(characteristic.getUuid())){
+
+        	final byte[] data = characteristic.getValue();
+
+            Log.d(TAG, "Message type: " + data[0]);
+
+        	if(data[0] == 0x01){
+
+        		Log.d(TAG, "Packet Start Length: " + (data[1] & 0xFF));
+
+        		packetTotalLength = data[1] & 0xFF; // Convert to unsigned
+        		packetData[0] = data[1];
+        		packetCurrentLength = 0;
+        		for(int i = 2; i < data.length; i++){
+        			packetData[packetCurrentLength + 1] = data[i];
+        			packetCurrentLength++;
+        		}
+
+        	} else if(data[0] == 0x02){
+
+        		Log.d(TAG, "Packet Continued...");
+
+        		if(packetCurrentLength + data.length >= packetData.length){
+
+        			Log.e(TAG, "Error: Packet to long!");
+
+        			packetTotalLength = 0;
+            		packetCurrentLength = 256;
+
+            		return;
+
+        		}
+
+        		for(int i = 1; i < data.length; i++){
+        			packetData[packetCurrentLength + 1] = data[i];
+        			packetCurrentLength++;
+        		}
+
+        	} else if(data[0] == 0x03){
+
+        		Log.d(TAG, "Volume Peak: " + (data[1] & 0xFF));
+
+        		final Intent intent = new Intent(action);
+        		intent.putExtra(BLE_TNC_VOLUME, (int) (data[1] & 0xFF));
+                sendBroadcast(intent);
+
+        	}
+
+        	Log.d(TAG, "ptl: " + packetTotalLength);
+        	Log.d(TAG, "pcl: " + packetCurrentLength);
+
+        	if(packetTotalLength == packetCurrentLength){
+
+        		Log.d(TAG, "Broadcasting packet");
+
+        		final Intent intent = new Intent(action);
+        		intent.putExtra(BLE_TNC_PACKET_DATA, packetData);
+                sendBroadcast(intent);
+
+        		packetTotalLength = 0;
+        		packetCurrentLength = 256;
+
+        	} else if(packetTotalLength < packetCurrentLength && packetCurrentLength != 256){
+
+        		Log.e(TAG, "Error: Packet to long!");
+
+        		// Error, don't broadcast
+        		packetTotalLength = 0;
+        		packetCurrentLength = 256;
+
+        	}
+
+        }
+    }
+
+    public class LocalBinder extends Binder {
+        public BluetoothLeService getService() {
+            return BluetoothLeService.this;
+        }
+    }
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return mBinder;
+    }
+
+    @Override
+    public boolean onUnbind(Intent intent) {
+        // After using a given device, you should make sure that BluetoothGatt.close() is called
+        // such that resources are cleaned up properly.  In this particular example, close() is
+        // invoked when the UI is disconnected from the Service.
+        close();
+        return super.onUnbind(intent);
+    }
+
+    private final IBinder mBinder = new LocalBinder();
+
+    /**
+     * Initializes a reference to the local Bluetooth adapter.
+     *
+     * @return Return true if the initialization is successful.
+     */
+    public boolean initialize() {
+        // For API level 18 and above, get a reference to BluetoothAdapter through
+        // BluetoothManager.
+        if (mBluetoothManager == null) {
+            mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
+            if (mBluetoothManager == null) {
+                Log.e(TAG, "Unable to initialize BluetoothManager.");
+                return false;
+            }
+        }
+
+        mBluetoothAdapter = mBluetoothManager.getAdapter();
+        if (mBluetoothAdapter == null) {
+            Log.e(TAG, "Unable to obtain a BluetoothAdapter.");
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Connects to the GATT server hosted on the Bluetooth LE device.
+     *
+     * @param address The device address of the destination device.
+     *
+     * @return Return true if the connection is initiated successfully. The connection result
+     *         is reported asynchronously through the
+     *         {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
+     *         callback.
+     */
+    public boolean connect(final String address) {
+        if (mBluetoothAdapter == null || address == null) {
+            Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
+            return false;
+        }
+
+        // Previously connected device.  Try to reconnect.
+        if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress)
+                && mBluetoothGatt != null) {
+            Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection.");
+            if (mBluetoothGatt.connect()) {
+                mConnectionState = STATE_CONNECTING;
+                return true;
+            } else {
+                return false;
+            }
+        }
+
+        final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
+        if (device == null) {
+            Log.w(TAG, "Device not found.  Unable to connect.");
+            return false;
+        }
+        // We want to directly connect to the device, so we are setting the autoConnect
+        // parameter to false.
+        mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
+        Log.d(TAG, "Trying to create a new connection.");
+        mBluetoothDeviceAddress = address;
+        mConnectionState = STATE_CONNECTING;
+        return true;
+    }
+
+    /**
+     * Disconnects an existing connection or cancel a pending connection. The disconnection result
+     * is reported asynchronously through the
+     * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
+     * callback.
+     */
+    public void disconnect() {
+        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
+            Log.w(TAG, "BluetoothAdapter not initialized");
+            return;
+        }
+        mBluetoothGatt.disconnect();
+    }
+
+    /**
+     * After using a given BLE device, the app must call this method to ensure resources are
+     * released properly.
+     */
+    public void close() {
+        if (mBluetoothGatt == null) {
+            return;
+        }
+        mBluetoothGatt.close();
+        mBluetoothGatt = null;
+    }
+
+    /**
+     * Request a read on a given {@code BluetoothGattCharacteristic}. The read result is reported
+     * asynchronously through the {@code BluetoothGattCallback#onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int)}
+     * callback.
+     *
+     * @param characteristic The characteristic to read from.
+     */
+    public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
+        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
+            Log.w(TAG, "BluetoothAdapter not initialized");
+            return;
+        }
+        mBluetoothGatt.readCharacteristic(characteristic);
+    }
+
+    public void writeDescriptor(BluetoothGattDescriptor descriptor) {
+        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
+            Log.w(TAG, "BluetoothAdapter not initialized");
+            return;
+        }
+        mBluetoothGatt.writeDescriptor(descriptor);
+    }
+
+    
+    /**
+     * Enables or disables notification on a give characteristic.
+     *
+     * @param characteristic Characteristic to act on.
+     * @param enabled If true, enable notification.  False otherwise.
+     */
+    public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
+                                              boolean enabled) {
+        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
+            Log.w(TAG, "BluetoothAdapter not initialized");
+            return;
+        }
+
+        mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
+
+        if (UUID_BLE_TNC_PACKET_DATA.equals(characteristic.getUuid())) {
+
+        	BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
+                    UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
+
+        	descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
+            mBluetoothGatt.writeDescriptor(descriptor);
+
+        }
+    }
+
+    /**
+     * Retrieves a list of supported GATT services on the connected device. This should be
+     * invoked only after {@code BluetoothGatt#discoverServices()} completes successfully.
+     *
+     * @return A {@code List} of supported services.
+     */
+    public List<BluetoothGattService> getSupportedGattServices() {
+        if (mBluetoothGatt == null) return null;
+
+        return mBluetoothGatt.getServices();
+    }
+}
+

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/services/DataManager.java
@@ -1,1 +1,42 @@
+package com.dryerzinia.aprs_x.services;

+

+import java.text.SimpleDateFormat;

+import java.util.Date;

+

+import com.dryerzinia.aprs_x.test.TestManager;

+

+public class DataManager {

+

+	private DataManager() {

+

+	}

+

+	private static class SingletonHolder {

+		static final DataManager INSTANCE = new DataManager();

+	}

+

+	public static DataManager getInstance() {

+		return SingletonHolder.INSTANCE;

+	}

+

+	public void initialize() {

+		TestManager.getInstance().initialize();

+	}

+

+	/**

+	 * 

+	 * @return The current time with the yyyy-MM-dd HH:mm:ss format.

+	 */

+	public String getCurrentTimestamp() {

+		try {

+			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+			String currentTimeStamp = dateFormat.format(new Date());

+			return currentTimeStamp;

+		} catch (Exception e) {

+			e.printStackTrace();

+			return null;

+		}

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/test/DeviceControlActivity.java
@@ -1,1 +1,295 @@
-
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.dryerzinia.aprs_x.test;
+
+import android.app.Activity;
+import android.bluetooth.BluetoothGattCharacteristic;
+import android.bluetooth.BluetoothGattService;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
+import android.graphics.Color;
+import android.graphics.PorterDuff.Mode;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.IBinder;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import com.dryerzinia.aprs_x.R;
+import com.dryerzinia.aprs_x.services.BluetoothLeService;
+
+/**
+ * For a given BLE device, this Activity provides the user interface to connect, display data,
+ * and display GATT services and characteristics supported by the device.  The Activity
+ * communicates with {@code BluetoothLeService}, which in turn interacts with the
+ * Bluetooth LE API.
+ */
+public class DeviceControlActivity extends Activity {
+
+	private final static String TAG = DeviceControlActivity.class.getSimpleName();
+
+    public static final String EXTRAS_DEVICE_NAME = "DEVICE_NAME";
+    public static final String EXTRAS_DEVICE_ADDRESS = "DEVICE_ADDRESS";
+    
+    public static final String BLE_TNC_SERVICE = "00002220-0000-1000-8000-00805f9b34fb";
+    public static final String BLE_TNC_PACKET_DATA = "00002221-0000-1000-8000-00805f9b34fb";
+
+    private TextView mConnectionState;
+    private String mDeviceName;
+    private String mDeviceAddress;
+    private ArrayAdapter<String> mPacketListArrayAdapter;
+    private List<String> mPacketList = new ArrayList<String>();
+    private ListView mPacketListView;
+    private ProgressBar volumeBar;
+    private BluetoothLeService mBluetoothLeService;
+    private boolean mConnected = false;
+    private OutputStream mLogOutputStream;
+
+    // Code to manage Service lifecycle.
+    private final ServiceConnection mServiceConnection = new ServiceConnection() {
+
+        @Override
+        public void onServiceConnected(ComponentName componentName, IBinder service) {
+            mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
+            if (!mBluetoothLeService.initialize()) {
+                Log.e(TAG, "Unable to initialize Bluetooth");
+                finish();
+            }
+            // Automatically connects to the device upon successful start-up initialization.
+            mBluetoothLeService.connect(mDeviceAddress);
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName componentName) {
+            mBluetoothLeService = null;
+        }
+    };
+
+    // Handles various events fired by the Service.
+    // ACTION_GATT_CONNECTED: connected to a GATT server.
+    // ACTION_GATT_DISCONNECTED: disconnected from a GATT server.
+    // ACTION_GATT_SERVICES_DISCOVERED: discovered GATT services.
+    // ACTION_DATA_AVAILABLE: received data from the device.  This can be a result of read
+    //                        or notification operations.
+    private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            final String action = intent.getAction();
+            if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
+
+            	mConnected = true;
+                updateConnectionState(R.string.connected);
+                invalidateOptionsMenu();
+
+            } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
+
+            	mConnected = false;
+                updateConnectionState(R.string.disconnected);
+                invalidateOptionsMenu();
+
+            } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
+
+            	List<BluetoothGattService> services = mBluetoothLeService.getSupportedGattServices();
+            	for(BluetoothGattService service : services){
+            		if(service.getUuid().equals(UUID.fromString(BLE_TNC_SERVICE))){
+            			BluetoothGattCharacteristic tncCharacteristic = service.getCharacteristic(UUID.fromString(BLE_TNC_PACKET_DATA));
+           				mBluetoothLeService.setCharacteristicNotification(tncCharacteristic, true);
+            		}
+            	}
+
+            } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
+
+                if(intent.hasExtra(BluetoothLeService.BLE_TNC_VOLUME)){
+
+                	int volume = intent.getIntExtra(BluetoothLeService.BLE_TNC_VOLUME, -1);
+                	if(volume != -1){
+
+                		volumeBar.setProgress(volume);
+                		if(volume > 110){
+                			volumeBar.getProgressDrawable().setColorFilter(Color.RED, Mode.MULTIPLY);
+                		} else if(volume > 70){
+                			volumeBar.getProgressDrawable().setColorFilter(Color.GREEN, Mode.MULTIPLY);
+                		} else {
+                			volumeBar.getProgressDrawable().setColorFilter(Color.BLUE, Mode.MULTIPLY);
+                		}
+
+                	}
+
+                } else if(intent.hasExtra(BluetoothLeService.BLE_TNC_PACKET_DATA)){
+
+                    Log.d(TAG, "Displaying Packet");
+
+                	byte[] data = intent.getByteArrayExtra(BluetoothLeService.BLE_TNC_PACKET_DATA);
+	            	byte[] shortData = new byte[data[0] & 0xFF];
+	
+	            	for(int i = 0; i < (data[0] & 0xFF); i++){
+	            		shortData[i] = data[i + 1];
+	            	}
+	
+	                Log.d(TAG, "Len: " + (data[0] & 0xFF));
+	
+	                try {
+	                	mLogOutputStream.write(0x00);
+	                	mLogOutputStream.write(data[0]);
+						mLogOutputStream.write(shortData);
+						mLogOutputStream.flush();
+					} catch (IOException e1) {
+					}
+	
+	            	try {
+	                    Log.d(TAG, "Data: " + new String(shortData, "US-ASCII"));
+	            		displayData(new String(shortData, "US-ASCII"));
+					} catch (UnsupportedEncodingException e) {
+					}
+
+                }
+
+            }
+        }
+    };
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.gatt_services_characteristics);
+
+        final Intent intent = getIntent();
+        mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
+        mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);
+
+        // Sets up UI references.
+        ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
+        mPacketListView = (ListView) findViewById(R.id.packet_list);
+        mPacketListArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mPacketList);
+        mPacketListView.setAdapter(mPacketListArrayAdapter);
+        mConnectionState = (TextView) findViewById(R.id.connection_state);
+        volumeBar = (ProgressBar) findViewById(R.id.volume_bar);
+        volumeBar.setProgress(0);
+
+        Log.d(TAG, "EXT: " + Environment.getExternalStorageDirectory());
+      	try {
+			mLogOutputStream = new FileOutputStream(Environment.getExternalStorageDirectory()+"/packets.dat", true);
+		} catch (FileNotFoundException e) {
+		}
+
+        getActionBar().setTitle(mDeviceName);
+        getActionBar().setDisplayHomeAsUpEnabled(true);
+        Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
+        bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
+        registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        //registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
+        if (mBluetoothLeService != null) {
+            final boolean result = mBluetoothLeService.connect(mDeviceAddress);
+            Log.d(TAG, "Connect request result=" + result);
+        }
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        //unregisterReceiver(mGattUpdateReceiver);
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        unregisterReceiver(mGattUpdateReceiver);
+        unbindService(mServiceConnection);
+        mBluetoothLeService = null;
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.gatt_services, menu);
+        if (mConnected) {
+            menu.findItem(R.id.menu_connect).setVisible(false);
+            menu.findItem(R.id.menu_disconnect).setVisible(true);
+        } else {
+            menu.findItem(R.id.menu_connect).setVisible(true);
+            menu.findItem(R.id.menu_disconnect).setVisible(false);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch(item.getItemId()) {
+            case R.id.menu_connect:
+                mBluetoothLeService.connect(mDeviceAddress);
+                return true;
+            case R.id.menu_disconnect:
+                mBluetoothLeService.disconnect();
+                return true;
+            case android.R.id.home:
+                onBackPressed();
+                return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    private void updateConnectionState(final int resourceId) {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mConnectionState.setText(resourceId);
+            }
+        });
+    }
+
+    private void displayData(String data) {
+        if (data != null) {
+
+        	Log.d(TAG, "Disp: " + data);
+
+        	mPacketList.add(data);
+        	mPacketListArrayAdapter.notifyDataSetChanged();
+        }
+    }
+
+    private static IntentFilter makeGattUpdateIntentFilter() {
+        final IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
+        intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
+        intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
+        intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
+        return intentFilter;
+    }
+}
+

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/test/DeviceScanActivity.java
@@ -1,1 +1,270 @@
-
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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 com.dryerzinia.aprs_x.test;
+
+import android.app.Activity;
+import android.app.ListActivity;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+
+import com.dryerzinia.aprs_x.R;
+
+/**
+ * Activity for scanning and displaying available Bluetooth LE devices.
+ */
+public class DeviceScanActivity extends ListActivity {
+    private LeDeviceListAdapter mLeDeviceListAdapter;
+    private BluetoothAdapter mBluetoothAdapter;
+    private boolean mScanning;
+    private Handler mHandler;
+
+    private static final int REQUEST_ENABLE_BT = 1;
+    // Stops scanning after 10 seconds.
+    private static final long SCAN_PERIOD = 10000;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        getActionBar().setTitle(R.string.title_devices);
+        mHandler = new Handler();
+
+        // Use this check to determine whether BLE is supported on the device.  Then you can
+        // selectively disable BLE-related features.
+        if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
+            Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
+            finish();
+        }
+
+        // Initializes a Bluetooth adapter.  For API level 18 and above, get a reference to
+        // BluetoothAdapter through BluetoothManager.
+        final BluetoothManager bluetoothManager =
+                (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
+        mBluetoothAdapter = bluetoothManager.getAdapter();
+
+        // Checks if Bluetooth is supported on the device.
+        if (mBluetoothAdapter == null) {
+            Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show();
+            finish();
+            return;
+        }
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.ble_scan, menu);
+        if (!mScanning) {
+            menu.findItem(R.id.menu_stop).setVisible(false);
+            menu.findItem(R.id.menu_scan).setVisible(true);
+            menu.findItem(R.id.menu_refresh).setActionView(null);
+        } else {
+            menu.findItem(R.id.menu_stop).setVisible(true);
+            menu.findItem(R.id.menu_scan).setVisible(false);
+            menu.findItem(R.id.menu_refresh).setActionView(
+                    R.layout.actionbar_indeterminate_progress);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.menu_scan:
+                mLeDeviceListAdapter.clear();
+                scanLeDevice(true);
+                break;
+            case R.id.menu_stop:
+                scanLeDevice(false);
+                break;
+        }
+        return true;
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        // Ensures Bluetooth is enabled on the device.  If Bluetooth is not currently enabled,
+        // fire an intent to display a dialog asking the user to grant permission to enable it.
+        if (!mBluetoothAdapter.isEnabled()) {
+            if (!mBluetoothAdapter.isEnabled()) {
+                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+                startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+            }
+        }
+
+        // Initializes list view adapter.
+        mLeDeviceListAdapter = new LeDeviceListAdapter();
+        setListAdapter(mLeDeviceListAdapter);
+        scanLeDevice(true);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        // User chose not to enable Bluetooth.
+        if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {
+            finish();
+            return;
+        }
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        scanLeDevice(false);
+        mLeDeviceListAdapter.clear();
+    }
+
+    @Override
+    protected void onListItemClick(ListView l, View v, int position, long id) {
+        final BluetoothDevice device = mLeDeviceListAdapter.getDevice(position);
+        if (device == null) return;
+        final Intent intent = new Intent(this, DeviceControlActivity.class);
+        intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_NAME, device.getName());
+        intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_ADDRESS, device.getAddress());
+        if (mScanning) {
+            mBluetoothAdapter.stopLeScan(mLeScanCallback);
+            mScanning = false;
+        }
+        startActivity(intent);
+    }
+
+    private void scanLeDevice(final boolean enable) {
+        if (enable) {
+            // Stops scanning after a pre-defined scan period.
+            mHandler.postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    mScanning = false;
+                    mBluetoothAdapter.stopLeScan(mLeScanCallback);
+                    invalidateOptionsMenu();
+                }
+            }, SCAN_PERIOD);
+
+            mScanning = true;
+            mBluetoothAdapter.startLeScan(mLeScanCallback);
+        } else {
+            mScanning = false;
+            mBluetoothAdapter.stopLeScan(mLeScanCallback);
+        }
+        invalidateOptionsMenu();
+    }
+
+    // Adapter for holding devices found through scanning.
+    private class LeDeviceListAdapter extends BaseAdapter {
+        private ArrayList<BluetoothDevice> mLeDevices;
+        private LayoutInflater mInflator;
+
+        public LeDeviceListAdapter() {
+            super();
+            mLeDevices = new ArrayList<BluetoothDevice>();
+            mInflator = DeviceScanActivity.this.getLayoutInflater();
+        }
+
+        public void addDevice(BluetoothDevice device) {
+            if(!mLeDevices.contains(device)) {
+                mLeDevices.add(device);
+            }
+        }
+
+        public BluetoothDevice getDevice(int position) {
+            return mLeDevices.get(position);
+        }
+
+        public void clear() {
+            mLeDevices.clear();
+        }
+
+        @Override
+        public int getCount() {
+            return mLeDevices.size();
+        }
+
+        @Override
+        public Object getItem(int i) {
+            return mLeDevices.get(i);
+        }
+
+        @Override
+        public long getItemId(int i) {
+            return i;
+        }
+
+        @Override
+        public View getView(int i, View view, ViewGroup viewGroup) {
+            ViewHolder viewHolder;
+            // General ListView optimization code.
+            if (view == null) {
+                view = mInflator.inflate(R.layout.listitem_device, null);
+                viewHolder = new ViewHolder();
+                viewHolder.deviceAddress = (TextView) view.findViewById(R.id.device_address);
+                viewHolder.deviceName = (TextView) view.findViewById(R.id.device_name);
+                view.setTag(viewHolder);
+            } else {
+                viewHolder = (ViewHolder) view.getTag();
+            }
+
+            BluetoothDevice device = mLeDevices.get(i);
+            final String deviceName = device.getName();
+            if (deviceName != null && deviceName.length() > 0)
+                viewHolder.deviceName.setText(deviceName);
+            else
+                viewHolder.deviceName.setText(R.string.unknown_device);
+            viewHolder.deviceAddress.setText(device.getAddress());
+
+            return view;
+        }
+    }
+
+    // Device scan callback.
+    private BluetoothAdapter.LeScanCallback mLeScanCallback =
+            new BluetoothAdapter.LeScanCallback() {
+
+        @Override
+        public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
+            runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    mLeDeviceListAdapter.addDevice(device);
+                    mLeDeviceListAdapter.notifyDataSetChanged();
+                }
+            });
+        }
+    };
+
+    static class ViewHolder {
+        TextView deviceName;
+        TextView deviceAddress;
+    }
+}

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/test/TestManager.java
@@ -1,1 +1,26 @@
+package com.dryerzinia.aprs_x.test;

+

+public class TestManager {

+

+	private TestManager() {

+

+	}

+

+	private static class SingletonHolder {

+		static final TestManager INSTANCE = new TestManager();

+	}

+

+	public static TestManager getInstance() {

+		return SingletonHolder.INSTANCE;

+	}

+

+	public void initialize() {

+

+	}

+

+	public void generateMockMessages(){

+		

+	}

+	

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/ui/MainActivity.java
@@ -1,1 +1,64 @@
+package com.dryerzinia.aprs_x.ui;

+

+import android.app.Activity;

+import android.content.Intent;

+import android.os.Bundle;

+import android.support.v4.widget.DrawerLayout;

+import android.view.Menu;

+import android.view.MenuItem;

+import android.widget.ListView;

+

+import com.dryerzinia.aprs_x.R;

+import com.dryerzinia.aprs_x.services.DataManager;

+import com.dryerzinia.aprs_x.test.DeviceScanActivity;

+

+public class MainActivity extends Activity {

+

+	private DrawerLayout navigationDrawer;

+

+	/*

+	 * ListView variables.

+	 */

+	private ListView listViewNavDrawer;

+

+	@Override

+	protected void onCreate(Bundle savedInstanceState) {

+		super.onCreate(savedInstanceState);

+		setContentView(R.layout.activity_main);

+

+		/*

+		 * Initialize DataManager.

+		 */

+		DataManager.getInstance().initialize();

+		UIManager.getInstance().initialize();

+

+		/*

+		 * Initialize the NavigationDrawer.

+		 */

+		navigationDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);

+		listViewNavDrawer = (ListView) findViewById(R.id.list_view_navigation_drawer);

+	}

+

+	@Override

+	public boolean onCreateOptionsMenu(Menu menu) {

+		getMenuInflater().inflate(R.menu.main, menu);

+		return true;

+	}

+

+	@Override

+	public boolean onOptionsItemSelected(MenuItem item) {

+		// Handle action bar item clicks here. The action bar will

+		// automatically handle clicks on the Home/Up button, so long

+		// as you specify a parent activity in AndroidManifest.xml.

+		int id = item.getItemId();

+		if (id == R.id.action_settings) {

+			return true;

+		}

+		if (id == R.id.ble_scan) {

+			Intent intent = new Intent(this, DeviceScanActivity.class);

+			startActivity(intent);

+		}

+		return super.onOptionsItemSelected(item);

+	}

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/ui/UIManager.java
@@ -1,1 +1,22 @@
+package com.dryerzinia.aprs_x.ui;

+

+public class UIManager {

+

+	private UIManager() {

+

+	}

+

+	private static class SingletonHolder {

+		static final UIManager INSTANCE = new UIManager();

+	}

+

+	public static UIManager getInstance() {

+		return SingletonHolder.INSTANCE;

+	}

+

+	public void initialize() {

+

+	}

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/ui/adapter/CommThreadArrayAdapter.java
@@ -1,1 +1,6 @@
+package com.dryerzinia.aprs_x.ui.adapter;

+

+public class CommThreadArrayAdapter {

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/ui/adapter/XMessageArrayAdapter.java
@@ -1,1 +1,6 @@
+package com.dryerzinia.aprs_x.ui.adapter;

+

+public class XMessageArrayAdapter {

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/ui/fragment/ConversationFragment.java
@@ -1,1 +1,8 @@
+package com.dryerzinia.aprs_x.ui.fragment;

+

+import android.app.Fragment;

+

+public class ConversationFragment extends Fragment {

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/ui/fragment/MapFragment.java
@@ -1,1 +1,8 @@
+package com.dryerzinia.aprs_x.ui.fragment;

+

+import android.app.Fragment;

+

+public class MapFragment extends Fragment {

+

+}

 

--- /dev/null
+++ b/src/com/dryerzinia/aprs_x/ui/fragment/NewConversationFragment.java
@@ -1,1 +1,8 @@
+package com.dryerzinia.aprs_x.ui.fragment;

+

+import android.app.Fragment;

+

+public class NewConversationFragment extends Fragment{

+

+}