Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Looks like you are using the <code>WiShield</code> library. There should be an examples folder in the <code>WiShield</code> download with a <code>SocketApp</code> and <code>UDPApp</code> example. This is a good place to start.</p> <p>A few things I learned while making a UDP app.</p> <ol> <li><p>You may have to edit some #defines (<em>e.g. <code>APP_UDPAPP</code> in <code>apps-conf.h</code>, <code>UIP_CONF_UDP</code> in <code>uip-conf.h</code></em>) before recompiling your app.</p></li> <li><p>If you are doing a <code>UDP</code> app, keep in mind that you have a limited receive buffer (<em><code>UIP_CONF_BUFFER_SIZE</code> in <code>uip-conf.h</code> sets it to <strong>400</strong></em>). My router was sending out a UDP broadcast XML message that was <strong>~700 bytes</strong> which caused this buffer to overflow and over write other data. I don't think TCP will have this problem because it will negotiate a MSS that won't overrun the buffer.</p></li> </ol> <p>In the end I made changes to the <code>handle_connection()</code> function in the <code>UDPapp</code> example. Below is a snippet (<em>with <code>uip_ipaddr</code> set to <code>255.255.255.255</code></em>).</p> <pre class="lang-cpp prettyprint-override"><code>void send_state(void) { sprintf((char*)uip_appdata, "state %ld %ld %ld %c %d", clock_time(), state.sensors.ping[0].cm, state.sensors.ping[1].cm, state.actuators.chassis.direction, state.actuators.chassis.speed); uip_send(uip_appdata, strlen((char*)uip_appdata)); } void send_beacon(void) { if(timer_expired(&amp;beacon_timer)) { timer_reset(&amp;beacon_timer); sprintf((char*)uip_appdata, "beacon %ld", clock_time()); uip_send(uip_appdata, strlen((char*)uip_appdata)); uip_log("beacon sent"); } } boolean data_or_poll(void) { return (uip_newdata() || uip_poll()); } static PT_THREAD(handle_connection(void)) { PT_BEGIN(&amp;s.pt); PT_WAIT_UNTIL(&amp;s.pt, data_or_poll()); if(uip_newdata()) { uip_flags &amp;= (~UIP_NEWDATA); send_state(); } else if (uip_poll()) { uip_flags &amp;= (~UIP_POLL); send_beacon(); } PT_END(&amp;s.pt); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload