   }
 
   /* if receive completed */
-  if (irDataIdx >= IR_REMOTE_DATA_WIDTH)
+  if (irDataIdx == IR_REMOTE_DATA_WIDTH)
   {
     Serial.print(irDataIdx);
     Serial.print("@data:");
-    Serial.println(irData, HEX);
+    Serial.print(irData, HEX);
+    Serial.print("@dataExtra:");
+    Serial.println(irDataExtra, HEX);
   }
 
   /* must reset to receive next pulse */
   pulseStartTiming = 0;
 }
 
-
+/* IRRemote controller to set a start signal according with definition
+ *  
+ *  currently this implementation is based on the remote controller of GREE air conditioner
+ */
+void IRremoteSendStartSignal(void)
+{
+  /* set low signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, LOW);
+  delayMicroseconds(IR_REMOTE_STANDARD_START_TIMING_LOW);
+
+  /* set high signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, HIGH);
+  delayMicroseconds(IR_REMOTE_STANDARD_START_TIMING_HIGH);
+}
+
+/* IRRemote controller to set a continue signal according with definition
+ *  
+ *  currently this implementation is based on the remote controller of GREE air conditioner
+ */
+void IRremoteSendContinueSignal(void)
+{
+  /* set low signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, LOW);
+  delayMicroseconds(IR_REMOTE_STANDARD_CONTINUE_TIMING_LOW);
+
+  /* set high signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, HIGH);
+  delayMicroseconds(IR_REMOTE_STANDARD_CONTINUE_TIMING_HIGH);
+
+}
+
+/* IRRemote controller to set a zero  signal according with definition
+ *  
+ *  currently this implementation is based on the remote controller of GREE air conditioner
+ */
+void IRremoteSendZeroSignal(void)
+{
+  /* set low signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, LOW);
+  delayMicroseconds(IR_REMOTE_STANDARD_ZERO_TIMING_LOW);
+
+  /* set high signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, HIGH);
+  delayMicroseconds(IR_REMOTE_STANDARD_ZERO_TIMING_HIGH);
+
+}
+
+/* IRRemote controller to set an 'one' signal according with definition
+ *  
+ *  currently this implementation is based on the remote controller of GREE air conditioner
+ */
+void IRremoteSendOneSignal(void)
+{
+  /* set low signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, LOW);
+  delayMicroseconds(IR_REMOTE_STANDARD_ONE_TIMING_LOW);
+
+  /* set high signal according with GREE definiion */
+  digitalWrite(pinIRSendRemote, HIGH);
+  delayMicroseconds(IR_REMOTE_STANDARD_ONE_TIMING_HIGH);
+
+}
+
+/*
+ * Send a data, maximum 32bits
+ * note:
+ * Send a start signal by 'IRremoteSendStartSignal' before invoking this function
+ */
+void IRRemoteSendData(unsigned long data, int num)
+{
+  int i, value;
+  
+  for (i = 0; i < num; i++)
+  {
+    value = bitRead(data, i);
+    if (value == 0){
+      IRremoteSendZeroSignal();
+    } else
+    {
+      IRremoteSendOneSignal();
+    }
+  }
+}
+
+/* To switch GREE air conditioner on
+ * */
+void IRRemoteSendGreePowerOn(String param)
+{
+  /* send start signal */
+  IRremoteSendStartSignal();
+
+  IRRemoteSendData(greeIRCodeSwitchOnD0, GREE_DATA0_BITS);
+  IRRemoteSendData(GREE_DATA0_FIXED_BITS_TYPE0, 35 - GREE_DATA0_BITS);
+
+  IRremoteSendContinueSignal();
+  IRRemoteSendData(greeIRCodeOnD1Type0, 32);
+
+  /* send start signal */
+  IRremoteSendStartSignal();
+  /* send start signal */
+  IRremoteSendStartSignal();
+  
+
+  IRRemoteSendData(greeIRCodeSwitchOnD0, GREE_DATA0_BITS);
+  IRRemoteSendData(GREE_DATA0_FIXED_BITS_TYPE1, 35 - GREE_DATA0_BITS);
+
+  IRremoteSendContinueSignal();
+  IRRemoteSendData(greeIRCodeOnD1Type1, 32);
+
+  
+}

      irData = 0;
      dataStartTiming = pulseStartTiming;
      pulseStartTiming = 0;
      return;
  }
  else if (isDataValid == true) {

#ifdef __IRREMOTE_RECEIVE_REVERT__
      bitClear(irData, (IR_REMOTE_DATA_WIDTH - 1 - irDataIdx));
#else
     if (irDataIdx >= 32){
        bitClear(irDataExtra, irDataIdx - 32);
      } else {
        bitClear(irData, irDataIdx);
      }
#endif
    }
    else if ((dur <= (IR_REMOTE_CONTINUE_TIMING_MAX)) &&
    (dur >= (IR_REMOTE_CONTINUE_TIMING_MIN)))
    {
      irDataLongCode = irData;
      Serial.print(irData, HEX);
      Serial.print("continues@");
      Serial.println(irDataExtra, HEX);
      irDataIdx = 0; /* reset index to continue receive next data */
      irDataExtra = 0;
        /* must reset to receive next pulse */
       pulseStartTiming = 0;
       return;
    }
    else{
      Serial.print("unkn!");
