Change 'listen' methods to take a 'uint16_t'. Temporarily include a test socket creation--THIS BREAKS the webserver demo. NOTE/TODO: Supplying port numbers greater than 255 IS BROKEN--I don't know why--see comments for more details.

git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@103 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
follower 17 years ago
parent 6e0f16aec1
commit e4dfd94a4c

@ -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
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?
@ -233,7 +233,7 @@ class NetworkConnection { // Essentially a Socket wrapper
SOCKET _socket;
};
NetworkConnection::NetworkConnection(uint8_t port) {
NetworkConnection::NetworkConnection(uint16_t port) {
/*
*/
@ -265,7 +265,7 @@ class NetworkInterface {
public:
NetworkInterface(Wiz810MjDevice& networkDevice);
NetworkConnection listen(uint8_t port);
NetworkConnection listen(uint16_t port);
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.
*/
@ -341,7 +350,25 @@ void setup () {
digitalWrite(PIN_LED, HIGH);
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) {}
/**/
}

Loading…
Cancel
Save