araepm: Add EPM ON/OFF buttons
Writes values into the mailbox on the switch.
Tested on AP Dev Board 1.0 to Endo Dev Board 1.0
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
index 92f43a4..d3128c1 100644
--- a/res/layout/activity_main.xml
+++ b/res/layout/activity_main.xml
@@ -1,4 +1,4 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout 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"
@@ -8,14 +8,18 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
- <TextView
- android:id="@+id/textView"
- android:layout_width="wrap_content"
+<Button
android:layout_height="wrap_content"
- android:text="@string/hello_world" />
+ android:layout_width="fill_parent"
+ android:layout_weight="1"
+ android:text="@string/EPM_ON"
+ android:onClick="EpmOn" />
- <Button
+<Button
android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:onClick="getReq" />
-</RelativeLayout>
+ android:layout_width="fill_parent"
+ android:layout_weight="1"
+ android:text="@string/EPM_OFF"
+ android:onClick="EpmOff" />
+
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9725e98..59709a1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4,5 +4,7 @@
<string name="app_name">AraEPM</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
+ <string name="EPM_ON">EPM ON</string>
+ <string name="EPM_OFF">EPM OFF</string>
</resources>
diff --git a/src/com/projectara/araepm/DME.java b/src/com/projectara/araepm/DME.java
index b25b026..754f35c 100644
--- a/src/com/projectara/araepm/DME.java
+++ b/src/com/projectara/araepm/DME.java
@@ -24,7 +24,9 @@
T_PEERBUFFERSPACE (0x4029),
T_CREDITSTOSEND (0x402A),
T_CPORTMODE (0x402B),
- DME_LINKSTARTUP (0xD020);
+ DME_LINKSTARTUP (0xD020),
+ DME_FC0PROTECTIONTIMEOUTVAL (0xD041),
+ DME_MAILBOX (0x6100);
private int id;
private AttributeId(int id) {
@@ -188,6 +190,7 @@
Log.d(TAG, "setCnf portId: " + setCnf.portId);
Log.d(TAG, "setCnf functionId: " + setCnf.functionId);
Log.d(TAG, "setCnf resultCode: " + setCnf.resultCode);
+ return;
}
public int readDMEConfig(int port,
diff --git a/src/com/projectara/araepm/MainActivity.java b/src/com/projectara/araepm/MainActivity.java
index 0cf3113..03c4156 100644
--- a/src/com/projectara/araepm/MainActivity.java
+++ b/src/com/projectara/araepm/MainActivity.java
@@ -6,14 +6,12 @@
import android.view.View;
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 {
- TextView textView;
private static final String TAG = "araepm";
private DME dme = null;
@@ -21,7 +19,6 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- textView = (TextView)findViewById(R.id.textView);
}
@Override
@@ -45,14 +42,32 @@
super.onStop();
}
- public void getReq(View view) {
+ public void EpmOn(View view) {
int rc;
- Log.d(TAG, "button pressed");
+ Log.d(TAG, "EPM ON button pressed");
try {
- rc = dme.readDMEConfig(0, false, DME.AttributeId.DME_LINKSTARTUP, 0, 0);
+ dme.writeDMEConfig(0,
+ true,
+ DME.AttributeId.DME_MAILBOX,
+ 0,
+ 1,
+ 0);
} catch (IOException e) {
return;
}
- Log.d(TAG, "DME rc: " + rc);
+ }
+
+ public void EpmOff(View view) {
+ int rc;
+ Log.d(TAG, "EPM OFF button pressed");
+ try {
+ dme.writeDMEConfig(0, true,
+ DME.AttributeId.DME_MAILBOX,
+ 0,
+ 2,
+ 0);
+ } catch (IOException e) {
+ return;
+ }
}
}