예제 #1
0
  public void decodeMessage(long binaryMessage) {
    int command = (int) (binaryMessage >> 4) & 0x1;
    int address = (int) ((binaryMessage >> 6) & ((1 << 26) - 1));
    int button = (int) ((binaryMessage & 0x0F) + ((binaryMessage & 0x20) >> 1) + 1);
    ProtocolMessage message = new ProtocolMessage("NexaL", command, address, 4);
    message.setRawMessageByteAt(3, (int) (binaryMessage & 0xFF));
    message.setRawMessageByteAt(2, (int) ((binaryMessage >> 8) & 0xFF));
    message.setRawMessageByteAt(1, (int) ((binaryMessage >> 16) & 0xFF));
    message.setRawMessageByteAt(0, (int) ((binaryMessage >> 24) & 0xFF));

    message.addField(new FieldValue("Command", command));
    message.addField(new FieldValue("Address", address));
    message.addField(new FieldValue("Button", button));

    // It is, check if this really is a repeat
    if ((m_RepeatCount > 0) && (binaryMessage == m_LastData)) {
      message.setRepeat(m_RepeatCount);
    } else {
      // It is not a repeat, reset counter
      m_RepeatCount = 0;
    }
    // Report the parsed message
    m_Sink.parsedMessage(message);
    if (m_PrintAnalyze) {
      analyzer.printPulses();
    }
    m_State = READING_LAST_BIT_MARK;
  }
예제 #2
0
 /* (non-Javadoc)
  * @see ssg.ir.IRDecoder#parse(java.lang.Double)
  */
 public int parse(double pulse, boolean state) {
   switch (m_State) {
     case IDLE:
       {
         if (NEXA_HEADER_MARK.matches(pulse) && (m_LastPulse > (NEXA_REPEAT.length() / 2))) {
           m_State = READING_HEADER_SPACE;
         }
         break;
       }
     case READING_HEADER_SPACE:
       {
         if (NEXA_HEADER_SPACE.matches(pulse)) {
           m_State = READING_BIT_MARK_BEFORE;
           m_Data = 0;
           m_BitCounter = 0;
         } else {
           m_State = IDLE;
         }
         break;
       }
     case READING_BIT_MARK_BEFORE:
       {
         if (NEXA_MARK.matches(pulse)) {
           m_State = READING_BIT_SPACE;
         } else {
           m_Sink.partiallyParsedMessage("NexaL BMB " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
         }
         break;
       }
     case READING_BIT_SPACE:
       {
         if (NEXA_SHORT_SPACE.matches(pulse)) {
           m_State = READING_BIT_MARK_AFTER_SHORT;
           addBit(0);
         } else if (NEXA_LONG_SPACE.matches(pulse)) {
           m_State = READING_BIT_MARK_AFTER_LONG;
           addBit(1);
         } else {
           m_Sink.partiallyParsedMessage("NexaL BS " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
         }
         break;
       }
     case READING_BIT_MARK_AFTER_SHORT:
       {
         if (NEXA_MARK.matches(pulse)) {
           m_State = READING_INTER_SPACE_LONG;
         } else {
           m_Sink.partiallyParsedMessage("NexaL BMAS " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
         }
         break;
       }
     case READING_BIT_MARK_AFTER_LONG:
       {
         if (NEXA_MARK.matches(pulse)) {
           m_State = READING_INTER_SPACE_SHORT;
         } else {
           m_Sink.partiallyParsedMessage("NexaL BMAL " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
         }
         break;
       }
     case READING_INTER_SPACE_SHORT:
       {
         if (NEXA_SHORT_INTER_SPACE.matches(pulse)) {
           m_State = READING_BIT_MARK_BEFORE;
         } else {
           m_Sink.partiallyParsedMessage("NexaL ISS " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
         }
         break;
       }
     case READING_INTER_SPACE_LONG:
       {
         if (NEXA_LONG_INTER_SPACE.matches(pulse)) {
           m_State = READING_BIT_MARK_BEFORE;
         } else {
           m_Sink.partiallyParsedMessage("NexaL ISL " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
         }
         break;
       }
     case READING_LAST_BIT_MARK:
       {
         if (NEXA_MARK.matches(pulse)) {
           m_State = READING_TRAILING_SPACE;
         } else {
           m_Sink.partiallyParsedMessage("NexaL LBM " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
           m_RepeatCount = 0;
         }
         break;
       }
     case READING_TRAILING_SPACE:
       {
         if (NEXA_LONG_INTER_SPACE.matches(pulse) || NEXA_SHORT_INTER_SPACE.matches(pulse)) {
           m_State = READING_TRAILING_MARK;
         } else {
           m_Sink.partiallyParsedMessage("NexaL TS " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
           m_RepeatCount = 0;
         }
         break;
       }
     case READING_TRAILING_MARK:
       {
         if (NEXA_MARK.matches(pulse)) {
           m_State = REPEAT_SCAN;
         } else {
           m_Sink.partiallyParsedMessage("NexaL TM " + Double.toString(pulse), m_BitCounter);
           m_State = IDLE;
           m_RepeatCount = 0;
         }
         break;
       }
     case REPEAT_SCAN:
       {
         if (NEXA_REPEAT.matches(pulse)) {
           m_RepeatCount += 1; // Start repeat sequence
           // Save this sequence
           m_LastData = m_Data;
         } else {
           m_RepeatCount = 0;
         }
         m_State = IDLE;
         break;
       }
   }
   m_LastPulse = pulse;
   return m_State;
 }