following code is working good....but as a new comer i dont know about scalibility and stabilty..please help in giving proper flow thank you
#include <NeoSWSerial.h>
NeoSWSerial scanner1( 2, 3 );
#include <AltSoftSerial.h>
AltSoftSerial scanner2; // pins 8 & 9
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 10, 11);
IPAddress server(192,168,10,105);
IPAddress gateway( 192,168,10,3 );
IPAddress subnet( 255,255,255,0 );
IPAddress dns1( 59,144,127,16);
// 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):
EthernetClient client;
boolean clientConnected = false;
String in1,in2;
void softReset(){
asm volatile (" jmp 0");
}
void setup()
{
Ethernet.begin(mac, ip,dns1,gateway,subnet);
Serial.begin( 9600 );
scanner2.begin( 9600 );
scanner1.begin( 9600 );
delay(1000);
Serial.println("connecting...");
delay(100);
// if you get a connection, report back via serial:
if (client.connect(server, 11000)) {
Serial.println("connected");
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
softReset();
}
}
void loop()
{
if (scanner1.available()) { // actually Serial, but this is easier to read
char scan1 = scanner1.read(); // echo to Serial monitor window
in1+=scan1;
if (scan1 == '\n')
{
Serial.print("Arduino Received: ");
Serial.print(in1);
client.println(in1);
in1="";
}}
if (scanner2.available()) { // actually Serial, but this is easier to read
char scan2 = scanner2.read(); // echo to Serial monitor window
in2+=scan2;
if (scan2 == '\n')
{
Serial.print("Arduino Received: ");
Serial.print(in2);
client.println(in2);
in2="";
}}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
softReset();
}
}