Lucas Citolin / Mbed OS Autoline
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Connectivity.h Source File

Connectivity.h

00001 /*
00002  * Connectivity.h
00003  *
00004  *  Created on: Jul 16, 2018
00005  *      Author: Claudio Pinheiro
00006  */
00007 
00008 #include "mbed.h"
00009 #include "EthernetInterface.h"
00010 #include "TCPServer.h"
00011 #include "TCPSocket.h"
00012 
00013 #ifndef PLC_CONNECTIVITY_H_
00014 #define PLC_CONNECTIVITY_H_
00015 
00016 
00017 #define IP "192.168.0.177"
00018 #define MASK "255.255.255.0"
00019 #define GATEWAY "192.168.0.1"
00020 
00021 class Connectivity {
00022 public:
00023     Connectivity();
00024     virtual ~Connectivity();
00025     
00026     int send(char *data, int length);
00027     void registerReadCallback(Callback<void(char*,int)> r);
00028 
00029 private:
00030     void monitor();
00031     //void monitor2();
00032 
00033     Thread thread;
00034     EthernetInterface eth1;
00035     
00036     Callback<void(char*,int)> readCallback;
00037     
00038     Serial pc;
00039 
00040     void foo(nsapi_event_t event, intptr_t arg);
00041 
00042     DigitalOut led_link;
00043 
00044     EthernetInterface eth;
00045     TCPServer srv;
00046     TCPSocket client;
00047     SocketAddress client_addr;
00048 
00049     char buffer[256];
00050 };
00051 
00052 #endif /* PLC_CONNECTIVITY_H_ */