亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? aps.c

?? ZIGBEE2006協議棧
?? C
?? 第 1 頁 / 共 3 頁
字號:
		 apsInjectPacket(FALSE);
		 aps_pib.flags.bits.IsUsrBufferFree = 1;
		 apsState = APS_STATE_IDLE;
		 goto apsFSM_start;

#ifdef LRWPAN_COORDINATOR
	 case APS_STATE_INJECT_INDIRECT:
		 //wait for RX to become idle
		 if (apsRxState != APS_RXSTATE_IDLE) break;
		 //inject packet into RX FSM
		 if (apsRxBuffFull()) {
			 //will not be able to copy buffer into indirect space
			 a_aps_service.status = LRWPAN_STATUS_INDIRECT_BUFFER_FULL;
		 }else {
			 apsInjectPacket(TRUE);
		 }
		 aps_pib.flags.bits.IsUsrBufferFree = 1;
		 apsState = APS_STATE_IDLE;
		 goto apsFSM_start;

#endif

#ifdef LRWPAN_COORDINATOR
	 case APS_STATE_INDIRECT_GETDST:
		 rxPtr = &aps_pib.rxBuff[aps_pib.rxTail];
		 //get the next bind destination for this src endpoint, cluster
		 if (!evbResolveBind(&rxPtr->dstEP, &rxPtr->dstSADDR)) {
			 //at this point, we have finished with the indirect transmit.
			 //lets free the original packet, and continue
			 apsFreeRxPacket(TRUE);
			 apsState = APS_STATE_IDLE;
		 } else {
			 //we have destination
			 //see if we are sending to ourself
			 if (rxPtr->dstSADDR == macGetShortAddr()) {
				 apsState = APS_STATE_INDIRECT_LOOPBACK;
			 }else {
				 apsState = APS_STATE_INDIRECT_TX;
			 }
			 goto apsFSM_start;
		 }
		 break;

	 case APS_STATE_INDIRECT_LOOPBACK:
		 if (apsRxBusy()) break;  //wait until RX buffer free
		 //copy to RX buffer
		 rxPtr = &aps_pib.rxBuff[aps_pib.rxTail];
		 halUtilMemCopy((BYTE *)&a_aps_rx_data,(BYTE *)rxPtr, sizeof(APS_RX_DATA));
		 //do user callback
		 usrRxPacketCallback();
		 apsState = APS_STATE_INDIRECT_GETDST;
		 goto apsFSM_start;


	 case APS_STATE_INDIRECT_TX:
		 //have a destination for our indirect TX. Lets do it.
		 if (phyTxLocked()) break;
		 phyGrabTxLock();
		 rxPtr = &aps_pib.rxBuff[aps_pib.rxTail];
		 a_aps_tx_data.aps_fcf = rxPtr->aps_fcf;
		 a_aps_tx_data.tsn = rxPtr->tsn;
		 a_aps_tx_data.af_fcf = rxPtr->af_fcf;
		 a_aps_tx_data.dstEP = rxPtr->dstEP;
		 a_aps_tx_data.dstMode = APS_DSTMODE_SHORT;
		 a_aps_tx_data.dstSADDR = rxPtr->dstSADDR;
		 a_aps_tx_data.cluster = rxPtr->cluster;
		 a_aps_tx_data.usrPlen = rxPtr->usrPlen;
		 a_aps_tx_data.usrPload = rxPtr->usrPload;
		 phy_pib.currentTxFlen = 0;  //set frame length to zero, build from scratch
		 apsTxData(TRUE);
		 apsState = APS_STATE_INDIRECT_TX_WAIT;
		 break;

		 //wait for last indirect TX to finish
	 case APS_STATE_INDIRECT_TX_WAIT:
		 if (nwkBusy()) break;
		 //at this point we have a status, but can't do much about it.
		 //either it went through or it did not.
		 //release the TX buffer lock before exiting.
		 phyReleaseTxLock();
		 //loop around, and see if there is another destination for this indirect packet
		 apsState = APS_STATE_INDIRECT_GETDST;
		 goto apsFSM_start;

