I have a code downloaded from this site http://www.yetihacks.com/2013/04/arduino-mysql-and-php-part-3.html . The download link is https://docs.google.com/file/d/0ByM856etTcJlTF9VaVd1anRfbHM/edit?usp=sharing.
This code will read an RFID tag code using an RFID reader and arduino and then sends the tag code to a mysql database using php. Now when I compile the code I have encountered a problem which is ('IOdirection' not declared in this scope) I want to know the real syntax for the line "sendData(buffer, IOdirection);" so it can help fix the problem.
This is part of the original code downloaded from the link above.
void loop(void)
{
// Serial.println("main loop running"); debugging message
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID from the card shield
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
String buffer; // text buffer used to read the card UID from the serial data stream.
//using this we can verify the card type.
int i; //loop count variable
buffer = ""; //clear the buffer
// read the card
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
if (success)
{
Serial.println("Found a card!"); // debugging message to serial port
Serial.print(" Card UID Value: "); //debugging message to serial port
lcd.clear();
lcd.setCursor( 0, 0);
lcd.print("Card # ");
// read datastream into a text buffer
for (uint8_t i = 0; i < uidLength; i++)
{
buffer = String(buffer + String(uid[i], HEX));
}
}
lcd.print(buffer); // display the card ID on the Oled
Serial.print(buffer); //debugging message to serial port
if (uidLength == 4)
{
if (uidLength == 7)
{
Serial.println("Seems to be a Mifare Ultralight tag (7 byte UID)");
if (success)
{
}
else
{
lcd.clear();
lcd.setCursor(2, 1);
lcd.print("card error 4"); // shouldn't happen but just in case some on swipes a 7 byte tag !!!
}
}
sendData(buffer, IOdirection ); // send data to database server
delay(2000);
}
else
{
}
Ethernet.maintain();
Serial.println();
}
String readPage()
{
//read the page returned py the PHP script we called
// and capture & everything between '<' and '>' to display on the OLED
stringPos = 0;
memset( &inString, 0, 32 ); //clear inString memory
while (true)
{
if (client.available())
{
while (client.connected())
{
char c = client.read();
Serial.print(c);
// How long to wait for it all to arrive?
if (c == '<' ) //'<' is our begining character
{
startRead = true; //Ready to start reading the part
}
else if (startRead)
{
if (c != '>') //'>' is our ending character
{
inString[stringPos] = c;
stringPos ++;
// Serial.print(c);
}
else
{
//got what we need here! We can disconnect now
startRead = false;
client.stop();
client.flush();
Serial.println("disconnecting.");
return inString;
}
}
}
}
}
}
// this method makes a HTTP connection to the database server: and calls the PHP script to write into the database.
void sendData(String thisData, String InOut)
{
if (client.connect(DBserver, 80))
{
delay(100);
// format and send the HTTP GET request:
client.print("GET /idreader/addcard.php?");
// client.print(InOut);
client.print("&cardid=");
client.print(thisData);
client.println(" HTTP/1.1"); //
client.println("Host: localhost"); //run the php script on the server
client.println("Accept: text/html"); //
client.println("Connection: close"); //
client.println(); //
client.println();
// client.println();
Serial.println();
Serial.println("data sent");
//Connected - Read the page
readPage();
//go and read the output
// if there are incoming bytes available
// from the server, read them and print them:
Serial.println(inString);
lcd.setCursor(0, 1);
lcd.print(inString);
beep (200);
delay (2000);
beep (100);
delay (1000);
lcd.setCursor(5, 0);
client.flush();
client.stop();
client.flush(); // close the connection network connection
}
else
{
// if you couldn't make a connection to the database server:
lcd.clear();
lcd.setCursor(2, 1);
lcd.print(" send fail");
// Serial.println("connection failed");
beep (3000); // a long obnoxous beep to flag an error
delay (1000);
client.flush();
client.stop();
client.flush();
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("Ready ");
}
}
void beep(int length)
{
digitalWrite( A3 , LOW);
delay(length);
digitalWrite(A3, LOW);
}
What i know from that line is the 'buffer' is the string variable where the code for the RFID tag code is stored.
The 'sendData' from what I understand is another function or another code where you send the data stored in 'buffer' variable.
The IOdirection is the one that confuse me.