@ -223,7 +223,7 @@ void Wiz810MjDevice::setMac(byte b0, byte b1, byte b2, byte b3, byte b4, byte b5
class NetworkConnection { // Essentially a Socket wrapper
class NetworkConnection { // Essentially a Socket wrapper
public:
public:
NetworkConnection(uint8 _t port); // TODO: Add UDP, TCP choice?
NetworkConnection(uint16 _t port); // TODO: Add UDP, TCP choice?
void listen(); // TODO: Return a useful value?
void listen(); // TODO: Return a useful value?
@ -233,7 +233,7 @@ class NetworkConnection { // Essentially a Socket wrapper
SOCKET _socket;
SOCKET _socket;
};
};
NetworkConnection::NetworkConnection(uint8 _t port) {
NetworkConnection::NetworkConnection(uint16 _t port) {
/*
/*
*/
*/
@ -265,7 +265,7 @@ class NetworkInterface {
public:
public:
NetworkInterface(Wiz810MjDevice& networkDevice);
NetworkInterface(Wiz810MjDevice& networkDevice);
NetworkConnection listen(uint8 _t port);
NetworkConnection listen(uint16 _t port);
Wiz810MjDevice& device; // TODO: Make this a generic "network device" interface
Wiz810MjDevice& device; // TODO: Make this a generic "network device" interface
};
};
@ -292,10 +292,19 @@ NetworkInterface::NetworkInterface(Wiz810MjDevice& networkDevice) : device (netw
};
};
NetworkConnection NetworkInterface::listen(uint8 _t port) {
NetworkConnection NetworkInterface::listen(uint16 _t port) {
/*
/*
NOTE: For reasons I don't understand, this FAILS TO WORK if port >255.
The port that gets opened is ~(port mod 255) but if you limit
port to be uint8_t for example you don't get an error until
the port number is bigger than 'long'.
TODO: Track and fix this for port numbers > 255.
Returns a NetworkConnection listening on the specified TCP port.
Returns a NetworkConnection listening on the specified TCP port.
*/
*/
@ -341,7 +350,25 @@ void setup () {
digitalWrite(PIN_LED, HIGH);
digitalWrite(PIN_LED, HIGH);
Serial.println("Setup exit...");
Serial.println("Setup exit...");
/**/
Serial.println("Test sockets...");
NetworkConnection conn = Network.listen(7);
Serial.println("Waiting for connection...");
while (!conn.isConnected()) {
//Serial.print(!conn.isConnected());
delay(500);
}
Serial.println("Connected...");
Serial.println("End test and dummy loop");
while (1) {}
/**/
}
}