#endif


	 default:  break;


	}//end switch(apsState)
	HAL_SUSPEND(0);  //for WIN32
}


//inject this packet into stack as if it has been received
//so that the binding can be resolved.
static void apsInjectPacket(BOOL indirect_flag){
	BYTE *dst;

	//allocate some heap space for this data
	if (a_aps_tx_data.usrPlen) {
	   a_aps_rx_data.orgpkt.data = MemAlloc(a_aps_tx_data.usrPlen);
	   if (!a_aps_rx_data.orgpkt.data ) {
	  	  //can't even get started, return
		  a_aps_service.status = LRWPAN_STATUS_HEAPFULL;
		 return;
	   }
	}
	//copy user payload into new space
	dst = a_aps_rx_data.orgpkt.data;
	a_aps_rx_data.usrPlen = a_aps_tx_data.usrPlen;  //save len
	while(a_aps_tx_data.usrPlen){
		*dst = *a_aps_tx_data.usrPload;  //copy data
		a_aps_tx_data.usrPload++;
		dst++;
		a_aps_tx_data.usrPlen--;
	}
	//set up rest of rx data
	a_aps_rx_data.cluster = a_aps_tx_data.cluster;
	a_aps_rx_data.af_fcf = a_aps_tx_data.af_fcf;
	a_aps_rx_data.srcEP = a_aps_tx_data.srcEP;
	a_aps_rx_data.srcSADDR = a_aps_tx_data.srcSADDR;
	a_aps_rx_data.usrPload = a_aps_rx_data.orgpkt.data;
	a_aps_rx_data.dstEP = a_aps_tx_data.dstEP;
	a_aps_rx_data.orgpkt.rssi = 0xFF;  //highest value


	if (indirect_flag) {
#ifdef LRWPAN_COORDINATOR
		//this packet has arrived at the coordinator
		a_aps_rx_data.dstSADDR = 0;
		//ensure that the submode bit is a '1'
		a_aps_rx_data.aps_fcf = a_aps_tx_data.aps_fcf |APS_FRM_INDIRECT_SUBMODE_MASK ;

		//copy data into indirect buffer space
		apsRxBuffAdd(&a_aps_rx_data);

		//set the RX FSM to the pending state
		aps_pib.flags.bits.indirectPending = 1;
		apsRxState = APS_RXSTATE_RESOLVE_INDIRECT;

#endif
		//at this point, we have simulated this packet being
		//received by the stack. When we return, the mainFSM
		//will process it, resolve the indirect binding, and re-transmit
	} else {
		//this is a direct packet sent to ourselves
		//check for DST endpoint of 0, special endpoint
		if (a_aps_rx_data.dstEP == 0) {
			//not a user endpoint, handle this
			DEBUG_STRING(DBG_INFO,"APS: Received ZEP Request.\n");
			zepHandleRxPacket();
			MemFree(a_aps_rx_data.orgpkt.data);				
		} else {
			//deliver to user endpoint right here.
			usrRxPacketCallback();
			//finished, free the space
			MemFree(a_aps_rx_data.orgpkt.data);
		}

	}
	a_aps_service.status = LRWPAN_STATUS_SUCCESS;

}



//Add the AF and APS headers, then send it to NWK
//the AF header probably should be a seperate layer,
//but will place it here since we are only handling MSG frames,
//reduces the depth of the stack.

