Commit ceb4c7ca1fadbca1cb64d0cbc54d829670291fd7

Authored by root
1 parent 3aa9dc85

changement carte pour 3eme noeud

RIOT/examples/dynamic_app/Makefile 100644 → 100755
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
101 101 // addr ipv6 link local node 2: fe80::3634:5110:3473:3762
102 102 uint8_t node2[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x34,0x51,0x10,0x34,0x73,0x37,0x62};
103 103 // addr ipv6 link local node 3: fe80::3734:510e:330b:342a
104   -uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0e,0x33,0x0b,0x34,0x2a};
  104 +uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x33,0x47,0x11,0x37,0x2c,0x34,0x12};
105 105 // addr ipv6 link local node 4: fe80::3734:510b:330b:340a
106 106 uint8_t node4[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0b,0x33,0x0b,0x34,0x0a};
107 107 // addr ipv6 link local node 5: fe80::3734:510b:330a:341e
... ... @@ -125,7 +125,7 @@ sock_udp_ep_t local = SOCK_IPV6_EP_ANY;
125 125 sock_udp_t sock;
126 126 sock_udp_ep_t local_ntp = SOCK_IPV6_EP_ANY;
127 127 sock_udp_t sock_ntp;
128   -static ntp_packet_t sntp_packet;
  128 +//static ntp_packet_t sntp_packet;
129 129  
130 130 typedef struct tableau {
131 131 uint32_t heure_actuelle;
... ... @@ -158,7 +158,7 @@ int crea_rpl_dodag_root(char *arg1, char *arg2)
158 158 }
159 159 /***************** /RPL functions ****************/
160 160  
161   -void *sock_time_server_thread(void *arg)
  161 +/*void *sock_time_server_thread(void *arg)
162 162 {
163 163 (void) arg;
164 164 local_ntp.port = NTP_PORT;
... ... @@ -194,37 +194,15 @@ void *sock_time_server_thread(void *arg)
194 194 }
195 195 }
196 196 return NULL;
197   -}
198   -/*void *pwm_thread(void *arg)
199   -{
200   - (void) arg;
201   - int tourne = 0;
202   - while(1)
203   - {
204   -
205   - if(ordre==1)
206   - {
207   - pwm_set(PWM_DEV(0),1,45);
208   - tourne = 1;
209   - }
210   - else if(ordre==0)
211   - {
212   - pwm_set(PWM_DEV(0),1,0);
213   - tourne = 0;
214   - }
215   - else if(ordre==2 && tourne == 1)
216   - pwm_set(PWM_DEV(0),1,31);
217   -
218   - }
219   - return NULL;
220 197 }*/
221 198  
  199 +
222 200 void *sock_server_thread(void *arg)
223 201 {
224 202 (void) arg;
225 203 Data buf;
226   - int compteur = 5;
227   - int deadline;
  204 + // int compteur = 5;
  205 + // int deadline;
228 206 local.port = 1234;
229 207 sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 };
230 208 ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "dead:beef::3402");
... ... @@ -233,12 +211,12 @@ void *sock_server_thread(void *arg)
233 211 puts("Error creating UDP sock");
234 212 return NULL;
235 213 }
236   - if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) {
  214 + /*if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) {
237 215 puts("Error in synchronization");
238 216 return NULL;
239 217 }
240 218 offset = sntp_get_offset();
241   - printf("offset : %i\n",(int)offset);
  219 + printf("offset : %i\n",(int)offset);*/
242 220  
243 221 while (1) {
244 222 sock_udp_ep_t remote;
... ... @@ -246,13 +224,13 @@ void *sock_server_thread(void *arg)
246 224  
247 225 if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT,
248 226 &remote)) >= 0) {
249   - // puts("Received a message");
  227 + puts("Received a message");
250 228 //printf("%s\n",buf);
251 229 /*if (sock_udp_send(&sock, buf, res, &remote) < 0) {
252 230 puts("Error sending reply");
253 231 }*/
254 232  
255   - deadline = xtimer_now_usec() + offset - buf.heure_actuelle;
  233 + /*deadline = xtimer_now_usec() + offset - buf.heure_actuelle;
256 234 printf("tps de transmission : %i\n",deadline);
257 235  
258 236 if(deadline >= DEADLINE && compteur >=5)
... ... @@ -287,14 +265,14 @@ void *sock_server_thread(void *arg)
287 265 }
288 266  
289 267 printf("compteur : %d\n",compteur);
290   - memset(&buf,0,sizeof(buf));
  268 + memset(&buf,0,sizeof(buf));*/
291 269 }
292 270 }
293 271 return NULL;
294 272 }
295 273  
296 274  
297   -/*void *sock_client_thread(void *arg)
  275 +void *sock_client_thread(void *arg)
298 276 {
299 277 (void) arg;
300 278 Data data;
... ... @@ -309,7 +287,7 @@ void *sock_server_thread(void *arg)
309 287 remote.addr.ipv6[2] = 0xbe;
310 288 remote.addr.ipv6[3] = 0xef;
311 289 remote.addr.ipv6[14] = 0x34;
312   - remote.addr.ipv6[15] = 0x2a;
  290 + remote.addr.ipv6[15] = 0x1e;
313 291 // memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN);
314 292 while (1) {
315 293 // //ipv6_addr_set_all_nodes_multicast((ipv6_addr_t *)&remote.addr.ipv6,
... ... @@ -319,10 +297,11 @@ void *sock_server_thread(void *arg)
319 297 if (sock_udp_send(NULL, &data, sizeof(data), &remote) < 0) {
320 298 puts("Error sending message");
321 299 }
  300 + puts("Send a message");
322 301 xtimer_sleep(2);
323 302 }
324 303 return NULL;
325   -}*/
  304 +}
