The working script for transferring data to MySQL.But I do not remember where I took these libraries.
#include <ArduinoStream.h>
#include <bufstream.h>
#include <ios.h>
#include <iostream.h>
#include <istream.h>
#include <ostream.h>
#include <Sd2Card.h>
#include <Sd2PinMap.h>
#include <SdBaseFile.h>
#include <SdFat.h>
#include <SdFatConfig.h>
#include <SdFatmainpage.h>
#include <SdFatStructs.h>
#include <SdFatUtil.h>
#include <SdFile.h>
#include <SdInfo.h>
#include <SdStream.h>
#include <SdVolume.h>
#include “SPI.h”
#include “Ethernet.h”
#include “sha1.h”
#include “mysql.h”
#include <SoftwareSerial.h>
#include <avr/pgmspace.h>
#if defined(ARDUINO) && ARDUINO >= 100
#include “Arduino.h”
#else
#include “WProgram.h”
#endif
PROGMEM const char tag_0 PROGMEM = “4C000705C789”;
PROGMEM const char tag_1 PROGMEM = “4C0006FF1CA9”;
PROGMEM const char tag_2 PROGMEM = “000000000000”;
PROGMEM const char tag_3 PROGMEM = “000000000000”;
PROGMEM const char tag_4 PROGMEM = “000000000000”;
PROGMEM const char tag_5 PROGMEM = “000000000000”;
PROGMEM const char tag_6 PROGMEM = “000000000000”;
PROGMEM const char tag_7 PROGMEM = “4C000705C789”;
PROGMEM const char tag_8 PROGMEM = “000000000000”;
PROGMEM const char tag_9 PROGMEM = “000000000000”;
PROGMEM const char* const tag_table ={tag_0,tag_1,tag_2,tag_3,tag_4,tag_5,tag_6,tag_7,tag_8,tag_9};
//SQL
/* Setup for Ethernet Library */
byte mac_addr = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(192, 168, 77, 93);
/* Setup for the Connector/Arduino */
Connector my_conn; // The Connector/Arduino reference
char user = “root”;
char password = “”;
//Antena
SoftwareSerial SoftSerial(3, 2);
unsigned char buffer[64];
int count=0;
char tagNumber[14];
boolean receivedTag;
void setup()
{
//SQL
Serial.begin(9600);
Ethernet.begin(mac_addr);
delay(1000);
Serial.println(“Connecting…”);
if (my_conn.mysql_connect(server_addr, 3306, user, password))
{
delay(500);
/* Write Hello, World to MySQL table test_arduino.hello */
Serial.println(“Query Success!”);
}
else
{Serial.println(“Connection failed.”);
}
//Antena
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
SoftSerial.begin(9600);
}
void loop()
{
tagNumber[0] = ‘\0’;
if (SoftSerial.available())
{
receivedTag=false;
while(SoftSerial.available())
{//Чтение данных из RDM6300
int BytesRead = SoftSerial.readBytesUntil(3, tagNumber, 15);
receivedTag=true;
}
Serial.print(tagNumber);
if (checkTag(tagNumber))
{
//SQL
String INSERT_SQL_SVOY1 = “INSERT INTO sc.Logs(acss,acss_st,acss_k,d_a_t) VALUES (2,‘His’,’”;
String INSERT_SQL_SVOY2 ="’,NOW())";
String INSERT_SQL_SVOY3 =INSERT_SQL_SVOY1 + tagNumber + INSERT_SQL_SVOY2 ;
tagNumber[0] = ‘\0’;
char INSERT_SQL_SVOY[90];
for (int i = 0; i < 90; i++)
{
INSERT_SQL_SVOY =INSERT_SQL_SVOY3*;
_ }_
Serial.println(INSERT_SQL_SVOY);
my_conn.cmd_query(INSERT_SQL_SVOY);
_ //Antena*_
* Serial.print(" Svoy");*
* for (int i=0; i<=4;i++)*
* {*
* digitalWrite(6, LOW);*
* delay (500);*
* digitalWrite(6, HIGH);*
* delay (500);*
* digitalWrite(6, LOW);*
* }*
* delay (1000);*
* }// Гасим диод “Свой”*
* else*
* {*
* //SQL*
* String INSERT_SQL_NESVOY1 = “INSERT INTO sc.Logs(acss,acss_st,acss_k,d_a_t) VALUES (2,‘Alian’,’”;
String INSERT_SQL_NESVOY2 ="’,NOW())";
String INSERT_SQL_NESVOY3 =INSERT_SQL_NESVOY1 + tagNumber + INSERT_SQL_NESVOY2 ;
char INSERT_SQL_NESVOY[90];
_ for (int i = 0; i < 90; i++)_
_ {*_
INSERT_SQL_NESVOY =INSERT_SQL_NESVOY3*;
_ }_
Serial.println(INSERT_SQL_NESVOY);
my_conn.cmd_query(INSERT_SQL_NESVOY);
_ //Antena
Serial.print(" Chuzhoy");
for (int i=0; i<=4;i++)
{
digitalWrite(7, LOW);
delay (500);
digitalWrite(6, HIGH);
delay (500);
digitalWrite(6, LOW);*_
* }*
* delay (1000);*
* }// Гасим диод “Чужой”*
* clearBufferArray();*
* count = 0;*
* Serial.println();*
* delay (5000);*
* }*
* }*
* boolean checkTag(String tag)*
* {*
* char testTag[14];*
* for (int i = 0; i < sizeof(tag_table)/2; i++)
_ {_
strcpy_P(testTag, (char)pgm_read_word(&(tag_table*)));
_ if(tag.substring(1,13)==testTag)
{
return true;
break;
}
}
return false;
}*_
* void clearBufferArray()*
* {*
* for (int i=0; i<count;i++)*
* {*
_ buffer*=NULL;
}
}*_