|
|
@ -215,6 +215,37 @@ void Wiz810MjDevice::setMac(byte b0, byte b1, byte b2, byte b3, byte b4, byte b5
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------- */
|
|
|
|
/* ----------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ---- NetworkConnection ---- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Make this 'NetworkServerConnection'? Or just 'ServerConnection'?
|
|
|
|
|
|
|
|
class NetworkConnection { // Essentially a Socket wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NetworkConnection(uint8_t port); // TODO: Add UDP, TCP choice?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void listen(); // TODO: Return a useful value?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
SOCKET _socket;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NetworkConnection::NetworkConnection(uint8_t port) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
socket(_socket, Sn_MR_TCP, port, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NetworkConnection::listen() { // TODO: Make private or protected?
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
::listen(_socket); // TODO: Use C++ namespaces for the driver functions?
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/* -- NetworkInterface -- */
|
|
|
|
/* -- NetworkInterface -- */
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkInterface {
|
|
|
|
class NetworkInterface {
|
|
|
@ -222,6 +253,8 @@ class NetworkInterface {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
NetworkInterface(Wiz810MjDevice& networkDevice);
|
|
|
|
NetworkInterface(Wiz810MjDevice& networkDevice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NetworkConnection listen(uint8_t port);
|
|
|
|
|
|
|
|
|
|
|
|
Wiz810MjDevice& device; // TODO: Make this a generic "network device" interface
|
|
|
|
Wiz810MjDevice& device; // TODO: Make this a generic "network device" interface
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -247,11 +280,24 @@ NetworkInterface::NetworkInterface(Wiz810MjDevice& networkDevice) : device (netw
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NetworkConnection NetworkInterface::listen(uint8_t port) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns a NetworkConnection listening on the specified TCP port.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
NetworkConnection connection = NetworkConnection(port);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connection.listen();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return connection;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NetworkInterface Network = NetworkInterface(...); // TODO: Make this a global
|
|
|
|
// NetworkInterface Network = NetworkInterface(...); // TODO: Make this a global
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------- */
|
|
|
|
/* ----------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// #define PIN_RESET 9 // WIZnet module /RESET
|
|
|
|
// #define PIN_RESET 9 // WIZnet module /RESET
|
|
|
|
|
|
|
|
|
|
|
|
#define PIN_RESET 8 // WIZnet module /RESET
|
|
|
|
#define PIN_RESET 8 // WIZnet module /RESET
|
|
|
|