DME: add error detection

Throw IOException if a GetCnf or SetCnf doesn't meet expectations.
diff --git a/src/com/projectara/araepm/DME.java b/src/com/projectara/araepm/DME.java
index b7011ea..b92cd98 100644
--- a/src/com/projectara/araepm/DME.java
+++ b/src/com/projectara/araepm/DME.java
@@ -184,8 +184,16 @@
         logByteArray("writeDMEConfig: setCnf, raw: ", results[0].data);
         SetCnf setCnf = new SetCnf(results[0].data);
 
-        if (setCnf.resultCode != 0) {
-            Log.e(TAG, "Unexpected resultCode: " + setCnf.resultCode);
+        FunctionId expectedFunctionId =
+            (peer ? FunctionId.C0_PEERSETCNF : FunctionId.C0_SETCNF);
+        if (setCnf.resultCode != expectedResultCode) {
+            String err = "Unexpected resultCode: " + setCnf.resultCode +
+                " (expected " + expectedResultCode + ")";
+            Log.e(TAG, err);
+            throw new IOException(err);
+        } else if (setCnf.functionId != expectedFunctionId) {
+            throw new IOException("Unexpected setCnf functionId: " +
+                                  setCnf.functionId);
         }
 
         Log.d(TAG, "writeDMEConfig: setCnf portId: " + setCnf.portId);
@@ -224,8 +232,16 @@
         logByteArray("readDMEConfig: getCnf, raw: ", results[0].data);
         GetCnf getCnf = new GetCnf(results[0].data);
 
-        if (getCnf.resultCode != 0) {
-            Log.e(TAG, "Unexpected resultCode: " + getCnf.resultCode);
+        FunctionId expectedFunctionId =
+            (peer ? FunctionId.C0_PEERGETCNF : FunctionId.C0_GETCNF);
+        if (getCnf.resultCode != expectedResultCode) {
+            String err = "Unexpected resultCode: " + getCnf.resultCode +
+                " (expected " + expectedResultCode + ")";
+            Log.e(TAG, err);
+            throw new IOException(err);
+        } else if (getCnf.functionId != expectedFunctionId) {
+            throw new IOException("Unexpected getCnf functionId: " +
+                                  getCnf.functionId);
         }
 
         Log.d(TAG, "readDMEConfig: getCnf portId: " + getCnf.portId);