private void updateLedStatus() {
   if (mSerialDevice != null && mHanDeviceLinkedList.size() > 0) {
     HanDevice hd = mHanDeviceLinkedList.get(2);
     if (hd.getOnOff() == true) mTextViewLedOnOff.setText(R.string.led_is_on);
     else mTextViewLedOnOff.setText(R.string.led_is_off);
   }
 }
  private void updateReceivedData(byte[] data) {
    // final String message = "Read " + data.length + " bytes: " + HexDump.dumpHexString(data);
    // Debug.d(TAG, message);
    //			mDumpTextView.append(message);
    //        mScrollView.smoothScrollTo(0, mDumpTextView.getBottom());

    if (Arrays.equals(data, RawData.CMBS_CMD_HELLO_RPLY)) mState = State.CMBS_CMD_HELLO_RPLY;
    else if (Arrays.equals(data, RawData.CMBS_CMD_HELLO_RPLY2)) mState = State.CMBS_CMD_HELLO_RPLY;
    else if (Arrays.equals(data, RawData.CMBS_EV_DSR_SYS_START_RES))
      mState = State.CMBS_EV_DSR_SYS_START_RES;
    else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MNGR_INIT_RES))
      mState = State.CMBS_EV_DSR_HAN_MNGR_INIT_RES;
    else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MNGR_START_RES))
      mState = State.CMBS_EV_DSR_HAN_MNGR_START_RES;
    else if (Arrays.equals(data, RawData.CMBS_EV_DSR_PARAM_AREA_SET_RES))
      mState = State.CMBS_EV_DSR_PARAM_AREA_SET_RES;
    else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MSG_RECV_REGISTER_RES))
      mState = State.CMBS_EV_DSR_HAN_MSG_RECV_REGISTER_RES;
    else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MSG_RECV_SMOKE_TAMPER)) {
      Debug.d(TAG, "Smoke TAMPER!!!");
      HanDevice hd = mHanDeviceLinkedList.get(0);
      hd.incTamperCnt();
      mHanDeviceLinkedList.set(0, hd);
      mState = State.IDLE;
      boolean enableSms = mPerf.getBoolean("enable_sms", false);
      if (enableSms == true) sendSMS("Smoke Tamper");
    } else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MSG_RECV_SMOKE_ALERT)) {
      Debug.d(TAG, "Smoke ALERT!!!");
      HanDevice hd = mHanDeviceLinkedList.get(0);
      hd.incAlertCnt();
      mHanDeviceLinkedList.set(0, hd);
      mState = State.IDLE;
      boolean enableSms = mPerf.getBoolean("enable_sms", false);
      if (enableSms == true) sendSMS("Smoke Alert");
    } else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MSG_RECV_MOTION_TAMPER)) {
      Debug.d(TAG, "Motion TAMPER!!!");
      HanDevice hd = mHanDeviceLinkedList.get(1);
      hd.incTamperCnt();
      mHanDeviceLinkedList.set(1, hd);
      mState = State.IDLE;
      boolean enableSms = mPerf.getBoolean("enable_sms", false);
      if (enableSms == true) sendSMS("Motion Tamper");
    } else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MSG_RECV_AC_OUTLET_KEEP_ALIVE)) {
      Debug.d(TAG, "AC Outlet KEEP ALIVE!!!");
      HanDevice hd = mHanDeviceLinkedList.get(2);
      hd.incKeepAliveCnt();
      mHanDeviceLinkedList.set(2, hd);
      mState = State.IDLE;
    } else if (Arrays.equals(data, RawData.CMBS_EV_DSR_HAN_MSG_RECV_AC_OUTLET_ON_OFF_ACK)) {
      HanDevice hd = mHanDeviceLinkedList.get(2);
      Debug.d(
          TAG, "AC Outlet ON/OFF ACK!!! original=" + hd.getOnOff() + " new=" + hd.getWaitOnOff());
      hd.setOnOff(hd.getWaitOnOff());
      mHanDeviceLinkedList.set(2, hd);
      updateLedStatus();
      mState = State.IDLE;
    } else mState = State.IDLE;

    StateMachine();
    updateHanDeviceTable();
  }