326 305  
327 306 /*static void arret_urgence(void *arg,int channel)
328 307 {
... ... @@ -392,19 +371,20 @@ static void _init_interface(void)
392 371 /* model ipv6 addr: dead:beef::Hwaddr */
393 372 if((addr.u8[14]==0x34)&&(addr.u8[15]==0x02)){
394 373 crea_rpl_dodag_root("1", "dead:beef::3402");
395   - /*client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread");
396   - xtimer_usleep(200);*/
397   - 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");
398   - xtimer_usleep(200);
  374 + client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread");
  375 + // xtimer_usleep(200);
  376 + //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");
  377 + // xtimer_usleep(200);
399 378 }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){
400 379  
401   - }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x2a)){
  380 + }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x12)){
402 381 //_init_timer();
403 382 //_init_pwm();
404 383 /*server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");*/
405 384  
406 385 }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x0a)){
407 386 }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x1e)){
  387 + server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");
408 388 }else{
409 389 puts("new node ?");
410 390 }
... ...
RIOT/examples/dynamic_app/udp.c 100644 → 100755
RIOT/examples/real_time_app/Makefile 100644 → 100755
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
87 87 // addr ipv6 link local node 2: fe80::3634:5110:3473:3762
88 88 uint8_t node2[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x34,0x51,0x10,0x34,0x73,0x37,0x62};
89 89 //addr ipv6 link local node 3: fe80::3634:5110:3471:3766
90   -uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x34,0x51,0x10,0x34,0x71,0x37,0x66};
  90 +uint8_t node3[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x33,0x47,0x11,0x37,0x2c,0x34,0x12};
