Package org.openhab.binding.maxcul.internal.messages

Examples of org.openhab.binding.maxcul.internal.messages.AckMsg


      messageHandler.sendPairPong(devAddr, this);
      state = PairingInitialisationState.PONG_ACKED;
      break;
    case PONG_ACKED:
      if (msg.msgType == MaxCulMsgType.ACK) {
        AckMsg ack = new AckMsg(msg.rawMsg);
        if (!ack.getIsNack()) {
          if (this.deviceType == MaxCulDevice.PUSH_BUTTON) {
            /* for a push button we're done now */
            state = PairingInitialisationState.FINISHED;
          } else {
            /* send group id information */
            logger.debug("Sending GROUP_ID");
            messageHandler.sendSetGroupId(devAddr, group_id, this);
            state = PairingInitialisationState.GROUP_ID_ACKED;
          }
        } else {
          logger.error("PAIR_PONG was nacked. Ending sequence");
          state = PairingInitialisationState.FINISHED;
        }
      } else {
        logger.error("Received " + msg.msgType + " when expecting ACK");
      }
      break;
    case GROUP_ID_ACKED:
      if (msg.msgType == MaxCulMsgType.ACK) {
        AckMsg ack = new AckMsg(msg.rawMsg);
        if (!ack.getIsNack()
            && (this.deviceType == MaxCulDevice.RADIATOR_THERMOSTAT
                || this.deviceType == MaxCulDevice.WALL_THERMOSTAT || this.deviceType == MaxCulDevice.RADIATOR_THERMOSTAT_PLUS)) {
          // send temps for comfort/eco etc
          messageHandler.sendConfigTemperatures(devAddr, this,
              config.getComfortTemp(), config.getEcoTemp(),
              config.getMaxTemp(), config.getMinTemp(),
              config.getMeasurementOffset(),
              config.getWindowOpenTemperature(),
              config.getWindowOpenDuration());
          state = PairingInitialisationState.CONFIG_TEMPS_ACKED;
        } else {
          logger.error("SET_GROUP_ID was nacked. Ending sequence");
          state = PairingInitialisationState.FINISHED;
        }
      } else {
        logger.error("Received " + msg.msgType + " when expecting ACK");
      }
      break;
    case CONFIG_TEMPS_ACKED:
      if (msg.msgType == MaxCulMsgType.ACK) {
        AckMsg ack = new AckMsg(msg.rawMsg);
        if (!ack.getIsNack()) {

          /*
           * associate device with us so we get updates - we pretend
           * to be the MAX! Cube
           */
          messageHandler.sendAddLinkPartner(devAddr, this,
              msg.dstAddrStr, MaxCulDevice.CUBE);

          /*
           * if there are more associations to come then set up
           * iterator and goto state to transmit more associations
           */
          if (associations.isEmpty() == false) {
            assocIter = associations.iterator();
            state = PairingInitialisationState.SENDING_ASSOCIATIONS;
          } else {
            logger.debug("No user configured associations");
            state = PairingInitialisationState.SENDING_ASSOCIATIONS_ACKED;
          }
        } else {
          logger.error("CONFIG_TEMPERATURES was nacked. Ending sequence");
          state = PairingInitialisationState.FINISHED;
        }
      } else {
        logger.error("Received " + msg.msgType + " when expecting ACK");
      }
      break;
    case SENDING_ASSOCIATIONS:
      if (msg.msgType == MaxCulMsgType.ACK) {
        AckMsg ack = new AckMsg(msg.rawMsg);
        if (!ack.getIsNack()) {
          if (assocIter.hasNext()) /*
                       * this should always be true, but
                       * good to check
                       */
          {
            MaxCulBindingConfig partnerCfg = assocIter.next();
            messageHandler.sendAddLinkPartner(this.devAddr, this,
                partnerCfg.getDevAddr(),
                partnerCfg.getDeviceType());
            /*
             * if it's the last association message then wait for
             * last ACK
             */
            if (assocIter.hasNext()) {
              state = PairingInitialisationState.SENDING_ASSOCIATIONS;
            } else {
              state = PairingInitialisationState.SENDING_ASSOCIATIONS_ACKED;
            }
          } else {
            // TODO NOTE: if further states are added then ensure
            // you go to the right state. I.e. when all associations
            // are done
            state = PairingInitialisationState.FINISHED;
          }
        } else {
          logger.error("SENDING_ASSOCIATIONS was nacked. Ending sequence");
          state = PairingInitialisationState.FINISHED;
        }
      } else {
        logger.error("Received " + msg.msgType + " when expecting ACK");
      }
      break;
    case SENDING_ASSOCIATIONS_ACKED:
      state = PairingInitialisationState.FINISHED;
      break;
    case SENDING_WEEK_PROFILE:
      // TODO implement this - but where to get a week profile from.
      // Meaningless at the moment!
      state = PairingInitialisationState.FINISHED;
      break;
    case FINISHED:
      /* done, do nothing */
      break;
    case RETX_WAKEUP_ACK:
      /* here are waiting for an ACK after sending a wakeup message */
      if (msg.msgType == MaxCulMsgType.ACK) {
        AckMsg ack = new AckMsg(msg.rawMsg);
        if (!ack.getIsNack()) {
          logger.debug("Attempt retransmission - resuming");
          this.useFast = true;
          messageHandler.sendMessage(reTxMsg);
          state = reTxState; // resume back to previous state
        } else {
View Full Code Here


      break;
    case SET_TEMPERATURE:
      new SetTemperatureMsg(data).printMessage();
      break;
    case ACK:
      new AckMsg(data).printMessage();
      break;
    case PAIR_PING:
      new PairPingMsg(data).printMessage();
      break;
    case PAIR_PONG:
View Full Code Here

      }
      break;
    case HANDLE_RESPONSE:
      /* check for ACK */
      if (msg.msgType == MaxCulMsgType.ACK) {
        AckMsg ack = new AckMsg(msg.rawMsg);
        if (ack.getIsNack()) {
          logger.error("TIME_INFO was nacked. Ending sequence");
          state = TimeUpdateRequestState.FINISHED;
        } else
          state = TimeUpdateRequestState.FINISHED;
      }
View Full Code Here

        boolean passToBinding = true;
        /* Handle Internal Messages */
        MaxCulMsgType msgType = BaseMsg.getMsgType(data);
        if (msgType == MaxCulMsgType.ACK) {
          passToBinding = false;
          AckMsg msg = new AckMsg(data);
          if (pendingAckQueue.containsKey(msg.msgCount)
              && msg.dstAddrStr.compareTo(srcAddr) == 0) {
            SenderQueueItem qi = pendingAckQueue
                .remove(msg.msgCount);
            /* verify ACK */
            if ((qi.msg.dstAddrStr.equalsIgnoreCase(msg.srcAddrStr))
                && (qi.msg.srcAddrStr
                    .equalsIgnoreCase(msg.dstAddrStr))) {
              if (msg.getIsNack()) {
                /* NAK'd! */
                // TODO resend?
                logger.error("Message was NAK'd, packet lost");
              } else {
                logger.debug("Message " + msg.msgCount
View Full Code Here

   *
   * @param msg
   *            Message we are acking
   */
  public void sendAck(BaseMsg msg) {
    AckMsg ackMsg = new AckMsg(msg.msgCount, (byte) 0x0, msg.groupid,
        this.srcAddr, msg.srcAddrStr, false);
    ackMsg.setFastSend(true); // all ACKs are sent to waiting device.
    sendMessage(ackMsg);
  }
View Full Code Here

   *
   * @param msg
   *            Message we are nacking
   */
  public void sendNack(BaseMsg msg) {
    AckMsg nackMsg = new AckMsg(msg.msgCount, (byte) 0x0, msg.groupid,
        this.srcAddr, msg.srcAddrStr, false);
    nackMsg.setFastSend(true); // all NACKs are sent to waiting device.
    sendMessage(nackMsg);
  }
View Full Code Here

TOP

Related Classes of org.openhab.binding.maxcul.internal.messages.AckMsg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.