Go Down

Topic: CC3000 get remote ip (Read 275 times) previous topic - next topic

Techno500

There is a modded Ethernet library to get remote ip: https://github.com/per1234/EthernetMod

Does anyone have a modded library for the Adafruit CC3000  that can get client remote ip (TCP)?


Adafruit CC3000 library:  https://github.com/adafruit/Adafruit_CC3000_Library

Code: [Select]
// Open a "access.txt" for appended writing.   Client access ip address logged.

SdFile logFile;
logFile.open("access.txt", O_WRITE | O_CREAT | O_APPEND);

if (!logFile.isOpen()) error("log");

IPAddress ip1(10,0,0,15);  //Server ip address
IPAddress ip2(10,0,0,146);  //Host ip address

//Do not log Host computer ip
if ((client.remoteIP() == ip2))   //Compare client ip address with Host ip address
{
exit;
}
else
{
logFile.print("Accessed:  ");
getDateTime(); //get accessed date and time
logFile.print(dtStamp + " -- ");
logFile.print(client.remoteIP());
logFile.print(" -- ");
logFile.print("Path:  ");
logFile.println(path);
logFile.close();
}




William

PaulS

Code: [Select]
if ((client.remoteIP() == ip2))   //Compare client ip address with Host ip address
{
exit;
}

What do you think this code is doing?
The art of getting good answers lies in asking good questions.

Techno500

@ PaulS

Quote
if ((client.remoteIP() == ip2))   //Compare client ip address with Host ip address
{
   exit;
}


What do you think this code is doing?
Compares remote client ip address to host ip address.  If it is host ip address; exit (do not log.)
remoteIP() is part of the "Modded Ethernet.h library."

PaulS

Quote
If it is host ip address; exit (do not log.)
Read that code carefully. exit; doesn't do anything!
The art of getting good answers lies in asking good questions.

Go Up