LeweiTcpClient::LeweiTcpClient(const char *userKey,const char *gatewayNo):
	server(EthernetServer(80)),
	tcpServer("tcp.lewei50.com")
{
	_userKey = (char*)malloc( strlen(userKey)+1 );
	strcpy( _userKey,userKey );
	
	_gatewayNo = (char*)malloc( strlen(gatewayNo)+1 );
	strcpy( _gatewayNo,gatewayNo );
	
	setupDefaultValue();
	
	//Ethernet.begin(_mac);
	byte _mac[] = {0x74, 0x69, 0x69, 0x2D, 0x30, 0x31};
	if (Ethernet.begin(_mac) == 0) {
    Serial.println("fail");
    // no point in carrying on, so do nothing forevermore:
    for (;;)
      ;
  }
	Serial.println(Ethernet.localIP());
	//Ethernet.begin(mac, ip);
	delay(1000);
	String clientStr="";
	keepOnline();
}
void ServerController::start() {
    // Set up the Ethernet server.
    // TODO: Use configurable port!
    ServerController::server = EthernetServer(23);

    // Set the started flag
    ServerController::started = true;
}
AtMegaWebServer::AtMegaWebServer(PathHandler handlers[],
			     const char** headers)
  : handlers_(handlers),
    server_(EthernetServer(80)),
    path_(NULL),
    request_type_(UNKNOWN_REQUEST),
    client_(EthernetClient(255))
     {
  if (headers) initHeaders(headers);
  }
LeweiTcpClient::LeweiTcpClient( const char *userKey,const char *gatewayNo,byte mac[],IPAddress ip,IPAddress dns,IPAddress gw,IPAddress subnet):
	server(EthernetServer(80)),
	tcpServer("tcp.lewei50.com")
{
	_userKey = (char*)malloc( strlen(userKey)+1 );
	strcpy( _userKey,userKey );
	
	_gatewayNo = (char*)malloc( strlen(gatewayNo)+1 );
	strcpy( _gatewayNo,gatewayNo );
	
	setupDefaultValue();
	Ethernet.begin(mac,ip,dns,gw,subnet);
	Serial.println(Ethernet.localIP());
	delay(1000);
	String clientStr="";
	keepOnline();
}
Exemple #5
0
TinyWebServer::TinyWebServer(PathHandler handlers[],
			     const char** headers)
  : handlers_(handlers),
    server_(EthernetServer(8000)),
    path_(NULL),
    request_type_(UNKNOWN_REQUEST),
    client_(EthernetClient(255)) {
  if (headers) {
    int size = 0;
    for (int i = 0; headers[i]; i++) {
      size++;
    }
    headers_ = (HeaderValue*)malloc_check(sizeof(HeaderValue) * (size + 1));
    if (headers_) {
      for (int i = 0; i < size; i++) {
        headers_[i].header = headers[i];
        headers_[i].value = NULL;
      }
      headers_[size].header = NULL;
    }
  }
}
Exemple #6
0
 *
 * Loguino is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Loguino.  If not, see "http://www.gnu.org/licenses/".
 *
*/



#ifdef ENABLE_ETHERNET_LOGGER
    #ifdef ETHERNET_ENABLE_SERVER
        EthernetServer eth_server = EthernetServer(ETHERNET_SERVER_PORT);
    #endif

    #ifdef ETHERNET_ENABLE_MQTT
        EthernetClient ethClient;
        byte mqtt_server[] = { ETHERNET_MQTT_SERVER };
        PubSubClient mqtt_client(mqtt_server, ETHERNET_MQTT_PORT, mqtt_callback, ethClient);
    #endif

    void mqtt_callback(char* topic, byte* payload, unsigned int length) {
        // handle message arrived, there wont be any however.
        return;
    }


    void init_ethernet_logger(){
 *
 *      -----------------
 *
 * This Hello World example sets up a server at 192.168.1.6 on port 1000.
 * Telnet here to access the service.  The uIP stack will also respond to
 * pings to test if you have successfully established a TCP connection to
 * the Arduino.
 *
 * This example was based upon uIP hello-world by Adam Dunkels <*****@*****.**>
 * Ported to the Arduino IDE by Adam Nielsen <*****@*****.**>
 * Adaption to Enc28J60 by Norbert Truchsess <*****@*****.**>
 */

#include <UIPEthernet.h>

EthernetServer server = EthernetServer(1000);

void setup()
{
	Serial.begin(9600);

	uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
	IPAddress myIP(192,168,0,6);

	Serial.println("Iniciando...");

	Ethernet.begin(mac,myIP);

	server.begin();

	Serial.println("Rodando!!!");