static void appDataConf(NWK_DataReq_t *req) { LED_Off(LED_DATA); if (NWK_SUCCESS_STATUS == req->status) { if (!appNetworkStatus) { LED_On(LED_NETWORK); SYS_TimerStop(&appNetworkStatusTimer); appNetworkStatus = true; } } else { if (appNetworkStatus) { LED_Off(LED_NETWORK); SYS_TimerStart(&appNetworkStatusTimer); appNetworkStatus = false; } } appState = APP_STATE_SENDING_DONE; }
static void appSendData(void) { #ifdef NWK_ENABLE_ROUTING appMsg.parentShortAddr = NWK_RouteNextHop(0, 0); #else appMsg.parentShortAddr = 0; #endif appMsg.sensors.battery = rand() & 0xffff; appMsg.sensors.temperature = rand() & 0x7f; appMsg.sensors.light = rand() & 0xff; #if APP_COORDINATOR appSendMessage((uint8_t *)&appMsg, sizeof(appMsg)); SYS_TimerStart(&appDataSendingTimer); appState = APP_STATE_WAIT_SEND_TIMER; #else nwkDataReq.dstAddr = 0; nwkDataReq.dstEndpoint = APP_ENDPOINT; nwkDataReq.srcEndpoint = APP_ENDPOINT; nwkDataReq.options = NWK_OPT_ACK_REQUEST | NWK_OPT_ENABLE_SECURITY; nwkDataReq.data = (uint8_t *)&appMsg; nwkDataReq.size = sizeof(appMsg); nwkDataReq.confirm = appDataConf; LED_On(LED_DATA); NWK_DataReq(&nwkDataReq); appState = APP_STATE_WAIT_CONF; #endif }
/*************************************************************************//** *****************************************************************************/ static void nwkRouteDiscoveryTimerHandler(SYS_Timer_t *timer) { NwkRouteDiscoveryTableEntry_t *entry; bool restart = false; for (uint8_t i = 0; i < NWK_ROUTE_DISCOVERY_TABLE_SIZE; i++) { entry = &nwkRouteDiscoveryTable[i]; if (entry->timeout > NWK_ROUTE_DISCOVERY_TIMER_INTERVAL) { entry->timeout -= NWK_ROUTE_DISCOVERY_TIMER_INTERVAL; restart = true; } else { entry->timeout = 0; if (entry->srcAddr == nwkIb.addr) nwkRouteDiscoveryDone(entry, entry->reverseLinkQuality > 0); } } if (restart) SYS_TimerStart(timer); }
void startTimeoutTimer() { timeoutTimer.interval = 250; timeoutTimer.mode = SYS_TIMER_INTERVAL_MODE; timeoutTimer.handler = timeoutTimerHandler; SYS_TimerStart(&timeoutTimer); }
/*************************************************************************//** *****************************************************************************/ static bool otaHandleBlockResp(NWK_DataInd_t *ind) { OtaBlockRespCommand_t *resp = (OtaBlockRespCommand_t *)ind->data; if (ind->size != sizeof(OtaBlockRespCommand_t)) return false; if (OTA_SERVER_STATE_WAIT_BLOCK_RESP != otaServer.state || otaServer.sessionId != resp->sessionId) return true; otaServer.retries = OTA_MAX_RETRIES; SYS_TimerStop(&otaResponseTimer); if (OTA_SUCCESS_STATUS == resp->status) { otaServer.state = OTA_SERVER_STATE_WAIT_FRAME_SPACING; SYS_TimerStart(&otaFrameSpacingTimer); } else { otaServer.state = OTA_SERVER_STATE_IDLE; OTA_ServerNotification((OTA_Status_t)resp->status); } return true; }
/*************************************************************************//** *****************************************************************************/ static void appInit(void) { appMsg.messageType = 1; appMsg.nodeType = APP_NODE_TYPE; appMsg.extAddr = APP_ADDR; appMsg.shortAddr = APP_ADDR; appMsg.softVersion = 0x01010100; appMsg.channelMask = (1L << APP_CHANNEL); appMsg.panId = APP_PANID; appMsg.workingChannel = APP_CHANNEL; appMsg.parentShortAddr = 0; appMsg.lqi = 0; appMsg.rssi = 0; appMsg.sensors.type = 1; appMsg.sensors.size = sizeof(int32_t) * 3; appMsg.sensors.battery = 0; appMsg.sensors.temperature = 0; appMsg.sensors.light = 0; appMsg.caption.type = 32; appMsg.caption.size = APP_CAPTION_SIZE; memcpy(appMsg.caption.text, APP_CAPTION, APP_CAPTION_SIZE); NWK_SetAddr(APP_ADDR); NWK_SetPanId(APP_PANID); PHY_SetChannel(APP_CHANNEL); #if (defined(PHY_AT86RF212B) || defined(PHY_AT86RF212)) PHY_SetBand(APP_BAND); PHY_SetModulation(APP_MODULATION); #endif PHY_SetRxState(true); #ifdef NWK_ENABLE_SECURITY NWK_SetSecurityKey((uint8_t *)APP_SECURITY_KEY); #endif NWK_OpenEndpoint(APP_ENDPOINT, appDataInd); appDataSendingTimer.interval = APP_SENDING_INTERVAL; appDataSendingTimer.mode = SYS_TIMER_INTERVAL_MODE; appDataSendingTimer.handler = appDataSendingTimerHandler; #if APP_ROUTER || APP_ENDDEVICE appNetworkStatus = false; appNetworkStatusTimer.interval = 500; appNetworkStatusTimer.mode = SYS_TIMER_PERIODIC_MODE; appNetworkStatusTimer.handler = appNetworkStatusTimerHandler; SYS_TimerStart(&appNetworkStatusTimer); #else LED_On(LED_NETWORK); #endif #ifdef PHY_ENABLE_RANDOM_NUMBER_GENERATOR srand(PHY_RandomReq()); #endif appState = APP_STATE_SEND; }
static void APP_TaskHandler(void) { switch (appState) { case APP_STATE_INITIAL: { appInit(); } break; case APP_STATE_SEND: { appSendData(); } break; case APP_STATE_SENDING_DONE: { #if APP_ENDDEVICE appState = APP_STATE_PREPARE_TO_SLEEP; #else SYS_TimerStart(&appDataSendingTimer); appState = APP_STATE_WAIT_SEND_TIMER; #endif } break; case APP_STATE_PREPARE_TO_SLEEP: { if (!NWK_Busy()) { NWK_SleepReq(); appState = APP_STATE_SLEEP; } } break; case APP_STATE_SLEEP: { ledsClose(); PHY_SetRxState(false); HAL_Sleep(APP_SENDING_INTERVAL); appState = APP_STATE_WAKEUP; } break; case APP_STATE_WAKEUP: { NWK_WakeupReq(); ledsInit(); ledOn(LED_NETWORK); PHY_SetRxState(true); appState = APP_STATE_SEND; } break; default: break; } }
static void appDataSendingTimerHandler(SYS_Timer_t *timer) { if (APP_STATE_WAIT_SEND_TIMER == appState) appState = APP_STATE_SEND; else SYS_TimerStart(&appDataSendingTimer); (void)timer; }
/*************************************************************************//** *****************************************************************************/ static bool nwkRxRejectDuplicate(NwkFrameHeader_t *header) { NwkDuplicateRejectionEntry_t *entry; NwkDuplicateRejectionEntry_t *freeEntry = NULL; for (uint8_t i = 0; i < NWK_DUPLICATE_REJECTION_TABLE_SIZE; i++) { entry = &nwkRxDuplicateRejectionTable[i]; if (entry->ttl && header->nwkSrcAddr == entry->src) { uint8_t diff = (int8_t)entry->seq - header->nwkSeq; if (diff < 8) { if (entry->mask & (1 << diff)) { #ifdef NWK_ENABLE_ROUTING if (nwkIb.addr == header->macDstAddr) nwkRouteRemove(header->nwkDstAddr, header->nwkFcf.multicast); #endif return true; } entry->mask |= (1 << diff); return false; } else { uint8_t shift = -(int8_t)diff; entry->seq = header->nwkSeq; entry->mask = (entry->mask << shift) | 1; entry->ttl = DUPLICATE_REJECTION_TTL; return false; } } if (0 == entry->ttl) freeEntry = entry; } if (NULL == freeEntry) return true; freeEntry->src = header->nwkSrcAddr; freeEntry->seq = header->nwkSeq; freeEntry->mask = 1; freeEntry->ttl = DUPLICATE_REJECTION_TTL; SYS_TimerStart(&nwkRxDuplicateRejectionTimer); return false; }
/*************************************************************************//** *****************************************************************************/ static void otaDataConf(NWK_DataReq_t *req) { if (NWK_SUCCESS_STATUS == req->status) { otaServer.state |= OTA_SERVER_STATE_WAIT_RESP_MASK; SYS_TimerStart(&otaResponseTimer); } else { otaRequestRetry(); } }
/*************************************************************************//** *****************************************************************************/ static bool appCmdHandle(uint8_t *data, uint8_t size) { AppCmdHeader_t *header = (AppCmdHeader_t *)data; if (size < sizeof(AppCmdHeader_t)) { return false; } if (APP_COMMAND_ID_IDENTIFY == header->id) { AppCmdIdentify_t *req = (AppCmdIdentify_t *)data; if (sizeof(AppCmdIdentify_t) != size) { return false; } SYS_TimerStop(&appCmdIdentifyDurationTimer); SYS_TimerStop(&appCmdIdentifyPeriodTimer); appCmdIdentifyDurationTimer.interval = req->duration; appCmdIdentifyDurationTimer.mode = SYS_TIMER_INTERVAL_MODE; appCmdIdentifyDurationTimer.handler = appCmdIdentifyDurationTimerHandler; SYS_TimerStart(&appCmdIdentifyDurationTimer); appCmdIdentifyPeriodTimer.interval = req->period; appCmdIdentifyPeriodTimer.mode = SYS_TIMER_PERIODIC_MODE; appCmdIdentifyPeriodTimer.handler = appCmdIdentifyPeriodTimerHandler; SYS_TimerStart(&appCmdIdentifyPeriodTimer); #if (LED_COUNT > 0) LED_On(LED_IDENTIFY); #endif NWK_Lock(); return true; } return false; }
void HalRgbLed::blinkColor(short red, short green, short blue, unsigned int ms, bool continuous) { if (!isEnabled()) { return; } if (continuous) { blinkTimer.mode = SYS_TIMER_PERIODIC_MODE; } else { blinkTimer.mode = SYS_TIMER_INTERVAL_MODE; } blinkTimer.interval = ms; setBlinkValues(red, green, blue); setColor(red, green, blue); SYS_TimerStart(&blinkTimer); }
void TIME_Init() { RTC_Init(); timeSyncState = TIME_SYNC_WAITING_NEXT_LOOP; timeSyncCounter = 2; currentNeighborAddress = 0; timeSyncRequest.header.opCode = DateTimeRead; //Configure Timer timeSyncTimer.interval = 1000; timeSyncTimer.mode = SYS_TIMER_PERIODIC_MODE; timeSyncTimer.handler = timeSyncTimerHandler; SYS_TimerStart(&timeSyncTimer); }
void HAL_UartBytesReceived(uint16_t bytes){ for (uint16_t i = 0; i < bytes; i++){ uint8_t byte = uartGetc(); if (appUartBufferPtr == sizeof(appUartBuffer)) appSendData(); if (appUartBufferPtr < sizeof(appUartBuffer)) appUartBuffer[appUartBufferPtr++] = byte; } SYS_TimerStop(&appTimer); SYS_TimerStart(&appTimer); }
/*************************************************************************//** *****************************************************************************/ static void nwkRxDuplicateRejectionTimerHandler(SYS_Timer_t *timer) { bool restart = false; for (uint8_t i = 0; i < NWK_DUPLICATE_REJECTION_TABLE_SIZE; i++) { if (nwkRxDuplicateRejectionTable[i].ttl) { nwkRxDuplicateRejectionTable[i].ttl--; restart = true; } } if (restart) SYS_TimerStart(timer); }
static void unitDataReq(void) { NWK_DataReq_t nwkDataReq; uint8_t appMsg[10] = "UnitTest\n\r"; nwkDataReq.dstAddr = 0; nwkDataReq.dstEndpoint = APP_ENDPOINT; nwkDataReq.srcEndpoint = APP_ENDPOINT; nwkDataReq.data = (uint8_t *)&appMsg; nwkDataReq.size = sizeof(appMsg); nwkDataReq.confirm = unitDataConf; NWK_DataReq(&nwkDataReq); NetworkStatusTimer.interval = 2000; NetworkStatusTimer.mode = SYS_TIMER_PERIODIC_MODE; NetworkStatusTimer.handler = NetworkStatusTimerHandler; SYS_TimerStart(&NetworkStatusTimer); }
void presenceModule_Init(void) { PRESENCE_CONFIG_t* configPtr; uint8_t* portPtr; uint8_t mask; //Set responses opCodes presenceResponse.header.opCode = PresenceReadResponse; //EEPROM config loading if(!validConfiguration) return; num_of_presen_elems = runningConfiguration.raw[runningConfiguration.topConfiguration.dinamicIndex.configModule_Presence]; //First byte is number of configs configPtr = &runningConfiguration.raw[runningConfiguration.topConfiguration.dinamicIndex.configModule_Presence + 1]; //At second byte the list start if(num_of_presen_elems > MAX_PRESENCE_DEVICES) { //TODO: SEND ERROR (MAX NUMBER OF PRESEN DEVICES EXCEEDED) num_of_presen_elems = MAX_PRESENCE_DEVICES; } for(uint8_t i = 0; i < num_of_presen_elems; i++) { portPtr = PORT_FROM_PINADDRESS(configPtr->pinAddress); mask = MASK_FROM_PINADDRESS(configPtr->pinAddress); HAL_GPIO_PORT_in(portPtr, mask); presen_elems[i].config = configPtr; presen_elems[i].portPtr = portPtr; presen_elems[i].mask = mask; presen_elems[i].timeCounter = 0; configPtr++; } if(num_of_presen_elems > 0) { //Configure Timer presenceReadTimer.interval = 500; presenceReadTimer.mode = SYS_TIMER_PERIODIC_MODE; presenceReadTimer.handler = presenceReadTimerHandler; SYS_TimerStart(&presenceReadTimer); } }
static void nwkTxAckWaitTimerHandler(SYS_Timer_t *timer) { if (0 == nwkTxActiveFrames) return; for (int i = 0; i < NWK_BUFFERS_AMOUNT; i++) { NwkFrame_t *frame = nwkFrameByIndex(i); if (NWK_TX_STATE_WAIT_ACK == frame->state && 0 == --frame->tx.timeout) { frame->state = NWK_TX_STATE_CONFIRM; frame->tx.status = NWK_NO_ACK_STATUS; } } SYS_TimerStart(timer); }
/*************************************************************************//** *****************************************************************************/ static void nwkTxDelayTimerHandler(SYS_Timer_t *timer) { NwkFrame_t *frame = NULL; bool restart = false; while (NULL != (frame = nwkFrameNext(frame))) { if (NWK_TX_STATE_WAIT_DELAY == frame->state) { restart = true; if (0 == --frame->tx.timeout) { frame->state = NWK_TX_STATE_SEND; } } } if (restart) { SYS_TimerStart(timer); } }
/*************************************************************************//** *****************************************************************************/ static void nwkTxAckWaitTimerHandler(SYS_Timer_t *timer) { NwkFrame_t *frame = NULL; bool restart = false; while (NULL != (frame = nwkFrameNext(frame))) { if (NWK_TX_STATE_WAIT_ACK == frame->state) { restart = true; if (0 == --frame->tx.timeout) { nwkTxConfirm(frame, NWK_NO_ACK_STATUS); } } } if (restart) { SYS_TimerStart(timer); } }
/*************************************************************************//** *****************************************************************************/ static NwkRouteDiscoveryTableEntry_t *nwkRouteDiscoveryNewEntry(void) { NwkRouteDiscoveryTableEntry_t *entry = NULL; for (uint8_t i = 0; i < NWK_ROUTE_DISCOVERY_TABLE_SIZE; i++) { if (0 == nwkRouteDiscoveryTable[i].timeout) { entry = &nwkRouteDiscoveryTable[i]; break; } } if (entry) { entry->forwardLinkQuality = NWK_ROUTE_DISCOVERY_NO_LINK; entry->reverseLinkQuality = NWK_ROUTE_DISCOVERY_NO_LINK; entry->timeout = NWK_ROUTE_DISCOVERY_TIMEOUT; SYS_TimerStart(&nwkRouteDiscoveryTimer); } return entry; }
static void appInit(void) { msg.messageType = 1; msg.nodeType = APP_NODE_TYPE; msg.extAddr = APP_ADDR; msg.shortAddr = APP_ADDR; msg.softVersion = 0x01010100; msg.channelMask = (1L << APP_CHANNEL); msg.panId = APP_PANID; msg.workingChannel = APP_CHANNEL; msg.parentShortAddr = 0; msg.lqi = 0; msg.rssi = 0; msg.sensors.type = 1; msg.sensors.size = sizeof(int32_t) * 3; msg.sensors.battery = 0; msg.sensors.temperature = 0; msg.sensors.light = 0; msg.caption.type = 32; msg.caption.size = APP_CAPTION_SIZE; memcpy(msg.caption.text, APP_CAPTION, APP_CAPTION_SIZE); #if APP_COORDINATOR // Enable RCB_BB RS232 level converter #if defined(PLATFORM_RCB128RFA1) DDRD = (1 << 4) | (1 << 6) | (1 << 7); PORTD = (0 << 4) | (1 << 6) | (1 << 7); #endif #if defined(PLATFORM_RCB231) DDRC = (1 << 4) | (1 << 6) | (1 << 7); PORTC = (0 << 4) | (1 << 6) | (1 << 7); #endif #endif ledsInit(); NWK_SetAddr(APP_ADDR); NWK_SetPanId(APP_PANID); PHY_SetChannel(APP_CHANNEL); PHY_SetRxState(true); #ifdef NWK_ENABLE_SECURITY NWK_SetSecurityKey((uint8_t *)APP_SECURITY_KEY); #endif NWK_OpenEndpoint(APP_ENDPOINT, appDataInd); appDataSendingTimer.interval = APP_SENDING_INTERVAL; appDataSendingTimer.mode = SYS_TIMER_INTERVAL_MODE; appDataSendingTimer.handler = appDataSendingTimerHandler; #if APP_ROUTER || APP_ENDDEVICE appNetworkStatus = false; appNetworkStatusTimer.interval = 500; appNetworkStatusTimer.mode = SYS_TIMER_PERIODIC_MODE; appNetworkStatusTimer.handler = appNetworkStatusTimerHandler; SYS_TimerStart(&appNetworkStatusTimer); #else ledOn(LED_NETWORK); #endif #ifdef PHY_ENABLE_RANDOM_NUMBER_GENERATOR PHY_RandomReq(); #endif appState = APP_STATE_SEND; }
void nwkTxTaskHandler(void) { if (0 == nwkTxActiveFrames) return; for (int i = 0; i < NWK_BUFFERS_AMOUNT; i++) { NwkFrame_t *frame = nwkFrameByIndex(i); switch (frame->state) { #ifdef NWK_ENABLE_SECURITY case NWK_TX_STATE_ENCRYPT: { nwkSecurityProcess(frame, true); } break; #endif case NWK_TX_STATE_SEND: { if (!PHY_Busy()) { nwkTxPhyActiveFrame = frame; frame->state = NWK_TX_STATE_WAIT_CONF; PHY_DataReq((uint8_t *)&frame->data, frame->size); } } break; case NWK_TX_STATE_WAIT_CONF: break; case NWK_TX_STATE_SENT: { if (NWK_SUCCESS_STATUS == frame->tx.status) { if (frame->data.header.nwkSrcAddr == nwkIb.addr && frame->data.header.nwkFcf.ackRequest) { frame->state = NWK_TX_STATE_WAIT_ACK; frame->tx.timeout = NWK_ACK_WAIT_TIME / NWK_TX_ACK_WAIT_TIMER_INTERVAL + 1; SYS_TimerStart(&nwkTxAckWaitTimer); } else { frame->state = NWK_TX_STATE_CONFIRM; } } else { frame->state = NWK_TX_STATE_CONFIRM; } } break; case NWK_TX_STATE_WAIT_ACK: break; case NWK_TX_STATE_CONFIRM: { #ifdef NWK_ENABLE_ROUTING nwkRouteFrameSent(frame); #endif frame->tx.confirm(frame); --nwkTxActiveFrames; } break; default: break; }; } }
void dimmerModule_Init() { DIMMER_CONFIG_t* configPtr; uint8_t* portPtr; uint8_t mask; uint8_t zeroCrossPin; //Set responses opCodes dimmerResponse.header.opCode = DimmerReadResponse; waitingForResponseConf = false; //EEPROM config loading if(!validConfiguration) return; num_of_dimmer_elems = runningConfiguration.raw[runningConfiguration.topConfiguration.dinamicIndex.configModule_Dimmable]; //First byte is number of configs zeroCrossPin = runningConfiguration.raw[runningConfiguration.topConfiguration.dinamicIndex.configModule_Dimmable + 1]; //Second byte is the Zero Cross pin configPtr = &runningConfiguration.raw[runningConfiguration.topConfiguration.dinamicIndex.configModule_Dimmable + 2]; //At third byte the list start if(num_of_dimmer_elems > MAX_DIMMER_DEVICES) { //TODO: SEND ERROR (MAX NUMBER OF DEVICES EXCEEDED) num_of_dimmer_elems = MAX_DIMMER_DEVICES; } zeroCrossPin = BASE_PinAddressToINT(zeroCrossPin); if(zeroCrossPin == 0xFF) { //TODO: SEND ERROR (INVALID ZEROCROSS PINPORT ADDRESS) return; } for(uint8_t i = 0; i<num_of_dimmer_elems; i++) { portPtr = PORT_FROM_PINADDRESS(configPtr->pinAddress); mask = MASK_FROM_PINADDRESS(configPtr->pinAddress); HAL_GPIO_PORT_out(portPtr, mask); HAL_GPIO_PORT_clr(portPtr, mask); // Off at startup dimmer_elems[i].config = configPtr; dimmer_elems[i].portPtr = portPtr; dimmer_elems[i].mask = mask; dimmer_elems[i].currentValue = 0; dimmer_elems[i].timerValue = 0; configPtr++; } if(num_of_dimmer_elems > 0) { //Configure System Timer timerDivider = 0; dimmerTimer.interval = 50; // 20 times per second dimmerTimer.mode = SYS_TIMER_PERIODIC_MODE; dimmerTimer.handler = dimmerTimerHandler; SYS_TimerStart(&dimmerTimer); //Initialize TIMER5 in normal mode OCR5A = OVR_COUNTER; // For elem 0 & 3 OCR5B = OVR_COUNTER; // For elem 1 & 4 OCR5C = OVR_COUNTER; // For elem 2 & 5 TIMSK5 |= (1 << TOIE5); // Enable overflow interrupt //Initialize zero crossing interrupt INTERRUPT_Attach(zeroCrossPin, dimmerZeroCrossInterrupt, RISING); } }
/*************************************************************************//** *****************************************************************************/ static void APP_TaskHandler(void) { switch (appState) { case APP_STATE_INITIAL: { appInit(); } break; case APP_STATE_SEND: { appSendData(); } break; case APP_STATE_SENDING_DONE: { #if APP_ENDDEVICE appState = APP_STATE_PREPARE_TO_SLEEP; #else SYS_TimerStart(&appDataSendingTimer); appState = APP_STATE_WAIT_SEND_TIMER; #endif } break; case APP_STATE_PREPARE_TO_SLEEP: { if (!NWK_Busy()) { NWK_SleepReq(); appState = APP_STATE_SLEEP; } } break; case APP_STATE_SLEEP: { sm_sleep(APP_SENDING_INTERVAL/1000); appState = APP_STATE_WAKEUP; } break; case APP_STATE_WAKEUP: { NWK_WakeupReq(); LED_On(LED_NETWORK); appState = APP_STATE_SEND; } break; default: break; } #if APP_COORDINATOR if(sio2host_rx(rx_data,APP_RX_BUF_SIZE) > 0) { LED_Toggle(LED_BLINK); } #endif }
void PinoccioScout::startAnalogStateChangeEvents() { SYS_TimerStart(&analogStateChangeTimer); }
void PinoccioScout::startPeripheralStateChangeEvents() { SYS_TimerStart(&peripheralStateChangeTimer); }
/*************************************************************************//** * @brief Tx Module task handler *****************************************************************************/ void nwkTxTaskHandler(void) { NwkFrame_t *frame = NULL; while (NULL != (frame = nwkFrameNext(frame))) { switch (frame->state) { #ifdef NWK_ENABLE_SECURITY case NWK_TX_STATE_ENCRYPT: { nwkSecurityProcess(frame, true); } break; #endif case NWK_TX_STATE_DELAY: { if (frame->tx.timeout > 0) { frame->state = NWK_TX_STATE_WAIT_DELAY; SYS_TimerStart(&nwkTxDelayTimer); } else { frame->state = NWK_TX_STATE_SEND; } } break; case NWK_TX_STATE_SEND: { if (NULL == nwkTxPhyActiveFrame) { nwkTxPhyActiveFrame = frame; frame->state = NWK_TX_STATE_WAIT_CONF; PHY_DataReq(&(frame->size)); nwkIb.lock++; } } break; case NWK_TX_STATE_WAIT_CONF: break; case NWK_TX_STATE_SENT: { if (NWK_SUCCESS_STATUS == frame->tx.status) { if (frame->header.nwkSrcAddr == nwkIb.addr && frame->header.nwkFcf. ackRequest) { frame->state = NWK_TX_STATE_WAIT_ACK; frame->tx.timeout = NWK_ACK_WAIT_TIME / NWK_TX_ACK_WAIT_TIMER_INTERVAL + 1; SYS_TimerStart(&nwkTxAckWaitTimer); } else { frame->state = NWK_TX_STATE_CONFIRM; } } else { frame->state = NWK_TX_STATE_CONFIRM; } } break; case NWK_TX_STATE_WAIT_ACK: break; case NWK_TX_STATE_CONFIRM: { #ifdef NWK_ENABLE_ROUTING nwkRouteFrameSent(frame); #endif if (NULL == frame->tx.confirm) { nwkFrameFree(frame); } else { frame->tx.confirm(frame); } } break; default: break; } } }
void PinoccioScout::startDigitalStateChangeEvents() { SYS_TimerStart(&digitalStateChangeTimer); }