/*
Garg10n3 Firmware 1.0 ALPHA
Copyright (c) 2010 Alfred Pennarini
https://www.dbmo.tk/
*/
//RC Control Pins
int left = 7;
int right = 6;
int back = 5;
int forward = 4;
//Other Pins
int aux1 = 8;
int aux2 = 9;
int aux3 = 10;
int buzzer = 11;
int irLeds = 12;
int leds = 13;
// DD-WRT user-ID,password,serial-speed settings
#define USER_ID "root"
#define PASSWD "admin"
#define SERIAL_SPEED 115200
//Server IP and TCP-Port Listening settings
#define SERVER "192.168.10.129"
#define PORT "5555"
//Setup Function
void setup()
{
Serial.begin(SERIAL_SPEED);
login(); //login DD-WRT
connect(); //connects to the server
digitalWrite(buzzer,HIGH);
delay(500);
digitalWrite(buzzer,LOW);
}
//Loop Function
void loop()
{
if(Serial.available()>0){
int receivedData = Serial.read(); //read out data from the Server
if(receivedData =='A')
{
//forward
}
}
}
/* login to DD-WRT */
void login()
{
Serial.print("¥n");
allflush(); // flushing serial read buffer
Serial.println(USER_ID);
delay(500);
Serial.println(PASSWD);
allflush();
}
/* logoff from DD-WRT */
void logoff()
{
Serial.print("¥x03"); //CTRL+C
delay(100);
Serial.println("exit");
allflush();
}
//Connection to the Server
void connect()
{
Serial.print("¥x03¥n¥n"); //CRTL+C,LF,LF
allflush();
//telnet to Processing-Server
Serial.print("telnet ");
Serial.print(SERVER);
Serial.print(" ");
Serial.println(PORT);
allflush();
//telnet change "character mode". cf: DD-WRT telnet command
Serial.print("¥x03"); //CTRL+C
Serial.print("c");
allflush();
Serial.print("¥n");
allflush();
//send first data to Processing-Server. first data is 0
Serial.println("0"); //send 0
}