Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethernet fixes #51

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/arduinoWrapper/ArduinoConfig.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
#pragma once

//#define ETHERNET // for WIZ5100
// #define ETHERNET // for WIZ5100
//#define ETHERNET2 // for WIZ5500

#if defined(ETHERNET) || defined(ETHERNET2)
#define ETH_MAC \
{ \
0x11, 0x11, 0x22, 0x33, 0x44, 0x55 \
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED \
} // make sure that MAC is unique per device
/*
#define ETH_IP \
{ \
192, 168, 5, 40 \
} // device will use this IP if it can not get ip automatically
{ \
192, 168, 5, 40 \
} // device will use this IP if it can not get ip automatically
#define ETH_DNS \
{ \
192, 168, 5, 1 \
} // IP of DNS server (router)
{ \
192, 168, 5, 1 \
} // IP of DNS server (router)
#define ETH_GATEWAY \
{ \
192, 168, 5, 1 \
} // IP of internet gateway (router)
{ \
192, 168, 5, 1 \
} // IP of internet gateway (router)
#define ETH_SUBNET \
{ \
255, 255, 255, 0 \
} // subnet (if you don't know what this is leave it like this)
{ \
255, 255, 255, 0 \
} // subnet (if you don't know what this is leave it like this)
*/
#endif // defined(ETHERNET) || defined(ETHERNET2)
3 changes: 1 addition & 2 deletions src/arduinoWrapper/ArduinoEspWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include "ArduinoEspWrapper.h"
#include "Arduino.h"
#include "ArduinoDebugLed.h"

//#define ESP_WRAPPER_DEBUG
#include "debugDefines.h"

#define RESTART_TIME 1800000L // 30 minutes

Expand Down
3 changes: 1 addition & 2 deletions src/arduinoWrapper/ArduinoEthernetWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
#include "Arduino.h"
#include "ArduinoDebugLed.h"
#include "ArduinoEthernetWrapper.h"
#include "debugDefines.h"

#ifndef ETH_MAC
#error "You need to define ETH_MAC with mac address. Make sure it is unique"
#endif

//#define ETHERNET_WRAPPER_DEBUG

static Client* m_client = nullptr;
static char m_uid[20] = {'0'};
static unsigned long m_last_time_connected = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/arduinoWrapper/ArduinoWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "PubSubClient.h"
#include "helperFunctions.h"

//#define ARDUINO_WRAPPER_DEBUG
#include "debugDefines.h"

// private vars:
#define TOPIC_BUFFER_LENGTH 30
Expand Down Expand Up @@ -79,6 +79,7 @@ void wrapperSetup()
#ifdef ARDUINO_WRAPPER_DEBUG
Serial.print(F("Will topic: "));
Serial.println(m_will_topic);
Serial.flush();
#endif
}

Expand Down Expand Up @@ -178,6 +179,7 @@ bool wrapperReconnectMqtt()

Serial.println(F("Trying to reconnect to mqtt broker"));
#endif

// Attempt to connect
if(m_mqtt_client.connect(getUniqueId(), m_username, m_password, m_will_topic, MQTTQOS1, true, "offline"))
{
Expand Down
8 changes: 7 additions & 1 deletion src/debugDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#define ENDPOINT_LEVEL_DEBUG
#define ENDPOINT_IDENTIFY_DEBUG
#define ENDPOINT_COLOR_DEBUG
#define ETHERNET_WRAPPER_DEBUG
#define ESP_WRAPPER_DEBUG
#define ARDUINO_WRAPPER_DEBUG

#endif

Expand All @@ -27,4 +30,7 @@
// #define ENDPOINT_MOTION_DEBUG
// #define ENDPOINT_LEVEL_DEBUG
// #define ENDPOINT_IDENTIFY_DEBUG
// #define ENDPOINT_COLOR_DEBUG
// #define ENDPOINT_COLOR_DEBUG
// #define ETHERNET_WRAPPER_DEBUG
// #define ESP_WRAPPER_DEBUG
// #define ARDUINO_WRAPPER_DEBUG