91 91  
92 92 //static char _stack_server[GNRC_PKTDUMP_STACKSIZE];
93 93 char pwm_stack[THREAD_STACKSIZE_MAIN];
... ... @@ -120,36 +120,36 @@ void *sock_time_server_thread(void *arg)
120 120 {
121 121 (void) arg;
122 122 local_ntp.port = NTP_PORT;
123   -
  123 +
124 124 if (sock_udp_create(&sock_ntp, &local_ntp, NULL, 0) < 0) {
125   - puts("Error creating UDP sock");
126   - return NULL;
  125 + puts("Error creating UDP sock");
  126 + return NULL;
127 127 }
128   -
  128 +
129 129 while (1) {
130   - sock_udp_ep_t remote;
131   - ssize_t res;
132   -
133   - if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT,
134   - &remote)) >= 0) {
135   - puts("Received a message");
136   - //printf("TT: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
137   -
138   - // printf("%c\n",remote.addr.ipv6[15]);
139   - //xtimer_ticks64_t now = xtimer_now64();
140   - // heure actuelle du serveur
141   - sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec());
142   - sntp_packet.origin.seconds=sntp_packet.transmit.seconds;
143   - sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec());
144   - //printf("heure actuelle : %lu\n",xtimer_now_usec());
145   - //printf("TT2: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
146   - //memset(&sntp_packet, 0, sizeof(sntp_packet));
147   - //ntp_packet_set_vn(&sntp_packet);
148   - //ntp_packet_set_mode(&sntp_packet, NTP_MODE_SERVER);
149   - if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) {
150   - puts("Error sending reply");
151   - }
152   - }
  130 + sock_udp_ep_t remote;
  131 + ssize_t res;
  132 +
  133 + if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT,
  134 + &remote)) >= 0) {
  135 + puts("Received a message");
  136 + //printf("TT: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
  137 +
  138 + // printf("%c\n",remote.addr.ipv6[15]);
  139 + //xtimer_ticks64_t now = xtimer_now64();
  140 + // heure actuelle du serveur
  141 + sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec());
  142 + sntp_packet.origin.seconds=sntp_packet.transmit.seconds;
  143 + sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec());
  144 + //printf("heure actuelle : %lu\n",xtimer_now_usec());
  145 + //printf("TT2: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
  146 + //memset(&sntp_packet, 0, sizeof(sntp_packet));
  147 + //ntp_packet_set_vn(&sntp_packet);
  148 + //ntp_packet_set_mode(&sntp_packet, NTP_MODE_SERVER);
  149 + if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) {
  150 + puts("Error sending reply");
  151 + }
  152 + }
153 153 }
154 154 return NULL;
155 155 }
... ... @@ -179,113 +179,99 @@ void *sock_time_server_thread(void *arg)
179 179  
180 180 void *sock_server_thread(void *arg)
181 181 {
182   - (void) arg;
183   - Data buf;
184   - int compteur = 5;
185   - int deadline;
186   - local.port = 1234;
187   - sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 };
188   - ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "dead:beef::3402");
189   -
190   - if (sock_udp_create(&sock, &local, NULL, 0) < 0) {
191   - puts("Error creating UDP sock");
192   - return NULL;
193   - }
194   - if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) {
195   - puts("Error in synchronization");
196   - return NULL;
197   - }
198   - offset = sntp_get_offset();
199   - printf("offset : %i\n",(int)offset);
  182 + (void) arg;
  183 + Data buf;
  184 + int compteur = 5;
  185 + int deadline;
  186 + local.port = 1234;
  187 + sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 };
  188 + ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "dead:beef::3402");
