Inizio un nuovo topic riprendendo il tema di una vecchia discussione riguardante la WiFi Shield e la libreria SocketIOClient.h
-Lancio un server con nodejs sulla porta 3000
-Uso un Arduino UNO con la WiFi shield (firmware aggiornato)
-Parte arduino, e quello che mi stampa il monitor seriale è questo:
Attempting to connect to the network...
SSID: CENTEC
Connected to wifi
10.26.153.86
Connessione al server ..
Not connected.
errore connessione
Dove presumibimente l'errore è quando viene fatta la client.connect(hostname,3000))
Lo SKetch è il seguente
#include "SocketIOClient.h"
#include "Ethernet.h"
#include "SPI.h"
#include "WiFi.h"
#define HELLO_INTERVAL 3000UL
unsigned long lasthello;
SocketIOClient client;
char ssid[] = "CENTEC"; // your network SSID (name)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char hostname[] = "10.26.153.84";
int port = 3000;
int status= WL_IDLE_STATUS;
void ondata(SocketIOClient client, char *data) {
Serial.print(data);
}
void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to the network...");
Serial.print("SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
// don't do anything else:
while(true);
} else if(status == WL_CONNECTED){
Serial.println("Connected to wifi");
IPAddress ip = WiFi.localIP();
Serial.print(ip);
Serial.println("\nConnessione al server ..\n");
client.setDataArrivedDelegate(ondata);
if (!client.connect(hostname,3000)) { // HELP !!!!!!
Serial.println("Not connected.");
}
if (client.connected()) {
Serial.println("Client here!");
} else if(!client.connected()) {
Serial.println("errore connessione");
}
}
}
void loop()
{
client.monitor();
}
NOTA: La console del server non stampa niente a video, nè tentativi di connessione nè altro...