这篇教程C++ tcpip_handler函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tcpip_handler函数的典型用法代码示例。如果您正苦于以下问题:C++ tcpip_handler函数的具体用法?C++ tcpip_handler怎么用?C++ tcpip_handler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tcpip_handler函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){#if UIP_CONF_ROUTER uip_ipaddr_t ipaddr;#endif /* UIP_CONF_ROUTER */ PROCESS_BEGIN(); PRINTF("UDP server started/n");#if UIP_CONF_ROUTER uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);#endif /* UIP_CONF_ROUTER */ print_local_addresses(); server_conn = udp_new(NULL, UIP_HTONS(3001), NULL); udp_bind(server_conn, UIP_HTONS(3000)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:13416795,项目名称:contiki,代码行数:30,
示例2: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){ PROCESS_BEGIN(); PRINTF("UDP server started/n");#if UIP_CONF_ROUTER uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); uip_netif_addr_add(&ipaddr, 64, 0, AUTOCONF);#endif /* UIP_CONF_ROUTER */ print_local_addresses(); server_conn = udp_new(NULL, HTONS(61617), NULL); udp_bind(server_conn, HTONS(61616)); PRINTF("Created a server connection with remote address "); PRINT6ADDR(&server_conn->ripaddr); PRINTF("local/remote port %u/%u/n", HTONS(server_conn->lport), HTONS(server_conn->rport)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:mlwymore,项目名称:contiki,代码行数:31,
示例3: PROCESS_THREADPROCESS_THREAD(udp_plug_process, ev, data){ static struct etimer et; PROCESS_BEGIN(); PRINTF("UDP server started/r/n"); #if DEV_BOARD leds_on(LEDS_RED | LEDS_GREEN); SENSORS_ACTIVATE(button_sensor);#else leds_on(LEDS_GREEN); #ifdef HAS_PIR_SENSOR pir_state = PIR_DISPATCH; etimer_set(&pir_timer, PIR_INIT_TIME); #endif#endif#if HAS_TEMP_SENSOR start_temp_conv();#endif#if HAS_LIGHT_SENSOR light_sensor_init();#endif udp_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(udp_conn, UIP_HTONS(PLUG_PORT)); PRINTF("listening on udp port %u/r/n",UIP_HTONS(udp_conn->lport)); etimer_set(&et, SEND_INTERVAL); while(1) { PROCESS_YIELD(); if(etimer_expired(&et)) { timeout_handler(); etimer_restart(&et); }#ifdef HAS_PIR_SENSOR if((pir_state == PIR_DISPATCH)&&(etimer_expired(&pir_timer))) { SENSORS_ACTIVATE(button_sensor); pir_state = PIR_READY; }#endif if(ev == tcpip_event) { PRINTF("Calling tcpip_Handler/r/n"); tcpip_handler(); } if (ev == sensors_event && data == &button_sensor) {#ifndef DEV_BOARD handle_pir_event();#endif PRINTF("Button Pressed/r/n"); } } PROCESS_END();}
开发者ID:bearxiong99,项目名称:tdma_demo,代码行数:60,
示例4: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(mcast_sink_process, ev, data){ PROCESS_BEGIN(); PRINTF("Multicast Engine: '%s'/n", UIP_MCAST6.name); if(join_mcast_group() == NULL) { PRINTF("Failed to join multicast group/n"); PROCESS_EXIT(); } count = 0; sink_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(sink_conn, UIP_HTONS(MCAST_SINK_UDP_PORT)); PRINTF("Listening: "); PRINT6ADDR(&sink_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(sink_conn->lport), UIP_HTONS(sink_conn->rport)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:PureEngineering,项目名称:contiki,代码行数:31,
示例5: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ PROCESS_BEGIN(); PROCESS_PAUSE(); set_global_address(); PRINTF("UDP client process started/n"); print_local_addresses(); /* new connection with remote host */ client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:Asterios,项目名称:contiki-econotag,代码行数:31,
示例6: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer et; uip_ipaddr_t ipaddr; PROCESS_BEGIN(); /* NOTE: Use IPv6 address of server here. */ uip_ip6addr(&ipaddr, 0xfe80, 0x0000, 0x0000, 0x0000, 0x48ad, 0x5dff, 0xfe71, 0x5d9d); /* new connection with remote host */ client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); udp_bind(client_conn, UIP_HTONS(3034)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&et, SEND_INTERVAL); while (1) { PROCESS_YIELD(); if (etimer_expired(&et)) { timeout_handler(); etimer_restart(&et); } else if (ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:ibr-cm,项目名称:contiki-inga,代码行数:34,
示例7: PROCESS_THREAD/* --------------------------------------------------------------- */PROCESS_THREAD(node_process, ev, data){ // All the process start with this PROCESS_BEGIN(); PRINTF("# Starting.../n"); // Configure the network network_config(); if (!conn) { printf("E01/n"); PROCESS_EXIT(); } #if IS_RPL_ROOT create_dag(); #endif // Main, infinite, loop of the process PRINTF("# Ready!/n"); while (1) { // Wait, block the process, until an event happens. // Meanwhile, other process will continue running. PROCESS_WAIT_EVENT(); // Check the type of event that unblock the process if (ev == tcpip_event) tcpip_handler(); else if (ev == serial_line_event_message) input_handler((char*)data); } // All the process ends with this PROCESS_END();}
开发者ID:RauPerez25,项目名称:Wall-E,代码行数:35,
示例8: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){ static struct etimer timer; PROCESS_BEGIN(); PRINTF("UDP server started/n"); // wait 3 second, in order to have the IP addresses well configured etimer_set(&timer, CLOCK_CONF_SECOND*5); // wait until the timer has expired PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); print_local_addresses(); server_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(server_conn, UIP_HTONS(3000)); PRINTF("Server listening on UDP port %u/n", UIP_HTONS(server_conn->lport)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:EDAyele,项目名称:wsn430,代码行数:31,
示例9: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){#if UIP_CONF_ROUTER uip_ipaddr_t ipaddr;#endif /* UIP_CONF_ROUTER */ PROCESS_BEGIN(); PRINTF("UDP server started/n");#if RESOLV_CONF_SUPPORTS_MDNS resolv_set_hostname("contiki-udp-server");#endif#if UIP_CONF_ROUTER uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);#endif /* UIP_CONF_ROUTER */ print_local_addresses(); server_conn = udp_new(NULL, UIP_HTONS(3001), NULL); udp_bind(server_conn, UIP_HTONS(3000)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:1uk3,项目名称:contiki,代码行数:34,
示例10: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer et; uip_ipaddr_t ipaddr; PROCESS_BEGIN(); PRINTF("UDP client process started/n"); print_local_addresses(); set_connection_address(&ipaddr); /* new connection with remote host */ client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); udp_bind(client_conn, UIP_HTONS(3001)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&et, SEND_INTERVAL); while(1) { PROCESS_YIELD(); if(etimer_expired(&et)) { timeout_handler(); etimer_restart(&et); } else if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:EDAyele,项目名称:wsn430,代码行数:35,
示例11: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer periodic; static struct ctimer backoff_timer;#if WITH_COMPOWER static int print = 0;#endif PROCESS_BEGIN(); PROCESS_PAUSE(); set_global_address(); PRINTF("UDP client process started/n"); print_local_addresses(); /* new connection with remote host */ client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); if(client_conn == NULL) { PRINTF("No UDP connection available, exiting the process!/n"); PROCESS_EXIT(); } udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));#if WITH_COMPOWER powertrace_sniff(POWERTRACE_ON);#endif etimer_set(&periodic, SEND_INTERVAL); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } if(etimer_expired(&periodic)) { etimer_reset(&periodic); ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);#if WITH_COMPOWER if (print == 0) { powertrace_print("#P"); } if (++print == 3) { print = 0; }#endif } } PROCESS_END();}
开发者ID:EmuxEvans,项目名称:calipso,代码行数:61,
示例12: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){ PROCESS_BEGIN(); putstring("Starting UDP server/n");#if BUTTON_SENSOR_ON putstring("Button 1: Print RIME stats/n");#endif#if SERVER_RPL_ROOT create_dag();#endif server_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(server_conn, UIP_HTONS(3000)); PRINTF("Listen port: 3000, TTL=%u/n", server_conn->ttl); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler();#if (BUTTON_SENSOR_ON && (DEBUG==DEBUG_PRINT)) } else if(ev == sensors_event && data == &button_sensor) { print_stats();#endif /* BUTTON_SENSOR_ON */ } } PROCESS_END();}
开发者ID:EmuxEvans,项目名称:contiki-cc2530eb,代码行数:33,
示例13: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){ uip_ipaddr_t ipaddr; struct uip_ds6_addr *root_if; PROCESS_BEGIN(); PROCESS_PAUSE(); SENSORS_ACTIVATE(button_sensor); PRINTF("UDP server started/n");#if UIP_CONF_ROUTER uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1); /* uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); */ uip_ds6_addr_add(&ipaddr, 0, ADDR_MANUAL); root_if = uip_ds6_addr_lookup(&ipaddr); if(root_if != NULL) { rpl_dag_t *dag; rpl_set_root((uip_ip6addr_t *)&ipaddr); dag = rpl_get_dag(RPL_ANY_INSTANCE); uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); rpl_set_prefix(dag, &ipaddr, 64); PRINTF("created a new RPL dag/n"); } else { PRINTF("failed to create a new RPL DAG/n"); }#endif /* UIP_CONF_ROUTER */ print_local_addresses(); /* The data sink runs with a 100% duty cycle in order to ensure high packet reception rates. */ NETSTACK_RDC.off(1); server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL); udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT)); PRINTF("Created a server connection with remote address "); PRINT6ADDR(&server_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(server_conn->lport), UIP_HTONS(server_conn->rport)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } else if (ev == sensors_event && data == &button_sensor) { PRINTF("Initiaing global repair/n"); rpl_repair_dag(rpl_get_dag(RPL_ANY_INSTANCE)); } } PROCESS_END();}
开发者ID:uoaerg,项目名称:wise,代码行数:57,
示例14: udp_client_process/*--------------------------------------------------------*/void udp_client_process(void){ /******************** lock the Scheduler ************************/ cyg_scheduler_lock();/****************************************************************/ static struct ctimer backoff_timer; PRINTF("UDP client started/n"); set_global_address(); print_local_addresses(); client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); ctimer_set(&backoff_timer,SEND_TIME,send_packet,NULL); // PRINTF(" local/remote port %u/%u/n", client_conn->lport, client_conn->rport); void* message = NULL; /******************** unlock the Scheduler ************************/ cyg_scheduler_unlock();/****************************************************************/ while(1){ // cyg_thread_yield(); message = cyg_mbox_tryget (mbox_out_tcpip_handle); MyEvent_t* msg_local = message ; if ( message != NULL){ cyg_handle_t* event_handlePtr; event_handlePtr = (cyg_handle_t*) msg_local-> dataPtr; if( cyg_thread_self() == *event_handlePtr){ tcpip_handler(); } } cyg_thread_yield(); }}
开发者ID:ntuDerekWang,项目名称:uIP_on_eCos,代码行数:57,
示例15: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer et, wake_timer, periodic_timer; uip_ipaddr_t ipaddr; PROCESS_BEGIN(); PRINTF("UDP client process started/n");#if UIP_CONF_ROUTER set_global_address();#endif print_local_addresses(); set_connection_address(&ipaddr); /* new connection with remote host */ client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); udp_bind(client_conn, UIP_HTONS(3001)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&et, CLOCK_SECOND*10); PROCESS_WAIT_UNTIL(etimer_expired(&et)); // Wait for DAD and Router Discovery procedure to end. etimer_set(&et, SEND_INTERVAL); etimer_set(&wake_timer, AWAKE_INTERVAL); etimer_set(&periodic_timer, 1); while(1) { PROCESS_YIELD(); if(etimer_expired(&wake_timer)){ // if timer hasn't expired do not go in deep sleep, in order to receive a response. printf("Sleeping.../r/n"); sensorsPowerDown(); sleep_seconds(SLEEP_INTERVAL_SECONDS); // Put system in deep sleep mode for a while. sensorsPowerUp(); printf("Awake/r/n"); } if(etimer_expired(&et)) { timeout_handler(); etimer_restart(&et); etimer_restart(&wake_timer); } else if(ev == tcpip_event) { tcpip_handler(); } /* Make the process be called almost immediately, * so that it can force the system to go into deep sleep. */ etimer_restart(&periodic_timer); } PROCESS_END();}
开发者ID:pkocsis,项目名称:contiki-mirror,代码行数:57,
示例16: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer periodic; static struct ctimer backoff_timer; PROCESS_BEGIN(); /* Start powertracing, once every 60 seconds. */ //powertrace_start(CLOCK_SECOND * 60); PROCESS_PAUSE(); set_global_address(); PRINTF("UDP Client process started/n"); print_local_addresses(); /* new connection with remote host */ client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); if(client_conn == NULL) { PRINTF("No UDP connection available, exiting the process!/n"); PROCESS_EXIT(); } udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF("/nlocal/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&periodic, SEND_INTERVAL); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } // send sensor data to root periodically. if(etimer_expired(&periodic)) { etimer_reset(&periodic); ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL); } } PROCESS_END();}
开发者ID:lixinlu2000,项目名称:iot-rpl,代码行数:54,
示例17: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer et; uip_ipaddr_t ipaddr; int port = 3000; /* Default to 3000 if not using service discovery. */ PROCESS_BEGIN(); PRINTF("UDP client process started/n");#if UIP_CONF_ROUTER set_global_address();#endif print_local_addresses(); static resolv_status_t status = RESOLV_STATUS_UNCACHED; while(status != RESOLV_STATUS_CACHED) {#if RESOLV_CONF_SUPPORTS_MDNS && RESOLV_CONF_SUPPORTS_DNS_SD status = set_connection_address(&ipaddr, &port);#else status = set_connection_address(&ipaddr, NULL);#endif if(status == RESOLV_STATUS_RESOLVING) { PROCESS_WAIT_EVENT_UNTIL(ev == resolv_event_found); } else if(status != RESOLV_STATUS_CACHED) { PRINTF("Can't get connection address./n"); PROCESS_YIELD(); } } /* new connection with remote host */ client_conn = udp_new(&ipaddr, UIP_HTONS(port), NULL); udp_bind(client_conn, UIP_HTONS(port + 1)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&et, SEND_INTERVAL); while(1) { PROCESS_YIELD(); if(etimer_expired(&et)) { timeout_handler(); etimer_restart(&et); } else if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:PureEngineering,项目名称:contiki,代码行数:54,
示例18: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer et; uip_ipaddr_t ipaddr; PROCESS_BEGIN(); PRINTF("UDP client process started/n"); uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145); /* new connection with remote host */ l_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); if(!l_conn) { PRINTF("udp_new l_conn error./n"); } udp_bind(l_conn, UIP_HTONS(LOCAL_CONN_PORT)); PRINTF("Link-Local connection with "); PRINT6ADDR(&l_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport)); uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145); g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); if(!g_conn) { PRINTF("udp_new g_conn error./n"); } udp_bind(g_conn, UIP_HTONS(GLOBAL_CONN_PORT)); PRINTF("Global connection with "); PRINT6ADDR(&g_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(g_conn->lport), UIP_HTONS(g_conn->rport)); etimer_set(&et, SEND_INTERVAL); while(1) { PROCESS_YIELD(); if(etimer_expired(&et)) { timeout_handler(); etimer_restart(&et); } else if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:1847123212,项目名称:ampm_contiki_wisun,代码行数:48,
示例19: PROCESS_THREADPROCESS_THREAD(udp_server_process, ev, data){ PROCESS_BEGIN(); PRINTF("UDP server started/n"); server_conn = udp_new(NULL, UIP_HTONS(3001), NULL); udp_bind(server_conn, UIP_HTONS(3000)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:denghongcai,项目名称:6lbr,代码行数:17,
示例20: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) static struct sensors_sensor *b1; static struct sensors_sensor *b2;#endif PROCESS_BEGIN(); putstring("Starting UDP server/n");#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) putstring("Button 1: Print RIME stats/n"); putstring("Button 2: Reboot/n");#endif#if SERVER_RPL_ROOT create_dag();#endif server_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(server_conn, UIP_HTONS(3000)); PRINTF("Listen port: 3000, TTL=%u/n", server_conn->ttl);#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) b1 = sensors_find(BUTTON_1_SENSOR); b2 = sensors_find(BUTTON_2_SENSOR);#endif while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler();#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) } else if(ev == sensors_event && data != NULL) { if(data == b1) { print_stats(); } else if(data == b2) { watchdog_reboot(); }#endif /* (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) */ } } PROCESS_END();}
开发者ID:jdurrant,项目名称:contiki-mirror,代码行数:47,
示例21: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(viztool_process, ev, data){ PROCESS_BEGIN(); server_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(server_conn, UIP_HTONS(VIZTOOL_UDP_PORT)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:18,
示例22: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(ntpd_process, ev, data){ static struct etimer et; static uip_ipaddr_t ipaddr; PROCESS_BEGIN(); PRINTF("ntpd process started/n"); set_connection_address(&ipaddr); /* find the IP of router */ //etimer_set(&et, CLOCK_SECOND); //while(1){ // if(uip_ds6_defrt_choose()){ // uip_ipaddr_copy(&ipaddr, uip_ds6_defrt_choose()); // break; // } // etimer_set(&et, CLOCK_SECOND); // PROCESS_YIELD_UNTIL(etimer_expired(&et)); //} /* new connection with remote host */ ntp_conn = udp_new(&ipaddr, UIP_HTONS(NTPD_PORT), NULL); etimer_set(&et, SEND_INTERVAL * CLOCK_SECOND); while(1) { PROCESS_YIELD(); if(etimer_expired(&et)) { timeout_handler(); if((clock_seconds() > 4294967290U) || (clock_seconds() < 20)){ SEND_INTERVAL = 2 * CLOCK_SECOND; etimer_set(&et, SEND_INTERVAL); } else { if(SEND_INTERVAL <= 512 && (getCurrTime() != 0)) { SEND_INTERVAL = 2 * SEND_INTERVAL; } etimer_set(&et, SEND_INTERVAL * CLOCK_SECOND); } } else if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:anhquang,项目名称:app-sync,代码行数:47,
示例23: PROCESS_THREADPROCESS_THREAD(sender_process, ev, data){ static struct etimer periodic; static struct ctimer backoff_timer; PROCESS_BEGIN();// PROCESS_PAUSE(); set_global_address(); PRINTF("The sender process begins./n"); print_local_addresses(); /* new connection with remote host */ sender_conn = udp_new(NULL, UIP_HTONS(UDP_SINK_PORT), NULL); if(sender_conn == NULL) { PRINTF("No UDP connection available, exiting the process!/n"); PROCESS_EXIT(); } udp_bind(sender_conn, UIP_HTONS(UDP_SENDER_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&sender_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(sender_conn->lport), UIP_HTONS(sender_conn->rport)); etimer_set(&periodic, SEND_INTERVAL * CLOCK_SECOND); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) tcpip_handler(); if(etimer_expired(&periodic)) { etimer_reset(&periodic); ctimer_set(&backoff_timer, RANDWAIT * CLOCK_SECOND, send_packet, NULL); } } PROCESS_END();}
开发者ID:RanHuang,项目名称:nick-project-contiki,代码行数:43,
示例24: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer et; uip_ipaddr_t ipaddr; PROCESS_BEGIN(); PRINTF("UDP client process started/n");#if UIP_CONF_ROUTER set_global_address();#endif print_local_addresses(); set_connection_address(&ipaddr); /* new connection with remote host */ SENSORS_ACTIVATE(button_sensor);//activate button //client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); simple_udp_register(&udp_connection, UDP_PORT, NULL, UDP_PORT, receiver); // udp_bind(client_conn, UIP_HTONS(3001)); //PRINTF("Created a connection with the server "); // PRINT6ADDR(&client_conn->ripaddr); // PRINTF(" local/remote port %u/%u/n",// UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); // etimer_set(&et, SEND_INTERVAL); while(1) { //PROCESS_YIELD(); PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor); // if(etimer_expired(&et)) { timeout_handler(); // etimer_restart(&et); //} else if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:johannesst,项目名称:aio-wsn,代码行数:44,
示例25: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(trickle_protocol_process, ev, data){ PROCESS_BEGIN(); PRINTF("Trickle protocol started/n"); uip_create_linklocal_allnodes_mcast(&ipaddr); /* Store for later */ trickle_conn = udp_new(NULL, UIP_HTONS(TRICKLE_PROTO_PORT), NULL); udp_bind(trickle_conn, UIP_HTONS(TRICKLE_PROTO_PORT)); PRINTF("Connection: local/remote port %u/%u/n", UIP_HTONS(trickle_conn->lport), UIP_HTONS(trickle_conn->rport)); token = 0; trickle_timer_config(&tt, IMIN, IMAX, REDUNDANCY_CONST); trickle_timer_set(&tt, trickle_tx, &tt); /* * At this point trickle is started and is running the first interval. All * nodes 'agree' that token == 0. This will change when one of them randomly * decides to generate a new one */ etimer_set(&et, NEW_TOKEN_INTERVAL); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } else if(etimer_expired(&et)) { /* Periodically (and randomly) generate a new token. This will trigger * a trickle inconsistency */ if((random_rand() % NEW_TOKEN_PROB) == 0) { token++; PRINTF("At %lu: Generating a new token 0x%02x/n", (unsigned long)clock_time(), token); trickle_timer_reset_event(&tt); } etimer_set(&et, NEW_TOKEN_INTERVAL); } } PROCESS_END();}
开发者ID:13416795,项目名称:contiki,代码行数:44,
示例26: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(tcp_server_process, ev, data){ static uip_ipaddr_t ipaddr; PROCESS_BEGIN(); PRINTF("TCP server started/r/n"); print_local_addresses(); tcp_listen(HTONS(3000)); while(1) { PROCESS_YIELD(); // or PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:kincki,项目名称:contiki,代码行数:21,
示例27: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(receive_process, ev, data){ static struct etimer et; PROCESS_BEGIN();server_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(server_conn, UIP_HTONS(5885)); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:tdautc19841202,项目名称:contikihouse,代码行数:22,
示例28: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ PROCESS_BEGIN(); PROCESS_PAUSE(); set_global_address(); PRINTF("UDP client process started/n"); print_local_addresses(); /* new connection with remote host */ client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); /* One socket to act as sever */ server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL); udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); /* Starting of the node is anonymous */ /* user with the help of serial command line argument set the region of the node */ region = ANONYMOUS; /* number of neighbor in the starting is always zero */ cur_nbr = 0; while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } } PROCESS_END();}
开发者ID:engalex,项目名称:652Final,代码行数:41,
示例29: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_client_process, ev, data){ static struct etimer periodic; static struct ctimer backoff_timer; PROCESS_BEGIN(); PROCESS_PAUSE(); set_global_address(); PRINTF("UDP client process started/n"); print_local_addresses(); /* new connection with remote host */ client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u/n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&periodic, SEND_INTERVAL); while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler(); } if(etimer_expired(&periodic)) { etimer_reset(&periodic); ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL); } } PROCESS_END();}
开发者ID:leoqin,项目名称:Contiki-leo,代码行数:40,
示例30: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) static struct sensors_sensor *b1; static struct sensors_sensor *b2;#endif PROCESS_BEGIN(); putstring("Starting UDP server/n");#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) putstring("Button X: Toggle LED X/n");#endif server_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(server_conn, UIP_HTONS(SERVER_PORT));#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) b1 = sensors_find(BUTTON_1_SENSOR); b2 = sensors_find(BUTTON_2_SENSOR);#endif while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { tcpip_handler();#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) } else if(ev == sensors_event && data != NULL) { if(data == b1) { leds_toggle(LEDS_GREEN); } else if(data == b2) { leds_toggle(LEDS_RED); }#endif /* (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) */ } } PROCESS_END();}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:40,
注:本文中的tcpip_handler函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tcpip_init函数代码示例 C++ tcp_write函数代码示例 |