Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Stuck on testing Ethernet Class #14

Closed
wants to merge 6 commits into from

Conversation

Kavikick
Copy link
Collaborator

@Kavikick Kavikick commented Nov 4, 2020

Created a wrapper class for the base Ethernet class in the Arduino Ethernet library. Stuck on issue Arduino-CI/arduino_ci#183.

#include "Ethernet_TC.h"
using namespace std;

TC_ethernet *TC_ethernet::_instance = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the name of the class to match the filename? Please use Ethernet_TC.

James Foster added 2 commits November 4, 2020 21:10
Remove extra spaces at end of last line.
@@ -0,0 +1,32 @@
#include "Ethernet_TC.h"
using namespace std;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you actually using anything from namespace std or is this just a habit? If you have anything from std then let's reference it directly as std::.

// if (current_millis - previous_lease >= LEASE_INTERVAL) {
Ethernet.maintain();
// }
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline.

}

void TC_ethernet::renewDHCPLease() {
// unsigned long current_millis = millis();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either take out the commented-out code or (even better), keep track of the previous lease time and the LEASE_INTERVAL as a private instance variable and constant so that this method can be called frequently and it will decide when it is time to renew (rather than that knowledge being in the caller).

TC_ethernet::TC_ethernet() {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
if (Ethernet.begin(mac) == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the begin() method is successful, does IP get initialized?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IP is either initialized through DHCP in the begin(mac) contructor, or (I moved the constructor so it won't be declared unless needed) it will be given a defaultIP with the begin(mac, IP) constructor

}

defaultIP = IPAddress(192, 168, 1, 2);
time_serverIP = IPAddress(132, 163, 97, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone use this?

Copy link
Collaborator Author

@Kavikick Kavikick Nov 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any references in the original implementation for the Time_server. But I'll remove it for now (since I'm not using it), and add it back in later if it's needed. As for defaultIP I moved the declaration to where it is used.


#include "Ethernet_TC.h"

unittest(test) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we should be able to do some testing! Get a reference to the singleton, query for the IP, renew the lease, etc.

@Kavikick Kavikick closed this Nov 5, 2020
@jgfoster
Copy link
Member

Did you intend to close this? Did this happen when we added high-level tests instead?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants