void sendIRData(uint8 addr1, uint8 addr2, uint8 value) {
	initTimer3();
	HalTimerStart(HAL_TIMER_0, 26);

	end_count = 346; //9ms
	flag = 1;
	count = 0;
	while (count < end_count) {
		if (count >= end_count - 1) {
			break;
		}
	}

	end_count = 173; //4.5ms
	flag = 0;
	count = 0;
	while (count < end_count) {
		if (count >= end_count - 1) {
			break;
		}
	}

	for (i = 0; i < 8; i++) {
		end_count = 21;
		flag = 1;
		count = 0;
		while (count < end_count) {
			if (count == end_count - 1) {
				break;
			}
		}
		if (addr1 - (addr1 / 2) * 2) {
			end_count = 64;
		} else {
			end_count = 21;
		}
		flag = 0;
		count = 0;
		while (count < end_count) {
			if (count == end_count - 1) {
				break;
			}
		}
		addr1 = addr1 >> 1;
	}

	HalTimerStop(HAL_TIMER_0);
}
/*********************************************************************
 * @fn      SampleApp_MessageMSGCB
 *
 * @brief   Data message processor callback.  This function processes
 *          any incoming data - probably from other devices.  So, based
 *          on cluster ID, perform the intended action.
 *
 * @param   none
 *
 * @return  none
 */
void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
{
  uint16 flashTime;

  switch ( pkt->clusterId )
  {
    case SAMPLEAPP_POINT_TO_POINT_CLUSTERID:
      /*************************************
      串口发送给ARM端,包格式如下
      @16位地址(不转换字符串)+XXXXX#
      **************************************/

      break;

    case SAMPLEAPP_FLASH_CLUSTERID:
      flashTime = BUILD_UINT16(pkt->cmd.Data[1], pkt->cmd.Data[2] );
      HalLedBlink( HAL_LED_4, 4, 50, (flashTime / 4) );
      break;
      //定义广播
    case SAMPLEAPP_PERIODIC_CLUSTERID:
       HalUARTWrite(0,&pkt->cmd.Data[0],7); 
#ifdef MODE_ED
      //HalLedBlink( HAL_LED_2, 2,50, 500); 
      //收到"+REBOT#"广播后重识别
      uint8 *broadcast_msg=&pkt->cmd.Data[0];
      uint16 i=5;
      if(broadcast_msg[1]=='R' && broadcast_msg[3]=='B')
      {
            HalLedBlink( HAL_LED_2, 2,50, 500);
      }
      /***************************
      收到开门命令
      +D01OP#
      ****************************/
      if(broadcast_msg[1]=='D' && broadcast_msg[3]=='2' && broadcast_msg[4]=='O')
      {
        //正转 电机导通相序 D-C-B-A
        //反转 电机导通相序 A-B-C-D
        HalLedBlink( HAL_LED_1, 2,50, 500);
        for(i=0;i<128;i++)
        {
          MotorCW();
        }
        Delay_ms(500);
        while(1)
        {
          
          trig=1;
          Delay_ms(5);
          trig=0;
          while(echo!=1);
          HalTimerStart(HAL_TIMER_0,50);
          while(echo==1);
          HalTimerStop(HAL_TIMER_0);
          dis=((float)stime)/58;
          if(dis<=10)
          {
            inflag++;
            //while(inflag>=4)
              
          }
          else 
          {
            if(inflag>=4)
              break;
            inflag=0;
          }
          stime=0;
          Delay_ms(100);
        }
        inflag=0;
        for(i=0;i<128;i++)
        {
          MotorCCW();
        }        
        HalLedBlink( HAL_LED_2, 2,50, 500);
      }
      
       
#endif
      
  }
}