Esempio n. 1
0
 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);
   }
 }
Esempio n. 2
0
 public void buttonResetHandler(View target) {
   for (int i = 0; i < mHanDeviceLinkedList.size(); i++) {
     HanDevice hd = mHanDeviceLinkedList.get(i);
     hd.resetCnt();
     mHanDeviceLinkedList.set(i, hd);
   }
   updateHanDeviceTable();
 }
Esempio n. 3
0
 public void buttonAcOutletOffHandler(View target) {
   if (mSerialIoManager != null) {
     HanDevice hd = mHanDeviceLinkedList.get(2);
     hd.setWaitOnOff(false);
     mHanDeviceLinkedList.set(2, hd);
     sendPacket(RawData.CMBS_EV_DSR_HAN_MSG_RECV_AC_OUTLET_OFF);
   }
 }
Esempio n. 4
0
  private void updateHanDeviceTable() {
    removeHanDeviceTable();
    if (mSerialDevice != null && mHanDeviceLinkedList.size() > 0) {
      for (int i = 0; i < mHanDeviceLinkedList.size(); i++) {
        HanDevice hd = mHanDeviceLinkedList.get(i);

        TableRow row = new TableRow(this);
        TextView tv1 = new TextView(this);
        tv1.setText("#" + hd.getDeviceId());

        TextView tv2 = new TextView(this);
        if (hd.getUnitType() == UnitType.SMOKE_SENSOR) {
          tv2.setText("Smoke (0x" + Integer.toHexString(UnitType.SMOKE_SENSOR.getUnitType()) + ")");
        } else if (hd.getUnitType() == UnitType.MOTION_SENSOR) {
          tv2.setText(
              "Motion (0x" + Integer.toHexString(UnitType.MOTION_SENSOR.getUnitType()) + ")");
        } else if (hd.getUnitType() == UnitType.AC_OUTLET) {
          tv2.setText(
              "AC Outlet (0x" + Integer.toHexString(UnitType.AC_OUTLET.getUnitType()) + ")");
        }

        TextView tvKeepAlive = new TextView(this);
        tvKeepAlive.setText(Integer.toString(hd.getKeepAliveCnt()));

        TextView tvAlert = new TextView(this);
        tvAlert.setText(Integer.toString(hd.getAlertCnt()));

        TextView tvTamper = new TextView(this);
        tvTamper.setText(Integer.toString(hd.getTamperCnt()));

        row.addView(tv1);
        row.addView(tv2);
        row.addView(tvKeepAlive);
        row.addView(tvAlert);
        row.addView(tvTamper);

        mScrollViewHanDeviceTableLayout.addView(row);
      }
      mTextViewHanConnectedDeviceAns.setText(Integer.toString(mHanDeviceLinkedList.size()));
    }
  }
Esempio n. 5
0
  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();
  }