merhaba. enc28j60 ile arduinoyu ağa bağlayıp sorunsuz ip alıyorum. ağda bir linux bir de windows sunucu var. windows sunucudan aşağıdaki kod ile istemci olarak cevap alabiliyorum. ama IP adresini değiştirip linux sunucudan veri almak istediğimde tutarsız çalışıyor. 10 dk içerisinde ard arda ve ara vererek test ediyorum sadece 1-2 sefer cevap alabiliyorum. linux sunucuda “iftop” komutu ile trafik izliyorum. sadece cevap alabildiğim zamanlarda istek listeye geliyor. cevap alamadığım zamanlarda istek ağ kartına bile gelmiyor. (Yani ben ağ kartına bile gelmediğini düşünüyorum iftop uygulamasına bile düşmediği için) kodu notifiymyadnroid örneğinden değiştirerek oluşturdum. dediğim gibi windows sunucuan talep edilen isteklerde sorunsuz çalışıyor kod: // This demo shows how to send a notification to the Notify My Android service // // Warning: Due to the limitations of the Arduino, this demo uses insecure // HTTP to interact with the nma api (not HTTPS). The API key WILL be sent // accross the wire in plain text. // // 2015-04-10 http://opensource.org/licenses/mit-license.php
#include <ethercard.h>
const char apihost PROGMEM = “192.168.0.12”;
static byte mymac = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };
byte Ethernet::buffer[900];
Stash stash;
static byte session;
static void notifyMyAndroid () {
byte sd = stash.create();
stash.print(“apikey=”);
stash.print(“0”);
stash.save();
int stash_size = stash.size();
// Compose the http POST request, taking the headers below and appending
// previously created stash in the sd holder.
Stash::prepare(PSTR(“POST /publicapi/notify HTTP/1.1” “\r\n”
“Host: $F” “\r\n”
“Content-Length: $D” “\r\n”
“Content-Type: text/html” “\r\n”
“\r\n”
“$H”),
apihost, stash_size, sd);
// send the packet - this also releases all stash buffers once done
// Save the session ID so we can watch for it in the main loop.
session = ether.tcpSend();
Serial.println("Session: " + (String)session);
}
void setup () {
Serial.begin(57600);
Serial.println(“\nStarting Notify My Android Example”);
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F(“Failed to access Ethernet controller”));
if (!ether.dhcpSetup())
Serial.println(F(“DHCP failed”));
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
ether.printIp("DNS: ", ether.netmask);
//ether.using_dhcp = true;
/if (!ether.dnsLookup(apihost))
Serial.println(F(“DNS lookup failed for the apihost”));/
ether.hisip[0] = 192;
ether.hisip[1] = 168;
ether.hisip[2] = 0;
ether.hisip[3] = 12;
ether.printIp("SRV: ", ether.hisip);
notifyMyAndroid();
}
void loop () {
ether.packetLoop(ether.packetReceive());
const char* reply = ether.tcpReply(session);
if (reply != 0) {
Serial.println(“Got a response!”);
Serial.println(reply);
}
}
linux:
https://i.imgsafe.org/c6140c375f.png
windows:
https://i.imgsafe.org/c614181a21.png
linux sunucun ubuntu 16.04 server
</ethercard.h>