Permalink
Browse files

latest

  • Loading branch information...
1 parent 7d38e92 commit 4765881e7d1eefe16c8cdeac5f10e44e8d7c6abb Tedb0t committed Feb 18, 2012
Showing with 4 additions and 80 deletions.
  1. +3 −3 node-pong.js
  2. +1 −1 nodeArduinoEthernet/nodeArduinoEthernet.ino
  3. +0 −76 nodeArduinoEthernet/nodeArduinoEthernet.pde
View
@@ -1,10 +1,10 @@
var net = require('net');
var server = net.createServer(function(c) {
- console.log("Server connected");
+ console.log("Client "+c.remoteAddress+" connected");
+
c.setEncoding('ascii');
c.on("data", function(data) {
- //data.setEncoding('utf8');
console.log("data:", data);
});
c.on("end", function() {
@@ -13,5 +13,5 @@ var server = net.createServer(function(c) {
});
server.listen(5001, function() {
- console.log("Server bound");
+ console.log("Server bound at localhost:5001");
});
@@ -27,7 +27,7 @@ byte ip[] = {
// Enter the IP address of the server you're connecting to:
byte server[] = {
- 192,168,1,109 };
+ 192,168,1,103 };
// Initialize the Ethernet client library
// with the IP address and port of the server
@@ -1,76 +0,0 @@
-/*
- nodeArduino Ethernet / Ted Hayes
- Uses the WizNet ethernet shield
-
- */
-
-#include <SPI.h>
-#include <Ethernet.h>
-
-// Enter a MAC address and IP address for your controller below.
-// The IP address will be dependent on your local network:
-byte mac[] = {
- 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = {
- 192,168,1,177 };
-
-// Enter the IP address of the server you're connecting to:
-byte server[] = {
- 1,1,1,1 };
-
-// Initialize the Ethernet client library
-// with the IP address and port of the server
-// that you want to connect to (port 23 is default for telnet;
-// if you're using Processing's ChatServer, use port 10002):
-Client client(server, 10002);
-
-void setup() {
- // start the Ethernet connection:
- Ethernet.begin(mac, ip);
- // start the serial library:
- Serial.begin(9600);
- // give the Ethernet shield a second to initialize:
- delay(1000);
- Serial.println("connecting...");
-
- // if you get a connection, report back via serial:
- if (client.connect()) {
- Serial.println("connected");
- }
- else {
- // if you didn't get a connection to the server:
- Serial.println("connection failed");
- }
-}
-
-void loop()
-{
- // if there are incoming bytes available
- // from the server, read them and print them:
- if (client.available()) {
- char c = client.read();
- Serial.print(c);
- }
-
- // as long as there are bytes in the serial queue,
- // read them and send them out the socket if it's open:
- while (Serial.available() > 0) {
- char inChar = Serial.read();
- if (client.connected()) {
- client.print(inChar);
- }
- }
-
- // if the server's disconnected, stop the client:
- if (!client.connected()) {
- Serial.println();
- Serial.println("disconnecting.");
- client.stop();
- // do nothing:
- while(true);
- }
-}
-
-
-
-

0 comments on commit 4765881

Please sign in to comment.