diff --git a/RIOT/examples/dynamic_app/Makefile b/RIOT/examples/dynamic_app/Makefile old mode 100644 new mode 100755 index eb114a0..eb114a0 --- a/RIOT/examples/dynamic_app/Makefile +++ b/RIOT/examples/dynamic_app/Makefile diff --git a/RIOT/examples/dynamic_app/main.c b/RIOT/examples/dynamic_app/main.c index 387b780..496d851 100755 --- a/RIOT/examples/dynamic_app/main.c +++ b/RIOT/examples/dynamic_app/main.c @@ -101,7 +101,7 @@ uint8_t node1[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0e,0 // addr ipv6 link local node 2: fe80::3634:5110:3473:3762 uint8_t node2[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x34,0x51,0x10,0x34,0x73,0x37,0x62}; // addr ipv6 link local node 3: fe80::3734:510e:330b:342a -uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0e,0x33,0x0b,0x34,0x2a}; +uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x33,0x47,0x11,0x37,0x2c,0x34,0x12}; // addr ipv6 link local node 4: fe80::3734:510b:330b:340a uint8_t node4[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0b,0x33,0x0b,0x34,0x0a}; // addr ipv6 link local node 5: fe80::3734:510b:330a:341e @@ -125,7 +125,7 @@ sock_udp_ep_t local = SOCK_IPV6_EP_ANY; sock_udp_t sock; sock_udp_ep_t local_ntp = SOCK_IPV6_EP_ANY; sock_udp_t sock_ntp; -static ntp_packet_t sntp_packet; +//static ntp_packet_t sntp_packet; typedef struct tableau { uint32_t heure_actuelle; @@ -158,7 +158,7 @@ int crea_rpl_dodag_root(char *arg1, char *arg2) } /***************** /RPL functions ****************/ -void *sock_time_server_thread(void *arg) +/*void *sock_time_server_thread(void *arg) { (void) arg; local_ntp.port = NTP_PORT; @@ -194,37 +194,15 @@ void *sock_time_server_thread(void *arg) } } return NULL; -} -/*void *pwm_thread(void *arg) -{ - (void) arg; - int tourne = 0; - while(1) - { - - if(ordre==1) - { - pwm_set(PWM_DEV(0),1,45); - tourne = 1; - } - else if(ordre==0) - { - pwm_set(PWM_DEV(0),1,0); - tourne = 0; - } - else if(ordre==2 && tourne == 1) - pwm_set(PWM_DEV(0),1,31); - - } - return NULL; }*/ + void *sock_server_thread(void *arg) { (void) arg; Data buf; - int compteur = 5; - int deadline; + // int compteur = 5; + // int deadline; local.port = 1234; sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 }; ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "dead:beef::3402"); @@ -233,12 +211,12 @@ void *sock_server_thread(void *arg) puts("Error creating UDP sock"); return NULL; } - if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { + /*if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { puts("Error in synchronization"); return NULL; } offset = sntp_get_offset(); - printf("offset : %i\n",(int)offset); + printf("offset : %i\n",(int)offset);*/ while (1) { sock_udp_ep_t remote; @@ -246,13 +224,13 @@ void *sock_server_thread(void *arg) if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT, &remote)) >= 0) { - // puts("Received a message"); + puts("Received a message"); //printf("%s\n",buf); /*if (sock_udp_send(&sock, buf, res, &remote) < 0) { puts("Error sending reply"); }*/ - deadline = xtimer_now_usec() + offset - buf.heure_actuelle; + /*deadline = xtimer_now_usec() + offset - buf.heure_actuelle; printf("tps de transmission : %i\n",deadline); if(deadline >= DEADLINE && compteur >=5) @@ -287,14 +265,14 @@ void *sock_server_thread(void *arg) } printf("compteur : %d\n",compteur); - memset(&buf,0,sizeof(buf)); + memset(&buf,0,sizeof(buf));*/ } } return NULL; } -/*void *sock_client_thread(void *arg) +void *sock_client_thread(void *arg) { (void) arg; Data data; @@ -309,7 +287,7 @@ void *sock_server_thread(void *arg) remote.addr.ipv6[2] = 0xbe; remote.addr.ipv6[3] = 0xef; remote.addr.ipv6[14] = 0x34; - remote.addr.ipv6[15] = 0x2a; + remote.addr.ipv6[15] = 0x1e; // memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN); while (1) { // //ipv6_addr_set_all_nodes_multicast((ipv6_addr_t *)&remote.addr.ipv6, @@ -319,10 +297,11 @@ void *sock_server_thread(void *arg) if (sock_udp_send(NULL, &data, sizeof(data), &remote) < 0) { puts("Error sending message"); } + puts("Send a message"); xtimer_sleep(2); } return NULL; -}*/ +} /*static void arret_urgence(void *arg,int channel) { @@ -392,19 +371,20 @@ static void _init_interface(void) /* model ipv6 addr: dead:beef::Hwaddr */ if((addr.u8[14]==0x34)&&(addr.u8[15]==0x02)){ crea_rpl_dodag_root("1", "dead:beef::3402"); - /*client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread"); - xtimer_usleep(200);*/ - time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),6,THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread"); - xtimer_usleep(200); + client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread"); + // xtimer_usleep(200); + //time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),6,THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread"); + // xtimer_usleep(200); }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){ - }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x2a)){ + }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x12)){ //_init_timer(); //_init_pwm(); /*server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");*/ }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x0a)){ }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x1e)){ + server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread"); }else{ puts("new node ?"); } diff --git a/RIOT/examples/dynamic_app/udp.c b/RIOT/examples/dynamic_app/udp.c old mode 100644 new mode 100755 index 74189c1..74189c1 --- a/RIOT/examples/dynamic_app/udp.c +++ b/RIOT/examples/dynamic_app/udp.c diff --git a/RIOT/examples/real_time_app/Makefile b/RIOT/examples/real_time_app/Makefile old mode 100644 new mode 100755 index 0214b5c..0214b5c --- a/RIOT/examples/real_time_app/Makefile +++ b/RIOT/examples/real_time_app/Makefile diff --git a/RIOT/examples/real_time_app/main.c b/RIOT/examples/real_time_app/main.c index 3f68a40..5c2ad75 100755 --- a/RIOT/examples/real_time_app/main.c +++ b/RIOT/examples/real_time_app/main.c @@ -87,7 +87,7 @@ uint8_t node1[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0e,0 // addr ipv6 link local node 2: fe80::3634:5110:3473:3762 uint8_t node2[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x34,0x51,0x10,0x34,0x73,0x37,0x62}; //addr ipv6 link local node 3: fe80::3634:5110:3471:3766 -uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x34,0x51,0x10,0x34,0x71,0x37,0x66}; +uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x33,0x47,0x11,0x37,0x2c,0x34,0x12}; //static char _stack_server[GNRC_PKTDUMP_STACKSIZE]; char pwm_stack[THREAD_STACKSIZE_MAIN]; @@ -120,36 +120,36 @@ void *sock_time_server_thread(void *arg) { (void) arg; local_ntp.port = NTP_PORT; - + if (sock_udp_create(&sock_ntp, &local_ntp, NULL, 0) < 0) { - puts("Error creating UDP sock"); - return NULL; + puts("Error creating UDP sock"); + return NULL; } - + while (1) { - sock_udp_ep_t remote; - ssize_t res; - - if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT, - &remote)) >= 0) { - puts("Received a message"); - //printf("TT: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds)); - - // printf("%c\n",remote.addr.ipv6[15]); - //xtimer_ticks64_t now = xtimer_now64(); - // heure actuelle du serveur - sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec()); - sntp_packet.origin.seconds=sntp_packet.transmit.seconds; - sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec()); - //printf("heure actuelle : %lu\n",xtimer_now_usec()); - //printf("TT2: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds)); - //memset(&sntp_packet, 0, sizeof(sntp_packet)); - //ntp_packet_set_vn(&sntp_packet); - //ntp_packet_set_mode(&sntp_packet, NTP_MODE_SERVER); - if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) { - puts("Error sending reply"); - } - } + sock_udp_ep_t remote; + ssize_t res; + + if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT, + &remote)) >= 0) { + puts("Received a message"); + //printf("TT: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds)); + + // printf("%c\n",remote.addr.ipv6[15]); + //xtimer_ticks64_t now = xtimer_now64(); + // heure actuelle du serveur + sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec()); + sntp_packet.origin.seconds=sntp_packet.transmit.seconds; + sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec()); + //printf("heure actuelle : %lu\n",xtimer_now_usec()); + //printf("TT2: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds)); + //memset(&sntp_packet, 0, sizeof(sntp_packet)); + //ntp_packet_set_vn(&sntp_packet); + //ntp_packet_set_mode(&sntp_packet, NTP_MODE_SERVER); + if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) { + puts("Error sending reply"); + } + } } return NULL; } @@ -179,113 +179,99 @@ void *sock_time_server_thread(void *arg) void *sock_server_thread(void *arg) { - (void) arg; - Data buf; - int compteur = 5; - int deadline; - local.port = 1234; - sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 }; - ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "dead:beef::3402"); - - if (sock_udp_create(&sock, &local, NULL, 0) < 0) { - puts("Error creating UDP sock"); - return NULL; - } - if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { - puts("Error in synchronization"); - return NULL; - } - offset = sntp_get_offset(); - printf("offset : %i\n",(int)offset); + (void) arg; + Data buf; + int compteur = 5; + int deadline; + local.port = 1234; + sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 }; + ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "dead:beef::3402"); - while (1) { - sock_udp_ep_t remote; - ssize_t res; - - if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT, - &remote)) >= 0) { - // puts("Received a message"); - //printf("%s\n",buf); - /*if (sock_udp_send(&sock, buf, res, &remote) < 0) { - puts("Error sending reply"); - }*/ - - deadline = xtimer_now_usec() + offset - buf.heure_actuelle; - printf("tps de transmission : %i\n",deadline); - - if(deadline >= DEADLINE && compteur >=5) - { - //ordre = 2; - compteur = 0; - if(tourne == 1) - pwm_set(PWM_DEV(0),1,31); - if(timer_run == 0) - { - timer_set(TIMER_DEV(1),0,25200); - printf("relance timer\n"); - timer_run = 1; - } - } - if(deadline >= DEADLINE && compteur < 5) - { - compteur = 0; - } - if(deadline<=DEADLINE && compteur >=5) - { - //ordre = 1; - pwm_set(PWM_DEV(0),1,45); - tourne = 1; - timer_run=0; - timer_clear(TIMER_DEV(1),0); - printf("clear timer\n"); - } - if(deadline<=DEADLINE && compteur <5) - { - compteur++; - } - - printf("compteur : %d\n",compteur); - memset(&buf,0,sizeof(buf)); + if (sock_udp_create(&sock, &local, NULL, 0) < 0) { + puts("Error creating UDP sock"); + return NULL; + } + if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { + puts("Error in synchronization"); + return NULL; + } + offset = sntp_get_offset(); + printf("offset : %i\n",(int)offset); + + while (1) { + sock_udp_ep_t remote; + ssize_t res; + if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT,&remote)) >= 0) { + deadline = xtimer_now_usec() + offset - buf.heure_actuelle; + printf("tps de transmission : %i\n",deadline); + + if(buf.donnees[0] == 'g' && buf.donnees[1] == 'o') { + if(deadline >= DEADLINE && compteur >=5) { + compteur = 0; + if(tourne == 1) + pwm_set(PWM_DEV(0),1,31); + if(timer_run == 0) { + timer_set(TIMER_DEV(1),0,25200); + printf("relance timer\n"); + timer_run = 1; + } + } + if(deadline >= DEADLINE && compteur < 5) { + compteur = 0; + } + if(deadline<=DEADLINE && compteur >=5) { + pwm_set(PWM_DEV(0),1,45); + tourne = 1; + timer_run=0; + timer_clear(TIMER_DEV(1),0); + printf("clear timer\n"); + } + if(deadline<=DEADLINE && compteur <5) { + compteur++; + } + printf("compteur : %d\n",compteur); + memset(&buf,0,sizeof(buf)); } } + } return NULL; } void *sock_client_thread(void *arg) { - (void) arg; - Data data; - data.donnees[0] = 'g'; - data.donnees[1] = 'o'; - //uint8_t paquet[]; - sock_udp_ep_t remote = { .family = AF_INET6 }; - - remote.port = 1234; - remote.addr.ipv6[0] = 0xde; - remote.addr.ipv6[1] = 0xad; - remote.addr.ipv6[2] = 0xbe; - remote.addr.ipv6[3] = 0xef; - remote.addr.ipv6[14] = 0x37; - remote.addr.ipv6[15] = 0x66; -// memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN); - while (1) { -// //ipv6_addr_set_all_nodes_multicast((ipv6_addr_t *)&remote.addr.ipv6, -// // IPV6_ADDR_MCAST_SCP_LINK_LOCAL); - data.heure_actuelle = xtimer_now_usec(); - - if (sock_udp_send(NULL, &data, sizeof(data), &remote) < 0) { - puts("Error sending message"); - } - xtimer_sleep(2); - } - return NULL; + (void) arg; + Data data; + data.donnees[0] = 'g'; + data.donnees[1] = 'o'; + //uint8_t paquet[]; + sock_udp_ep_t remote = { .family = AF_INET6 }; + + remote.port = 1234; + remote.addr.ipv6[0] = 0xde; + remote.addr.ipv6[1] = 0xad; + remote.addr.ipv6[2] = 0xbe; + remote.addr.ipv6[3] = 0xef; + remote.addr.ipv6[14] = 0x34; + remote.addr.ipv6[15] = 0x12; + // memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN); + while (1) { + // //ipv6_addr_set_all_nodes_multicast((ipv6_addr_t *)&remote.addr.ipv6, + // // IPV6_ADDR_MCAST_SCP_LINK_LOCAL); + data.heure_actuelle = xtimer_now_usec(); + + if (sock_udp_send(NULL, &data, sizeof(data), &remote) < 0) { + puts("Error sending message"); + } + puts("Send a message"); + xtimer_sleep(2); + } + return NULL; } static void arret_urgence(void *arg,int channel) { pwm_set(PWM_DEV(0),1,0); tourne = 0; - //ordre=0; timer_run = 0; printf("Arret d'urgence\n"); } @@ -300,94 +286,92 @@ static void arret_urgence(void *arg,int channel) static void _init_timer(void) { - printf("ok timer\n"); - //timer_init(XTIMER_DEV, CLOCK_CORECLOCK/2 ,°radation,NULL); - //timer_set(XTIMER_DEV, 0, 8400); - //timer_irq_enable(XTIMER_DEV); - timer_init(TIMER_DEV(1), CLOCK_CORECLOCK/2 ,&arret_urgence,NULL); - timer_irq_enable(TIMER_DEV(1)); + printf("ok timer\n"); + //timer_init(XTIMER_DEV, CLOCK_CORECLOCK/2 ,°radation,NULL); + //timer_set(XTIMER_DEV, 0, 8400); + //timer_irq_enable(XTIMER_DEV); + timer_init(TIMER_DEV(1), CLOCK_CORECLOCK/2 ,&arret_urgence,NULL); + timer_irq_enable(TIMER_DEV(1)); } static void _init_pwm(void) { - pwm_init(PWM_DEV(0), PWM_LEFT, PWM_FREQ, PWM_RES); - pwm_set(PWM_DEV(0),1,0); - -// thread_create(pwm_stack,sizeof(pwm_stack),7,THREAD_CREATE_STACKTEST,pwm_thread,NULL,"pwm_thread"); + pwm_init(PWM_DEV(0), PWM_LEFT, PWM_FREQ, PWM_RES); + pwm_set(PWM_DEV(0),1,0); } - - -static void _init_interface(void) -{ - kernel_pid_t ifs[GNRC_NETIF_NUMOF]; - ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED; - ipv6_addr_t tmp_addr= IPV6_ADDR_UNSPECIFIED; - uint8_t hwaddr[MAX_ADDR_LEN]; - int res; - - gnrc_netif_get(ifs); - - //addresses gobales - addr.u8[0] = 0xde; - addr.u8[1] = 0xad; - addr.u8[2] = 0xbe; - addr.u8[3] = 0xef; - - res = gnrc_netapi_get(ifs[0], NETOPT_ADDRESS, 0, hwaddr, sizeof(hwaddr)); + static void _init_interface(void) + { + kernel_pid_t ifs[GNRC_NETIF_NUMOF]; + ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED; + ipv6_addr_t tmp_addr= IPV6_ADDR_UNSPECIFIED; + uint8_t hwaddr[MAX_ADDR_LEN]; + int res; + + gnrc_netif_get(ifs); + + //addresses gobales + addr.u8[0] = 0xde; + addr.u8[1] = 0xad; + addr.u8[2] = 0xbe; + addr.u8[3] = 0xef; + + res = gnrc_netapi_get(ifs[0], NETOPT_ADDRESS, 0, hwaddr, sizeof(hwaddr)); + + if (res >= 0) { + addr.u8[14] = *hwaddr; + addr.u8[15] = *(hwaddr+1); + } + memcpy(tmp_addr.u8,addr.u8,IPV6_ADDR_BIT_LEN); + + gnrc_ipv6_netif_add_addr(ifs[0], &addr, 64, GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST); + /* model ipv6 addr: dead:beef::Hwaddr */ + if((addr.u8[14]==0x34)&&(addr.u8[15]==0x02)){ + + tmp_addr.u8[14] = 0x34; + tmp_addr.u8[15] = 0x12; + //fibroute dest: dead:beef::3766 via fe80::3634:5110:3473:3762 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); + tmp_addr.u8[14] = 0x37; + tmp_addr.u8[15] = 0x62; + //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); + client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread"); + xtimer_usleep(10000); + time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),6,THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread"); + xtimer_usleep(200); + }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){ + tmp_addr.u8[14] = 0x34; + tmp_addr.u8[15] = 0x12; + //fibroute dest: dead:beef::3766 via fe80::3634:5110:3471:3766 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node3, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); + tmp_addr.u8[14] = 0x34; + tmp_addr.u8[15] = 0x02; + //fibroute dest: dead:beef::3402 via fe80::3734:510e:3317:3402 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node1, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); + //sntp_sync(&local,5000); + //printf("temps : %i\n",(int)sntp_get_offset()); + }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x12)){ + tmp_addr.u8[14] = 0x34; + tmp_addr.u8[15] = 0x02; + //fibroute dest: dead:beef::3402 via fe80::3634:5110:3473:3762 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); tmp_addr.u8[14] = 0x37; + tmp_addr.u8[14] = 0x37; + tmp_addr.u8[15] = 0x62; + //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); + //start_server("1234"); + _init_timer(); + _init_pwm(); + server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread"); + + + }else{ + puts("new node ?"); + } + } - if (res >= 0) { - addr.u8[14] = *hwaddr; - addr.u8[15] = *(hwaddr+1); - } - memcpy(tmp_addr.u8,addr.u8,IPV6_ADDR_BIT_LEN); - - gnrc_ipv6_netif_add_addr(ifs[0], &addr, 64, GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST); - /* model ipv6 addr: dead:beef::Hwaddr */ - if((addr.u8[14]==0x34)&&(addr.u8[15]==0x02)){ - - tmp_addr.u8[14] = 0x37; - tmp_addr.u8[15] = 0x66; - //fibroute dest: dead:beef::3766 via fe80::3634:5110:3473:3762 - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); - tmp_addr.u8[14] = 0x37; - tmp_addr.u8[15] = 0x62; - //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); - client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread"); - xtimer_usleep(10000); - time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),6,THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread"); - xtimer_usleep(200); - }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){ - tmp_addr.u8[14] = 0x37; - tmp_addr.u8[15] = 0x66; - //fibroute dest: dead:beef::3766 via fe80::3634:5110:3471:3766 - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node3, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); - tmp_addr.u8[14] = 0x34; - tmp_addr.u8[15] = 0x02; - //fibroute dest: dead:beef::3402 via fe80::3734:510e:3317:3402 - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node1, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); - //sntp_sync(&local,5000); - //printf("temps : %i\n",(int)sntp_get_offset()); - }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x66)){ - tmp_addr.u8[14] = 0x34; - tmp_addr.u8[15] = 0x02; - //fibroute dest: dead:beef::3402 via fe80::3634:5110:3473:3762 - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); tmp_addr.u8[14] = 0x37; - tmp_addr.u8[15] = 0x62; - //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); - //start_server("1234"); - _init_timer(); - _init_pwm(); - server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread"); - - - }else{ - puts("new node ?"); - } -} static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; extern int udp_cmd(int argc, char **argv); diff --git a/RIOT/examples/real_time_app/udp.c b/RIOT/examples/real_time_app/udp.c old mode 100644 new mode 100755 index 74189c1..74189c1 --- a/RIOT/examples/real_time_app/udp.c +++ b/RIOT/examples/real_time_app/udp.c diff --git a/RIOT/examples/static_network_app_sock_udp/Makefile b/RIOT/examples/static_network_app_sock_udp/Makefile old mode 100644 new mode 100755 index c29f824..c29f824 --- a/RIOT/examples/static_network_app_sock_udp/Makefile +++ b/RIOT/examples/static_network_app_sock_udp/Makefile diff --git a/RIOT/examples/static_network_app_sock_udp/main.c b/RIOT/examples/static_network_app_sock_udp/main.c old mode 100644 new mode 100755 index 1720a92..1720a92 --- a/RIOT/examples/static_network_app_sock_udp/main.c +++ b/RIOT/examples/static_network_app_sock_udp/main.c -- libgit2 0.21.2