OLD | NEW |
1 /* | 1 /* |
2 * Redistribution and use in source and binary forms, with or without | 2 * Redistribution and use in source and binary forms, with or without |
3 * modification, are permitted provided that the following conditions | 3 * modification, are permitted provided that the following conditions |
4 * are met: | 4 * are met: |
5 * 1. Redistributions of source code must retain the above copyright | 5 * 1. Redistributions of source code must retain the above copyright |
6 * notice, this list of conditions and the following disclaimer. | 6 * notice, this list of conditions and the following disclaimer. |
7 * 2. Redistributions in binary form must reproduce the above copyright | 7 * 2. Redistributions in binary form must reproduce the above copyright |
8 * notice, this list of conditions and the following disclaimer in the | 8 * notice, this list of conditions and the following disclaimer in the |
9 * documentation and/or other materials provided with the distribution. | 9 * documentation and/or other materials provided with the distribution. |
10 * 3. Neither the name of the Institute nor the names of its contributors | 10 * 3. Neither the name of the Institute nor the names of its contributors |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #define UDP_CLIENT_PORT 8765 | 48 #define UDP_CLIENT_PORT 8765 |
49 #define UDP_SERVER_PORT 5678 | 49 #define UDP_SERVER_PORT 5678 |
50 | 50 |
51 #define UDP_EXAMPLE_ID 190 | 51 #define UDP_EXAMPLE_ID 190 |
52 | 52 |
53 static struct uip_udp_conn *server_conn; | 53 static struct uip_udp_conn *server_conn; |
54 | 54 |
55 PROCESS(udp_server_process, "UDP server process"); | 55 PROCESS(udp_server_process, "UDP server process"); |
56 AUTOSTART_PROCESSES(&udp_server_process); | 56 AUTOSTART_PROCESSES(&udp_server_process); |
57 | 57 |
58 | 58 /*reply_to_client is a function that rplies to the client that the msg was rece$ |
| 59 */ |
| 60 static void reply_to_client(char * rcv_msg){ |
| 61 char buf[50]; //used as packet buffer in the outgoing packet |
| 62 sprintf(buf, "Server: rcv your msg: %s \n", rcv_msg); // fill the buffer |
| 63 uip_udp_packet_sendto(server_conn, buf, strlen(buf),&UIP_IP_BUF->srcipaddr, U$ |
| 64 } |
59 /*---------------------------------------------------------------------------*/ | 65 /*---------------------------------------------------------------------------*/ |
60 | 66 |
61 | 67 |
62 static void | 68 static void |
63 tcpip_handler(void) | 69 tcpip_handler(void) |
64 { | 70 { |
65 char *appdata; | 71 char *appdata; |
66 | 72 |
67 if(uip_newdata()) { | 73 if(uip_newdata()) { |
68 appdata = (char *)uip_appdata;//uip_appdata is a *pointer* to application da
ta in the packet buffer.· | 74 appdata = (char *)uip_appdata;//uip_appdata is a *pointer* to application da
ta in the packet buffer.· |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 tcpip_handler(); | 184 tcpip_handler(); |
179 } else if (ev == sensors_event && data == &button_sensor) { | 185 } else if (ev == sensors_event && data == &button_sensor) { |
180 PRINTF("Initiaing global repair\n"); | 186 PRINTF("Initiaing global repair\n"); |
181 rpl_repair_root(RPL_DEFAULT_INSTANCE); | 187 rpl_repair_root(RPL_DEFAULT_INSTANCE); |
182 } | 188 } |
183 } | 189 } |
184 | 190 |
185 PROCESS_END(); | 191 PROCESS_END(); |
186 } | 192 } |
187 /*---------------------------------------------------------------------------*/ | 193 /*---------------------------------------------------------------------------*/ |
OLD | NEW |