/*---------------------------------------------------------------------------*/ static u8_t udphandler(process_event_t ev, process_data_t data) { if(etimer_expired(&udp_periodic_timer)) { printf("Event timer expired\r\n"); count=0; } if(ev == tcpip_event) { if(uip_newdata()) { ((char *)uip_appdata)[uip_datalen()] = 0; printf("Sender received: '%s'\r\n", uip_appdata); } } if(count < UDP_NB) { count++; printf("Sender sending to: "); PRINT6ADDR(&udpconn->ripaddr); printf("\r\n"); #if SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION uip_udp_packet_send(udpconn, "Sender says Hi!", UIP_APPDATA_SIZE); #else /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */ uip_udp_packet_send(udpconn, "Sender says Hi!", strlen("Sender says Hi!")); #endif /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */ } etimer_set(&udp_periodic_timer, 13*CLOCK_SECOND + random_rand()%(4*CLOCK_SECOND)); return 0; }
static void dhcp_send_packet(struct uip_udp_conn *conn, const char *name, DhcpPacket *out, DhcpPacket *in) { // Send the outbound packet. printf("Sending %s... ", name); uip_udp_packet_send(conn, out, sizeof(*out)); printf("done.\n"); // Prepare for the reply. printf("Waiting for reply... "); dhcp_in = in; dhcp_out = out; dhcp_in_ready = 0; // Poll network driver until we get a reply. Resend periodically. net_set_callback(&dhcp_callback); for (;;) { uint64_t start = timer_us(0); do { net_poll(); } while (!dhcp_in_ready && timer_us(start) < DhcpRespTimeoutUs); if (dhcp_in_ready) break; // No response, try again. uip_udp_packet_send(conn, out, sizeof(*out)); } net_set_callback(NULL); printf("done.\n"); }
/*---------------------------------------------------------------------------*/ static void timeout_handler(void) { #if CONTIKI_TARGET_AVR_RAVEN char buf[48]; strlcpy_P(buf, ntpmsg, 48); uip_udp_packet_send(ntp_conn, buf, 48); #else uip_udp_packet_send(ntp_conn, ntpmsg, 48); #endif printf("send ntp packet \n"); }
static void timeout_handler(void) { static int seq_id; printf("Client sending to: "); PRINT6ADDR(&client_conn->ripaddr); sprintf(buf, "Hello %d from the client", ++seq_id); printf(" (msg: %s)\n", buf); #if SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION uip_udp_packet_send(client_conn, buf, UIP_APPDATA_SIZE); #else /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */ uip_udp_packet_send(client_conn, buf, strlen(buf)); #endif /* SEND_TOO_LARGE_PACKET_TO_TEST_FRAGMENTATION */ }
/*---------------------------------------------------------------------------*/ static void tcpip_handler(void) { memset(buf, 0, MAX_PAYLOAD_LEN); if(uip_newdata()) { len = uip_datalen(); memcpy(buf, uip_appdata, len); PRINTF("%u bytes from [", len); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("]:%u\n", UIP_HTONS(UIP_UDP_BUF->srcport)); len = read_sensor(buf); if( len ) { server_conn->rport = UIP_UDP_BUF->srcport; uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr); uip_udp_packet_send(server_conn, buf, len); PRINTF("Sent %u bytes\n", len); } /* Restore server connection to allow data from any node */ uip_create_unspecified(&server_conn->ripaddr); server_conn->rport = 0; } return; }
/*---------------------------------------------------------------------------*/ static void tcpip_handler(void) { memset(buf, 0, MAX_PAYLOAD_LEN); if(uip_newdata()) { leds_on(LEDS_RED); len = uip_datalen(); memcpy(buf, uip_appdata, len); PRINTF("%u bytes from [", len); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("]:%u", UIP_HTONS(UIP_UDP_BUF->srcport)); PRINTF(" V=%u", *buf); PRINTF(" I=%u", *(buf + 1)); PRINTF(" T=%u", *(buf + 2)); PRINTF(" Val=%u\n", *(uint16_t *)(buf + 3)); #if SERVER_REPLY uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr); server_conn->rport = UIP_UDP_BUF->srcport; uip_udp_packet_send(server_conn, buf, len); /* Restore server connection to allow data from any node */ uip_create_unspecified(&server_conn->ripaddr); server_conn->rport = 0; #endif } leds_off(LEDS_RED); PRINTF("sent\n"); return; }
static void send_unicast(uip_ipaddr_t *dest, char *buf, int size) { uip_ipaddr_copy(&client_conn->ripaddr, dest); uip_udp_packet_send(client_conn, buf, size); uip_create_unspecified(&client_conn->ripaddr); }
/*---------------------------------------------------------------------------*/ static void timeout_handler(void) { static int seq_id; struct uip_udp_conn *this_conn; leds_on(LEDS_RED); memset(buf, 0, MAX_PAYLOAD_LEN); seq_id++; /* evens / odds */ if(seq_id & 0x01) { this_conn = l_conn; } else { this_conn = g_conn; if(uip_ds6_get_global(ADDR_PREFERRED) == NULL) { return; } } PRINTF("Client to: "); PRINT6ADDR(&this_conn->ripaddr); memcpy(buf, &seq_id, sizeof(seq_id)); PRINTF(" Remote Port %u,", UIP_HTONS(this_conn->rport)); PRINTF(" (msg=0x%04x), %u bytes\n", *(uint16_t *) buf, sizeof(seq_id)); uip_udp_packet_send(this_conn, buf, sizeof(seq_id)); leds_off(LEDS_RED); }
/*---------------------------------------------------------------------------*/ static void tcpip_handler(void) { static int seq_id; char buf[MAX_PAYLOAD_LEN]; if(uip_newdata()) { ((char *)uip_appdata)[uip_datalen()] = 0; PRINTF("Server received: '%s' from ", (char *)uip_appdata); PRINT6ADDR(&UDP_IP_BUF->srcipaddr); PRINTF("\n"); uip_ipaddr_copy(&server_conn->ripaddr, &UDP_IP_BUF->srcipaddr); server_conn->rport = UDP_IP_BUF->srcport; PRINTF("Responding with message: "); sprintf(buf, "Hello from the server! (%d)", ++seq_id); PRINTF("%s\n", buf); uip_udp_packet_send(server_conn, buf, strlen(buf)); /* Restore server connection to allow data from any node */ memset(&server_conn->ripaddr, 0, sizeof(server_conn->ripaddr)); server_conn->rport = 0; } }
static void send_data() { int data_size = 0; static unsigned temperature; temperature = 21; clear_buffer(outputBuffer); clear_buffer(payload_buf); generate_payload(payload_buf,temperature); if(init_buffer(COAP_DATA_BUFF_SIZE)){ coap_packet_t* request =\ (coap_packet_t*)allocate_buffer(sizeof(coap_packet_t)); init_packet(request); coap_set_method(request, COAP_POST); request->tid = xact_id++; request->type = MESSAGE_TYPE_CON; coap_set_header_uri(request,service_uri); coap_set_option(request, Option_Type_Uri_Host, sizeof(char)*strlen(server_ip), (uint8_t*)server_ip); coap_set_option(request, Option_Type_Proxy_Uri, sizeof(char)*strlen(proxy_uri), (uint8_t*)proxy_uri); coap_set_payload(request,(uint8_t*)payload_buf, sizeof(char)*strlen(payload_buf)); data_size = serialize_packet(request, (uint8_t*)outputBuffer); PRINTF("Now sending request to base station ["); PRINTF(&client_conn->ripaddr); PRINTF("]:%u/%s\n",REMOTE_PORT,service_uri); uip_udp_packet_send(client_conn, outputBuffer, data_size); delete_buffer(); } }
static void tcpip_handler(void) { static int seq_id; char buf[MAX_PAYLOAD_LEN]; if(uip_newdata()) { ((char *)uip_appdata)[uip_datalen()] = 0; PRINTF("Server received: '%s' from ", (char *)uip_appdata); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("\n"); #if CETIC_NODE_INFO node_info_t *node = node_info_lookup(&UIP_IP_BUF->srcipaddr); if(node == NULL) { node = node_info_add(&UIP_IP_BUF->srcipaddr); } if(node != NULL) { node->last_lookup = clock_time(); strncpy(node->my_info, (char *)uip_appdata, sizeof(node->my_info) - 1); } #endif uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr); PRINTF("Responding with message: "); sprintf(buf, "Hello from the server! (%d)", ++seq_id); PRINTF("%s\n", buf); uip_udp_packet_send(server_conn, buf, strlen(buf)); /* Restore server connection to allow data from any node */ memset(&server_conn->ripaddr, 0, sizeof(server_conn->ripaddr)); } }
static void send_rreq(uip_ipaddr_t *addr) { struct uaodv_msg_rreq *rm = (struct uaodv_msg_rreq *)uip_appdata; int len; print_debug("send RREQ for %d.%d.%d.%d\n", uip_ipaddr_to_quad(addr)); rm->type = UAODV_RREQ_TYPE; rm->dest_seqno = last_known_seqno(addr); if(rm->dest_seqno == 0) rm->flags = UAODV_RREQ_UNKSEQNO; else rm->flags = 0; rm->reserved = 0; rm->hop_count = 0; rm->rreq_id = uip_htonl(rreq_id++); uip_ipaddr_copy(&rm->dest_addr, addr); uip_gethostaddr(&rm->orig_addr); my_hseqno++; /* Always */ rm->orig_seqno = uip_htonl(my_hseqno); bcastconn->ttl = MY_NET_DIAMETER; len = sizeof(struct uaodv_msg_rreq); len += add_rreq_extensions(rm + 1); uip_udp_packet_send(bcastconn, rm, len); }
/*---------------------------------------------------------------------------*/ static void handle_incoming_rerr(void) { struct uaodv_msg_rerr *rm = (struct uaodv_msg_rerr *)uip_appdata; struct uaodv_rt_entry *rt; print_debug("RERR %d.%d.%d.%d -> %d.%d.%d.%d" " unreach=%d.%d.%d.%d seq=%lu\n", uip_ipaddr_to_quad(&BUF->srcipaddr), uip_ipaddr_to_quad(&BUF->destipaddr), uip_ipaddr_to_quad((uip_ipaddr_t *)&rm->unreach[0]), uip_ntohl(rm->unreach[0].seqno)); if(uip_ipaddr_cmp(&rm->unreach[0].addr, &uip_hostaddr)) return; rt = uaodv_rt_lookup_any(&rm->unreach[0].addr); if(rt != NULL && uip_ipaddr_cmp(&rt->nexthop, uip_udp_sender())) { if((rm->flags & UAODV_RERR_UNKNOWN) || rm->unreach[0].seqno == 0 || SCMP32(rt->hseqno, uip_ntohl(rm->unreach[0].seqno)) <= 0) { rt->is_bad = 1; if(rm->flags & UAODV_RERR_UNKNOWN) { rm->flags &= ~UAODV_RERR_UNKNOWN; rm->unreach[0].seqno = uip_htonl(rt->hseqno); } print_debug("RERR rebroadcast\n"); uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rerr)); } } }
static void send_data(void) { char buf[MAX_PAYLOAD_LEN]; if (init_buffer(COAP_DATA_BUFF_SIZE)) { int data_size = 0; coap_packet_t* request = (coap_packet_t*)allocate_buffer(sizeof(coap_packet_t)); init_packet(request); coap_set_method(request, COAP_POST); request->tid = xact_id++; request->type = MESSAGE_TYPE_NON; coap_set_header_uri(request, service_url); data_size = serialize_packet(request, buf); // PRINTF("Client sending request to:["); // PRINT6ADDR(&client_conn->ripaddr); // PRINTF("]:%u/%s\n", (uint16_t)REMOTE_PORT, service_urls[service_id]); uip_udp_packet_send(client_conn, buf, data_size); delete_buffer(); } }
PROCESS_THREAD(udp_process, ev, data) { static struct uip_udp_conn *s; static struct etimer et; PROCESS_BEGIN(); uart0_set_br(1000000); /* setup udp connection */ s = udp_broadcast_new(UIP_HTONS(2020),NULL); // incoming udp_bind(s,UIP_HTONS(2020)); // outgoing /* start estimator process and init psock connection handler */ process_start(&ahrs_process, NULL); etimer_set(&et, SEND_INTERVAL); while(1) { PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER); uip_udp_packet_send(s,msg,strlen(msg)); etimer_restart(&et); } PROCESS_END(); }
/*---------------------------------------------------------------------------*/ static void tcpip_handler(void) { char *appdata; char buf[10]; if(uip_newdata()) { packets++; rssi_packets++; rssi_rec += packetbuf_attr(PACKETBUF_ATTR_RSSI) - 45; appdata = (char *)uip_appdata; appdata[uip_datalen()] = 0; PRINTF("DATA recv '%s' from ", appdata); PRINTF("%d", UIP_IP_BUF->srcipaddr.u8[sizeof(UIP_IP_BUF->srcipaddr.u8) - 1]); PRINTF("\n"); if(rssi_packets == 3) { /*PRINTF("packets_received = %d\n", packets);*/ sprintf(buf, "%d %u", rssi_rec / rssi_packets, packets); /*PRINTF("RSSI: %d, %d\n",rssi/rssi_packets, packets);*/ uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr); uip_udp_packet_send(server_conn, buf, strlen(buf)); uip_create_unspecified(&server_conn->ripaddr); rssi_packets = 0; rssi_rec = 0; } } }
/*---------------------------------------------------------------------------*/ static void trickle_tx(void *ptr, uint8_t suppress) { /* *ptr is a pointer to the trickle_timer that triggered this callback. In * his example we know that ptr points to tt. However, we pretend that we did * not know (which would be the case if we e.g. had multiple trickle timers) * and cast it to a local struct trickle_timer* */ struct trickle_timer *loc_tt = (struct trickle_timer *)ptr; if(suppress == TRICKLE_TIMER_TX_SUPPRESS) { return; } leds_on(LEDS_RED); PRINTF("At %lu (I=%lu, c=%u): ", (unsigned long)clock_time(), (unsigned long)loc_tt->i_cur, loc_tt->c); PRINTF("Trickle TX token 0x%02x\n", token); /* Instead of changing ->ripaddr around by ourselves, we could have used * uip_udp_packet_sendto which would have done it for us. However it puts an * extra ~20 bytes on stack and the cc2x3x micros hate it, so we stick with * send() */ /* Destination IP: link-local all-nodes multicast */ uip_ipaddr_copy(&trickle_conn->ripaddr, &ipaddr); uip_udp_packet_send(trickle_conn, &token, sizeof(token)); /* Restore to 'accept incoming from any IP' */ uip_create_unspecified(&trickle_conn->ripaddr); leds_off(LEDS_RED); }
/* Subscribe to the specified topic */ void mqtt_msg_publish(const char *topic, const char *data) { uint8_t header_size = 7; int i; uint8_t topic_id = 0; printf("Publish : %s %s\n", topic, data); if (mqtt.state != MQTT_STATE_CONNECTED) return; for (i = 0; i < mqtt.nb_topics; i++) { if (!strcmp(topic, mqtt.topics[i].name)) { topic_id = mqtt.topics[i].id; printf("topic_id found : %d\n", topic_id); } } mqtt.data[0] = (strlen(topic) + header_size); mqtt.data[1] = MQTT_MSG_PUBLISH; mqtt.data[2] = 0; mqtt.data[3] = (topic_id & 0xff00) >> 8; mqtt.data[4] = (topic_id & 0x00ff); mqtt.data[5] = 0; mqtt.data[6] = 0; memcpy(mqtt.data + header_size, data, strlen(data)); mqtt.len = (strlen(data) + header_size); mqtt.pending_msg = MQTT_MSG_PUBLISH; printf("Send packet topicid : %d\n", topic_id); uip_udp_packet_send(mqtt.udp_connection, mqtt.data, mqtt.len); }
/* Subscribe to the specified topic */ void mqtt_subscribe(const char *topic) { uint8_t header_size = 5; int i; printf("Subscribe : %s\n", topic); if (mqtt.state != MQTT_STATE_CONNECTED) return; for (i = 0; i < mqtt.nb_topics; i++) { if (!strcmp(topic, mqtt.topics[i].name)) { printf("Topic alread registered with id : %d\n", mqtt.topics[i].id); return; } } printf("Nb topics : %d\n", mqtt.nb_topics); mqtt.data[0] = (strlen(topic) + header_size); mqtt.data[1] = MQTT_MSG_SUBSCRIBE; mqtt.data[2] = 0; mqtt.data[3] = (0 & 0xff00) >> 8; mqtt.data[4] = (0 & 0x00ff); memcpy(mqtt.data + header_size, topic, strlen(topic)); mqtt.len = (strlen(topic) + header_size); mqtt.pending_msg = MQTT_MSG_SUBSCRIBE; strcpy(mqtt.topics[mqtt.nb_topics].name, topic); printf("Send packet\n"); uip_udp_packet_send(mqtt.udp_connection, mqtt.data, mqtt.len); }
static void send_broadcast(unsigned char *buf, int size) { printf("In send broadcast: \n"); uip_create_linklocal_allnodes_mcast(&udp_bconn->ripaddr); uip_udp_packet_send(udp_bconn, buf, size); uip_create_unspecified(&udp_bconn->ripaddr); }
/*----------------------------------------------------------------------------*/ static void _demo_udp_sendMsg(uint64_t seqID) { char pc_buf[MAX_S_PAYLOAD_LEN]; sprintf(pc_buf, "%d | OK", seqID); LOG_INFO("Respond with message: %s\n\r",pc_buf); uip_ipaddr_copy(&pst_conn->ripaddr, &UIP_IP_BUF->srcipaddr); uip_udp_packet_send(pst_conn, pc_buf, strlen(pc_buf)); uip_create_unspecified(&pst_conn->ripaddr); } /* _demo_udp_sendMsg */
PROCESS_THREAD(mqtt_process, ev, data) { char *str; static struct etimer periodic_timer; PROCESS_BEGIN(); topiclist = NULL; onewire_init(); while(1) { /* connect to the server */ PRINTF("mqtt: connecting...\n"); /* Create a new udp connection */ mqtt.udp_connection = udp_new(&mqtt.address, mqtt.port, NULL); if (mqtt.udp_connection != NULL) { PRINTF("Created a connection with the server "); PRINT6ADDR(&mqtt.udp_connection->ripaddr); PRINTF(" local/remote port %u/%u\n", UIP_HTONS(mqtt.udp_connection->lport), UIP_HTONS(mqtt.udp_connection->rport)); } else { PRINTF("Could not open connection\n"); } /* Send a connect message to the broker */ mqtt_msg_connect_send(&mqtt); PRINTF("send message CONNECT\n"); uip_udp_packet_send(mqtt.udp_connection, mqtt.data, mqtt.len); /* Initialize timer for keepalive */ printf("Keepalive : %d\n", mqtt.keepalive); etimer_set(&periodic_timer, mqtt.keepalive); /* We are not yet connected so disable keepalive timer for now */ //etimer_stop(&ping_timer); while(1) { PROCESS_WAIT_EVENT(); if (ev == tcpip_event && uip_newdata()) { str = uip_appdata; str[uip_datalen()] = '\0'; handle_mqtt_input(str); } else if (ev == PROCESS_EVENT_TIMER && data == &periodic_timer) { printf("PERIODIC\n"); periodic_timer_cb(); etimer_reset(&periodic_timer); } } } PROCESS_END(); }
void plug_send_message(uip_ipaddr_t *dest, void *data, uint8_t length) { uip_ipaddr_copy(&udp_conn->ripaddr, dest); udp_conn->rport = UIP_HTONS(PLUG_PORT); uip_udp_packet_send(udp_conn, data, length); udp_conn->rport = 0; memset(&udp_conn->ripaddr, 0, sizeof(udp_conn->ripaddr)); }
static void periodic_timer_cb(void) { mqtt_event_data_t event_data; uint8_t val, frac; uint16_t temp; printf("Ping timer %d\n", mqtt.keepalive_error); if (mqtt.state != MQTT_STATE_CONNECTED) { /* Not connected : try to reconnect */ printf("Try to reconnect\n"); mqtt_msg_connect_send(&mqtt); uip_udp_packet_send(mqtt.udp_connection, mqtt.data, mqtt.len); return; } if (mqtt.keepalive_error >= MAX_KEEPALIVE_ERROR) { PRINTF("DISCONNECTED\n"); mqtt.state = MQTT_STATE_CONNECTION_IN_PROGRESS; event_data.type = MQTT_EVENT_TYPE_DISCONNECTED; process_post_synch(mqtt.calling_process, mqtt_event, &event_data); return; } else { mqtt.keepalive_error++; } temp = onewire_temp_read(); val = temp / 100; frac = temp % 100; sprintf(temperature, "%d.%d", val, frac); printf("temperature : %s\n", temperature); mqtt_msg_publish(topic_name, temperature); mqtt_msg_ping_send(&mqtt, MQTT_MSG_PINGREQ); uip_udp_packet_send(mqtt.udp_connection, mqtt.data, mqtt.len); }
/*---------------------------------------------------------------------------*/ static void timeout_handler(void) { cur_time++; buf[0] = 'P'; uip_create_linklocal_allnodes_mcast(&conn->ripaddr); conn->rport = UIP_HTONS(3000); uip_udp_packet_send(conn, buf, 1); uip_create_unspecified(&conn->ripaddr); conn->rport = 0; }
/*---------------------------------------------------------------------------*/ static void send_handler(process_event_t ev, process_data_t data) { pkt_data.counter++; pkt_data.seq_no++; PRINTF("Sending UDP!!! packet\n"); uip_udp_packet_send(client_conn, (uint8_t*) &pkt_data, sizeof(pkt_data_t)); PRINTF("After sent udp packet.\n"); }
static void timeout_handler(void) { static int seq_id; printf("Client sending to: "); PRINT6ADDR(&client_conn->ripaddr); sprintf(buf, "Hello %d from the client", ++seq_id); printf(" (msg: %s)\n", buf); uip_udp_packet_send(client_conn, buf, strlen(buf)); }
/*---------------------------------------------------------------------------*/ int udp_socket_send(struct net_buf *buf, struct udp_socket *c, const void *data, uint16_t datalen) { if(c == NULL || c->udp_conn == NULL) { return -1; } uip_udp_packet_send(buf, c->udp_conn, data, datalen); return datalen; }
static void udp_handler(void) { static uint8_t tries = 10; static camera_size_t camera_size; static uint16_t index, count, len; static uint32_t size; char temp[MAX_PAYLOAD_LEN]; if (uip_newdata()) { uip_ipaddr_copy(&server_conn->ripaddr, &UDP_HDR->srcipaddr); server_conn->rport = UDP_HDR->srcport; if (1 == uip_datalen()) { camera_size = camera_parse_size(((char*)uip_appdata)[0]); camera_take_picture(camera_size, DEFAULT_CAMERA_PACKET_SIZE, &size, &count); /* Send picture size and packet count. */ /* The first 2 bytes are packet_no. */ /* Here set packet_no to 0 as this packet is not a real packet. */ temp[0] = temp[1] = 0; temp[2] = size; /* The next 4 bytes are size. */ temp[3] = size >> 8; temp[4] = size >> 16; temp[5] = size >> 24; /* The coming is count. */ temp[6] = count; temp[7] = count >> 8; uip_udp_packet_send(server_conn, temp, 8); /* Send picture packet by packet. */ for (index = 1; index <= count; index++) { len = camera_try_get_packet(index, buffer, tries); /* The first 2 bytes are packet_no. */ temp[0] = index; temp[1] = index >> 8; /* Copy the picture data next to packet_no. */ memcpy(temp + 2, buffer, len); uip_udp_packet_send(server_conn, temp, len + 2); } } else {
/* Send a UDP packet to the specified destination */ static void send_packet(uip_ipaddr_t *dest, uint16_t destport, void *data, int data_size) { if(send_conn != NULL) { uip_ipaddr_copy(&send_conn->ripaddr, dest); send_conn->rport = destport; PRINTF("[APP] Sending UPD packet %s (%d) to", (char *)data, data_size); PRINT6ADDR(dest); PRINTF("\n"); uip_udp_packet_send(send_conn, data, data_size); } }