void icmpv6rpl_setDAOPeriod(uint16_t daoPeriod){ uint32_t daoPeriodRandom; icmpv6rpl_vars.daoPeriod = daoPeriod; daoPeriodRandom = icmpv6rpl_vars.daoPeriod - 0x80 + (openrandom_get16b()&0xff); opentimers_setPeriod( icmpv6rpl_vars.timerIdDAO, TIME_MS, daoPeriodRandom ); }
void task_resNotifSendDone() { OpenQueueEntry_t* msg; // get recently-sent packet from openqueue msg = openqueue_resGetSentPacket(); if (msg==NULL) { // log the error openserial_printError(COMPONENT_RES,ERR_NO_SENT_PACKET, (errorparameter_t)0, (errorparameter_t)0); // abort return; } // declare it as mine msg->owner = COMPONENT_RES; // indicate transmission (to update statistics) if (msg->l2_sendDoneError==E_SUCCESS) { neighbors_indicateTx(&(msg->l2_nextORpreviousHop), msg->l2_numTxAttempts, TRUE, &msg->l2_asn); /* piggy502: only apply Rx mask after a RES packet is sent */ switch(msg->creator){ case COMPONENT_RES: applyRxMask(); break; default: break; } } else { neighbors_indicateTx(&(msg->l2_nextORpreviousHop), msg->l2_numTxAttempts, FALSE, &msg->l2_asn); } // send the packet to where it belongs if (msg->creator == COMPONENT_RES) { // discard (ADV or KA) packets this component has created openqueue_freePacketBuffer(msg); // I can send the next ADV or KA res_vars.busySending = FALSE; // restart a random timer res_vars.periodMaintenance = 1700+(openrandom_get16b()&0xff); opentimers_setPeriod(res_vars.timerId, TIME_MS, res_vars.periodMaintenance); } else { // send the rest up the stack iphc_sendDone(msg,msg->l2_sendDoneError); } }
/** \brief Handler for DIO timer event. \note This function is executed in task context, called by the scheduler. */ void icmpv6rpl_timer_DIO_task() { uint32_t dioPeriod; // send DIO sendDIO(); // arm the DIO timer with this new value dioPeriod = icmpv6rpl_vars.dioPeriod - 0x80 + (openrandom_get16b()&0xff); opentimers_setPeriod( icmpv6rpl_vars.timerIdDIO, TIME_MS, dioPeriod ); }
/** \brief Handler for DAO timer event. \note This function is executed in task context, called by the scheduler. */ void icmpv6rpl_timer_DAO_task() { // update the delayDAO icmpv6rpl_vars.delayDAO = (icmpv6rpl_vars.delayDAO+1)%5; // check whether we need to send DAO if (icmpv6rpl_vars.delayDAO==0) { // send DAO sendDAO(); // pick a new pseudo-random periodDAO icmpv6rpl_vars.periodDAO = TIMER_DAO_TIMEOUT+(openrandom_get16b()&0xff); // arm the DAO timer with this new value opentimers_setPeriod( icmpv6rpl_vars.timerIdDAO, TIME_MS, icmpv6rpl_vars.periodDAO ); } }
void task_sixtopNotifSendDone() { OpenQueueEntry_t* msg; // get recently-sent packet from openqueue msg = openqueue_sixtopGetSentPacket(); if (msg==NULL) { openserial_printCritical( COMPONENT_SIXTOP, ERR_NO_SENT_PACKET, (errorparameter_t)0, (errorparameter_t)0 ); return; } // take ownership msg->owner = COMPONENT_SIXTOP; // update neighbor statistics if (msg->l2_sendDoneError==E_SUCCESS) { neighbors_indicateTx( &(msg->l2_nextORpreviousHop), msg->l2_numTxAttempts, TRUE, &msg->l2_asn ); } else { neighbors_indicateTx( &(msg->l2_nextORpreviousHop), msg->l2_numTxAttempts, FALSE, &msg->l2_asn ); } // send the packet to where it belongs switch (msg->creator) { case COMPONENT_SIXTOP: if (msg->l2_frameType==IEEE154_TYPE_BEACON) { // this is a ADV // not busy sending ADV anymore sixtop_vars.busySendingEB = FALSE; } else { // this is a KA // not busy sending KA anymore sixtop_vars.busySendingKA = FALSE; } // discard packets openqueue_freePacketBuffer(msg); // restart a random timer sixtop_vars.periodMaintenance = 872+(openrandom_get16b()&0xff); opentimers_setPeriod( sixtop_vars.maintenanceTimerId, TIME_MS, sixtop_vars.periodMaintenance ); break; case COMPONENT_SIXTOP_RES: sixtop_six2six_sendDone(msg,msg->l2_sendDoneError); break; default: // send the rest up the stack iphc_sendDone(msg,msg->l2_sendDoneError); break; } }
void sixtop_removeCell(open_addr_t* neighbor){ OpenQueueEntry_t* pkt; bool outcome; uint8_t len; uint8_t type; uint8_t frameID; uint8_t flag; cellInfo_ht cellList[SCHEDULEIEMAXNUMCELLS]; memset(cellList,0,sizeof(cellList)); // filter parameters if (sixtop_vars.six2six_state!=SIX_IDLE){ return; } if (neighbor==NULL){ return; } // generate candidate cell list outcome = sixtop_candidateRemoveCellList( &type, &frameID, &flag, cellList, neighbor ); if(outcome == FALSE){ return; } // get a free packet buffer pkt = openqueue_getFreePacketBuffer(COMPONENT_SIXTOP_RES); if(pkt==NULL) { openserial_printError( COMPONENT_SIXTOP_RES, ERR_NO_FREE_PACKET_BUFFER, (errorparameter_t)0, (errorparameter_t)0 ); return; } // update state sixtop_vars.six2six_state = SIX_SENDING_REMOVEREQUEST; // declare ownership over that packet pkt->creator = COMPONENT_SIXTOP_RES; pkt->owner = COMPONENT_SIXTOP_RES; memcpy( &(pkt->l2_nextORpreviousHop), neighbor, sizeof(open_addr_t) ); // create packet len = 0; len += processIE_prependSheduleIE(pkt,type,frameID, flag,cellList); len += processIE_prependOpcodeIE(pkt,SIXTOP_REMOVE_SOFT_CELL_REQUEST); processIE_prependMLMEIE(pkt,len); // indicate IEs present pkt->l2_IEListPresent = IEEE154_IELIST_YES; // send packet sixtop_send(pkt); // update state sixtop_vars.six2six_state = SIX_WAIT_REMOVEREQUEST_SENDDONE; // arm timeout opentimers_setPeriod( sixtop_vars.timeoutTimerId, TIME_MS, SIX2SIX_TIMEOUT_MS ); opentimers_restart(sixtop_vars.timeoutTimerId); }