EthernetGateway hangs after "Gateway startup complete"
-
Hello,
I spent some hours to get my EthernetGateway running on the following configuration:- SainSmart Arduino Uno R3
- SainSmart EthernetShield (5100)
- EthernetGateway.ino
I followed the steps in the documentation and luckily received the message: "Gateway startup complete"
BUT then I noticed that I could not ping the gateway.
After adding some "Serial.println"-calls in the setup() routine I discovered that the arduino did not return from the
gw.begin(...); call. Having a look at the implementation made me a bit curious.setup() does the following:
- gw.begin
- Ethernet.begin
- server.begin
gw.begin accepts a callback "writeEthernet" which is implemented as follows:
void writeEthernet(char *writeBuffer) {
server.write(writeBuffer);
}
This callback is called before server.begin is called. So server.write gets called before server.begin!To avoid calling server.write before server.begin was called I introduced a bool which is set to true at the end of setup() and used this
in the following way:
void writeEthernet(char *writeBuffer) {
if (serverUp)
{
server.write(writeBuffer);
}
}Now my EthernetGateway runs fine, with this workaround.
Is this a bug in the code?
Could anyone provide some help to find out why the arduino hangs when server.write is called before server.begin?
-
I think it is the same problem as in...
http://forum.mysensors.org/topic/737/uno-w5100-shield-not-pinging