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

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

?? aps.c

?? zigbee 2004協議棧
?? C
?? 第 1 頁 / 共 3 頁
字號:
		 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);
			  apsRxState = APS_RXSTATE_IDLE;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线观看美女| 亚洲va国产天堂va久久en| kk眼镜猥琐国模调教系列一区二区 | 欧美色爱综合网| 99久久综合色| 成人激情午夜影院| 成人一区在线看| 成人性生交大片免费看中文 | 97久久精品人人澡人人爽| 国产91精品久久久久久久网曝门 | 中文字幕在线不卡一区二区三区| 精品国产乱码久久久久久牛牛| 91麻豆精品国产91久久久更新时间 | 欧美在线短视频| 欧美三级电影精品| 91麻豆精品国产无毒不卡在线观看| 精品视频在线看| 日韩欧美中文一区| 国产人成一区二区三区影院| 中文字幕第一区综合| 亚洲欧美视频在线观看视频| 亚洲成人在线观看视频| 免费在线欧美视频| 懂色av中文一区二区三区| 91免费看视频| 7777精品伊人久久久大香线蕉完整版| 欧美一区二区三区成人| 国产女人18水真多18精品一级做| 中文字幕一区二区三区av| 亚洲香肠在线观看| 久久成人综合网| av福利精品导航| 欧美日韩成人综合在线一区二区| 在线精品视频一区二区三四| 欧美日韩国产一区二区三区地区| 欧美电影免费观看高清完整版在线 | 欧美一级高清片在线观看| 国产欧美一区二区三区沐欲| 亚洲一区在线观看免费| 经典一区二区三区| 色婷婷综合久久久久中文| 欧美高清视频一二三区| 国产精品色呦呦| 三级不卡在线观看| www.激情成人| 久久先锋影音av鲁色资源网| 伊人性伊人情综合网| 极品瑜伽女神91| 欧美色图激情小说| 国产精品色噜噜| 九九精品一区二区| 欧美日韩亚洲国产综合| 欧美激情综合网| 美国毛片一区二区三区| 91久久线看在观草草青青| 国产午夜精品福利| 美女被吸乳得到大胸91| 91蝌蚪porny成人天涯| 国产色91在线| 久久精品噜噜噜成人88aⅴ| 欧美影视一区在线| 亚洲视频一区二区免费在线观看| 国产精品一卡二卡在线观看| 在线综合视频播放| 亚洲大片精品永久免费| 在线观看日韩毛片| 亚洲欧美国产三级| av中文一区二区三区| 亚洲国产精品二十页| 国产精品系列在线播放| 精品国产凹凸成av人导航| 视频一区二区欧美| 欧美军同video69gay| 国产精品视频一二三| 成人午夜短视频| 中文一区二区完整视频在线观看| 日韩电影免费在线观看网站| 97久久精品人人爽人人爽蜜臀| 国产精品乱码人人做人人爱| 国产成a人亚洲精品| 国产视频在线观看一区二区三区 | 国产成人精品aa毛片| 久久久久久久国产精品影院| 国产自产2019最新不卡| 欧美精品一区二区精品网| 久久99国产精品久久99果冻传媒| 欧美www视频| 国产精品小仙女| 国产精品成人在线观看| 色婷婷综合久久久中文一区二区 | 欧美一级xxx| 亚洲国产精品精华液网站| 91色乱码一区二区三区| 久久久一区二区| 成人激情av网| 亚洲国产激情av| 色中色一区二区| 丝袜美腿亚洲一区| 久久久噜噜噜久久人人看 | 欧美日韩一区三区四区| 天天综合网 天天综合色| 欧美一区二区三区在线视频| 国产精品一区二区在线播放 | 精品视频一区二区三区免费| 久久精品国产一区二区| 欧美高清在线一区| 在线观看视频91| 久久99精品久久久久婷婷| 日本一区二区三区久久久久久久久不| 99麻豆久久久国产精品免费| 亚洲国产精品久久人人爱蜜臀| 91精品国产入口| 成人久久视频在线观看| 天堂久久一区二区三区| 国产欧美日韩另类一区| 欧美亚洲高清一区| 精品亚洲国内自在自线福利| 亚洲精品国产高清久久伦理二区| 日韩一区二区在线播放| 成人app下载| 久久精品国产亚洲5555| 一区二区三区中文字幕电影 | 5月丁香婷婷综合| 粉嫩aⅴ一区二区三区四区| 五月天精品一区二区三区| 欧美激情在线免费观看| 欧美一区二区三区视频免费| gogogo免费视频观看亚洲一| 琪琪一区二区三区| 亚洲一区二区三区免费视频| 国产亚洲精久久久久久| 欧美一级在线视频| 欧美日韩在线观看一区二区| 激情综合色综合久久| 亚洲美女视频在线| 欧美国产乱子伦| 精品久久久久久最新网址| 91福利视频在线| 成人黄色电影在线 | 精品一区二区三区香蕉蜜桃| 亚洲图片欧美一区| 国产精品无遮挡| 精品精品国产高清a毛片牛牛| 91国偷自产一区二区三区观看| 国产v综合v亚洲欧| 国产一区二三区| 日韩av不卡在线观看| 日韩精品午夜视频| 亚洲成人免费在线| 亚洲一区视频在线观看视频| 亚洲激情网站免费观看| 亚洲精品成人a在线观看| 自拍偷拍亚洲激情| 亚洲欧美视频在线观看视频| 国产精品美女久久久久久2018| 久久蜜臀中文字幕| 国产欧美日韩中文久久| 国产喷白浆一区二区三区| 国产日韩精品一区| 中文久久乱码一区二区| 国产精品久久99| 亚洲猫色日本管| 一区二区国产视频| 天堂久久一区二区三区| 欧美bbbbb| 日韩电影一二三区| 麻豆精品国产91久久久久久| 日本网站在线观看一区二区三区| 日本一不卡视频| 另类小说色综合网站| 蜜臀a∨国产成人精品| 日本伊人色综合网| 极品瑜伽女神91| 国产a久久麻豆| 99久久精品费精品国产一区二区| 99精品视频在线观看| 在线视频中文字幕一区二区| 欧美少妇bbb| 日韩精品一区二区在线观看| 久久色.com| 亚洲人成7777| 亚洲免费在线播放| 免费久久99精品国产| 国产精品一区二区在线看| 99在线热播精品免费| 欧美日韩免费视频| 久久九九久久九九| 一区二区在线观看免费视频播放| 五月婷婷欧美视频| 国产成人精品影院| 欧美日韩国产综合一区二区| 欧美精品一区视频| 一区二区三区在线免费视频| 喷白浆一区二区| 色婷婷av一区二区三区软件| 日韩欧美国产综合| 亚洲最新视频在线观看| 国产在线看一区| 欧美日韩免费观看一区二区三区| 久久午夜老司机|