I don't find any error in my code, but I am unable to see the values in my database. Kindly help me in Identifying this problem .
Code: Select all
// Include the GSM library
#include <GSM.h>
#define PINNUMBER ""
#include <Wire.h>
#include <Adafruit_NFCShield_I2C.h>
#define IRQ (6)
#define RESET (3) // Not connected by default on the NFC Shield
Adafruit_NFCShield_I2C nfc(IRQ, RESET);
// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;
GSMClient client;
GPRS gprs;
//********************************************************************
int p,c;
int s ;
String source;
String destination;
char cost[10];
int total;
char people[10];
// APN data
#define GPRS_APN "GPRS_APN" // replace your GPRS APN
#define GPRS_LOGIN "login" // replace with your GPRS login
#define GPRS_PASSWORD "password" // replace with your GPRS password
// URL, path & port (for example: arduino.cc)
char server[] = "domain.com";
char path[] = "/nfctravel.php";
int port = 80; // port 80 is the default for HTTP
//**********************************************************************
void setup()
{
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
// also spit it out
Serial.begin(115200);
Serial.println("Adafruit NFC basic test!");
boolean notConnected = true;
while(notConnected)
{
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
// Set the max number of retry attempts to read from a card
// This prevents us from waiting forever for a card, which is
// the default behaviour of the PN532.
nfc.setPassiveActivationRetries(0xFF);
// configure board to read RFID tags
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A card");
}
void loop(void) {
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
uint32_t cardidentifier = 0;
if (success) {
Serial.print("Card detected #");
// turn the four byte UID of a mifare classic into a single variable #
cardidentifier = uid[3];
cardidentifier <<= 8; cardidentifier |= uid[2];
cardidentifier <<= 8; cardidentifier |= uid[1];
cardidentifier <<= 8; cardidentifier |= uid[0];
Serial.println(cardidentifier);
//Serial.println("Found a card!");
readsource ();
readdestination ();
data();
//***************************************************************
if (client.connect(server, port))
{
client.print("GET /nfctravel.php?");
Serial.print("GET /nfctravel.php?");
client.print("Cardno=");client.print(cardidentifier);Serial.print(cardidentifier);
client.print("&&Source=");client.print(source);Serial.print(source);
client.print("&&Destination=");client.print(destination);Serial.print(destination);
client.print("&&People=");client.print(p);Serial.print(p);
client.print("&&Cost=");client.print(c);Serial.print(c);
client.print("&&Total=");client.print(total);Serial.print(total);
client.println(" HTTP/1.1");
Serial.println(" HTTP/1.1");
client.println("Host: www.domain.com");
Serial.println("Host: www.domain.com");
client.println("User-Agent: Arduino");
Serial.println("User-Agent: Arduino");
client.println("Accept: text/html");
Serial.println("Accept: text/html");
client.println("Connection: close");
Serial.println("Connection: close");
client.println();
Serial.println();
Serial.println("\nCOMPLETE!\n");
client.stop();
}
else
{
Serial.println("connection failed");
Serial.println("\n FAILED!\n");
client.stop();
}
//***************************************************************
// Wait 1 second before continuing
delay(1000);
}
else
{
// PN532 probably timed out waiting for a card
Serial.println("Timed out waiting for a card");
}
}
void readsource ()
{
int ss;
Serial.print("Please enter the source location :\n");
char sou[2];
readSerial(sou);
ss = atoi(sou);
//Serial.print(ss);
switch (ss) {
case 1:
source = String("A");
//Serial.print("\nSource Location = ");
Serial.print(source);
break;
case 2:
source = String("B");
//Serial.print("\nSource Location = ");
Serial.print(source);
break;
case 3:
source = String("C");
//Serial.print("\nSource Location = ");
Serial.print(source);
break;
case 4:
source = String("D");
//Serial.print("\nSource Location = ");
Serial.print(source);
break;
default:
Serial.print("\nEnter correct value");
}
}
void readdestination ()
{
int dd;
Serial.print("\nPlease enter the destination location :\n");
char des[2];
readSerial(des);
dd = atoi(des);
// Serial.print(dd);
switch (dd) {
case 1:
destination = String("A");
//Serial.print(" \ndestination Location = ");
Serial.print( destination);
break;
case 2:
destination = String("B");
//Serial.print("\n destination Location = ");
Serial.print( destination);
break;
case 3:
destination = String("C");
//Serial.print("\n destination Location = ");
Serial.print( destination);
break;
case 4:
destination = String("D");
//Serial.print("\n destination Location = ");
Serial.print( destination);
break;
default:
Serial.print("\nEnter correct value");
}
}
void data ()
{
Serial.print("\nPlease enter the number of people :\n");
readSerial(people);
p = atoi(people);
// Serial.print ("people = ");
Serial.print (p);
Serial.print("\n Cost per head :\n");
readSerial(cost);
c = atoi(cost);
// Serial.print ("\ncost = ");
Serial.print (c);
total = p * c;
// Serial.print ("\ntotal =");
// Serial.print (total);
}
int readSerial(char result[])
{
int i = 0;
while(1)
{
while (Serial.available() > 0)
{
char inChar = Serial.read();
if (inChar == '\n')
{
result[i] = '\0';
Serial.flush();
return 0;
}
if(inChar!='\r')
{
result[i] = inChar;
i++;
}
}
}
}
Result which I get is :
Code: Select all
Adafruit NFC basic test!
GSM initialized
Found chip PN532
Firmware ver. 1.6
Waiting for an ISO14443A card
Card detected #56789
Please enter the source location :
A
Please enter the destination location :
D
Please enter the number of people :
2
Cost per head :
10
Total :
20
GET /nfctravel.php?56789AD21020 HTTP/1.1
Host: http://www.domain.com
User-Agent: Arduino
Accept: text/html
Connection: close