Riprendendo il filone degli esperimenti precedenti in questo caso il lettore Rfid e' legato ad una Arduino che si occupa del carico di lavoro per l'interfaccia Web
Le connessioni per il lettore RFID sono
MOSI: Pin 11 / ICSP-4
MISO: Pin 12 / ICSP-1
SCK: Pin 13 / ISCP-3
SS: Pin 6
RST: Pin 7
La scheda Arduino ha ovviamente montato lo Shield Ethernet
----------------------------------------
#include <SPI.h>
#include <Ethernet.h>#include <RFID.h>
#define SS_PIN 6
#define RST_PIN 7
RFID rfid(SS_PIN, RST_PIN);
int serNum0;
int serNum1;
int serNum2;
int serNum3;
int serNum4;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "m.xxxxxnifi.it";
IPAddress ip(192,168,0,177);
EthernetClient client;
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.init();
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
else
{
Serial.println("IP Acquisito");
}
delay(1000);
}
void loop()
{
if (rfid.isCard()) {
if (rfid.readCardSerial()) {
serNum0 = rfid.serNum[0];
serNum1 = rfid.serNum[1];
serNum2 = rfid.serNum[2];
serNum3 = rfid.serNum[3];
serNum4 = rfid.serNum[4];
String Id = String(rfid.serNum[0],HEX)+String(rfid.serNum[1],HEX)+String(rfid.serNum[2],HEX)+String(rfid.serNum[3],HEX)+ String(rfid.serNum[4],HEX);
Serial.println(Id);
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /luca/xxxxxxx/rfid_server2.php?rfid="+Id+" HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
}
else {
Serial.println("connection failed");
}
}
}
rfid.halt();
}
----------------------------------------
----------------------------------------
<?
require_once '../src/facebook.php';
//Luca
if ($_GET["rfid"] == "f479abb492")
{
$accessToken = "CAAJkNq2LttoBAJywtmNSbVHqFPubOjYmQ2yyUG4kpibD75BHid9J7xsvif8osSOc4ewgK4aYerrLZBsZCQM5wykRTYVLDkCJXlXYl3gi8WFRQ8U4p4y4ZAXYsdamz6RVdRJZAe4vZA80mWBayuG0qc4IAj2TMDmQXKiv1OrKp8CwKjD6Rz2ZCAqp8yxxxxxxxx";
print "Luca<br>";
}
$appid = '673135956xxxxxx';
$appsecret = 'dde6cfb07dbb769c7efe949xxxxxx';
$msg = $_GET["msg"];
$title = 'Dove sono ??';
$uri = 'http://debiaonoldcomputers.blogspot.com/';
$desc = 'Sono ad Arcetri';
$pic = 'http://wwxxxxxxxxxxxxxxxxxmes/Boozook/images/testa.gif';
$action_name = 'Link';
$action_link = 'http://www.geo.unifi.it/';
$facebook = new Facebook(array(
'appId' => $appid,
'secret' => $appsecret,
'cookie' => false,
));
$user = $facebook->getUser();
$attachment = array(
'access_token' => $accessToken,
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);
$status = $facebook->api("/me/feed", "post", $attachment);
print "Ok";
?>
Nessun commento:
Posta un commento