@@ -57,7 +57,7 @@ void EthConnectionManager::check() {
57
57
int networkStatus = 0 ;
58
58
if (now - lastConnectionTickTime > connectionTickTimeInterval) {
59
59
switch (netConnectionState) {
60
- case CONNECTION_STATE_INIT : {
60
+ case NetworkConnectionState::INIT : {
61
61
if (ss_pin == -1 ) {
62
62
networkStatus = Ethernet.begin (mac);
63
63
} else {
@@ -68,7 +68,7 @@ void EthConnectionManager::check() {
68
68
if (networkStatus == EthernetNoHardware) {
69
69
debugMessage (DebugLevel::Error, " No Ethernet chip connected" );
70
70
// don't continue:
71
- changeConnectionState (CONNECTION_STATE_ERROR );
71
+ changeConnectionState (NetworkConnectionState::ERROR );
72
72
lastConnectionTickTime = now;
73
73
return ;
74
74
}
@@ -77,15 +77,15 @@ void EthConnectionManager::check() {
77
77
if (networkStatus == LinkOFF) {
78
78
debugMessage (DebugLevel::Error, " Failed to configure Ethernet via dhcp" );
79
79
// don't continue:
80
- changeConnectionState (CONNECTION_STATE_ERROR );
80
+ changeConnectionState (NetworkConnectionState::ERROR );
81
81
lastConnectionTickTime = now;
82
82
return ;
83
83
}
84
84
debugMessage (DebugLevel::Error, " Ethernet shield recognized: ID" , Ethernet.hardwareStatus ());
85
- changeConnectionState (CONNECTION_STATE_CONNECTING );
85
+ changeConnectionState (NetworkConnectionState::CONNECTING );
86
86
}
87
87
break ;
88
- case CONNECTION_STATE_CONNECTING : {
88
+ case NetworkConnectionState::CONNECTING : {
89
89
debugMessage (DebugLevel::Info, " Connecting via dhcp" );
90
90
if (ss_pin == -1 ) {
91
91
networkStatus = Ethernet.begin (mac);
@@ -96,42 +96,42 @@ void EthConnectionManager::check() {
96
96
if (networkStatus == 0 ) {
97
97
debugMessage (DebugLevel::Error, " Connection failed" );
98
98
debugMessage (DebugLevel::Info, " Retrying in \" %d\" milliseconds" , connectionTickTimeInterval);
99
- // changeConnectionState(CONNECTION_STATE_CONNECTING );
99
+ // changeConnectionState(NetworkConnectionState::CONNECTING );
100
100
return ;
101
101
} else {
102
102
debugMessage (DebugLevel::Info, " Connected!" );
103
- changeConnectionState (CONNECTION_STATE_GETTIME );
103
+ changeConnectionState (NetworkConnectionState::GETTIME );
104
104
return ;
105
105
}
106
106
}
107
107
break ;
108
- case CONNECTION_STATE_GETTIME : {
108
+ case NetworkConnectionState::GETTIME : {
109
109
debugMessage (DebugLevel::Debug, " Acquiring Time from Network" );
110
110
unsigned long networkTime;
111
111
networkTime = getTime ();
112
112
debugMessage (DebugLevel::Debug, " Network Time: %u" , networkTime);
113
113
if (networkTime > lastValidTimestamp){
114
114
lastValidTimestamp = networkTime;
115
- changeConnectionState (CONNECTION_STATE_CONNECTED );
115
+ changeConnectionState (NetworkConnectionState::CONNECTED );
116
116
}
117
117
}
118
118
break ;
119
- case CONNECTION_STATE_CONNECTED : {
119
+ case NetworkConnectionState::CONNECTED : {
120
120
// keep testing connection
121
121
Ethernet.maintain ();
122
122
networkStatus = Ethernet.linkStatus ();
123
123
debugMessage (DebugLevel::Verbose, " Eth link status(): %d" , networkStatus);
124
124
if (networkStatus != LinkON) {
125
- changeConnectionState (CONNECTION_STATE_DISCONNECTED );
125
+ changeConnectionState (NetworkConnectionState::DISCONNECTED );
126
126
return ;
127
127
}
128
128
debugMessage (DebugLevel::Info, " Connected" );
129
129
}
130
130
break ;
131
- case CONNECTION_STATE_DISCONNECTED : {
131
+ case NetworkConnectionState::DISCONNECTED : {
132
132
debugMessage (DebugLevel::Error, " Connection lost." );
133
133
debugMessage (DebugLevel::Info, " Attempting reconnection" );
134
- changeConnectionState (CONNECTION_STATE_CONNECTING );
134
+ changeConnectionState (NetworkConnectionState::CONNECTING );
135
135
// wifiClient.stop();
136
136
}
137
137
break ;
@@ -148,11 +148,11 @@ void EthConnectionManager::changeConnectionState(NetworkConnectionState _newStat
148
148
netConnectionState = _newState;
149
149
int newInterval = CHECK_INTERVAL_IDLE;
150
150
switch (_newState) {
151
- case CONNECTION_STATE_INIT : newInterval = CHECK_INTERVAL_INIT; break ;
152
- case CONNECTION_STATE_CONNECTING : newInterval = CHECK_INTERVAL_CONNECTING; break ;
153
- case CONNECTION_STATE_GETTIME : newInterval = CHECK_INTERVAL_GETTIME; break ;
154
- case CONNECTION_STATE_CONNECTED : newInterval = CHECK_INTERVAL_CONNECTED; break ;
155
- case CONNECTION_STATE_DISCONNECTED : newInterval = CHECK_INTERVAL_DISCONNECTED; break ;
151
+ case NetworkConnectionState::INIT : newInterval = CHECK_INTERVAL_INIT; break ;
152
+ case NetworkConnectionState::CONNECTING : newInterval = CHECK_INTERVAL_CONNECTING; break ;
153
+ case NetworkConnectionState::GETTIME : newInterval = CHECK_INTERVAL_GETTIME; break ;
154
+ case NetworkConnectionState::CONNECTED : newInterval = CHECK_INTERVAL_CONNECTED; break ;
155
+ case NetworkConnectionState::DISCONNECTED : newInterval = CHECK_INTERVAL_DISCONNECTED; break ;
156
156
}
157
157
connectionTickTimeInterval = newInterval;
158
158
lastConnectionTickTime = millis ();
0 commit comments