void apsTxData(BOOL copy_payload) {

	BYTE *src;

	//if currentTxFlen is zero, we need to build the frame, else, it is
	// a retransmission
	if (phy_pib.currentTxFlen == 0) {
		//assume that the frame is just now being built.
		//use temporary space for building frame
		if (copy_payload){
			//copy user payload into tmpTxBuff space
			//if userPlen is 0, nothing is copied into the payload area
			phy_pib.currentTxFrm = &tmpTxBuff[LRWPAN_MAX_FRAME_SIZE];
			//get a pointer to the end of the payload
			src = a_aps_tx_data.usrPload + a_aps_tx_data.usrPlen;
			phy_pib.currentTxFlen = a_aps_tx_data.usrPlen;
			//now copy the user payload to the frame
			while (phy_pib.currentTxFlen) {
				src--;                //decrement to first src location with data
				phy_pib.currentTxFrm--;     //decrement to free location
				phy_pib.currentTxFlen--;    //decrement length
				*(phy_pib.currentTxFrm) = *src;
			}
		} else {
			//assume that TXBuff already has the payload, the ZEP
			//commands build their payload in this space
			//point currentTxFrm to this payload
			phy_pib.currentTxFrm = &tmpTxBuff[LRWPAN_MAX_FRAME_SIZE] - a_aps_tx_data.usrPlen;
		}
		//restore length
		phy_pib.currentTxFlen = a_aps_tx_data.usrPlen;

		if (APS_IS_DATA(a_aps_tx_data.aps_fcf)) {
			//DATA frame
			//Build AF header.
			//ONLY MSG FRAMES ARE SUPPORTED, so all we need to write is the
			//length of user payload
			--phy_pib.currentTxFrm; phy_pib.currentTxFlen++;
			*phy_pib.currentTxFrm = a_aps_tx_data.usrPlen;

			//sequence number
			--phy_pib.currentTxFrm; phy_pib.currentTxFlen++;
			*phy_pib.currentTxFrm = a_aps_tx_data.tsn;

			//AF frame control
			--phy_pib.currentTxFrm; phy_pib.currentTxFlen++;
			*phy_pib.currentTxFrm = a_aps_tx_data.af_fcf;
		}


		if (APS_GET_FRM_DLVRMODE(a_aps_tx_data.aps_fcf) == APS_FRM_DLVRMODE_INDIRECT){
			//this is indirect packet
#ifdef LRWPAN_COORDINATOR
			//TX packet from coordinator, ensure that the submode bit is a '0'

			a_aps_tx_data.aps_fcf = a_aps_tx_data.aps_fcf & ~APS_FRM_INDIRECT_SUBMODE_MASK ;
			//the dstSADDR has already been filled in during the binding resolution, copy to nwk
			a_nwk_tx_data.dstSADDR = a_aps_tx_data.dstSADDR;

#else
			//the destination for indirect packets is the coordinator
			a_nwk_tx_data.dstSADDR = 0;
			//ensure that the submode bit is a '1'
			a_aps_tx_data.aps_fcf = a_aps_tx_data.aps_fcf |APS_FRM_INDIRECT_SUBMODE_MASK ;
#endif
		} else {
			//copy destination address

			a_nwk_tx_data.dstSADDR = a_aps_tx_data.dstSADDR;
			a_nwk_tx_data.dstLADDR = a_aps_tx_data.dstLADDR;
		}



		//Build APS header.
		//SRC Endpoint
		if (!(((APS_GET_FRM_DLVRMODE(a_aps_tx_data.aps_fcf))==APS_FRM_DLVRMODE_INDIRECT) &&
			(!APS_GET_FRM_INDIRECT_SUBMODE(a_aps_tx_data.aps_fcf)))){
				//SRC endpoint is only omitted if INDIRECT frame and
				//indirect sub-mode bit is a '0'
				--phy_pib.currentTxFrm;phy_pib.currentTxFlen++;
				*phy_pib.currentTxFrm=a_aps_tx_data.srcEP;
			}

			//profile ID
			if ((APS_GET_FRM_TYPE(a_aps_tx_data.aps_fcf) == APS_FRM_TYPE_DATA)||
				(APS_GET_FRM_TYPE(a_aps_tx_data.aps_fcf) == APS_FRM_TYPE_ACK)) {
					//insert the profile ID, this hardcoded by the configuration
					--phy_pib.currentTxFrm;phy_pib.currentTxFlen++;
					*phy_pib.currentTxFrm= (BYTE) ((LRWPAN_APP_PROFILE) >> 8);
					--phy_pib.currentTxFrm;phy_pib.currentTxFlen++;
					*phy_pib.currentTxFrm = 0xFF & LRWPAN_APP_PROFILE ;
				}
				//cluster ID
				if (APS_GET_FRM_TYPE(a_aps_tx_data.aps_fcf) == APS_FRM_TYPE_DATA) {
					--phy_pib.currentTxFrm;phy_pib.currentTxFlen++;
					*phy_pib.currentTxFrm= a_aps_tx_data.cluster;
				}


				//Destination EP
				if (!(((APS_GET_FRM_DLVRMODE(a_aps_tx_data.aps_fcf))==APS_FRM_DLVRMODE_INDIRECT) &&
					(APS_GET_FRM_INDIRECT_SUBMODE(a_aps_tx_data.aps_fcf)))){
						//DST endpoint is only omitted if INDIRECT frame and
						//indirect sub-mode bit is a '1'
						--phy_pib.currentTxFrm;phy_pib.currentTxFlen++;
						*phy_pib.currentTxFrm=a_aps_tx_data.dstEP;
					}

					//frame control
					--phy_pib.currentTxFrm;phy_pib.currentTxFlen++;
					*phy_pib.currentTxFrm=a_aps_tx_data.aps_fcf;

					if (a_aps_tx_data.flags.bits.loopback) {
						//Zep commands to ourselves have to go all the way through formatting
						//before we inject them into stack
						apsInjectTxPacket();
						
					} else {

						//setup call to network layer
						//use the SRC address passed in by the aps layer
						//will be the SADDR of the originating node for this message
						a_nwk_tx_data.srcSADDR = a_aps_tx_data.srcSADDR;

						//now set the network bytes
						//since we are using tree routing, the Route Discovery is always suppressed.
						a_nwk_tx_data.radius = LRWPAN_NWK_MAX_RADIUS;
						a_nwk_tx_data.fcflsb = NWK_FRM_TYPE_DATA | NWK_PROTOCOL | NWK_SUPPRESS_ROUTE_DISCOVER ;

						//Send via the network layer
						a_nwk_service.cmd = LRWPAN_SVC_NWK_GENERIC_TX;

						// at this point, we will attempt a TX
						if (APS_GET_FRM_ACKREQ(a_aps_tx_data.aps_fcf)){
							//need an ACK back. set ackPending bit, start timer.
							aps_pib.flags.bits.ackPending = 1;
							aps_pib.tx_start_time = halGetMACTimer();
							//lets compute our Ack Wait duration
							//aps_pib.apscAckWaitDuration
							aps_pib.apsAckWaitMultiplier = nwkGetHopsToDest(a_nwk_tx_data.dstSADDR);
							aps_pib.apsAckWaitMultiplierCntr = aps_pib.apsAckWaitMultiplier;
						}
						else aps_pib.flags.bits.ackPending = 0;
						apsSetTxBusy();
						aps_pib.currentAckRetries = aps_pib.apscMaxFrameRetries; //set retry count
						apsTxFSM_status = LRWPAN_STATUS_APS_INPROGRESS;

						//we need to remember this offset in case of a retry, as we
						//will have to reset the flen to this point
						a_aps_tx_data.aps_flen = phy_pib.currentTxFlen;
						a_aps_tx_data.aps_ptr = phy_pib.currentTxFrm;
					}

	}

	if (!a_aps_tx_data.flags.bits.loopback)   nwkDoService();

}