200 189  
201   - while (1) {
202   - sock_udp_ep_t remote;
203   - ssize_t res;
204   -
205   - if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT,
206   - &remote)) >= 0) {
207   - // puts("Received a message");
208   - //printf("%s\n",buf);
209   - /*if (sock_udp_send(&sock, buf, res, &remote) < 0) {
210   - puts("Error sending reply");
211   - }*/
212   -
213   - deadline = xtimer_now_usec() + offset - buf.heure_actuelle;
214   - printf("tps de transmission : %i\n",deadline);
215   -
216   - if(deadline >= DEADLINE && compteur >=5)
217   - {
218   - //ordre = 2;
219   - compteur = 0;
220   - if(tourne == 1)
221   - pwm_set(PWM_DEV(0),1,31);
222   - if(timer_run == 0)
223   - {
224   - timer_set(TIMER_DEV(1),0,25200);
225   - printf("relance timer\n");
226   - timer_run = 1;
227   - }
228   - }
229   - if(deadline >= DEADLINE && compteur < 5)
230   - {
231   - compteur = 0;
232   - }
233   - if(deadline<=DEADLINE && compteur >=5)
234   - {
235   - //ordre = 1;
236   - pwm_set(PWM_DEV(0),1,45);
237   - tourne = 1;
238   - timer_run=0;
239   - timer_clear(TIMER_DEV(1),0);
240   - printf("clear timer\n");
241   - }
242   - if(deadline<=DEADLINE && compteur <5)
243   - {
244   - compteur++;
245   - }
246   -
247   - printf("compteur : %d\n",compteur);
248   - memset(&buf,0,sizeof(buf));
  190 + if (sock_udp_create(&sock, &local, NULL, 0) < 0) {
  191 + puts("Error creating UDP sock");
  192 + return NULL;
  193 + }
  194 + if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) {
  195 + puts("Error in synchronization");
  196 + return NULL;
  197 + }
  198 + offset = sntp_get_offset();
  199 + printf("offset : %i\n",(int)offset);
  200 +
  201 + while (1) {
  202 + sock_udp_ep_t remote;
  203 + ssize_t res;
  204 + if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT,&remote)) >= 0) {
  205 + deadline = xtimer_now_usec() + offset - buf.heure_actuelle;
  206 + printf("tps de transmission : %i\n",deadline);
  207 +
  208 + if(buf.donnees[0] == 'g' && buf.donnees[1] == 'o') {
  209 + if(deadline >= DEADLINE && compteur >=5) {
  210 + compteur = 0;
  211 + if(tourne == 1)
  212 + pwm_set(PWM_DEV(0),1,31);
  213 + if(timer_run == 0) {
  214 + timer_set(TIMER_DEV(1),0,25200);
  215 + printf("relance timer\n");
  216 + timer_run = 1;
  217 + }
  218 + }
  219 + if(deadline >= DEADLINE && compteur < 5) {
  220 + compteur = 0;
  221 + }
  222 + if(deadline<=DEADLINE && compteur >=5) {
  223 + pwm_set(PWM_DEV(0),1,45);
  224 + tourne = 1;
  225 + timer_run=0;
  226 + timer_clear(TIMER_DEV(1),0);
  227 + printf("clear timer\n");
  228 + }
  229 + if(deadline<=DEADLINE && compteur <5) {
  230 + compteur++;
  231 + }
  232 + printf("compteur : %d\n",compteur);
  233 + memset(&buf,0,sizeof(buf));
249 234 }
250 235 }
  236 + }
