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

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

?? aps.c

?? ZigBee協議棧2.0的程序
?? 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| 国产a精品视频| 欧美日韩亚州综合| 日韩毛片在线免费观看| 精品一区二区三区在线观看国产 | 精品一区二区三区免费观看| 91在线精品一区二区三区| 欧美白人最猛性xxxxx69交| 亚洲欧美日韩一区| 国产成人自拍在线| 精品国产三级a在线观看| 亚洲成人在线观看视频| 不卡电影一区二区三区| 精品日韩99亚洲| 日本中文字幕不卡| 欧美色窝79yyyycom| 亚洲色图一区二区| 欧美不卡123| 性感美女久久精品| 日本乱人伦aⅴ精品| 亚洲欧美自拍偷拍| 成人av影院在线| 中文字幕不卡在线| 国产99久久久国产精品潘金| 精品久久久久久久一区二区蜜臀| 日韩精品成人一区二区三区| 欧美日韩不卡在线| 日本欧美加勒比视频| 欧美一区二区三区在线观看视频 | 在线91免费看| 日韩制服丝袜av| 4438成人网| 七七婷婷婷婷精品国产| 日韩小视频在线观看专区| 日韩av成人高清| 精品动漫一区二区三区在线观看| 久久国产精品一区二区| 精品久久一二三区| 国产精品77777| 成人免费视频在线观看| 欧美综合天天夜夜久久| 欧美性一级生活| 亚洲国产日韩av| 欧美成人伊人久久综合网| 国产老肥熟一区二区三区| 国产午夜精品理论片a级大结局| 成人午夜视频福利| 亚洲精品你懂的| 7777精品伊人久久久大香线蕉经典版下载| 视频一区二区国产| wwww国产精品欧美| 色综合天天狠狠| 五月婷婷另类国产| 国产偷v国产偷v亚洲高清| 99精品国产一区二区三区不卡 | 国产精品久久久久婷婷| 一本色道亚洲精品aⅴ| 亚洲成人777| 久久综合丝袜日本网| 色成年激情久久综合| 美女在线一区二区| 中文字幕一区二区三| 欧美人体做爰大胆视频| 高潮精品一区videoshd| 舔着乳尖日韩一区| 中文字幕不卡三区| 91精品免费在线观看| 国产成人av电影免费在线观看| 一区二区免费视频| 欧美国产精品久久| 欧美一区二区国产| 在线中文字幕一区二区| 国产一区二区在线看| 亚洲国产wwwccc36天堂| 国产精品女同一区二区三区| 91精品综合久久久久久| av动漫一区二区| 欧美精品1区2区3区| 99精品视频在线观看| 紧缚奴在线一区二区三区| 亚洲图片欧美视频| 国产精品免费人成网站| 日韩美女一区二区三区| 欧美日韩国产电影| 一本久道中文字幕精品亚洲嫩| 国产精品一二三| 人妖欧美一区二区| 一区二区三区国产精华| 国产精品久久久久久久久晋中| 精品国产亚洲在线| 欧美一区二区成人| 欧美午夜电影网| 91老司机福利 在线| 成人精品国产福利| 国产精品一区二区在线看| 老司机精品视频一区二区三区| 亚洲国产精品久久不卡毛片 | 激情综合网最新| 爽好久久久欧美精品| 亚洲一区二区欧美日韩| 亚洲人成亚洲人成在线观看图片| 国产精品天美传媒| 久久九九久精品国产免费直播| 亚洲1区2区3区4区| 亚洲五码中文字幕| 亚洲在线一区二区三区| 一区二区三区在线免费观看| 亚洲欧美日韩在线播放| 亚洲精品视频自拍| 亚洲精品美腿丝袜| 亚洲一区二区在线免费观看视频| 亚洲国产一区二区视频| 亚洲综合激情小说| 亚洲成人综合在线| 婷婷国产在线综合| 久久国内精品视频| 国产乱一区二区| 成人午夜av电影| 99久久综合国产精品| 99久久99久久精品免费观看| 色综合天天综合色综合av| 色先锋aa成人| 欧美另类videos死尸| 69av一区二区三区| 久久综合九色综合欧美亚洲| 欧美激情一区二区三区四区| 国产精品久线观看视频| 亚洲伦理在线精品| 亚洲自拍偷拍图区| 蜜臀av性久久久久av蜜臀妖精| 久久99精品国产.久久久久| 国产精品主播直播| 91小视频免费看| 91麻豆精品久久久久蜜臀| 精品久久久久一区| 国产在线日韩欧美| 不卡av免费在线观看| 欧美视频一区二区三区在线观看| 在线播放91灌醉迷j高跟美女 | 亚洲成人综合网站| 精品一区中文字幕| 色综合久久中文综合久久牛| 欧美一区二区在线观看| 国产精品水嫩水嫩| 亚洲第四色夜色| 国产99久久久国产精品免费看| 欧美图片一区二区三区| 精品少妇一区二区三区视频免付费| 国产精品另类一区| 午夜视频一区二区三区| 国产99精品在线观看| 欧美一区午夜精品| 国产精品国模大尺度视频| 日本不卡视频一二三区| 成人国产精品免费| 欧美成人一区二区三区片免费| 亚洲乱码日产精品bd| 国产麻豆精品视频| 欧美美女bb生活片| 国产精品国产三级国产专播品爱网 | 日本女优在线视频一区二区| 成人黄色网址在线观看| 日韩欧美综合在线| 一区二区欧美国产| 成人晚上爱看视频| 久久婷婷一区二区三区| 日韩主播视频在线| 欧美亚洲国产bt| 中文字幕中文字幕一区二区| 激情综合色综合久久| 欧美日韩国产乱码电影| 亚洲男人的天堂av| 国产一区二区三区久久久| 欧美日韩国产123区| 一区二区三区精品| 99re热这里只有精品免费视频| 久久这里都是精品| 久久电影网电视剧免费观看| 欧美日韩一区二区三区高清| 亚洲欧美成人一区二区三区| 国产成人一区在线| 26uuu国产一区二区三区| 久久精品国产一区二区| 日韩欧美一区二区不卡| 一本久久精品一区二区| 国产精品嫩草久久久久| 国产福利不卡视频| 精品国内片67194| 青草国产精品久久久久久| 91精品国产美女浴室洗澡无遮挡| 亚洲自拍偷拍九九九| 欧美性欧美巨大黑白大战| 亚洲综合色自拍一区| 欧美日韩一区二区三区在线 | 欧美三级视频在线播放| 亚洲一级二级三级| 欧美性三三影院| 日日骚欧美日韩| 91麻豆精品国产91久久久资源速度|