From 3e04fbc2598a4e6e54d1066d1641a4e96f6f5da3 Mon Sep 17 00:00:00 2001 From: follower Date: Sat, 8 Dec 2007 14:01:59 +0000 Subject: [PATCH] (*Much* later...) Include skeleton of 'NetworkInterface' class and enable it to be initialised with a pre-configured 'Wiz810MjDevice' instance. (This required the use of 'References' and an 'initialization list' which was all news to me...) git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@97 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b --- .../wiz810mj/src/demo/WizDemo4/WizDemo4.pde | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde b/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde index 832b251..770a506 100644 --- a/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde +++ b/branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde @@ -215,6 +215,33 @@ void Wiz810MjDevice::setMac(byte b0, byte b1, byte b2, byte b3, byte b4, byte b5 /* ----------------------- */ +/* -- NetworkInterface -- */ + +class NetworkInterface { + + public: + NetworkInterface(Wiz810MjDevice& networkDevice); + + Wiz810MjDevice& device; // TODO: Make this a generic "network device" interface +}; + +NetworkInterface::NetworkInterface(Wiz810MjDevice& networkDevice) : device (networkDevice) { + /* + + Note: The "weirdness" in this function declaration is a "initalization list", + i.e. this bit: + + ) : device (networkDevice) { + + it is needed to give the 'device' Reference a value supplied to the method + rather than having a new 'Wiz810MjDevice' instance created. + */ +}; + +// NetworkInterface Network = NetworkInterface(...); // TODO: Make this a global + +/* ----------------------- */ + // #define PIN_RESET 9 // WIZnet module /RESET @@ -238,10 +265,14 @@ void setup () { WIZ810MJ.setMac(0x02,0xDE,0xAD,0xBE,0xEF,0x00); - WIZ810MJ.setIp(192,168,2,105); + // WIZ810MJ.setIp(192,168,2,105); WIZ810MJ.setMask(255,255,255,0); WIZ810MJ.setGateway(192,168,2,101); + NetworkInterface Network = NetworkInterface(WIZ810MJ); + + Network.device.setIp(192,168,2,105); + Serial.println("End test W5100 configuration...");