WiShield 2.0 client
i extended rfid reader bit, , added wishield 2.0 too, can't call server
serial output says:
and if manually call http://192.168.1.6/add.asp?pass=doit&id=3a008602358b&access=granted
it adds database
what doing wrong? modified twitter sketch, maybe removed bit much?
code: [select]
int door_locked = 0; // 0-180
int door_unlocked = 90; // 0-180
long interval = 5000; //how long doorwill stay unlocked
boolean locked = true;
#include <softwareservo.h>
softwareservo myservo; // create servo object control servo
#include <wstring.h>
#include <newsoftserial.h>
#include <wishield.h>
newsoftserial rfid(5, 6);
string msg = string(60);
string id = string(60); //string store allowed cards
long previousmillis = 0; //store when door got unlocked
long previousservo = 0; //store when servo last set
long previouswifi = 0; //set how call webpage
string temp = "";
boolean debug = true;
//wifi stuff
#include <wishield.h>
#define wireless_mode_infra 1
#define wireless_mode_adhoc 2
// wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,10}; // ip address of wishield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway ip address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask local network
const prog_char ssid[] progmem = {"dd-wrt"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - wep; 2 - wpa; 3 - wpa2
// wpa/wpa2 passphrase
const prog_char security_passphrase[] progmem = {"xxxxxxxxxxxxxxxxxxxxx"}; // max 64 characters
// wep 128-bit keys
// sample hex keys
prog_uchar wep_keys[] progmem = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // key 3
};
// setup wireless mode
// infrastructure - connect ap
// adhoc - connect wifi device
unsigned char wireless_mode = wireless_mode_infra;
unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------
char server_ip[] = {192,168,1,6}; // server
const prog_char twitter[] progmem = {""};
void setup()
{
//wifi
wifi.init();
//serial
serial.begin(9600);
serial.println("serial ready");
//rfid
id.append("3a008602358b");
rfid.begin(9600);
serial.println("rfid ready");
//servo
myservo.attach(7); // attaches servo on pin 4 servo object
myservo.write(door_locked); //move servo locked position
}
void loop()
{
if (!locked)
{
if(millis() - previousmillis > interval) //lock after being unlocked amount of time defined interval
{
locked = true; //change locked
myservo.write(door_locked); //move servo locked position
}
}
char c;
while(rfid.available() > 0)
{
c=rfid.read();
msg.append(c);
}
if(msg.length() >= 12) //check if valid id
{
int length = msg.length();
for (int i=0; <= length; i++) //run through string
{
if (byte(msg.charat(i)) >= 32) //check if char more, or 32 byte
{
temp.append(msg.charat(i)); //add temp message holding id
if (debug) serial.println(temp);
}
}
verify(); //validate id
}
msg=""; //empty message
temp = ""; //empty string holding id temp
if(millis() - previousservo > 50) //check if time set servo position again
{
previousservo = millis();
softwareservo::refresh();
}
}
void verify()
{
string logger;
logger.append("/add.asp?pass=doit&id=");
logger.append(temp);
if (debug) serial.println(temp); //uncomment view tag id
if(id.contains(temp) && temp.length() > 0)
{
serial.println("> access granted.");
logger.append("&access=granted");
myservo.write(door_unlocked); //move servo unlocked position
locked = false;
previousmillis = millis();
}
else
{
serial.println("> access denied.");
logger.append("&access=denied");
myservo.write(door_locked); //move servo locked position, sure
}
if (debug) serial.println(logger);
webclient_get(server_ip, 80, logger);
wifi.run();
}serial output says:
quote
> access granted.
/add.asp?pass=doit&id=3a008602358b&access=granted
and if manually call http://192.168.1.6/add.asp?pass=doit&id=3a008602358b&access=granted
it adds database
what doing wrong? modified twitter sketch, maybe removed bit much?
updated code, problems wishield , rfid reader, because accidently used same pin multiple things.
that fixed, still got problem wishield not accessing url want to
that fixed, still got problem wishield not accessing url want to
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > WiShield 2.0 client
arduino
Comments
Post a Comment