[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/zigbee/ieee802154/nwk Makefile, NONE, 1.1 NWK.nc, NONE, 1.1 NWKM.nc, NONE, 1.1 nwk_const.h, NONE, 1.1 nwk_enumerations.h, NONE, 1.1

André Cunha a_cunha at users.sourceforge.net
Mon Feb 11 09:50:35 PST 2008


Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/zigbee/ieee802154/nwk
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29875/nwk

Added Files:
	Makefile NWK.nc NWKM.nc nwk_const.h nwk_enumerations.h 
Log Message:


--- NEW FILE: Makefile ---
COMPONENT=NWK

PFLAGS += 	-I$(TOSROOT)/tos/ieee802154/includes \
			-I$(TOSROOT)/tos/ieee802154/mac \
			-I$(TOSROOT)/tos/ieee802154/phy \
			-I$(TOSROOT)/tos/ieee802154/timerasync \
			-I$(TOSROOT)/tos/ieee802154/interfaces \
			-I$(TOSROOT)/tos/ieee802154/interfaces/mac \
			-I$(TOSROOT)/tos/ieee802154/interfaces/phy \
			-I$(TOSROOT)/tos/chips/cc2420/ieee802154
include $(MAKERULES)


--- NEW FILE: NWK.nc ---
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author Andre Cunha
 *
 */
#include <Timer.h>

#include "phy_const.h"
#include "phy_enumerations.h"
#include "mac_const.h"
#include "mac_enumerations.h"
#include "mac_func.h"

#include "nwk_func.h"
#include "nwk_enumerations.h"
#include "nwk_const.h"


configuration NWK {

	//provides
	
	//NLDE NWK data service  
	
	provides interface NLDE_DATA;
	
	
	//NLME NWK Management service
	
	provides interface NLME_NETWORK_FORMATION;
	provides interface NLME_NETWORK_DISCOVERY;
	provides interface NLME_START_ROUTER;
	provides interface NLME_JOIN;
	provides interface NLME_LEAVE;
	
	/*     
	provides interface NLME_PERMIT_JOINING;
	provides interface NLME_DIRECT_JOIN;		
	provides interface NLME_RESET;
	*/
	provides interface NLME_SYNC;
	
	provides interface NLME_GET;
	provides interface NLME_SET;

}
implementation {

  components MainC;
  MainC.SoftwareInit -> NWKM;
  
  components LedsC;
  components NWKM;
       
  components Mac;
  
  NWKM.Leds -> LedsC;
   
   
	components RandomC;
	NWKM.Random -> RandomC;
   
   
  //MAC interfaces
  
  NWKM.MLME_START -> Mac.MLME_START;
  
  NWKM.MLME_GET ->Mac.MLME_GET;
  NWKM.MLME_SET ->Mac.MLME_SET;
  
  NWKM.MLME_BEACON_NOTIFY ->Mac.MLME_BEACON_NOTIFY;
  NWKM.MLME_GTS -> Mac.MLME_GTS;
  
  NWKM.MLME_ASSOCIATE->Mac.MLME_ASSOCIATE;
  NWKM.MLME_DISASSOCIATE->Mac.MLME_DISASSOCIATE;
  
  NWKM.MLME_ORPHAN->Mac.MLME_ORPHAN;
  NWKM.MLME_SYNC->Mac.MLME_SYNC;
  NWKM.MLME_SYNC_LOSS->Mac.MLME_SYNC_LOSS;
  NWKM.MLME_RESET->Mac.MLME_RESET;
  
  NWKM.MLME_SCAN->Mac.MLME_SCAN;
  
  
  NWKM.MCPS_DATA->Mac.MCPS_DATA;
	
	
	
	//NLDE NWK data service  
	NLDE_DATA=NWKM;
	
	//NLME NWK Management service
	NLME_NETWORK_FORMATION=NWKM;
	NLME_NETWORK_DISCOVERY=NWKM;
	
	NLME_START_ROUTER=NWKM;
	
	NLME_JOIN=NWKM;
	NLME_LEAVE=NWKM;
	
	/*
	NLME_PERMIT_JOINING=NWKM;
	NLME_DIRECT_JOIN=NWKM;
	NLME_RESET=NWKM;
	*/
	NLME_SYNC=NWKM;
	NLME_GET=NWKM;
	NLME_SET=NWKM;
	  
	  
}

--- NEW FILE: NWKM.nc ---
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author Andre Cunha
 *
 */
#include <Timer.h>
#include "printfUART.h"

module NWKM {
	
//uses
	uses interface Leds;

	//MAC interfaces
	
	uses interface MLME_START;
	
	uses interface MLME_GET;
	uses interface MLME_SET;
[...1462 lines suppressed...]
		nwk_IB.nwkMaxRouters=0x02;	//number of routers anyone device is allowed to have on its current network
		//neighbortableentry nwkNeighborTable[];//null set
		nwk_IB.nwkNetworkBroadcastDeliveryTime=( nwk_IB.nwkPassiveAckTimeout * nwk_IB.nwkMaxBroadcastRetries );
		nwk_IB.nwkReportConstantCost=0x00;
		nwk_IB.nwkRouteDiscoveryRetriesPermitted=nwkcDiscoveryRetryLimit;
	//set? nwkRouteTable;//Null set
		nwk_IB.nwkSymLink=0;
		nwk_IB.nwkCapabilityInformation=0x00;
		nwk_IB.nwkUseTreeAddrAlloc=1;
		nwk_IB.nwkUseTreeRouting=1;
		nwk_IB.nwkNextAddress=0x0000;
		nwk_IB.nwkAvailableAddresses=0x0000;
		nwk_IB.nwkAddressIncrement=0x0001;
		nwk_IB.nwkTransactionPersistenceTime=0x01f4;
	}


  
}


--- NEW FILE: nwk_const.h ---
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author http://www.open-zb.net
 * @author Andre Cunha
 */
#ifndef __NWK_CONST__
#define __NWK_CONST__
 
//GLOBAL VARIABLES

#define MAC_PANID 0x1234

//SELECTED DEVICE TYPE

#define TYPE_DEVICE END_DEVICE
//#define TYPE_DEVICE ROUTER
//#define TYPE_DEVICE COORDINATOR

//test definitions
#define DEVICE_DEPTH 0x01

//used to operate in a fixed channel
#define LOGICAL_CHANNEL 0x15

//PAN VARIABLES
//conflict error
//#define PANID 0x1234

#define AVAILABLEADDRESSES 0x04
#define ADDRESSINCREMENT 0x0001
#define MAXCHILDREN 0x06
#define MAXDEPTH 0x03
#define MAXROUTERS 0x04

#define BEACON_ORDER 8
#define SUPERFRAME_ORDER 4

//test definitions

//activated when the device depth is 0x01
#define D1_PAN_EXT0 0x00000001
#define D1_PAN_EXT1 0x00000001
#define D1_PAN_SHORT 0x0000

//activated when the device depth is 0x02
#define D2_PAN_EXT0 0x00000002
#define D2_PAN_EXT1 0x00000002
#define D2_PAN_SHORT 0x0001

//activated when the device depth is 0x03
#define D3_PAN_EXT0 0x00000003
#define D3_PAN_EXT1 0x00000003
#define D3_PAN_SHORT 0x0002

//activated when the device depth is 0x04
#define D4_PAN_EXT0 0x00000006
#define D4_PAN_EXT1 0x00000006
#define D4_PAN_SHORT 0x0022


 
// The Network layer constants are defined in here.
//page 202
//#define nwkcCoordinatorCapable     //set at build time
//#define nwkcDefaultSecurityLevel   ENC-MIC-64

#define nwkcDiscoveryRetryLimit		0x03
#define nwkcMaxDepth				0x0f
#define nwkcMinHeaderOverhead		0x08
#define nwkcProtocolVersion			0x01    
#define nwkcRepairThreshold			0x03
#define nwkcRouteDiscoveryTime		0x2710
#define nwkcMaxBroadcastJitter		0x40
#define nwkcInitialRREQRetries		0x03
#define nwkcRREQRetries				0x02
#define nwkcRREQRetryInterval		0xfe
#define nwkcMinRReQJitter			0x01
#define nwkcMaxRReQJitter			0x40


// The NWK IB attributes are defined in here.
typedef struct
{
//page 204
	uint8_t nwkSequenceNumber;
	uint8_t nwkPassiveAckTimeout;
	uint8_t nwkMaxBroadcastRetries;
	uint8_t nwkMaxChildren;
	uint8_t nwkMaxDepth;
	uint8_t nwkMaxRouters;
//neighbortableentry nwkNeighborTable[];
	uint8_t nwkNetworkBroadcastDeliveryTime;
	uint8_t nwkReportConstantCost;
	uint8_t nwkRouteDiscoveryRetriesPermitted;
//set? nwkRouteTable;
	uint8_t nwkSymLink;
	uint8_t nwkCapabilityInformation;
	uint8_t nwkUseTreeAddrAlloc;
	uint8_t nwkUseTreeRouting;
	uint16_t nwkNextAddress;
	uint16_t nwkAvailableAddresses;
	uint16_t nwkAddressIncrement;
	uint16_t nwkTransactionPersistenceTime;
	
} nwkIB;


//NWK layer NeighborTableEntry
typedef struct
{
//page 218
	uint16_t PAN_Id;
	uint32_t Extended_Address0;
	uint32_t Extended_Address1;
	uint16_t Network_Address;
	uint8_t Device_Type;
	uint8_t Relationship;
	
	//optional fields
	//we choose to exclude this fields due to memory limitation
	
	//bool RxOnWhenIdle;
	uint8_t Depth;
	uint8_t Permit_Joining;
	uint8_t Logical_Channel;
	uint8_t Potential_Parent;
	/*
	uint8_t Beacon_Order;
	
	uint8_t Transmit_Failure;
	uint8_t Potential_Parent;
	uint8_t LQI;
	uint8_t Logical_Channel;
	uint32_t Incoming_Beacon_Timestamp;
	uint32_t Beacon_Transmission_Time_Offset;
*/
} neighbortableentry;

// NWK layer NetworkDescriptor
typedef struct
{
//page 166
	uint16_t PANId;
	uint8_t LogicalChannel;
	uint8_t StackProfile;
	uint8_t ZigBeeVersion;
	uint8_t BeaconOrder;
	uint8_t SuperframeOrder;
	uint8_t PermitJoining;
	
} networkdescriptor;

//NEIGhBOUR TABLE COUNT
#define NEIGHBOUR_TABLE_SIZE 7

//beacon scheduling mechanims
typedef struct
{
	uint8_t request_type;
	uint8_t beacon_order;
	uint8_t superframe_order;
	uint8_t transmission_offset[3];
	
}beacon_scheduling;

#define SCHEDULING_REQUEST 0x01
#define SCHEDULING_ACCEPT 0x02
#define SCHEDULING_DENY 0x03

#endif

--- NEW FILE: nwk_enumerations.h ---
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author open-zb http://www.open-zb.net
 * @author Andre Cunha
 */
 
#ifndef __NWK_ENUMERATIONS__
#define __NWK_ENUMERATIONS__
 
//NWK layer status values 
//page 243
enum { 
	NWK_SUCCESS = 0x00,
    NWK_INVALID_PARAMETER = 0xc1,
    NWK_INVALID_REQUEST = 0xc2,
	NWK_NOT_PERMITTED = 0xc3,
	NWK_STARTUP_FAILURE = 0xc4,
	NWK_ALREADY_PRESENT = 0xc5,
	NWK_SYNC_FAILURE = 0xc6,
	NWK_TABLE_FULL = 0xc7,
	NWK_UNKNOWN_DEVICE = 0xc8,
	NWK_UNSUPPORTED_ATTRIBUTE = 0xc9,
	NWK_NO_NETWORKS = 0xca,
	NWK_LEAVE_UNCONFIRMED = 0xcb,
	NWK_MAX_FRM_CNTR = 0xcc,
	NWK_NO_KEY = 0xcd,
	NWK_BAD_CCM_OUTPUT = 0xce
    };

//NWK layer device types
//page 342
enum {
	COORDINATOR = 0x00,
	ROUTER =0x01,
	END_DEVICE = 0x02
	};


//NWK layer Relationship
//page 342
enum {
	NEIGHBOR_IS_PARENT = 0x00,
	NEIGHBOR_IS_CHILD = 0x01,
	NEIGHBOR_IS_SIBLING = 0x02,
	NEIGHBOR_IS_NON = 0x03,
	NEIGHBOR_IS_PREVIOUS_CHILD = 0x04,
	};
	

//NWK layer PIB attributs ennumerations
//PAG 317
enum{
	NWKSEQUENCENUMBER = 0x81,
	NWKPASSIVEACKTIMEOUT = 0x82,
	NWKMAXBROADCASTRETRIES = 0x83,
	NWKMAXCHILDREN = 0x84,
	NWKMAXDEPTH = 0x85,
	NWKMAXROUTERS = 0x86,
	//NWKNEIGHBORTABLE = 0x87
	NWKMETWORKBROADCASTDELIVERYTIME = 0x88,
	NWKREPORTCONSTANTCOST = 0x89,
	NWKROUTEDISCOVERYRETRIESPERMITED = 0x8a,
	//NWKROUTETABLE
	NWKSYMLINK = 0x8e,
	NWKCAPABILITYINFORMATION = 0x8f,
	NWKUSETREEADDRALLOC = 0x90,
	NWKUSETREEROUTING = 0x91,
	NWKNEXTADDRESS = 0x92,
	NWKAVAILABLEADDRESSES = 0x93,
	NWKADDRESSINCREMENT = 0x94,
	NWKTRANSACTIONPERSISTENCETIME = 0x95
};

#endif



More information about the Tinyos-2-commits mailing list