本文整理汇总了C++中set_global_address函数的典型用法代码示例。如果您正苦于以下问题:C++ set_global_address函数的具体用法?C++ set_global_address怎么用?C++ set_global_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_global_address函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(receiver_node_process, ev, data)
{
static struct etimer et;
static struct uip_ds6_notification n;
uip_ipaddr_t *ipaddr;
PROCESS_BEGIN();
ipaddr = set_global_address();
uip_ds6_notification_add(&n, route_callback);
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
etimer_set(&et, CLOCK_SECOND);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
if(should_blink) {
leds_on(LEDS_ALL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
leds_off(LEDS_ALL);
}
}
PROCESS_END();
}
开发者ID:1uk3,项目名称:contiki,代码行数:29,代码来源:receiver-node.c
示例2: PROCESS_THREAD
PROCESS_THREAD(server_process, ev, data)
{
PROCESS_BEGIN();
set_global_address();
leds_init();
print_local_addresses();
printf("Starting TCP server on port=%d\n", PORT);
tcp_listen(UIP_HTONS(PORT));
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
if(uip_aborted() )
printf("TCP aborted\n");
if(uip_timedout() )
printf("TCP timeoutn\n");
if(uip_closed() )
printf("TCP closed\n");
if(uip_connected()) {
printf("TCP Connected\n\r");
PSOCK_INIT(&ps, buf, sizeof(buf));
while(!(uip_aborted() || uip_closed() || uip_timedout())) {
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
handle_connection(&ps);
}
}
}
PROCESS_END();
}
开发者ID:1847123212,项目名称:contiki,代码行数:32,代码来源:server.c
示例3: 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,代码来源:udp-client.c
示例4: PROCESS_THREAD
/*-----------------------------------------------------------------------*/
PROCESS_THREAD(udp_sender_process, ev, data)
{
static struct etimer period_timer, wait_timer;
PROCESS_BEGIN();
set_global_address();
PRINTF("UDP sender process started\n");
print_local_address();
/* new connection with remote host */
sender_conn = udp_new(NULL, UIP_HTONS(UDP_SINK_PORT), NULL);
udp_bind(sender_conn, UIP_HTONS(UDP_SENDER_PORT));
PRINTF("Created a connection with the sink ");
PRINT6ADDR(&sender_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(sender_conn->lport), UIP_HTONS(sender_conn->rport));
etimer_set(&period_timer, CLOCK_SECOND * PERIOD);
while(1) {
PROCESS_WAIT_EVENT();
if(ev == PROCESS_EVENT_TIMER) {
if(data == &period_timer) {
etimer_reset(&period_timer);
etimer_set(&wait_timer,
random_rand() % (CLOCK_SECOND * RANDWAIT));
} else if(data ==&wait_timer) {
/* Time to send a data. */
collect_common_send();
}
}
}
PROCESS_END();
}
开发者ID:RanHuang,项目名称:nick-project-contiki,代码行数:35,代码来源:udp-sender.c
示例5: simple_rpl_init
/*---------------------------------------------------------------------------*/
void
simple_rpl_init(void)
{
to_become_root = 0;
set_global_address();
uip_ds6_notification_add(&n, route_callback);
}
开发者ID:Cancan79,项目名称:mist,代码行数:8,代码来源:simple-rpl.c
示例6: PROCESS_THREAD
PROCESS_THREAD(rest_server_example, ev, data)
{
PROCESS_BEGIN();
PRINTF("Starting Erbium Example Server\n");
PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
PRINTF("LL header: %u\n", UIP_LLH_LEN);
PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);
/* if static routes are used rather than RPL */
#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE)
set_global_address();
configure_routing();
#endif
/* Initialize the OSD Hardware. */
hw_init();
/* Initialize the REST engine. */
rest_init_engine();
/* Activate the application-specific resources. */
rest_activate_resource(&resource_info);
SENSORS_ACTIVATE(t4_servo_sensor);
rest_activate_resource(&resource_t4_servo);
/* Define application-specific events here. */
while(1) {
PROCESS_WAIT_EVENT();
}
PROCESS_END();
}
开发者ID:osdomotics,项目名称:osd-contiki,代码行数:33,代码来源:er-example-server.c
示例7: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(otau_client_process, ev, data)
{
static struct etimer server_timer;
uip_ip6addr_t *srv_addr;
PROCESS_BEGIN();
servreg_hack_init();
set_global_address();
ota_mgr_init();
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
etimer_set(&server_timer, SEND_INTERVAL);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&server_timer));
srv_addr = servreg_hack_lookup(SERVICE_ID);
if(srv_addr != NULL) {
printf("Server address configured\r\n");
server_configured =1;
configure_server_details(srv_addr);
memcpy((uint8_t *)&(global_server_addr.u16[4]),&(srv_addr->u16[4]),NATIVE_ADDR_SIZE);
//uip_create_linklocal_allnodes_mcast(srv_addr);
etimer_stop(&server_timer);
}
else
{
etimer_reset(&server_timer);
printf("server not found\r\n");
}
}
PROCESS_END();
}
开发者ID:songjw0820,项目名称:contiki_atmel,代码行数:35,代码来源:sc6-ota-mgr.c
示例8: 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,代码来源:udp-sender.c
示例9: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udpstream_process, ev, data)
{
static uint16_t streamno;
static struct etimer et;
static uip_ipaddr_t *ipaddr;
PROCESS_BEGIN();
PROCESS_PAUSE();
printf("Formatting Coffee FS...\n");
cfs_coffee_format();
printf("done.\n");
/* We need re-initialize queuebuf after formatting */
queuebuf_init();
/* Start service registration */
servreg_hack_init();
ipaddr = set_global_address();
if(node_id == SINK_ID) {
/* The sink creates a dag and waits for UDP datagrams */
create_rpl_dag(ipaddr);
servreg_hack_register(SERVICE_ID, ipaddr);
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
while(1) {
PROCESS_WAIT_EVENT();
}
} else if(node_id == SENDER_ID) {
/* The sender looks for the sink and sends UDP streams */
ipaddr = NULL;
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
etimer_set(&et, 10*CLOCK_SECOND);
etimer_restart(&et);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
if(ipaddr != NULL) {
streamno++;
send_stream(ipaddr, streamno);
} else {
ipaddr = servreg_hack_lookup(SERVICE_ID);
if(ipaddr != NULL) {
etimer_set(&et, 2*CLOCK_SECOND);
printf("Streaming to ");
uip_debug_ipaddr_print(ipaddr);
printf("\n");
} else {
printf("Service %d not found\n", SERVICE_ID);
}
}
etimer_restart(&et);
}
}
PROCESS_END();
}
开发者ID:Blade87,项目名称:contiki-stm32f10x-iar,代码行数:60,代码来源:udp-stream.c
示例10: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_sender_process, ev, data)
{
static struct etimer periodic_timer;
static struct etimer send_timer;
uip_ipaddr_t *addr;
PROCESS_BEGIN();
SENSORS_ACTIVATE(button_sensor);
// SENSORS_ACTIVATE(light_sensor);
servreg_hack_init();
set_global_address();
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
//etimer_set(&periodic_timer, SEND_INTERVAL);
while(1) {
// PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
// etimer_reset(&periodic_timer);
etimer_set(&send_timer, SEND_TIME);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));
addr = servreg_hack_lookup(SERVICE_ID);
if(addr != NULL) {
static unsigned int button_number;
char buf[50];
if(button_number == 0) {
button_number = 1;
leds_toggle(LEDS_ALL);
} else {
button_number = 0;
leds_toggle(LEDS_ALL);
}
printf("Sending unicast to ");
uip_debug_ipaddr_print(addr);
printf("\n");
//sprintf(buf, "Occupancy Detector: %d, Luminaire Illuminance: %d", button_number, LUMINAIRE_ILLUMINANCE);
sprintf(buf, "Occupancy Detector: %d, Luminaire Illuminance: %d", button_number, (int)(410 ));
simple_udp_sendto(&unicast_connection, buf, strlen(buf) + 1, addr);
} else {
printf("Service %d not found\n", SERVICE_ID);
}
}
PROCESS_END();
}
开发者ID:xytgeorge,项目名称:User-conflict-prevention-CLS,代码行数:58,代码来源:desk-controller.c
示例11: 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,代码来源:udp-client.c
示例12: 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,代码来源:client1017.c
示例13: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(tcp_client_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
PRINTF("TCP client process started\n");
process_start(&adjust_packet_length_process, 0);
#if UIP_CONF_ROUTER
set_global_address();
#endif
print_local_addresses();
/* Fill buffer with test data */
for (int i = 0; i < MAX_PAYLOAD_LEN; i++) {
buf[i] = i;
}
static resolv_status_t status = RESOLV_STATUS_UNCACHED;
while(status != RESOLV_STATUS_CACHED) {
status = set_connection_address(&ipaddr);
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 */
tcp_socket_register(&socket, NULL,
inputbuf, sizeof(inputbuf),
outputbuf, sizeof(outputbuf),
input, event);
tcp_socket_connect(&socket, &ipaddr, SERVER_PORT);
PRINTF("Connecting with the server...");
PRINT6ADDR(&ipaddr);
PRINTF("\n");
while(1) {
etimer_set(&et, send_interval);
PROCESS_YIELD();
if(etimer_expired(&et)) {
timeout_handler();
}
}
PROCESS_END();
}
开发者ID:EasyRF,项目名称:contiki,代码行数:55,代码来源:tcp-client.c
示例14: PROCESS_THREAD
PROCESS_THREAD(plugtest_server, ev, data)
{
PROCESS_BEGIN();
PRINTF("ETSI IoT CoAP Plugtests Server\n");
PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
PRINTF("LL header: %u\n", UIP_LLH_LEN);
PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);
/* if static routes are used rather than RPL */
#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET)
set_global_address();
configure_routing();
#endif
/* Initialize the REST engine. */
rest_init_engine();
/* Activate the application-specific resources. */
#if REST_RES_TEST
rest_activate_resource(&resource_test);
#endif
#if REST_RES_LONG
rest_activate_resource(&resource_longpath);
#endif
#if REST_RES_QUERY
rest_activate_resource(&resource_query);
#endif
#if REST_RES_SEPARATE
rest_activate_periodic_resource(&periodic_resource_separate);
#endif
#if REST_RES_LARGE
rest_activate_resource(&resource_large);
#endif
#if REST_RES_LARGE_UPDATE
large_update_ct = REST.type.APPLICATION_OCTET_STREAM;
rest_activate_resource(&resource_large_update);
#endif
#if REST_RES_LARGE_CREATE
rest_activate_resource(&resource_large_create);
#endif
#if REST_RES_OBS
rest_activate_periodic_resource(&periodic_resource_obs);
#endif
/* Define application-specific events here. */
while(1) {
PROCESS_WAIT_EVENT();
} /* while (1) */
PROCESS_END();
}
开发者ID:osdomotics,项目名称:osd-contiki,代码行数:54,代码来源:er-plugtest-server.c
示例15: rpl_dag_root_init
/*---------------------------------------------------------------------------*/
void
rpl_dag_root_init(void)
{
static uint8_t initialized = 0;
if(!initialized) {
to_become_root = 0;
set_global_address();
uip_ds6_notification_add(&n, route_callback);
initialized = 1;
}
}
开发者ID:0009281,项目名称:contiki,代码行数:13,代码来源:rpl-dag-root.c
示例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,代码来源:udp-client.c
示例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,代码来源:udp-client.c
示例18: rpl_dag_root_init
/*---------------------------------------------------------------------------*/
void
rpl_dag_root_init(void)
{
static uint8_t initialized = 0;
if(!initialized) {
to_become_root = 0;
set_global_address();
#if (UIP_CONF_MAX_ROUTES != 0)
uip_ds6_notification_add(&n, route_callback);
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
initialized = 1;
}
}
开发者ID:1847123212,项目名称:contiki,代码行数:15,代码来源:rpl-dag-root.c
示例19: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_receiver_process, ev, data)
{
uip_ipaddr_t *ipaddr;
PROCESS_BEGIN();
ipaddr = set_global_address();
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
while(1) {
PROCESS_WAIT_EVENT();
}
PROCESS_END();
}
开发者ID:lab-anaws,项目名称:lab2,代码行数:17,代码来源:receiver.c
示例20: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_sender_process, ev, data)
{
static struct etimer periodic_timer;
static struct etimer send_timer;
uip_ipaddr_t *addr;
PROCESS_BEGIN();
servreg_hack_init();
set_global_address();
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
etimer_set(&periodic_timer, SEND_INTERVAL);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
etimer_reset(&periodic_timer);
etimer_set(&send_timer, SEND_TIME);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));
PRINTF("SIMPLE_UNICAST_SENDER: Unicast attempt!\n");
addr = servreg_hack_lookup(SERVICE_ID);
if(addr != NULL) {
static unsigned int message_number;
char buf[20];
printf("Sending unicast to ");
uip_debug_ipaddr_print(addr);
printf(" \n");
sprintf(buf, "Message %d", message_number);
message_number++;
simple_udp_sendto(&unicast_connection, buf, strlen(buf) + 1, addr);
} else {
printf("Service %d not found\n", SERVICE_ID);
}
}
PROCESS_END();
}
开发者ID:EmuxEvans,项目名称:calipso,代码行数:44,代码来源:unicast-sender.c
注:本文中的set_global_address函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论