Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is there a debug mode? #63

Open
bluelemonade opened this issue Jan 15, 2019 · 0 comments
Open

is there a debug mode? #63

bluelemonade opened this issue Jan 15, 2019 · 0 comments

Comments

@bluelemonade
Copy link

I put an ethernet shield on an arduino uno. also no connection with my node.js socket.io server, I used also your app.js and the older socket implementation.

is there a way to debug the conncetion on the arduino?

I can send udp, read http with the ethernet shield. any ideas? would be realy great to get help.

regards

#define W5100
#include "SocketIOClient.h"
#include "Ethernet.h"
#include "SPI.h"

SocketIOClient client;

byte mac[] = {  0xDE, 0xAA, 0xBB, 0xEF, 0xFE, 0xED };
char hostname[] = "192.168.1.56";
int port = 4444;

extern String RID;
extern String Rname;
extern String Rcontent;

unsigned long previousMillis = 0; 
long interval = 10000; 


void setup() {
	// pinMode(10, OUTPUT);    //for some ethernet shield on the mega : disables the SD and enables the W5100
	// digitalWrite(10, LOW);
	// pinMode(4, OUTPUT);
	// digitalWrite(4, HIGH);
	Serial.begin(9600);
  delay(100);
  Ethernet.init(10); // ???
	Ethernet.begin(mac);

  
  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      Serial.println("Ethernet shield found :(");
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  } else {
    Serial.println("Ethernet linkStatus ok ");
  }

  delay(1000);
	while (!client.connect(hostname, port)) {
		Serial.println(F("Not connected.") ); 
    
  	if (client.connected()) {
  		client.send("connection", "message", "Connected !!!!");
  	} else { 
  	  Serial.println("Connection Error");
  		// while(1); 
  	}
  	delay(1000);
  }
  delay(1000);

  if (client.connect(hostname, port))  
    Serial.println(F("connected."));
}

void loop() {
	unsigned long currentMillis = millis();
	if(currentMillis - previousMillis > interval) {
	  previousMillis = currentMillis; 
     Serial.println(F("Interval"));
	  //client.heartbeat(0);
	  client.send("atime", "message", "Time please?");
	}
	if (client.monitor()) {
		Serial.println(RID);
		if (RID == "atime" && Rname == "time") {
			Serial.print("Time is ");
			Serial.println(Rcontent);
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant