initial commit
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..c93e604
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := araepm
+
+include $(BUILD_PACKAGE)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..7dc966e
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.projectara.araepm"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="18" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name="com.projectara.araepm.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>
+    </application>
+    <uses-permission
+                 android:name="android.permission.WRITE_EXTERNAL_STORAGE"
+                      android:maxSdkVersion="18" />
+</manifest>
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
new file mode 100644
index 0000000..a18cbb4
--- /dev/null
+++ b/ic_launcher-web.png
Binary files differ
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
new file mode 100644
index 0000000..9056828
--- /dev/null
+++ b/libs/android-support-v4.jar
Binary files differ
diff --git a/proguard-project.txt b/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/project.properties b/project.properties
new file mode 100644
index 0000000..4ab1256
--- /dev/null
+++ b/project.properties
@@ -0,0 +1,14 @@
+# 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
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..288b665
--- /dev/null
+++ b/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..6ae570b
--- /dev/null
+++ b/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..d4fb7cd
--- /dev/null
+++ b/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..85a6081
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
new file mode 100644
index 0000000..0befe60
--- /dev/null
+++ b/res/layout/activity_main.xml
@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".MainActivity" >
+
+    <TextView
+        android:id="@+id/textView" 
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/hello_world" />
+</RelativeLayout>
diff --git a/res/menu/main.xml b/res/menu/main.xml
new file mode 100644
index 0000000..c002028
--- /dev/null
+++ b/res/menu/main.xml
@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..44f01db
--- /dev/null
+++ b/res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw600dp devices (e.g. 7" tablets) here.
+    -->
+
+</resources>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..61e3fa8
--- /dev/null
+++ b/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+    -->
+    <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>
diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml
new file mode 100644
index 0000000..3c02242
--- /dev/null
+++ b/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+<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>
diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml
new file mode 100644
index 0000000..a91fd03
--- /dev/null
+++ b/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<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>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,5 @@
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..9725e98
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">AraEPM</string>
+    <string name="action_settings">Settings</string>
+    <string name="hello_world">Hello world!</string>
+
+</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644
index 0000000..6ce89c7
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,20 @@
+<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>
diff --git a/src/com/projectara/araepm/AFE4400Thread.java b/src/com/projectara/araepm/AFE4400Thread.java
new file mode 100644
index 0000000..5658958
--- /dev/null
+++ b/src/com/projectara/araepm/AFE4400Thread.java
@@ -0,0 +1,226 @@
+package com.projectara.araepm;
+
+import android.hardware.I2cManager;
+import android.hardware.I2cTransaction;
+import android.util.Log;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.DataOutputStream;
+import java.io.FileOutputStream;
+
+public class AFE4400Thread extends Thread {
+
+    // The 7-bit slave address
+    private static final int address = (0x50 >> 1);
+    private static final String TAG = "araepm";
+
+    private Mlx90620Listener listener;
+    private I2cManager i2c;
+
+    private volatile boolean stopped;
+    private DataOutputStream buf = null;
+
+    private static final I2cTransaction[] setupWrites = {
+        WriteReg(0x00, 0x00, 0x00, 0x00), //AFE4400_CONTROL0
+        WriteReg(0x01, 0x00, 0x17, 0xD4), //AFE4400_LED2STC
+        WriteReg(0x02, 0x00, 0x1D, 0xAE), //AFE4400_LEDENDC
+        WriteReg(0x03, 0x00, 0x17, 0x70), //AFE4400_LED2LEDSTC
+        WriteReg(0x04, 0x00, 0x1D, 0xAF), //AFE4400_LED2LEDENDC
+        WriteReg(0x05, 0x00, 0x00, 0x00), //AFE4400_ALED2STC
+        WriteReg(0x06, 0x00, 0x06, 0x3E), //AFE4400_ALED2ENDC
+        WriteReg(0x07, 0x00, 0x08, 0x34), //AFE4400_LED1STC
+        WriteReg(0x08, 0x00, 0x0E, 0x0E), //AFE4400_LED1ENDC
+        WriteReg(0x09, 0x00, 0x07, 0xD0), //AFE4400_LED1LEDSTC
+        WriteReg(10, 0x00, 0x0E, 0x0F), //AFE4400_LED1LEDENDC
+
+        WriteReg(11, 0x00, 0x0F, 0xA0), //AFE4400_ALED1STC
+        WriteReg(12, 0x00, 0x15, 0xDE), //AFE4400_ALED1ENDC
+        WriteReg(13, 0x00, 0x00, 0x02), //AFE4400_LED2CONVST
+        WriteReg(14, 0x00, 0x07, 0xCF), //AFE4400_LED2CONVEND
+        WriteReg(15, 0x00, 0x07, 0xD2), //AFE4400_ALED2CONVST
+        WriteReg(16, 0x00, 0x0F, 0x9F), //AFE4400_ALED2CONVEND
+        WriteReg(17, 0x00, 0x0F, 0xA2), //AFE4400_LED1CONVST
+        WriteReg(18, 0x00, 0x17, 0x6F), //AFE4400_LED1CONVEND
+        WriteReg(19, 0x00, 0x17, 0x72), //AFE4400_ALED1CONVST
+        WriteReg(20, 0x00, 0x1F, 0x3F), //AFE4400_ALED1CONVEND
+
+        WriteReg(21, 0x00, 0x00, 0x00),//AFE4400_ADCRSTSTCT0
+        WriteReg(22, 0x00, 0x00, 0x00),//AFE4400_ADCRSTENDCT0
+        WriteReg(23, 0x00, 0x07, 0xD0),//AFE4400_ADCRSTSTCT1
+        WriteReg(24, 0x00, 0x07, 0xD0),//AFE4400_ADCRSTENDCT1
+        WriteReg(25, 0x00, 0x0F, 0XA0),//AFE4400_ADCRSTSTCT2
+        WriteReg(26, 0x00, 0x0F, 0XA0),//AFE4400_ADCRSTENDCT2
+        WriteReg(27, 0x00, 0x17, 0x70),//AFE4400_ADCRSTSTCT3
+        WriteReg(28, 0x00, 0x17, 0x70),//AFE4400_ADCRSTENDCT3
+        WriteReg(29, 0x00, 0x1F, 0x3F),//AFE4400_PRPCOUNT
+        WriteReg(30, 0x00, 0x01, 0x01),//AFE4400_CONTROL1
+
+        WriteReg(31, 0x00, 0x00, 0x00),//AFE4400_SPARE1
+        WriteReg(32, 0x00, 0x00, 0x00),//AFE4400_TIAGAIN
+        WriteReg(33, 0x00, 0x00, 0x0A),//AFE4400_TIA_AMB_GAIN
+        WriteReg(34, 0x01, 0x14, 0x29),//AFE4400_LEDCNTRL
+        WriteReg(35, 0x02, 0x01, 0x00),//AFE4400_CONTROL2
+        WriteReg(36, 0x00, 0x00, 0x00),//AFE4400_SPARE2
+        WriteReg(37, 0x00, 0x00, 0x00),//AFE4400_SPARE3
+        WriteReg(38, 0x00, 0x00, 0x00),//AFE4400_SPARE4
+        WriteReg(39, 0x00, 0x00, 0x00),//AFE4400_RESERVED1
+        WriteReg(40, 0x00, 0x00, 0x00),//AFE4400_RESERVED2
+        WriteReg(41, 0x00, 0x00, 0x00),//AFE4400_ALARM
+        WriteReg(42, 0x00, 0x00, 0x00),//AFE4400_LED2VAL
+
+        WriteReg(43, 0x00, 0x00, 0x00),//AFE4400_ALED2VAL
+        WriteReg(44, 0x00, 0x00, 0x00),//AFE4400_LED1VAL
+        WriteReg(45, 0x00, 0x00, 0x00),//AFE4400_ALED1VAL
+        WriteReg(46, 0x00, 0x00, 0x00),//AFE4400_LED2-ALED2VAL
+        WriteReg(47, 0x00, 0x00, 0x00),//AFE4400_LED1-ALED1VAL
+        WriteReg(48, 0x00, 0x00, 0x00),//AFE4400_DIAG
+
+        // Setup SPI_READ
+        WriteReg(0, 0x00, 0x00, 0x01),//AFE4400_DIAG
+    };
+
+    public AFE4400Thread(Mlx90620Listener listener, I2cManager i2c) {
+        this.listener = listener;
+        this.i2c = i2c;
+        this.stopped = false;
+        try {
+            this.buf = new DataOutputStream(new FileOutputStream("/sdcard/plox.dat"));
+        } catch (FileNotFoundException e) {
+            Log.e(TAG, e.toString());
+        }
+    }
+
+    @Override
+    public void run() {
+        String[] buses = i2c.getI2cBuses();
+        if (buses.length == 0) {
+            setText("no I2C buses found :(");
+            return;
+        }
+        String bus = buses[0];
+
+        int nsecs = 0;
+        while (nsecs > 0) {
+            setText("starting in " + nsecs + "...");
+            nsecs--;
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {}
+        }
+
+        I2cTransaction[] results;
+        for (I2cTransaction txn: setupWrites) {
+            try {
+                results = i2c.performTransactions(bus, address, txn);
+            } catch (IOException e) {
+                setText("transaction error: " + e);
+                return;
+            }
+        }
+
+        while (!isStopped()) {
+            results = null;
+            boolean stop = true;
+            String updateString = "";
+            byte[] data;
+            int LED1VAL;
+            int LED2VAL;
+            I2cTransaction[] txns0 = {
+                I2cTransaction.newWrite(0x01,                 // Select SPI device 1
+                                        0x2e,                 // LED2-ALED2VAL
+                                        0xff, 0xff, 0xff),    // 3 dummy bytes
+                I2cTransaction.newRead(4),
+            };
+
+            I2cTransaction[] txns1 = {
+                I2cTransaction.newWrite(0x01,                 // Select SPI device 1
+                                        0x2f,                 // LED2-ALED2VAL
+                                        0xff, 0xff, 0xff),    // 3 dummy bytes
+                I2cTransaction.newRead(4),
+            };
+
+            try {
+                if (stop) {
+                    for (I2cTransaction txn: txns0) {
+                        results = i2c.performTransactions(bus, address, txn);
+                    }
+                } else {
+                    results = i2c.performTransactions(bus, address, txns0);
+                }
+            } catch (IOException e) {
+                setText("error while reading back: " + e);
+                return;
+            }
+
+            if (stop)
+                data = results[0].data;
+            else
+                data = results[1].data;
+
+            LED1VAL = (((int)data[1]) << 16) |
+                      (((int)data[2] & 0xFF) <<  8) |
+                      (((int)data[3] & 0xFF));
+
+            try {
+                if (stop) {
+                    for (I2cTransaction txn: txns1) {
+                        results = i2c.performTransactions(bus, address, txn);
+                    }
+                } else {
+                    results = i2c.performTransactions(bus, address, txns1);
+                }
+            } catch (IOException e) {
+                setText("error while reading back: " + e);
+                return;
+            }
+
+            if (stop)
+                data = results[0].data;
+            else
+                data = results[1].data;
+
+            LED2VAL = (((int)data[1]) << 16) |
+                      (((int)data[2] & 0xFF) <<  8) |
+                      (((int)data[3] & 0xFF));
+            try {
+                this.buf.writeInt(LED1VAL);
+                this.buf.writeInt(LED2VAL);
+            } catch (IOException e) {
+                Log.e(TAG, "IOException: " + e);
+            }
+
+            updateString = String.format("%8d %8d", LED1VAL, LED2VAL);
+            setText(updateString);
+        //    try {
+        //        Thread.sleep(50);
+        //    } catch (InterruptedException e) {
+        //        Log.e(TAG, e.toString());
+        //    }
+        }
+
+        try {
+            this.buf.close();
+        } catch (IOException e) {
+            Log.e(TAG, "IOException: " + e);
+        }
+    }
+
+
+    private static I2cTransaction WriteReg(int reg, int b1, int b2, int b3) {
+        return I2cTransaction.newWrite(0x01, reg, b1, b2, b3);
+    }
+
+    // ------------------------------------------------------------
+
+    private void setText(String text) {
+        this.listener.updateAFE4400Status(text);
+    }
+
+    public void requestStop() {
+        this.stopped = true;
+    }
+
+    public boolean isStopped() {
+        return this.stopped;
+    }
+}
diff --git a/src/com/projectara/araepm/L3Switch.java b/src/com/projectara/araepm/L3Switch.java
new file mode 100644
index 0000000..c0fbf28
--- /dev/null
+++ b/src/com/projectara/araepm/L3Switch.java
@@ -0,0 +1,160 @@
+package com.projectara.araepm;
+
+import android.hardware.I2cManager;
+import android.hardware.I2cTransaction;
+import java.io.IOException;
+
+public class L3Switch {
+    private static final int slaveAddress = 0x44;
+    private static String i2cBus;
+    private I2cManager i2c;
+
+    private static enum AttributeId {
+        T_PEERDEVICEID    (0x4021),
+        T_PEERCPORTID     (0x4022),
+        T_CONNECTIONSTATE (0x4020),
+        T_TRAFFICCLASS    (0x4023),
+        T_PROTOCOLID      (0x4024),
+        T_CPORTFLAGS      (0x4025),
+        T_TXTOKENVALUE    (0x4026),
+        T_RXTOKENVALUE    (0x4027),
+        T_LOCALBUFFERSPACE(0x4028),
+        T_PEERBUFFERSPACE (0x4029),
+        T_CREDITSTOSEND   (0x402A),
+        T_CPORTMODE       (0x402B);
+
+        private int id;
+        private AttributeId(int id) {
+            this.id = id;
+        }
+    }
+
+    private static enum FunctionId {
+        C0_SETREQ           (0x00),
+        C0_SETCNF           (0x01),
+        C0_PEERSETREQ       (0x02),
+        C0_PEERSETCNF       (0x03),
+        C0_GETREQ           (0x04),
+        C0_GETCNF           (0x05),
+        C0_PEERGETREQ       (0x06),
+        C0_PEERGETCNF       (0x07),
+        C0_LUTSETREQ        (0x08),
+        C0_LUTSETCNF        (0x09),
+        C0_LUTGETREQ        (0x0a),
+        C0_LUTGETCNF        (0x0b),
+        C0_SWITCHATTRSETREQ (0x0c),
+        C0_SWITCHATTRSETCNF (0x0d),
+        C0_SWITCHATTRGETREQ (0x0e),
+        C0_SWITCHATTERGETCNF(0x0f);
+
+        private int id;
+        private FunctionId(int id) {
+            this.id = id;
+        }
+    }
+
+    private class SetRequest {
+        int portId;
+        FunctionId functionId;
+        AttributeId attrId;
+        int selectorIndex;
+        int attrVal;
+
+        public byte[] getBytes() {
+            byte[] rawBytes = new byte[10];
+            rawBytes[0] = (byte)(portId & 0xFF);
+
+            rawBytes[1] = (byte)(functionId.id & 0xFF);
+
+            rawBytes[2] = (byte)((attrId.id >> 8) & 0xFF); // msb
+            rawBytes[3] = (byte)(attrId.id & 0xFF);        // lsb
+
+            rawBytes[4] = (byte)((selectorIndex >> 8) & 0xFF);
+            rawBytes[5] = (byte)((selectorIndex) & 0xFF);
+
+            rawBytes[6] = (byte)((attrVal >> 24) & 0xFF);
+            rawBytes[7] = (byte)((attrVal >> 16) & 0xFF);
+            rawBytes[8] = (byte)((attrVal >> 8) & 0xFF);
+            rawBytes[9] = (byte)((attrVal) & 0xFF);
+            return rawBytes;
+        }
+    }
+
+    public L3Switch(I2cManager i2c) {
+        this.i2c = i2c;
+        this.i2cBus = i2c.getI2cBuses()[0];
+    }
+
+    // api_write_switch_config
+    public void writeSwitchConfig(int port, boolean peer, AttributeId attrId,
+                                  int selectorIndex, int attrVal,
+                                  int expectedResultCode) {
+        I2cTransaction txn = null;
+        SetRequest setReq = new SetRequest();
+
+        setReq.portId = port;
+        setReq.functionId = peer ? FunctionId.C0_PEERSETREQ : FunctionId.C0_SETREQ;
+        setReq.attrId = attrId;
+        setReq.selectorIndex = selectorIndex;
+        setReq.attrVal = attrVal;
+
+        txn = I2cTransaction.newWrite(setReq.getBytes());
+        I2cTransaction[] results;
+        try {
+            results = i2c.performTransactions(i2cBus, slaveAddress, txn);
+        } catch (IOException e) {
+            return;
+        }
+    }
+
+    // api_write_switch_config, peer = 0 (false)
+    public void writeSwitchConfigLocal(int port, AttributeId attrId,
+                                       int selectorIndex, int attrVal,
+                                       int expectedResultCode) {
+        writeSwitchConfig(port, false, attrId, selectorIndex, attrVal,
+                          expectedResultCode);
+    }
+
+    // api_write_switch_config, peer = 1 (true)
+    public void writeSwitchConfigPeer(int port, AttributeId attrId,
+                                      int selectorIndex, int attrVal,
+                                      int expectedResultCode) {
+        writeSwitchConfig(port, true, attrId, selectorIndex, attrVal,
+                          expectedResultCode);
+    }
+
+//    // api_read_switch_config
+//    int readSwitchConfig(int port, boolean peer, AttributeId attrId,
+//                         int selectorIndex,
+//                         int expectedResultCode) {
+//        return 0;
+//    }
+//
+//    // api_read_switch_config, peer = 0 (false)
+//    int readSwitchConfigLocal(int port, int attrId,
+//                              int selectorIndex,
+//                              int expectedResultCode) {
+//        return readSwitchConfig(port, false, attrId, selectorIndex,
+//                                expectedResultCode);
+//    }
+//
+//    // api_read_switch_config, peer = 1 (true)
+//    int readSwitchConfigPeer(int port, int attrId,
+//                             int selectorIndex,
+//                             int expectedResultCode) {
+//        return readSwitchConfig(port, true, attrId, selectorIndex,
+//                                expectedResultCode);
+//    }
+
+    // api_write_switch_lut_config
+    public void writeSwitchLutConfig(int port, int lutAddr, int destPortId,
+                             int destCPortId, int expectedResultCode) {
+
+    }
+
+    public void configureL3Device(int portA, int cPortA,
+                          int cPortB, int deviceIdB) {
+
+    }
+
+}
diff --git a/src/com/projectara/araepm/MainActivity.java b/src/com/projectara/araepm/MainActivity.java
new file mode 100644
index 0000000..c8594e2
--- /dev/null
+++ b/src/com/projectara/araepm/MainActivity.java
@@ -0,0 +1,63 @@
+package com.projectara.araepm;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+import android.hardware.I2cManager;
+import android.hardware.I2cTransaction;
+import android.widget.TextView;
+import java.io.IOException;
+import android.os.Handler;
+import android.util.Log;
+
+public class MainActivity extends Activity implements Mlx90620Listener{
+
+    TextView textView;
+    AFE4400Thread thread;
+    Handler handler;
+    private static final String TAG = "araepm";
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        textView = (TextView)findViewById(R.id.textView);
+        handler = new Handler();
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        // Inflate the menu; this adds items to the action bar if it is present.
+        getMenuInflater().inflate(R.menu.main, menu);
+        return true;
+    }
+
+    @Override
+    protected void onStart(){
+        super.onStart();
+        I2cManager i2c = (I2cManager) getSystemService(I2C_SERVICE);
+        thread = new AFE4400Thread(this, i2c);
+        thread.start();
+        Log.d(TAG, "onstart");
+    }
+
+    @Override
+    protected void onStop() {
+    	super.onStop();
+    	thread.requestStop();
+        Log.d(TAG, "onstop");
+    }
+
+    // -- AFE4400 API --------------------------------------------------------
+
+    @Override
+    public void updateAFE4400Status(String text) {
+        final String t = text;
+        handler.post(new Runnable() {
+                @Override
+                public void run() {
+                    textView.setText(t);
+                }
+            });
+    }
+}
diff --git a/src/com/projectara/araepm/Mlx90620Listener.java b/src/com/projectara/araepm/Mlx90620Listener.java
new file mode 100644
index 0000000..c2d87b6
--- /dev/null
+++ b/src/com/projectara/araepm/Mlx90620Listener.java
@@ -0,0 +1,5 @@
+package com.projectara.araepm;
+
+public interface Mlx90620Listener{
+    public void updateAFE4400Status(String status);
+}