251 237 return NULL;
252 238 }
253 239  
254 240 void *sock_client_thread(void *arg)
255 241 {
256   - (void) arg;
257   - Data data;
258   - data.donnees[0] = 'g';
259   - data.donnees[1] = 'o';
260   - //uint8_t paquet[];
261   - sock_udp_ep_t remote = { .family = AF_INET6 };
262   -
263   - remote.port = 1234;
264   - remote.addr.ipv6[0] = 0xde;
265   - remote.addr.ipv6[1] = 0xad;
266   - remote.addr.ipv6[2] = 0xbe;
267   - remote.addr.ipv6[3] = 0xef;
268   - remote.addr.ipv6[14] = 0x37;
269   - remote.addr.ipv6[15] = 0x66;
270   -// memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN);
271   - while (1) {
272   -// //ipv6_addr_set_all_nodes_multicast((ipv6_addr_t *)&remote.addr.ipv6,
273   -// // IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
274   - data.heure_actuelle = xtimer_now_usec();
275   -
276   - if (sock_udp_send(NULL, &data, sizeof(data), &remote) < 0) {
277   - puts("Error sending message");
278   - }
279   - xtimer_sleep(2);
280   - }
281   - return NULL;
  242 + (void) arg;
  243 + Data data;
  244 + data.donnees[0] = 'g';
  245 + data.donnees[1] = 'o';
  246 + //uint8_t paquet[];
  247 + sock_udp_ep_t remote = { .family = AF_INET6 };
  248 +
  249 + remote.port = 1234;
  250 + remote.addr.ipv6[0] = 0xde;
  251 + remote.addr.ipv6[1] = 0xad;
  252 + remote.addr.ipv6[2] = 0xbe;
  253 + remote.addr.ipv6[3] = 0xef;
  254 + remote.addr.ipv6[14] = 0x34;
  255 + remote.addr.ipv6[15] = 0x12;
  256 + // memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN);
  257 + while (1) {
  258 + // //ipv6_addr_set_all_nodes_multicast((ipv6_addr_t *)&remote.addr.ipv6,
  259 + // // IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
  260 + data.heure_actuelle = xtimer_now_usec();
  261 +
  262 + if (sock_udp_send(NULL, &data, sizeof(data), &remote) < 0) {
  263 + puts("Error sending message");
  264 + }
  265 + puts("Send a message");
  266 + xtimer_sleep(2);
  267 + }
  268 + return NULL;
282 269 }
283 270  
284 271 static void arret_urgence(void *arg,int channel)
285 272 {
286 273 pwm_set(PWM_DEV(0),1,0);
287 274 tourne = 0;
288   - //ordre=0;
289 275 timer_run = 0;
290 276 printf("Arret d'urgence\n");
291 277 }
... ... @@ -300,94 +286,92 @@ static void arret_urgence(void *arg,int channel)
300 286  
301 287 static void _init_timer(void)
302 288 {
303   - printf("ok timer\n");
304   - //timer_init(XTIMER_DEV, CLOCK_CORECLOCK/2 ,&degradation,NULL);
305   - //timer_set(XTIMER_DEV, 0, 8400);
306   - //timer_irq_enable(XTIMER_DEV);
307   - timer_init(TIMER_DEV(1), CLOCK_CORECLOCK/2 ,&arret_urgence,NULL);
308   - timer_irq_enable(TIMER_DEV(1));
  289 + printf("ok timer\n");
  290 + //timer_init(XTIMER_DEV, CLOCK_CORECLOCK/2 ,&degradation,NULL);
  291 + //timer_set(XTIMER_DEV, 0, 8400);
  292 + //timer_irq_enable(XTIMER_DEV);
  293 + timer_init(TIMER_DEV(1), CLOCK_CORECLOCK/2 ,&arret_urgence,NULL);
  294 + timer_irq_enable(TIMER_DEV(1));
309 295 }
310 296  
311 297 static void _init_pwm(void)
312 298 {
313   - pwm_init(PWM_DEV(0), PWM_LEFT, PWM_FREQ, PWM_RES);
314   - pwm_set(PWM_DEV(0),1,0);
315   -
316   -// thread_create(pwm_stack,sizeof(pwm_stack),7,THREAD_CREATE_STACKTEST,pwm_thread,NULL,"pwm_thread");
  299 + pwm_init(PWM_DEV(0), PWM_LEFT, PWM_FREQ, PWM_RES);
  300 + pwm_set(PWM_DEV(0),1,0);
317 301 }
318 302  
319   -
320   -
321 303  
322   -static void _init_interface(void)
323   -{
324   - kernel_pid_t ifs[GNRC_NETIF_NUMOF];
325   - ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED;
326   - ipv6_addr_t tmp_addr= IPV6_ADDR_UNSPECIFIED;
327   - uint8_t hwaddr[MAX_ADDR_LEN];
328   - int res;
329   -
330   - gnrc_netif_get(ifs);
331   -
332   - //addresses gobales
333   - addr.u8[0] = 0xde;
334   - addr.u8[1] = 0xad;
335   - addr.u8[2] = 0xbe;
336   - addr.u8[3] = 0xef;
337   -
338   - res = gnrc_netapi_get(ifs[0], NETOPT_ADDRESS, 0, hwaddr, sizeof(hwaddr));
  304 + static void _init_interface(void)
  305 + {
  306 + kernel_pid_t ifs[GNRC_NETIF_NUMOF];
  307 + ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED;
  308 + ipv6_addr_t tmp_addr= IPV6_ADDR_UNSPECIFIED;
  309 + uint8_t hwaddr[MAX_ADDR_LEN];
  310 + int res;
  311 +
  312 + gnrc_netif_get(ifs);
  313 +
  314 + //addresses gobales
  315 + addr.u8[0] = 0xde;
  316 + addr.u8[1] = 0xad;
  317 + addr.u8[2] = 0xbe;
  318 + addr.u8[3] = 0xef;
  319 +
  320 + res = gnrc_netapi_get(ifs[0], NETOPT_ADDRESS, 0, hwaddr, sizeof(hwaddr));
  321 +
  322 + if (res >= 0) {
  323 + addr.u8[14] = *hwaddr;
  324 + addr.u8[15] = *(hwaddr+1);
  325 + }
  326 + memcpy(tmp_addr.u8,addr.u8,IPV6_ADDR_BIT_LEN);
  327 +
  328 + gnrc_ipv6_netif_add_addr(ifs[0], &addr, 64, GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST);
  329 + /* model ipv6 addr: dead:beef::Hwaddr */
  330 + if((addr.u8[14]==0x34)&&(addr.u8[15]==0x02)){
  331 +
  332 + tmp_addr.u8[14] = 0x34;
  333 + tmp_addr.u8[15] = 0x12;
  334 + //fibroute dest: dead:beef::3766 via fe80::3634:5110:3473:3762
  335 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
  336 + tmp_addr.u8[14] = 0x37;
  337 + tmp_addr.u8[15] = 0x62;
  338 + //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762
  339 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
  340 + client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread");
  341 + xtimer_usleep(10000);
  342 + 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");
  343 + xtimer_usleep(200);
  344 + }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){
  345 + tmp_addr.u8[14] = 0x34;
  346 + tmp_addr.u8[15] = 0x12;
  347 + //fibroute dest: dead:beef::3766 via fe80::3634:5110:3471:3766
  348 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node3, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
  349 + tmp_addr.u8[14] = 0x34;
  350 + tmp_addr.u8[15] = 0x02;
  351 + //fibroute dest: dead:beef::3402 via fe80::3734:510e:3317:3402
  352 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node1, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
  353 + //sntp_sync(&local,5000);
  354 + //printf("temps : %i\n",(int)sntp_get_offset());
  355 + }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x12)){
  356 + tmp_addr.u8[14] = 0x34;
  357 + tmp_addr.u8[15] = 0x02;
  358 + //fibroute dest: dead:beef::3402 via fe80::3634:5110:3473:3762
  359 + 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;
  360 + tmp_addr.u8[14] = 0x37;
  361 + tmp_addr.u8[15] = 0x62;
  362 + //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762
  363 + fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
  364 + //start_server("1234");
  365 + _init_timer();
  366 + _init_pwm();
  367 + server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");
  368 +
  369 +
  370 + }else{
  371 + puts("new node ?");
  372 + }
  373 + }
