Code style fixes: sensinode examples
This commit is contained in:
parent
594ba9a0ed
commit
64a95dcb59
19 changed files with 205 additions and 251 deletions
|
@ -88,7 +88,7 @@ static void
|
|||
timeout_handler(void)
|
||||
{
|
||||
static int seq_id;
|
||||
struct uip_udp_conn * this_conn;
|
||||
struct uip_udp_conn *this_conn;
|
||||
|
||||
leds_on(LEDS_RED);
|
||||
memset(buf, 0, MAX_PAYLOAD_LEN);
|
||||
|
@ -131,9 +131,9 @@ print_local_addresses(void)
|
|||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||
state = uip_ds6_if.addr_list[i].state;
|
||||
if(uip_ds6_if.addr_list[i].isused && (state == ADDR_TENTATIVE || state
|
||||
== ADDR_PREFERRED)) {
|
||||
== ADDR_PREFERRED)) {
|
||||
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
|
||||
if (state == ADDR_TENTATIVE) {
|
||||
if(state == ADDR_TENTATIVE) {
|
||||
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
|
||||
}
|
||||
PRINTF(" state: %u.\n", uip_ds6_if.addr_list[i].state);
|
||||
|
@ -168,7 +168,7 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
|||
|
||||
print_local_addresses();
|
||||
|
||||
uip_ip6addr(&ipaddr,0xfe80,0,0,0,0x0215,0x2000,0x0002,0x0302);
|
||||
uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x0302);
|
||||
/* new connection with remote host */
|
||||
l_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
|
||||
if(!l_conn) {
|
||||
|
@ -179,10 +179,11 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
|||
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_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport));
|
||||
|
||||
#if UIP_CONF_ROUTER
|
||||
uip_ip6addr(&ipaddr,0x2001,0x630,0x301,0x6453,0x0215,0x2000,0x0002,0x0302);
|
||||
uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0x0215, 0x2000, 0x0002,
|
||||
0x0302);
|
||||
g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
|
||||
if(!g_conn) {
|
||||
PRINTF("udp_new g_conn error.\n");
|
||||
|
@ -192,7 +193,7 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
|||
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));
|
||||
UIP_HTONS(g_conn->lport), UIP_HTONS(g_conn->rport));
|
||||
#endif
|
||||
|
||||
etimer_set(&et, SEND_INTERVAL);
|
||||
|
|
|
@ -101,18 +101,19 @@ ping6handler()
|
|||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(ping6_process, ev, data)
|
||||
{
|
||||
|
||||
|
||||
#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON)
|
||||
static struct sensors_sensor * btn;
|
||||
static struct sensors_sensor *btn;
|
||||
#endif
|
||||
|
||||
PROCESS_BEGIN();
|
||||
PRINTF("ping6 running.\n");
|
||||
PRINTF("Button 1: 5 pings 16 byte payload.\n");
|
||||
|
||||
uip_ip6addr(&dest_addr,0x2001,0x470,0x55,0,0x0215,0x2000,0x0002,0x0302);
|
||||
uip_ip6addr(&dest_addr, 0x2001, 0x470, 0x55, 0, 0x0215, 0x2000, 0x0002,
|
||||
0x0302);
|
||||
count = 0;
|
||||
|
||||
|
||||
/* Check if we have buttons */
|
||||
#if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON)
|
||||
btn = sensors_find(BUTTON_1_SENSOR);
|
||||
|
@ -132,7 +133,7 @@ PROCESS_THREAD(ping6_process, ev, data)
|
|||
ping6handler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -104,9 +104,10 @@ static void
|
|||
print_stats()
|
||||
{
|
||||
PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n",
|
||||
rimestats.toolong, rimestats.tooshort, rimestats.badsynch, rimestats.badcrc);
|
||||
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n",
|
||||
rimestats.llrx, rimestats.lltx, rimestats.rx, rimestats.tx);
|
||||
rimestats.toolong, rimestats.tooshort, rimestats.badsynch,
|
||||
rimestats.badcrc);
|
||||
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.llrx,
|
||||
rimestats.lltx, rimestats.rx, rimestats.tx);
|
||||
}
|
||||
#else
|
||||
#define print_stats()
|
||||
|
@ -122,11 +123,11 @@ print_local_addresses(void)
|
|||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||
state = uip_ds6_if.addr_list[i].state;
|
||||
if(uip_ds6_if.addr_list[i].isused && (state == ADDR_TENTATIVE || state
|
||||
== ADDR_PREFERRED)) {
|
||||
== ADDR_PREFERRED)) {
|
||||
PRINTF(" ");
|
||||
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
|
||||
PRINTF("\n");
|
||||
if (state == ADDR_TENTATIVE) {
|
||||
if(state == ADDR_TENTATIVE) {
|
||||
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +146,8 @@ create_dag()
|
|||
|
||||
print_local_addresses();
|
||||
|
||||
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);
|
||||
dag = rpl_set_root(RPL_DEFAULT_INSTANCE,
|
||||
&uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);
|
||||
if(dag != NULL) {
|
||||
uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0, 0, 0, 0);
|
||||
rpl_set_prefix(dag, &ipaddr, 64);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue