Arkadaşlar, aşağıda ardunio için yazılan, internet yani web kontrollü led ve röle için yazılmış kodları görüyorsunuz. C temelim olduğundan belli bir yere kadar anladım. Ancak, kodlar arasındaki <<strstr((char *)Ethernet::buffer + pos, "GET /?status=ON">> gibi veya,
<<
word len = ether.packetReceive();
word pos = ether.packetLoop(len); >> gibi kodları anlayamıyorum.
Bunlar hangi dilin komutları. Bu dili öğreten bir kitap tavsiyeniz olurmu?
#include <EtherCard.h>
static byte mymac[] = {0xDE,0xAD,0xBE,0xEF,0xFE,0xED};
//static byte myip[] = {192,168,2,3};
byte Ethernet::buffer[700];
const int ledPin = 2;
const int rolePin=3;
boolean ledDurum;
boolean roleDurum;
char* ac = "ON";
char* kapa = "OFF";
char* lDurum;
char* LabelButon;
char* roleAc="RoleAcik";
char* roleKapa="RoleKapali";
char* rDurum;
char* roleButon;
void setup () {
Serial.begin(9600);
Serial.println("Web Led Kontrol");
if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
Serial.println( "Ethernet kontrolu ile baglanti saglanamadi");
else
Serial.println("Ethernet kontrolu kuruluyor.");
if(ether.dhcpSetup())//dhcp serverdan konfigurasyon alınır
{
Serial.println("DHCP konfigurasyon saglandi");
}
else
{
Serial.println("DHCP konfigurasyon saglanamadi");
}
//serial monitöre ip adresini printIp() metoduyla gönderebiliriz.
ether.printIp("IP ADRES:\t",ether.myip);
ether.printIp("NetMAsk:\t",ether.netmask);
ether.printIp("GateWay:\t",ether.gwip);
Serial.println();
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
ledDurum = false;
pinMode(rolePin,OUTPUT);
digitalWrite(rolePin,HIGH);
roleDurum=false;
}
void loop() {
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if(pos) {
if(strstr((char *)Ethernet::buffer + pos, "GET /?status=ON") != 0) {
Serial.println("ON komutu alindi");
ledDurum = true;
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?status=OFF") != 0) {
Serial.println("OFF komutu alindi");
ledDurum = false;
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?status=RoleAcik") != 0) {
Serial.println("Röle Aç komutu Alındı");
roleDurum = true;
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?status=RoleKapali") != 0) {
Serial.println("Role Kapat Komutu Alındı");
roleDurum = false;
}
if(ledDurum) {
digitalWrite(ledPin, HIGH);
lDurum = ac;
LabelButon = kapa;
} else
{
digitalWrite(ledPin, LOW);
lDurum = kapa;
LabelButon = ac;
}
if(roleDurum) {
digitalWrite(rolePin, LOW);
rDurum = roleAc;
roleButon =roleKapa;
} else
{
digitalWrite(rolePin, HIGH);
rDurum = roleKapa;
roleButon = roleAc;
}
BufferFiller bfill = ether.tcpOffset();
bfill.emit_p(PSTR(
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
"<html><HEAD>"
"<title>web kontrol</title>"
"</HEAD>"
"<body><h2>LED Durum: $S </h2></br>"
"<h2> Role Durum: $S</h2></br>"
"<a href=\"/?status=$S\"><input type=\"button\" value=\"$S\"></a>"
"<a href=\"/?status=$S\"><input type=\"button\" value=\"$S\"></a>"
"</body></html>"
), lDurum, rDurum,LabelButon, LabelButon,roleButon,roleButon);
ether.httpServerReply(bfill.position());
}
}