Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. ukaszyk
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    ukaszyk

    @ukaszyk

    1
    Reputation
    2
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    ukaszyk Follow

    Best posts made by ukaszyk

    • RE: Unblocking loop when DHCP fails

      @electrik said in Unblocking loop when DHCP fails:

      MQTT_SOCKET_TIMEOUT

      Thanks for your suggestion. Unfortunately it was not enough, but I manipulated in ethernet library and right now I have enough CPU time in my main loop (reading 16 buttons state and control 15 GPIO outputs).
      Here is what I changed so far. I'm not sure about it long time stability, but it works on my desk:

      diff --git a/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h b/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h
      index 376e6c5..9d5e6b4 100644
      --- a/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h
      +++ b/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h
      @@ -213,8 +213,8 @@ public:
       
       class EthernetClient : public Client {
       public:
      -	EthernetClient() : sockindex(MAX_SOCK_NUM), _timeout(1000) { }
      -	EthernetClient(uint8_t s) : sockindex(s), _timeout(1000) { }
      +	EthernetClient() : sockindex(MAX_SOCK_NUM), _timeout(5) { }
      +	EthernetClient(uint8_t s) : sockindex(s), _timeout(5) { }
       
       	uint8_t status();
       	virtual int connect(IPAddress ip, uint16_t port);
      diff --git a/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp b/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp
      index 12cfd67..754ae03 100644
      --- a/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp
      +++ b/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp
      @@ -155,7 +155,7 @@ bool reconnectMQTT(void)
       
       		return true;
       	}
      -	delay(1000);
      +	delay(1);
       	GATEWAY_DEBUG(PSTR("!GWT:RMQ:FAIL\n"));
       	return false;
       }
      @@ -190,7 +190,7 @@ bool gatewayTransportConnect(void)
       	              Ethernet.localIP()[0],
       	              Ethernet.localIP()[1], Ethernet.localIP()[2], Ethernet.localIP()[3]);
       	// give the Ethernet interface a second to initialize
      -	delay(1000);
      +	delay(10);
       #endif
       	return true;
       }
      
      
      posted in Troubleshooting
      ukaszyk
      ukaszyk

    Latest posts made by ukaszyk

    • RE: Unblocking loop when DHCP fails

      @electrik said in Unblocking loop when DHCP fails:

      MQTT_SOCKET_TIMEOUT

      Thanks for your suggestion. Unfortunately it was not enough, but I manipulated in ethernet library and right now I have enough CPU time in my main loop (reading 16 buttons state and control 15 GPIO outputs).
      Here is what I changed so far. I'm not sure about it long time stability, but it works on my desk:

      diff --git a/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h b/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h
      index 376e6c5..9d5e6b4 100644
      --- a/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h
      +++ b/.pio/libdeps/megaatmega2560/Ethernet/src/Ethernet.h
      @@ -213,8 +213,8 @@ public:
       
       class EthernetClient : public Client {
       public:
      -	EthernetClient() : sockindex(MAX_SOCK_NUM), _timeout(1000) { }
      -	EthernetClient(uint8_t s) : sockindex(s), _timeout(1000) { }
      +	EthernetClient() : sockindex(MAX_SOCK_NUM), _timeout(5) { }
      +	EthernetClient(uint8_t s) : sockindex(s), _timeout(5) { }
       
       	uint8_t status();
       	virtual int connect(IPAddress ip, uint16_t port);
      diff --git a/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp b/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp
      index 12cfd67..754ae03 100644
      --- a/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp
      +++ b/.pio/libdeps/megaatmega2560/MySensors/core/MyGatewayTransportMQTTClient.cpp
      @@ -155,7 +155,7 @@ bool reconnectMQTT(void)
       
       		return true;
       	}
      -	delay(1000);
      +	delay(1);
       	GATEWAY_DEBUG(PSTR("!GWT:RMQ:FAIL\n"));
       	return false;
       }
      @@ -190,7 +190,7 @@ bool gatewayTransportConnect(void)
       	              Ethernet.localIP()[0],
       	              Ethernet.localIP()[1], Ethernet.localIP()[2], Ethernet.localIP()[3]);
       	// give the Ethernet interface a second to initialize
      -	delay(1000);
      +	delay(10);
       #endif
       	return true;
       }
      
      
      posted in Troubleshooting
      ukaszyk
      ukaszyk
    • RE: Unblocking loop when DHCP fails

      Hi @NeoX ,
      did you found any solution for this problem?
      I also have arduino Mega2560 with W5100 ETH shield on it. Arduino board is MQTT ethernet gateway, but I also have many local sensors atached to GPIO pins (buttons, temperature sensor, etc.) and relay board to control lights.

      I'm stuck with the same problem: when there is no ethernet connectivity (ETH cable plugged out, ETH router or switch is rebooting) Arduino framework is waiting somewhere (probably in ETH driver) to get connectivity up again. This causes almost no time given to main loop and my code controlling GPIO peripherals is not executed until ETH connectivity goes back.
      I don't like it. I would like to use Mega2560 board as local controller for home automation, but it also must work in case when connectivity is gone. I though that mySensors libabry can be used on Arduino board together with other code doing local stuff.
      What do you think, should I abandon Arduino framework I write code for my controller using for example some small RTOS?
      Regards
      Lukasz

      posted in Troubleshooting
      ukaszyk
      ukaszyk