//inject this packet into stack as if it has been received
//so that the binding can be resolved.
static void apsInjectTxPacket(void){

	//allocate some heap space for this data
	a_aps_rx_data.orgpkt.data = MemAlloc(phy_pib.currentTxFlen);
	a_aps_rx_data.apsOffset =0;
	if (!a_aps_rx_data.orgpkt.data ) {
		//can't even get started, return
		//we use th apsTxFSM status to return this status since we are injecting from TX machine
		apsTxFSM_status = LRWPAN_STATUS_HEAPFULL;
		return;
	}
	//copy tx buffer into rx space
	halUtilMemCopy(a_aps_rx_data.orgpkt.data, phy_pib.currentTxFrm, phy_pib.currentTxFlen);
	//set up FCF, RSSI, everything else will be parsed from packet
	a_aps_rx_data.aps_fcf = a_aps_tx_data.aps_fcf;
	//insure that APS field ACK field is NOT set since we will not be getting an ACK back
	a_aps_rx_data.aps_fcf &= ~APS_FRM_ACKREQ_MASK;
    *(a_aps_rx_data.orgpkt.data) = a_aps_rx_data.aps_fcf;

	a_aps_rx_data.orgpkt.rssi = 0xFF;  //highest value since loopback
	a_aps_rx_data.flags.val = 0;
	apsRxState = APS_RXSTATE_START; //kick off RX FSM
	apsRxFSM(); //call apsRxFSM to process packet
	apsTxFSM_status = LRWPAN_STATUS_SUCCESS;
}



//handle RX of packets at APS level
static void apsRxFSM(void)
{
	LRWPAN_STATUS_ENUM callback_status;


apsRxFSM_start:

 switch(apsRxState) {
  case APS_RXSTATE_IDLE:
	  break;
  case APS_RXSTATE_START:
	  //we have a packet, lets check it out.

	  if (APS_IS_RSV(a_aps_rx_data.aps_fcf)) {
		  //unknown packet type
		  DEBUG_STRING(DBG_INFO,"APS: Received APS RSV packet, discarding.\n");
		  MemFree(a_aps_rx_data.orgpkt.data);
		  apsRxState = APS_RXSTATE_IDLE;
		  break;
	  }
	  if ((APS_GET_FRM_DLVRMODE(a_aps_rx_data.aps_fcf) == APS_FRM_DLVRMODE_BCAST) ||
		  (APS_GET_FRM_DLVRMODE(a_aps_rx_data.aps_fcf) == APS_FRM_DLVRMODE_RSV)){
			  //Delivery mode not handled.
			  DEBUG_STRING(DBG_INFO,"APS: Received APS packet with BCAST or RSV delivery mode, discarding.\n");
			  MemFree(a_aps_rx_data.orgpkt.data);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99久久久久| 国产精品久久久久久久久图文区| 懂色中文一区二区在线播放| 日韩国产成人精品| 亚洲一区在线观看视频| 尤物视频一区二区| 亚洲最新视频在线播放| 亚洲欧美日韩国产综合| 亚洲免费在线视频一区 二区| 国产精品美女久久久久久久| 中文字幕不卡的av| 亚洲欧美日韩电影| 亚洲激情男女视频| 亚洲国产精品一区二区www在线| 亚洲欧美日韩久久| 性做久久久久久久久| 天堂成人国产精品一区| 男人操女人的视频在线观看欧美| 日韩av网站免费在线| 国内精品伊人久久久久av影院| 韩国成人在线视频| 国产98色在线|日韩| 成人h动漫精品一区二区 | 欧美成人三级在线| 精品剧情v国产在线观看在线| 亚洲精品一区二区三区99 | 欧美精选一区二区| 欧美一级高清片在线观看| 日韩美女在线视频| 中文字幕av不卡| 亚洲大片一区二区三区| 日韩黄色免费网站| 国产福利电影一区二区三区| 99r精品视频| 欧美精品久久一区二区三区| 精品国偷自产国产一区| 专区另类欧美日韩| 天天操天天色综合| 国产成人午夜电影网| 在线中文字幕一区二区| 久久天天做天天爱综合色| 国产精品免费视频观看| 亚洲永久免费av| 国产在线不卡一卡二卡三卡四卡| 91污在线观看| 欧美成人a∨高清免费观看| 亚洲欧美偷拍另类a∨色屁股| 美女在线视频一区| 色综合视频在线观看| 日韩欧美国产三级电影视频| 亚洲婷婷国产精品电影人久久| 蜜芽一区二区三区| 91免费视频网| 国产亚洲欧美激情| 欧美aaa在线| 欧美日本在线一区| 国产精品高潮呻吟久久| 老司机精品视频一区二区三区| 91福利视频网站| 国产精品网站在线观看| 日韩国产精品久久| 欧美在线观看你懂的| 国产三级精品三级| 美日韩黄色大片| 欧美午夜精品久久久久久超碰| 亚洲国产精品精华液2区45| 奇米色一区二区三区四区| 91在线精品秘密一区二区| 久久久一区二区三区| 视频一区在线播放| 欧美艳星brazzers| 亚洲欧美一区二区在线观看| 国产麻豆成人精品| 欧美mv日韩mv国产网站app| 天天综合色天天综合| 色琪琪一区二区三区亚洲区| 综合自拍亚洲综合图不卡区| 国产成人精品三级| 2024国产精品视频| 久久电影网站中文字幕| 欧美电影免费观看高清完整版 | 亚洲综合激情网| 972aa.com艺术欧美| 国产精品美女www爽爽爽| 国产精品66部| 欧美激情一区在线观看| 国产风韵犹存在线视精品| 久久精品欧美一区二区三区麻豆| 精品一区二区三区免费| 日韩欧美在线1卡| 久久国产欧美日韩精品| 精品国产一二三区| 国产一区二区三区香蕉| 久久久久9999亚洲精品| 国产河南妇女毛片精品久久久| 久久一区二区视频| 国产不卡视频在线播放| 亚洲视频一二区| 欧洲另类一二三四区| 日本在线不卡视频一二三区| 91精品啪在线观看国产60岁| 奇米精品一区二区三区四区| 日韩一区二区免费在线电影| 国产一区二区三区美女| 国产人成亚洲第一网站在线播放 | 92国产精品观看| 亚洲欧洲制服丝袜| 欧美精品久久一区| 国产精品自拍毛片| 亚洲少妇屁股交4| 欧美一区二区三区四区视频| 国产在线一区观看| 亚洲男人的天堂av| 日韩美女视频在线| 成人毛片老司机大片| 曰韩精品一区二区| 精品奇米国产一区二区三区| 粉嫩在线一区二区三区视频| 亚洲精品成人精品456| 91精品欧美久久久久久动漫| 国产乱码精品一品二品| 亚洲欧美激情一区二区| 91精品久久久久久久91蜜桃| 国产91在线|亚洲| 视频一区二区三区中文字幕| 久久精品综合网| 欧美日韩国产成人在线免费| 国产精品88av| 午夜国产精品一区| 中文字幕乱码一区二区免费| 在线播放/欧美激情| 99久久99久久精品免费看蜜桃| 日本亚洲一区二区| 亚洲男人的天堂在线观看| 久久久久久久网| 欧美午夜一区二区三区| 成人午夜视频在线| 免费高清在线视频一区·| 亚洲视频精选在线| 欧美精品一区二区久久久| 91精品1区2区| av电影一区二区| 精品影视av免费| 无码av中文一区二区三区桃花岛| 国产网红主播福利一区二区| 678五月天丁香亚洲综合网| 91在线视频在线| 国产精品一区二区三区四区| 青青草原综合久久大伊人精品| 亚洲人精品午夜| 国产精品丝袜在线| 精品国产精品网麻豆系列| 欧美日本在线播放| 在线精品视频一区二区| aa级大片欧美| www.欧美日韩| av一二三不卡影片| 成人aaaa免费全部观看| 成人午夜激情影院| 国产盗摄精品一区二区三区在线| 麻豆国产91在线播放| 日本不卡不码高清免费观看| 亚洲成在线观看| 亚洲午夜激情网页| 亚洲国产欧美在线| 亚洲一区在线视频观看| 亚洲国产精品一区二区久久恐怖片| 亚洲色图制服丝袜| 亚洲黄网站在线观看| 一区二区三区毛片| 亚洲午夜久久久久| 婷婷国产在线综合| 日本欧美一区二区在线观看| 图片区小说区国产精品视频| 性做久久久久久免费观看欧美| 婷婷综合五月天| 奇米影视7777精品一区二区| 蜜桃一区二区三区四区| 久久99久久99精品免视看婷婷| 久久se这里有精品| 国产a久久麻豆| 99久久伊人精品| 欧洲一区二区三区在线| 欧美亚洲精品一区| 欧美一激情一区二区三区| 精品电影一区二区| 国产精品蜜臀在线观看| 中文字幕日韩av资源站| 亚洲激情av在线| 久久精品国产亚洲a| 国产99精品在线观看| 在线观看一区二区视频| 3751色影院一区二区三区| 日韩欧美123| 国产精品福利在线播放| 一区二区免费看| 久久国内精品视频| 国产成人精品网址| 欧美三级一区二区| 久久先锋影音av|