⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macm.nc

📁 tinyos2.0版本驱动
💻 NC
📖 第 1 页 / 共 2 页
字号:
	error_t remove_indirect_trans(uint8_t handler);	//function used to increment the transaction persistent time on each message	//if the transaction time expires the messages are discarded	void increment_indirect_trans();	/*****************************************************//*				RECEIVE buffers		                  *//*****************************************************/  	/***************Variables*************************/		//buffering variables	norace MPDU buffer_msg[RECEIVE_BUFFER_SIZE];	int current_msg_in=0;	int current_msg_out=0;	int buffer_count=0;	/***************Functions Definition***************/			task void data_indication();		void indication_cmd(MPDU *pdu, int8_t ppduLinkQuality);	void indication_ack(MPDU *pdu, int8_t ppduLinkQuality);	void indication_data(MPDU *pdu, int8_t ppduLinkQuality);/*****************************************************//*				RECEPTION AND TRANSMISSION		                  *//*****************************************************/  		/***************Variables*************************/		//buffering for sending	norace MPDUBuffer send_buffer[SEND_BUFFER_SIZE];	uint8_t send_buffer_count=0;	uint8_t send_buffer_msg_in=0;	uint8_t send_buffer_msg_out=0;		//retransmission information	uint8_t send_ack_check;//ack requested in the transmitted frame	uint8_t retransmit_count;//retransmission count	uint8_t ack_sequence_number_check;//transmission sequence number	uint8_t send_retransmission;	uint8_t send_indirect_transmission;	uint8_t pending_request_data=0;		uint8_t ackwait_period;		uint8_t link_quality;		norace ACK mac_ack;	ACK *mac_ack_ptr;		uint32_t gts_expiration;	uint8_t I_AM_IN_CAP=0;	uint8_t I_AM_IN_CFP=0;	uint8_t I_AM_IN_IP=0;		/***************Functions Definition***************/			task void send_frame_csma();		uint8_t check_csma_ca_send_conditions(uint8_t frame_length,uint8_t frame_control1);	uint8_t check_gts_send_conditions(uint8_t frame_length);		uint8_t calculate_ifs(uint8_t pk_length);/*****************************************************//*				BEACON MANAGEMENT  		              *//*****************************************************/ 	/***************Variables*************************/	norace MPDU mac_beacon_txmpdu;	MPDU *mac_beacon_txmpdu_ptr;		uint8_t *send_beacon_frame_ptr;	uint8_t send_beacon_length;	/***************Functions Definition***************/		/*function to create the beacon*/	task void create_beacon();	/*function to process the beacon information*/	void process_beacon(MPDU *packet,uint8_t ppduLinkQuality);	/*****************************************************//*				Fault tolerance functions            *//*****************************************************/ 		void create_coordinator_realignment_cmd(uint32_t device_extended0, uint32_t device_extended1, uint16_t device_short_address);	void create_orphan_notification();			void process_coordinator_realignment(MPDU *pdu);/***************************DEBUG FUNCTIONS******************************//* This function are list functions with the purpose of debug, to use then uncomment the declatarionon top of this file*//*	void list_mac_pib();		void list_gts();		void list_my_gts();	void list_gts_null();	*/	//list all the handles in the indirect transmission buffer, debug purposes	void list_indirect_trans_buffer();				/***************************END DEBUG FUNCTIONS******************************//***************** Init Commands ****************/  command error_t Init.init() {    call AMControl.start();	//initialization of the beacon structure	mac_beacon_txmpdu_ptr = &mac_beacon_txmpdu;   atomic{	//inicialize the mac PIB	init_MacPIB();		init_GTS_db();		init_GTS_null_db();		init_gts_slot_list();		init_available_gts_index();		aExtendedAddress0=TOS_NODE_ID;	aExtendedAddress1=TOS_NODE_ID;			call AddressFilter.set_address(mac_PIB.macShortAddress, aExtendedAddress0, aExtendedAddress1);	call AddressFilter.set_coord_address(mac_PIB.macCoordShortAddress, mac_PIB.macPANId);					init_indirect_trans_buffer();	}		//beacon	mac_beacon_txmpdu_ptr = &mac_beacon_txmpdu;			//ack	mac_ack_ptr = &mac_ack;		//Other timers, sync timers units expressed in miliseconds	ackwait_period = ((mac_PIB.macAckWaitDuration * 4.0 ) / 250.0) * 3;	response_wait_time = ((aResponseWaitTime * 4.0) / 250.0) * 2;	atomic{					BI = aBaseSuperframeDuration * powf(2,mac_PIB.macBeaconOrder);		SD = aBaseSuperframeDuration * powf(2,mac_PIB.macSuperframeOrder);						//backoff_period		backoff = aUnitBackoffPeriod;		//backoff_period_boundary				time_slot = SD / NUMBER_TIME_SLOTS;					call TimerAsync.set_enable_backoffs(1);			call TimerAsync.set_backoff_symbols(backoff);				call TimerAsync.set_bi_sd(BI,SD);				call TimerAsync.start();	}printfUART_init();    return SUCCESS;  }  event void AMControl.startDone(error_t err) {    if (err == SUCCESS) {     		call TimerAsync.start();			}    else {      call AMControl.start();    }  }  event void AMControl.stopDone(error_t err) {  }/*****************************************************//*				TIMERS FIRED       					 *//*****************************************************/ async event error_t TimerAsync.before_bi_fired(){	////printfUART("bbi %i\n",call TimerAsync.get_current_ticks());			if (mac_PIB.macBeaconOrder != mac_PIB.macSuperframeOrder )	{		if ( Beacon_enabled_PAN == 1 )		{			//			//post set_trx();			trx_status = PHY_TX_ON;			call PLME_SET_TRX_STATE.request(PHY_TX_ON);		}		else		{			//			//post set_trx();			trx_status = PHY_RX_ON;			call PLME_SET_TRX_STATE.request(PHY_RX_ON);		}	}		//I_AM_IN_CAP = 1;	findabeacon = 1;			return SUCCESS;}/*******************Timer BEACON INTERVAL******************/async event error_t TimerAsync.bi_fired(){	call Leds.led2On();	//call Test_send.send();		I_AM_IN_CAP = 1;	I_AM_IN_IP = 0;		////printfUART("bi\n","");			if ( Beacon_enabled_PAN == 1 )	{		//the beacon is send directly without CSMA/CA		call PD_DATA.request(send_beacon_length,send_beacon_frame_ptr);	}	number_backoff =0;	number_time_slot=0;			//CHECK there is the need to wait a small amount of time before checking if the beacon as been processed or not	//possible solition, if it receives a packet stand by for confirmation it its a beacon	//The device must always receive the beacon	if (TrackBeacon == 1) 	{		if (beacon_processed==1) 		{			beacon_processed=0;		}		else		{			//dealocate all GTS			//beacon loss			on_sync =0;			beacon_loss_reason = MAC_BEACON_LOSS;						//TODO			//post signal_loss();		}	}		post send_frame_csma();	return SUCCESS;}/*******************Timer SUPERFRAME DURATION******************/async event error_t TimerAsync.sd_fired(){	call Leds.led2Off();	////printfUART("sd\n","");	I_AM_IN_CFP = 0;	I_AM_IN_IP = 1;			number_backoff=0;	number_time_slot=0;			if (PANCoordinator == 0 && TYPE_DEVICE == ROUTER)	{		trx_status = PHY_RX_ON;			call PLME_SET_TRX_STATE.request(PHY_RX_ON);	}	else	{		trx_status = PHY_RX_ON;				call PLME_SET_TRX_STATE.request(PHY_RX_ON);			}		if (mac_PIB.macShortAddress==0xffff && TYPE_DEVICE == END_DEVICE)	{		trx_status = PHY_RX_ON;				call PLME_SET_TRX_STATE.request(PHY_RX_ON);	}		//trx_status = PHY_RX_ON;	//post set_trx();	/*		//turn the transceiver off	if (mac_PIB.macBeaconOrder != mac_PIB.macSuperframeOrder )	{		if ( mac_PIB.macRxOnWhenIdle == 0 && findabeacon == 0) 		{			trx_status = PHY_TRX_OFF;			post set_trx();		}		else		{			trx_status = PHY_RX_ON;			post set_trx();		}	}	//if the node is trying to synchronize		if (on_sync == 0 || mac_PIB.macPromiscuousMode == 1)	{		atomic{			trx_status = PHY_RX_ON;			post set_trx();		}	}	*/	if (PANCoordinator == 1)	{		//increment the gts_null descriptors		atomic{							//if (GTS_null_descriptor_count > 0) post increment_gts_null();							//if (GTS_descriptor_count >0 ) post check_gts_expiration();							//if (indirect_trans_count > 0) increment_indirect_trans();								//creation of the beacon				post create_beacon();		}		//trx_status = PHY_TRX_OFF;		//post set_trx();	}	else	{	//temporariamente aqui //aten玢o quando for para o cluster-tree 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -