Denver Hayward / Mbed OS Robot

Dependencies:   Commands charQueue esp8266-driver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wifi.h Source File

wifi.h

00001 #ifndef __WIFI_INCLUDED__
00002 #define __WIFI_INCLUDED__
00003 
00004 #define DEBUG
00005 #define DELAY 15
00006 #define BUFFERSIZE 256
00007 #define QUEUESIZE 1024
00008 #define CONNECTDELAY 3000
00009 #define SOCKETTIMEOUT 5000
00010 
00011 #include "mbed.h"
00012 #include "TCPSocket.h"
00013 #include "ESP8266Interface.h"
00014 #include "objectQueue.h"
00015 #include "commands.h"
00016 #include <string>
00017 #include <sstream>
00018 
00019 class Wifi : public ESP8266Interface{
00020 private:
00021     Thread wifi_thread;
00022     TCPSocket *sender, *receiver;
00023     int port;
00024     char host[15]; 
00025     
00026     DigitalOut ch_pd, rst;
00027     
00028     StrQueue sendQueue;
00029     StrQueue recvQueue;
00030     
00031     char rbuffer[BUFFERSIZE];
00032     char ssbuffer[BUFFERSIZE];
00033     char srbuffer[BUFFERSIZE];
00034 
00035     bool sendConnected, recvConnected;
00036     int sendState, recvState;
00037     bool sendReady, recvReady;
00038     
00039     void run();
00040     int connectWifi();
00041     int connectSockets();
00042 
00043 public:
00044     Wifi(osPriority, int);
00045     void start();
00046     int send(string message);
00047     int send(char* message);
00048     int send(int message);
00049     
00050     Message recv();
00051 };
00052 
00053 #endif