From eb9d689e4a4a4485875a72b8e2e57486e443601b Mon Sep 17 00:00:00 2001 From: changtengfei Date: Sat, 6 Jun 2015 22:57:08 +0800 Subject: [PATCH 01/46] GD_IM1.Make the variable of image configurable. --- drivers/common/openserial.c | 8 +++++ drivers/common/openserial.h | 1 + inc/opendefs.h | 5 +++ openstack/02a-MAClow/IEEE802154E.c | 32 +++++++++++++++++-- openstack/02a-MAClow/IEEE802154E.h | 16 ++++++++++ openstack/02b-MAChigh/neighbors.c | 6 ++++ openstack/02b-MAChigh/neighbors.h | 2 ++ openstack/02b-MAChigh/schedule.c | 5 ++- openstack/02b-MAChigh/sixtop.c | 11 ++++++- openstack/02b-MAChigh/sixtop.h | 3 ++ openstack/03b-IPv6/icmpv6rpl.c | 18 +++++++++++ openstack/03b-IPv6/icmpv6rpl.h | 3 +- .../03oos_openwsn/03oos_openwsn.ewp | 10 ++++++ projects/python/SConscript.env | 7 ++++ 14 files changed, 122 insertions(+), 5 deletions(-) diff --git a/drivers/common/openserial.c b/drivers/common/openserial.c index bade4a9fa1..68b25dacca 100644 --- a/drivers/common/openserial.c +++ b/drivers/common/openserial.c @@ -398,6 +398,14 @@ void openserial_stop() { //echo function must reset input buffer after reading the data. openserial_echo(&openserial_vars.inputBuf[1],inputBufFill-1); break; + case SERFRAME_PC2MOTE_SETKAPERIOD: + sixtop_setKaPeriod(((openserial_vars.inputBuf[1]<<8) & 0xFF00) | + (openserial_vars.inputBuf[2] & 0x00FF) + ); + printf("byte 0: %x byte 1: %x\n", + openserial_vars.inputBuf[1], + openserial_vars.inputBuf[2]); + break; default: openserial_printError(COMPONENT_OPENSERIAL,ERR_UNSUPPORTED_COMMAND, (errorparameter_t)cmdByte, diff --git a/drivers/common/openserial.h b/drivers/common/openserial.h index cbd9548e2f..4c47163eaf 100644 --- a/drivers/common/openserial.h +++ b/drivers/common/openserial.h @@ -53,6 +53,7 @@ enum { #define SERFRAME_PC2MOTE_SETROOT ((uint8_t)'R') #define SERFRAME_PC2MOTE_DATA ((uint8_t)'D') #define SERFRAME_PC2MOTE_TRIGGERSERIALECHO ((uint8_t)'S') +#define SERFRAME_PC2MOTE_SETKAPERIOD ((uint8_t)'K') //=========================== typedef ========================================= diff --git a/inc/opendefs.h b/inc/opendefs.h index bc101940b6..d3965e86c3 100644 --- a/inc/opendefs.h +++ b/inc/opendefs.h @@ -20,6 +20,11 @@ static const uint8_t infoStackName[] = "OpenWSN "; #define OPENWSN_VERSION_MINOR 9 #define OPENWSN_VERSION_PATCH 0 +// golden image version and type +#define GOLDEN_IMAGE_VERSION 1 +#define GOLDEN_IMAGE_TYPE 1 // dagroot + + //to delimit the implementation of draft-thubert-6man-flow-label-for-rpl-03 #define FLOW_LABEL_RPL_DOMAIN 1 diff --git a/openstack/02a-MAClow/IEEE802154E.c b/openstack/02a-MAClow/IEEE802154E.c index 8a398216b9..082fec9a04 100644 --- a/openstack/02a-MAClow/IEEE802154E.c +++ b/openstack/02a-MAClow/IEEE802154E.c @@ -105,6 +105,16 @@ void ieee154e_init() { memset(&ieee154e_vars,0,sizeof(ieee154e_vars_t)); memset(&ieee154e_dbg,0,sizeof(ieee154e_dbg_t)); + ieee154e_vars.singleChannel = SYNCHRONIZING_CHANNEL; + ieee154e_vars.isAckEnabled = TRUE; + ieee154e_vars.isSecurityEnabled = FALSE; + // default hopping template + memcpy( + &(ieee154e_vars.chTemplate[0]), + chTemplate_default, + sizeof(ieee154e_vars.chTemplate) + ); + if (idmanager_getIsDAGroot()==TRUE) { changeIsSync(TRUE); } else { @@ -1445,7 +1455,7 @@ port_INLINE void activity_ri5(PORT_RADIOTIMER_WIDTH capturedTime) { } // check if ack requested - if (ieee802514_header.ackRequested==1) { + if (ieee802514_header.ackRequested==1 && ieee154e_vars.isAckEnabled == TRUE) { // arm rt5 radiotimer_schedule(DURATION_rt5); } else { @@ -1772,6 +1782,19 @@ port_INLINE void ieee154e_syncSlotOffset() { ieee154e_vars.slotOffset = (slotOffset_t) slotOffset; } + +void ieee154e_setIsAckEnabled(bool isEnabled){ + ieee154e_vars.isAckEnabled = isEnabled; +} + +void ieee154e_setSingleChannel(uint8_t channel){ + ieee154e_vars.singleChannel = channel; +} + +void ieee154e_setIsSecurityEnabled(bool isEnabled){ + ieee154e_vars.isSecurityEnabled = isEnabled; +} + //======= synchronization void synchronizePacket(PORT_RADIOTIMER_WIDTH timeReceived) { @@ -1956,7 +1979,12 @@ different channel offsets in the same slot. */ port_INLINE uint8_t calculateFrequency(uint8_t channelOffset) { // comment the following line out to disable channel hopping - return SYNCHRONIZING_CHANNEL; // single channel + if (ieee154e_vars.singleChannel >= 11 && ieee154e_vars.singleChannel <= 26 ) { + return ieee154e_vars.singleChannel; // single channel + } else { + // channel hopping enabled, use the channel depending on hopping template + return 11 + ieee154e_vars.chTemplate[(ieee154e_vars.asnOffset+channelOffset)%16]; + } //return 11+(ieee154e_vars.asnOffset+channelOffset)%16; //channel hopping } diff --git a/openstack/02a-MAClow/IEEE802154E.h b/openstack/02a-MAClow/IEEE802154E.h index 418de49503..e5c872b47a 100644 --- a/openstack/02a-MAClow/IEEE802154E.h +++ b/openstack/02a-MAClow/IEEE802154E.h @@ -15,6 +15,11 @@ //=========================== debug define ==================================== +//=========================== static ========================================== +static const uint8_t chTemplate_default[] = { + 5,6,12,7,15,4,14,11,8,0,1,2,13,3,9,10 +}; + //=========================== define ========================================== #define SYNCHRONIZING_CHANNEL 20 // channel the mote listens on to synchronize @@ -206,10 +211,16 @@ typedef struct { // channel hopping uint8_t freq; // frequency of the current slot uint8_t asnOffset; // offset inside the frame + uint8_t singleChannel; // the single channel used for transmission + uint8_t chTemplate[16]; // storing the template of hopping sequence PORT_RADIOTIMER_WIDTH radioOnInit; // when within the slot the radio turns on PORT_RADIOTIMER_WIDTH radioOnTics; // how many tics within the slot the radio is on bool radioOnThisSlot; // to control if the radio has been turned on in a slot. + + //control + bool isAckEnabled; // whether reply for ack, used for synchronization test + bool isSecurityEnabled; // whether security is applied } ieee154e_vars_t; BEGIN_PACK @@ -239,6 +250,11 @@ void ieee154e_init(void); PORT_RADIOTIMER_WIDTH ieee154e_asnDiff(asn_t* someASN); bool ieee154e_isSynch(void); void ieee154e_getAsn(uint8_t* array); +void ieee154e_setIsAckEnabled(bool isEnabled); +void ieee154e_setSingleChannel(uint8_t channel); +void ieee154e_setIsSecurityEnabled(bool isEnabled); + + // events void ieee154e_startOfFrame(PORT_RADIOTIMER_WIDTH capturedTime); void ieee154e_endOfFrame(PORT_RADIOTIMER_WIDTH capturedTime); diff --git a/openstack/02b-MAChigh/neighbors.c b/openstack/02b-MAChigh/neighbors.c index 7e136e9071..eebe65044c 100644 --- a/openstack/02b-MAChigh/neighbors.c +++ b/openstack/02b-MAChigh/neighbors.c @@ -483,6 +483,12 @@ void neighbors_getNeighbor(open_addr_t* address, uint8_t addr_type, uint8_t ind } } +//===== setters + +void neighbors_setMyDAGrank(dagrank_t rank){ + neighbors_vars.myDAGrank = rank; +} + //===== managing routing info /** diff --git a/openstack/02b-MAChigh/neighbors.h b/openstack/02b-MAChigh/neighbors.h index 95c86324d0..2357ea4167 100644 --- a/openstack/02b-MAChigh/neighbors.h +++ b/openstack/02b-MAChigh/neighbors.h @@ -78,6 +78,8 @@ dagrank_t neighbors_getMyDAGrank(void); uint8_t neighbors_getNumNeighbors(void); bool neighbors_getPreferredParentEui64(open_addr_t* addressToWrite); open_addr_t* neighbors_getKANeighbor(uint16_t kaPeriod); +// setters +void neighbors_setMyDAGrank(dagrank_t rank); // interrogators bool neighbors_isStableNeighbor(open_addr_t* address); diff --git a/openstack/02b-MAChigh/schedule.c b/openstack/02b-MAChigh/schedule.c index 47cbd7aa15..ec74068c76 100644 --- a/openstack/02b-MAChigh/schedule.c +++ b/openstack/02b-MAChigh/schedule.c @@ -36,6 +36,9 @@ void schedule_init() { schedule_vars.backoffExponent = MINBE-1; schedule_vars.maxActiveSlots = MAXACTIVESLOTS; + // default slotframe length + schedule_vars.frameLength = SUPERFRAME_LENGTH; + start_slotOffset = SCHEDULE_MINIMAL_6TISCH_SLOTOFFSET; if (idmanager_getIsDAGroot()==TRUE) { schedule_startDAGroot(); @@ -65,7 +68,7 @@ void schedule_startDAGroot() { start_slotOffset = SCHEDULE_MINIMAL_6TISCH_SLOTOFFSET; // set frame length, handle and number (default 1 by now) - schedule_setFrameLength(SUPERFRAME_LENGTH); + schedule_setFrameLength(schedule_vars.frameLength); schedule_setFrameHandle(SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_HANDLE); schedule_setFrameNumber(SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_NUMBER); diff --git a/openstack/02b-MAChigh/sixtop.c b/openstack/02b-MAChigh/sixtop.c index efc96c6c08..0e04357a64 100644 --- a/openstack/02b-MAChigh/sixtop.c +++ b/openstack/02b-MAChigh/sixtop.c @@ -123,6 +123,7 @@ void sixtop_init() { sixtop_vars.dsn = 0; sixtop_vars.mgtTaskCounter = 0; sixtop_vars.kaPeriod = MAXKAPERIOD; + sixtop_vars.ebPeriod = EBTIMEOUT; sixtop_vars.maintenanceTimerId = opentimers_start( sixtop_vars.periodMaintenance, @@ -147,6 +148,14 @@ void sixtop_setKaPeriod(uint16_t kaPeriod) { } } +void sixtop_setEBPeriod(uint16_t ebPeriod) { + if(ebPeriod < SIXTOP_MINIMAL_EBPERIOD) { + sixtop_vars.ebPeriod = SIXTOP_MINIMAL_EBPERIOD; + } else { + sixtop_vars.ebPeriod = ebPeriod; + } +} + void sixtop_setHandler(six2six_handler_t handler) { sixtop_vars.handler = handler; } @@ -742,7 +751,7 @@ The body of this function executes one of the MAC management task. */ void timer_sixtop_management_fired(void) { scheduleEntry_t* entry; - sixtop_vars.mgtTaskCounter = (sixtop_vars.mgtTaskCounter+1)%EBTIMEOUT; + sixtop_vars.mgtTaskCounter = (sixtop_vars.mgtTaskCounter+1)%sixtop_vars.ebPeriod; switch (sixtop_vars.mgtTaskCounter) { case 0: diff --git a/openstack/02b-MAChigh/sixtop.h b/openstack/02b-MAChigh/sixtop.h index 0e9dd1e53a..50326b7b87 100644 --- a/openstack/02b-MAChigh/sixtop.h +++ b/openstack/02b-MAChigh/sixtop.h @@ -48,6 +48,7 @@ typedef enum { //=========================== typedef ========================================= #define SIX2SIX_TIMEOUT_MS 4000 +#define SIXTOP_MINIMAL_EBPERIOD 5 // minist period of sending EB //=========================== module variables ================================ @@ -60,6 +61,7 @@ typedef struct { opentimer_id_t maintenanceTimerId; opentimer_id_t timeoutTimerId; // TimeOut timer id uint16_t kaPeriod; // period of sending KA + uint16_t ebPeriod; // period of sending EB six2six_state_t six2six_state; uint8_t commandID; six2six_handler_t handler; @@ -70,6 +72,7 @@ typedef struct { // admin void sixtop_init(void); void sixtop_setKaPeriod(uint16_t kaPeriod); +void sixtop_setEBPeriod(uint16_t ebPeriod); void sixtop_setHandler(six2six_handler_t handler); // scheduling void sixtop_addCells(open_addr_t* neighbor, uint16_t numCells); diff --git a/openstack/03b-IPv6/icmpv6rpl.c b/openstack/03b-IPv6/icmpv6rpl.c index 083c547690..691376299e 100644 --- a/openstack/03b-IPv6/icmpv6rpl.c +++ b/openstack/03b-IPv6/icmpv6rpl.c @@ -563,3 +563,21 @@ void sendDAO() { openqueue_freePacketBuffer(msg); } } + +void icmpv6rpl_setDIOPeriod(uint16_t dioPeriod){ + icmpv6rpl_vars.periodDIO = dioPeriod; + opentimers_setPeriod( + icmpv6rpl_vars.timerIdDIO, + TIME_MS, + icmpv6rpl_vars.periodDIO + ); +} + +void icmpv6rpl_setDAOPeriod(uint16_t daoPeriod){ + icmpv6rpl_vars.periodDAO = daoPeriod; + opentimers_setPeriod( + icmpv6rpl_vars.timerIdDAO, + TIME_MS, + icmpv6rpl_vars.periodDAO + ); +} diff --git a/openstack/03b-IPv6/icmpv6rpl.h b/openstack/03b-IPv6/icmpv6rpl.h index 4de638ea01..da775062ae 100644 --- a/openstack/03b-IPv6/icmpv6rpl.h +++ b/openstack/03b-IPv6/icmpv6rpl.h @@ -159,7 +159,8 @@ void icmpv6rpl_sendDone(OpenQueueEntry_t* msg, owerror_t error); void icmpv6rpl_receive(OpenQueueEntry_t* msg); void icmpv6rpl_writeDODAGid(uint8_t* dodagid); uint8_t icmpv6rpl_getRPLIntanceID(void); - +void icmpv6rpl_setDIOPeriod(uint16_t dioPeriod); +void icmpv6rpl_setDAOPeriod(uint16_t daoPeriod); /** \} \} diff --git a/projects/openmotestm/03oos_openwsn/03oos_openwsn.ewp b/projects/openmotestm/03oos_openwsn/03oos_openwsn.ewp index f73ed8b0c2..5b1b8567e3 100644 --- a/projects/openmotestm/03oos_openwsn/03oos_openwsn.ewp +++ b/projects/openmotestm/03oos_openwsn/03oos_openwsn.ewp @@ -326,6 +326,7 @@ $PROJ_DIR$\..\..\..\openapps\uecho\ $PROJ_DIR$\..\..\..\openapps\cstorm\ $PROJ_DIR$\..\..\..\openapps\rrt\ + $PROJ_DIR$\..\..\..\openapps\uinject\