339 374  
340   - if (res >= 0) {
341   - addr.u8[14] = *hwaddr;
342   - addr.u8[15] = *(hwaddr+1);
343   - }
344   - memcpy(tmp_addr.u8,addr.u8,IPV6_ADDR_BIT_LEN);
345   -
346   - gnrc_ipv6_netif_add_addr(ifs[0], &addr, 64, GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST);
347   - /* model ipv6 addr: dead:beef::Hwaddr */
348   - if((addr.u8[14]==0x34)&&(addr.u8[15]==0x02)){
349   -
350   - tmp_addr.u8[14] = 0x37;
351   - tmp_addr.u8[15] = 0x66;
352   - //fibroute dest: dead:beef::3766 via fe80::3634:5110:3473:3762
353   - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
354   - tmp_addr.u8[14] = 0x37;
355   - tmp_addr.u8[15] = 0x62;
356   - //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762
357   - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
358   - client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread");
359   - xtimer_usleep(10000);
360   - 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");
361   - xtimer_usleep(200);
362   - }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){
363   - tmp_addr.u8[14] = 0x37;
364   - tmp_addr.u8[15] = 0x66;
365   - //fibroute dest: dead:beef::3766 via fe80::3634:5110:3471:3766
366   - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node3, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
367   - tmp_addr.u8[14] = 0x34;
368   - tmp_addr.u8[15] = 0x02;
369   - //fibroute dest: dead:beef::3402 via fe80::3734:510e:3317:3402
370   - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node1, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
371   - //sntp_sync(&local,5000);
372   - //printf("temps : %i\n",(int)sntp_get_offset());
373   - }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x66)){
374   - tmp_addr.u8[14] = 0x34;
375   - tmp_addr.u8[15] = 0x02;
376   - //fibroute dest: dead:beef::3402 via fe80::3634:5110:3473:3762
377   - 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;
378   - tmp_addr.u8[15] = 0x62;
379   - //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762
380   - fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
381   - //start_server("1234");
382   - _init_timer();
383   - _init_pwm();
384   - server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");
385   -
386   -
387   - }else{
388   - puts("new node ?");
389   - }
390   -}
391 375 static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
392 376  
393 377 extern int udp_cmd(int argc, char **argv);
... ...
RIOT/examples/real_time_app/udp.c 100644 → 100755
RIOT/examples/static_network_app_sock_udp/Makefile 100644 → 100755
RIOT/examples/static_network_app_sock_udp/main.c 100644 → 100755