[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/zigbee/ieee802154/mac Mac.nc, NONE, 1.1 MacM.nc, NONE, 1.1 mac_const.h, NONE, 1.1 mac_enumerations.h, NONE, 1.1

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


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

Added Files:
	Mac.nc MacM.nc mac_const.h mac_enumerations.h 
Log Message:


--- NEW FILE: Mac.nc ---
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author Andre Cunha
 *
 */

#include <Timer.h>

configuration Mac {


		//MLME  
		provides interface MLME_START;
		provides interface MLME_SET;
		provides interface MLME_GET;
		
		provides interface MLME_ASSOCIATE;
		provides interface MLME_DISASSOCIATE;
		
		provides interface MLME_BEACON_NOTIFY;
		provides interface MLME_GTS;
		
		provides interface MLME_ORPHAN;

		provides interface MLME_SYNC;
		provides interface MLME_SYNC_LOSS;
		
		provides interface MLME_RESET;
		
		provides interface MLME_SCAN;
		
		//MCPS
		provides interface MCPS_DATA;
		provides interface MCPS_PURGE;

}
implementation {

	components MainC;
	MainC.SoftwareInit -> MacM;

	components LedsC;
	components MacM;

	components Phy;

	components TimerAsyncC;
	
	MacM.TimerAsync ->TimerAsyncC;

	MacM.Leds -> LedsC;
	
	
	MacM.AMControl ->Phy.SplitControl;
	
	components HplCC2420PinsC as Pins;
	MacM.CCA -> Pins.CCA;
	
	components RandomC;
	MacM.Random -> RandomC;

	components new TimerMilliC() as T_ackwait;
	MacM.T_ackwait -> T_ackwait;
	
	components new TimerMilliC() as T_ResponseWaitTime;
	MacM.T_ResponseWaitTime -> T_ResponseWaitTime;
	
	components new TimerMilliC() as T_ScanDuration;
	MacM.T_ScanDuration -> T_ScanDuration;

	components CC2420ReceiveC;
	MacM.AddressFilter -> CC2420ReceiveC;

	/*****************************************************/
	/*				INTERFACES         					 */
	/*****************************************************/  
	MacM.PD_DATA -> Phy.PD_DATA;
	MacM.PLME_ED ->Phy.PLME_ED;
	MacM.PLME_CCA -> Phy.PLME_CCA;
	MacM.PLME_SET -> Phy.PLME_SET;
	MacM.PLME_GET -> Phy.PLME_GET;
	MacM.PLME_SET_TRX_STATE -> Phy.PLME_SET_TRX_STATE;


	//MLME interfaces
	MLME_START=MacM;

	MLME_SET=MacM;
	MLME_GET=MacM;
	
	MLME_ASSOCIATE=MacM;
	MLME_DISASSOCIATE=MacM;
	
	MLME_BEACON_NOTIFY = MacM;
	MLME_GTS=MacM;
	
	MLME_ORPHAN=MacM;
	
	MLME_SYNC=MacM;
	MLME_SYNC_LOSS=MacM;
	
	MLME_RESET=MacM;
	
	MLME_SCAN=MacM;
	
	MCPS_DATA=MacM;
	MCPS_PURGE=MacM;
	
	
	
	

}


--- NEW FILE: MacM.nc ---
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author Andre Cunha
 *
 */

#include <Timer.h>

#include "printfUART.h"

#include "frame_format.h"
#include "phy_const.h"

#include "mac_const.h"
#include "mac_enumerations.h"

#include "mac_func.h"

module MacM {
[...5340 lines suppressed...]
	int i;
	////////////printfUART("GTS null list%i\n", GTS_null_descriptor_count); 
	
	for (i=0; i< GTS_null_descriptor_count;i++)
	{
		//////////////printfUART("GTSID: %i",GTS_null_db[i].gts_id); 	
		////////////printfUART("start slot: %i",GTS_null_db[i].starting_slot);
		////////////printfUART("lenght: %i",GTS_null_db[i].length); 	
		//////////////printfUART("dir: %i",GTS_null_db[i].direction); 	
		////////////printfUART("DevAddressType: %i \n",GTS_null_db[i].DevAddressType); 
		////////////printfUART("persistencetime: %i \n",GTS_null_db[i].persistencetime); 
	}
	
}

*/


}


--- NEW FILE: mac_const.h ---
/*
 * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
 * @author open-zb http://www.open-zb.net
 * @author Andre Cunha
 */

// The MAC constants are defined in here.
// Notice that these makes use of the PHY constants.
//pag 134

#ifndef __MAC_CONST__
#define __MAC_CONST__


#define aBaseSlotDuration          60
#define aBaseSuperframeDuration    960 //aBaseSlotDuration*aNumSuperframeSlots

//#define aExtendedAddress         // This should be defined by the device!

#define aMaxBE                     5 //CSMA-CA

#define aMaxBeaconOverhead         75
#define aMaxBeaconPayloadLength    aMaxPHYPacketSize-aMaxBeaconOverhead
#define aGTSDescPersistenceTime    4
#define aMaxFrameOverhead          25
#define aMaxFrameResponseTime      1220
#define aMaxFrameRetries           1

//(SYNC)number of beacons lost before sending a Beacon-Lost indication
#define aMaxLostBeacons            4
#define aMaxMACFrameSize           aMaxPHYPacketSize-aMaxFrameOverhead
#define aMaxSIFSFrameSize          18
#define aMinCAPLength              440
#define aMinLIFSPeriod             40
#define aMinSIFSPeriod             12
#define aNumSuperframeSlots        16
#define aResponseWaitTime          32*aBaseSuperframeDuration
#define aUnitBackoffPeriod         20


#define TYPE_BEACON 0
#define TYPE_DATA 1
#define TYPE_ACK 2
#define TYPE_CMD 3

#define SHORT_ADDRESS 2
#define LONG_ADDRESS 3
#define RESERVED_ADDRESS 1

#define NUMBER_TIME_SLOTS 16

#define ACK_LENGTH 5

//buffer sizes
#define MAX_GTS_BUFFER 7

//#define MAX_GTS_PEND 2
//#define MAX_GTS_IN_SLOT 1

#define INDIRECT_BUFFER_SIZE 2
#define RECEIVE_BUFFER_SIZE 4
#define SEND_BUFFER_SIZE 3

#define UPSTREAM_BUFFER_SIZE 3

#define GTS_SEND_BUFFER_SIZE 3

#define BACKOFF_PERIOD_MS 0.34724
#define BACKOFF_PERIOD_US 347.24

//value of each symbol in us
#define EFFECTIVE_SYMBOL_VALUE 17.362

// MAC PIB attribute
typedef struct
{
	//pag 135
	uint8_t macAckWaitDuration;
	bool macAssociationPermit;//FDD
	bool macAutoRequest;
	bool macBattLifeExt;
	uint8_t macBattLifeExtPeriods;
	
	uint8_t macBeaconPayload[aMaxBeaconPayloadLength];//FDD
	
	uint8_t macBeaconPayloadLenght;//FDD
	uint8_t macBeaconOrder;//FDD
	
	uint32_t macBeaconTxTime;//FDD
	uint8_t macBSN;//FDD
	uint32_t macCoordExtendedAddress0;
	uint32_t macCoordExtendedAddress1;
	uint16_t macCoordShortAddress;
	uint8_t macDSN;
	bool macGTSPermit;//FDD
	uint8_t macMaxCSMABackoffs;
	uint8_t macMinBE;
	uint16_t macPANId;
	bool macPromiscuousMode;//FDD
	bool macRxOnWhenIdle;
	uint32_t macShortAddress;
	uint8_t macSuperframeOrder;//FDD
	uint32_t macTransactionPersistenceTime;//FDD
	
} macPIB;

// MAC PIB security ACL entry descriptor
typedef struct
{
	uint32_t ACLExtendedAddress[2];
	uint16_t ACLShortAddress;
	uint16_t ACLPANId;
	uint8_t ACLSecurityMaterialLength;
	//variable string
	uint8_t ACLSecurityMaterial;
	uint8_t ACLSecuritySuite;
	
}ACLDescriptor;

// MAC PIB security attribute
typedef struct
{
	//pag 138
	ACLDescriptor macACLEntryDescriptorSet;
	uint8_t macACLEntryDescriptorSetSize;
	bool macDefaultSecurity;
	uint8_t macDefaultSecurityMaterialLength;
	//variable string
	uint8_t macDefaultSecurityMaterial;
	uint8_t macDefaultSecuritySuite;
	uint8_t macSecurityMode;
	
}macPIBsec;

//MAC PANDescriptor
typedef struct
{
	//pag76
	uint8_t CoordAddrMode;
	uint16_t CoordPANId;
	uint32_t CoordAddress0;
	uint32_t CoordAddress1;
	uint8_t LogicalChannel;
	//superframe specification field
	uint16_t SuperframeSpec;
	bool GTSPermit;
	uint8_t LinkQuality;
	uint32_t TimeStamp;
	bool SecurityUse;
	uint8_t ACLEntry;
	bool SecurityFailure;

}PANDescriptor;

//GTS entry (used in the PAN coordinator)
typedef struct
{
	uint8_t gts_id;
	uint8_t starting_slot;
	uint8_t length;
	uint8_t direction;
	uint16_t DevAddressType;
	uint8_t expiration;

}GTSinfoEntryType;

//GTS entry (used in the PAN coordinator)
typedef struct
{
	uint8_t gts_id;
	uint8_t starting_slot;
	uint8_t length;
	uint16_t DevAddressType;
	uint8_t persistencetime;

}GTSinfoEntryType_null;

typedef struct
{
	uint8_t handler;
	uint16_t transaction_persistent_time;
	
	//MPDU frame;
	uint8_t frame[127];

}indirect_transmission_element;

typedef struct gts_slot_element
{
	uint8_t element_count;
	uint8_t element_in;
	uint8_t element_out;
	uint8_t gts_send_frame_index[GTS_SEND_BUFFER_SIZE];

}gts_slot_element;


typedef struct time_stamp32
{

uint32_t time_stamp;

}time_stamp32;

typedef struct time_stamp16
{

uint16_t time_stamp;

}time_stamp16;

//MAC ACTIVE CHANNEL SCAN REDUCED PAN DESCRIPTOR (SHOR ADDRESS ONLY)
typedef struct SCAN_PANDescriptor
{
	//pag76
	uint16_t CoordPANId;
	uint16_t CoordAddress;
	uint8_t LogicalChannel;
	//superframe specification field
	uint16_t SuperframeSpec;
	uint8_t lqi;
}SCAN_PANDescriptor;


#endif

--- NEW FILE: mac_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 __MAC_ENUMERATIONS__
#define __MAC_ENUMERATIONS__
 
//Mac enumerations standard pag 110

enum { 
		MAC_SUCCESS = 0x00,
        MAC_BEACON_LOSS = 0xE0,
        MAC_CHANNEL_ACCESS_FAILURE = 0xE1,
        MAC_DENIED = 0xE2,
		//MLME-RESET
        MAC_DISABLE_TRX_FAILURE = 0xE3,
        MAC_FAILED_SECURITY_CHECK = 0xE4,
        MAC_FRAME_TOO_LONG = 0xE5,
        MAC_INVALID_GTS = 0xE6,
        MAC_INVALID_HANDLE = 0xE7,
        MAC_INVALID_PARAMETER = 0xE8,
        MAC_NO_ACK = 0xE9,
        MAC_NO_BEACON = 0xEA,
        MAC_NO_DATA = 0xEB,
        MAC_NO_SHORT_ADDRESS = 0xEC,
        MAC_OUT_OF_CAP = 0xED,
        MAC_PAN_ID_CONFLICT = 0xEE,
        MAC_REALIGNMENT = 0xEF,
        MAC_TRANSACTION_EXPIRED = 0xF0,
        MAC_TRANSACTION_OVERFLOW = 0xF1,
        MAC_TX_ACTIVE = 0xF2,
        MAC_UNAVAILABLE_KEY = 0xF3,
        MAC_UNSUPPORTED_ATTRIBUTE = 0xF4
        };



//mac dissassociation enums
enum{
		MAC_PAN_COORD_LEAVE = 0x01,
        MAC_PAN_DEVICE_LEAVE = 0x02,

};



//mac commands enums
enum {

	CMD_ASSOCIATION_REQUEST = 0x01,
	CMD_ASSOCIATION_RESPONSE = 0x02,
	CMD_DISASSOCIATION_NOTIFICATION = 0x03,
	CMD_DATA_REQUEST = 0x04,
	CMD_PANID_CONFLICT = 0x05,
	CMD_ORPHAN_NOTIFICATION = 0x06,
	CMD_BEACON_REQUEST = 0x07,
	CMD_COORDINATOR_REALIGNMENT = 0x08,
	CMD_GTS_REQUEST = 0x09
};


//mac association responses
enum {

	CMD_RESP_ASSOCIATION_SUCCESSFUL = 0x00,
	CMD_RESP_PAN_CAPACITY =0x01,
	CMD_RESP_ACCESS_DENIED =0x02
	
};

//MAC PIB Enumeration
enum {

	MACACKWAITDURATION = 0x40,
	MACASSOCIATIONPERMIT=0x41,
	MACAUTOREQUEST = 0x42,
	MACBATTLIFEEXT=0x43,
	MACBATTLIFEEXTPERIODS=0x44,
	MACBEACONPAYLOAD=0x45,
	MACMAXBEACONPAYLOADLENGTH=0x46,
	MACBEACONORDER=0x47,
	MACBEACONTXTIME=0x48,
	MACBSN=0x49,
	MACCOORDEXTENDEDADDRESS=0x4a,
	MACCOORDSHORTADDRESS=0x4b,
	MACDSN=0x4c,
	MACGTSPERMIT=0x4d,
	MACMAXCSMABACKOFFS=0x4e,
	MACMINBE=0x4f,
	MACPANID=0x50,
	MACPROMISCUOUSMODE=0x51,
	MACRXONWHENIDLE=0x52,
	MACSHORTADDRESS=0x53,
	MACSUPERFRAMEORDER=0x54,
	MACTRANSACTIONPERSISTENCETIME=0x55

};

//gts enumerations
enum{
	GTS_TX_ONLY = 0x00,
	GTS_RX_ONLY = 0x01
};

//channel scan enumerations
enum{
	ED_SCAN = 0x00,
	ACTIVE_SCAN = 0x01,
	PASSIVE_SCAN = 0x02,
	ORPHAN_SCAN = 0x03
};


#endif




More information about the Tinyos-2-commits mailing list