0
votes

I'm using an Arduino with an Ethernet Shield configured as a telnet server.

Is it possible to detect when a client is connected without the client having sent any characters? The server.available() method only returns a client object if there is data available for reading.

1

1 Answers

0
votes

You can try this an example:

include <SPI.h>
#include <Ethernet.h>
#include <CapSense.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, 84, 3 };

#define encoderGSMask B00000001
#define encoderGSPin 8

// Initialize the Ethernet server library
Server server(8423);

void setup() {   

 pinMode(encoderGSPin, INPUT); //Encoder GS
 digitalWrite(encoderGSPin, HIGH);

 Serial.begin(115200);

 // start the Ethernet connection and the server:
 Ethernet.begin(mac, ip);
 server.begin();  
}

void loop(){

   if ((PINB&encoderGSMask)==0)
   {
     server.write('S');   //Sync
     server.write(1);     //Rev 1
     server.write('B');   //Message Type
     server.write(0x01);  //Button ID

     delay(1000);
   }    
 }