/** * \brief This function initiates packet streaming test. * \param gap_time Gap to be provided between consecutive frames * in terms of milliseconds * \timeout : This parameter is used by the receptor node to * timeout/stop the packet streaming * \param frame_len Length of the Data frame to be streamed */ void pktstream_test(uint16_t gap_time,uint16_t timeout,bool start_stop,uint16_t frame_len) { pkt_stream_gap_time = gap_time; /*Return if the frame length is less than 127(Max MPDU Length)*/ if(frame_len<=127) { usr_pkt_stream_confirm(MAC_SUCCESS,start_stop); } else { usr_pkt_stream_confirm(INVALID_ARGUMENT,start_stop); } /* Send the Packet Stream Start Confirm in case of Receptor before beginning * packet streaming.Serial Handler will take care in sending the confirmation * over the air to the Host*/ if((node_info.main_state == PER_TEST_RECEPTOR)) { serial_data_handler(); } if(start_stop) { /*Configure the frame for streaming*/ configure_pkt_stream_frames(frame_len); op_mode=PKT_STREAM_MODE; /*Start the gap timer*/ if(pkt_stream_gap_time) { sw_timer_start(T_APP_TIMER,pkt_stream_gap_time*1E3,SW_TIMEOUT_RELATIVE,(FUNC_PTR)pkt_stream_gap_timer,NULL); } else { rdy_to_tx = true; } pkt_stream_stop = false; if((node_info.main_state == PER_TEST_RECEPTOR) && 1 <= timeout ) { sw_timer_start(CW_TX_TIMER, (uint32_t)timeout * 1E6, SW_TIMEOUT_RELATIVE, (FUNC_PTR)stop_pkt_streaming, NULL); } } else { /*stop packet streaming once the current packet transmission is completed*/ pkt_stream_stop = true; sw_timer_stop(T_APP_TIMER); op_mode=TX_OP_MODE; } }
/*! \brief Main function. */ int main(void) { irq_initialize_vectors(); #if SAMD20 system_init(); delay_init(); #else sysclk_init(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); #endif sw_timer_init(); serial_interface_init(); if (MAC_SUCCESS != wpan_init()) { app_alert(); } LED_On(LED_POWER); cpu_irq_enable(); while (1) { wpan_task(); serial_data_handler(); } }
/** * \brief Main function of the Performance Analyzer application * \ingroup group_app_init */ int main(void) { irq_initialize_vectors(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); sysclk_init(); /* * Power ON - so set the board to INIT state. All hardware, PAL, TAL and * stack level initialization must be done using this function */ set_main_state(INIT, NULL); cpu_irq_enable(); sio2host_init(); /* INIT was a success - so change to WAIT_FOR_EVENT state */ set_main_state(WAIT_FOR_EVENT, NULL); /* Endless while loop */ while (1) { pal_task(); /* Handle platform specific tasks, like serial interface */ tal_task(); /* Handle transceiver specific tasks */ app_task(); /* Application task */ serial_data_handler(); } }
/** * Main function, initialization and main message loop * * @return error code */ int main(void) { irq_initialize_vectors(); #if SAMD21 || SAMD20 || SAMR21 system_init(); delay_init(); #else sysclk_init(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); #endif sw_timer_init(); if (nwk_init() != NWK_SUCCESS) { app_alert(); } stack_indication_callback_init(); #ifdef FLASH_NVRAM pal_ps_set(EE_IEEE_ADDR, 8, &tal_pib.IeeeAddress); #endif /* Initialize LEDs */ /* pal_led_init(); */ cpu_irq_enable(); /* * The global interrupt has to be enabled here as TAL uses the timer * delay which in turn requires interrupt to be enabled */ /* pal_global_irq_enable(); */ serial_interface_init(); /* Loop forever, the interrupts are doing the rest */ while (1) { nwk_task(); serial_data_handler(); } /* No return statement here, because this code is unreachable */ }
/** * Main function, initialization and main message loop * * @return error code */ int main (void) { irq_initialize_vectors(); /* Initialize the board. * The board-specific conf_board.h file contains the configuration of * the board initialization. */ board_init(); sysclk_init(); sw_timer_init(); if (nwk_init() != NWK_SUCCESS) { app_alert(); } zid_indication_callback_init(); cpu_irq_enable(); /* * The global interrupt has to be enabled here as TAL uses the timer * delay which in turn requires interrupt to be enabled */ serial_interface_init(); /* Loop forever, the interrupts are doing the rest */ while (1) { nwk_task(); serial_data_handler(); } /* No return statement here, because this code is unreachable */ }
int main(int argc, char *argv[]) { node_id_restore(); /* init system: clocks, board etc */ system_init(); sio2host_init(); leds_init(); leds_on(LEDS_ALL); system_interrupt_enable_global(); flash_init(); delay_init(); /* Initialize Contiki and our processes. */ #ifdef LOW_POWER_MODE configure_tc3(); #else clock_init(); #endif process_init(); ctimer_init(); rtimer_init(); process_start(&etimer_process, NULL); /* Set MAC address and node ID */ #ifdef NODEID node_id = NODEID; #ifdef BURN_NODEID node_id_burn(node_id); #endif /* BURN_NODEID */ #else/* NODE_ID */ #endif /* NODE_ID */ printf("\r\n\n\n\n Starting the SmartConnect-6LoWPAN \r\n Platform : Atmel IoT device \r\n"); print_reset_causes(); netstack_init(); #if BOARD == SAMR21_XPLAINED_PRO eui64 = edbg_eui_read_eui64(); SetIEEEAddr(eui64); #else SetIEEEAddr(node_mac); #endif set_link_addr(); rf_set_channel(RF_CHANNEL); printf("\r\n Configured RF channel: %d\r\n", rf_get_channel()); leds_off(LEDS_ALL); process_start(&sensors_process, NULL); energest_init(); ENERGEST_ON(ENERGEST_TYPE_CPU); if(node_id > 0) { printf(" Node id %u.\r\n", node_id); } else { printf(" Node id not set.\r\n"); } /* Setup nullmac-like MAC for 802.15.4 */ #if SAMD memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr)); #else memcpy(&uip_lladdr.addr, eui64, sizeof(uip_lladdr.addr)); #endif queuebuf_init(); printf(" %s %lu %d\r\n", NETSTACK_RDC.name, (uint32_t) (CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: NETSTACK_RDC.channel_check_interval())), RF_CHANNEL); process_start(&tcpip_process, NULL); printf(" IPv6 Address: "); { uip_ds6_addr_t *lladdr; int i; lladdr = uip_ds6_get_link_local(-1); for(i = 0; i < 7; ++i) { printf("%02x%02x:", lladdr->ipaddr.u8[i * 2], lladdr->ipaddr.u8[i * 2 + 1]); } printf("%02x%02x\r\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); } { uip_ipaddr_t ipaddr; int i; uip_ip6addr(&ipaddr, 0xfc00, 0, 0, 0, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); printf("Tentative global IPv6 address "); for(i = 0; i < 7; ++i) { printf("%02x%02x:", ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]); } printf("%02x%02x\r\n", ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); } print_processes(autostart_processes); /* set up AES key */ #if ((THSQ_CONF_NETSTACK) & THSQ_CONF_AES) #ifndef NETSTACK_AES_KEY #error Please define NETSTACK_AES_KEY! #endif /* NETSTACK_AES_KEY */ { const uint8_t key[] = NETSTACK_AES_KEY; netstack_aes_set_key(key); } printf("AES encryption is enabled\n"); #else /* ((THSQ_CONF_NETSTACK) & THSQ_CONF_AES) */ printf("\r\n Warning: AES encryption is disabled\n"); #endif /* ((THSQ_CONF_NETSTACK) & THSQ_CONF_AES) */ #ifdef ENABLE_LEDCTRL ledctrl_init(); #endif autostart_start(autostart_processes); while(1){ int r = 0; serial_data_handler(); do { r = process_run(); } while(r > 0); } }