/*---------------------------------------------------------------------------*/ void uip_netif_init(void) { /* INITIALIZE INTERFACE (default values for now) */ uip_netif_physical_if.link_mtu = UIP_LINK_MTU; uip_netif_physical_if.cur_hop_limit = UIP_TTL; uip_netif_physical_if.base_reachable_time = UIP_ND6_REACHABLE_TIME; uip_netif_physical_if.reachable_time = uip_netif_compute_reachable_time(); uip_netif_physical_if.retrans_timer = UIP_ND6_RETRANS_TIMER; uip_netif_physical_if.dup_addr_detect_transmit = 1; /* * STATELESS AUTOCONFIGURATION of the link local address. We set it to * infinite (this will become really true once DAD succeeds) */ uip_ip6addr(&(uip_netif_physical_if.addresses[0].ipaddr), 0xfe80,0,0,0,0,0,0,0); uip_netif_addr_autoconf_set(&(uip_netif_physical_if.addresses[0].ipaddr), &uip_lladdr); uip_netif_physical_if.addresses[0].state = TENTATIVE; uip_netif_physical_if.addresses[0].type = MANUAL; uip_netif_physical_if.addresses[0].is_infinite = 1; /* set all other addresses to NOT_USED initialy */ for(i = 1; i < UIP_CONF_NETIF_MAX_ADDRESSES; i ++) uip_netif_physical_if.addresses[i].state = NOT_USED; uip_ip6addr_u8(&(uip_netif_physical_if.solicited_node_mcastaddr), 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xff, uip_lladdr.addr[UIP_LLADDR_LEN - 3], uip_lladdr.addr[UIP_LLADDR_LEN - 2], uip_lladdr.addr[UIP_LLADDR_LEN - 1]); /* Start DAD */ uip_netif_sched_dad(&(uip_netif_physical_if.addresses[0])); /* Find router (send rs to all-routers multicast group)) */ uip_netif_sched_send_rs(); /* Reset the timer */ etimer_set(&uip_netif_timer_periodic, CLOCK_SECOND); }
PROCESS_THREAD(coap_app_client, ev, data) { PROCESS_BEGIN(); uip_ip6addr_u8(&server_ipaddr,0xfe,0x80,0,0,0,0,0,0,0xc0,0xa0,0x08,0x39,0xd1,0xe4,0x02,0x05); /* new connection with server */ client_conn = udp_new(&server_ipaddr, UIP_HTONS(REMOTE_PORT), NULL); udp_bind(client_conn, UIP_HTONS(LOCAL_PORT)); // UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); while(1) { PROCESS_YIELD(); if (ev == PROCESS_EVENT_CONTINUE) { send_data(); } else if (ev == tcpip_event) { sprintf(outStr_buf,"\r\nPacket received\r\n\r\n"); sendData_inBackground((uint8_t*)outStr_buf,strlen(outStr_buf),1,0); //handle_incoming_data(); } } PROCESS_END(); }