nwl_func.h.svn-base

来自「802.15.4协议的实现」· SVN-BASE 代码 · 共 70 行

SVN-BASE
70
字号
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author Andre Cunha
 */

//TEST
typedef struct associated_device
{

uint32_t address0;
uint32_t address1;

uint16_t pan_address;

}associated_device;
//END TEST

typedef struct routing_fields
{

uint16_t frame_control;

uint16_t destination_address;
uint16_t source_address;
uint8_t radius;
uint8_t sequence_number;

}routing_fields;

/*******************************************************************************************************************/  
/********************************FRAME CONTROL FUNCTIONS************************************************************/
/*******************************************************************************************************************/
  
 //build NPDU frame control field
uint16_t set_route_frame_control(uint8_t Frame_type,uint8_t Protocol_version,uint8_t Discover_route,uint8_t Security) 
{
	  uint8_t fc_byte1=0;
	  uint8_t fc_byte2=0;
  	  fc_byte1 = ( (Discover_route << 6) | (Protocol_version << 2) | (Frame_type << 0) );				  
	  fc_byte2 = ((Security<< 2));
	  return ( (fc_byte2 <<8 ) | (fc_byte1 << 0) );

} 

uint8_t get_route_frame_type(uint16_t frame_control)
{
	return (frame_control & 0x3);
}

uint8_t get_route_protocol_version(uint16_t frame_control)
{
	return ( (frame_control >> 2) & 0xf);
}

uint8_t get_route_discover_route(uint16_t frame_control)
{
	return ( (frame_control >> 6) & 0x3);
}

uint8_t get_route_security(uint16_t frame_control)
{
	if( ((frame_control >> 8) & 0x2) == 0x2)
		return 1;
	else
		return 0;
}



⌨️ 快捷键说明

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