For test

Dependencies:   mbed

Committer:
shennongmin
Date:
Fri Jan 30 11:45:49 2015 +0000
Revision:
4:962bf18523f4
Child:
5:218b5decd1ea
Add uartWiFi.h/cpp files. ready to transplant.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shennongmin 4:962bf18523f4 1
shennongmin 4:962bf18523f4 2 /*
shennongmin 4:962bf18523f4 3 ESP8266 library
shennongmin 4:962bf18523f4 4
shennongmin 4:962bf18523f4 5 Created by Stan Lee(Lizq@iteadstudio.com)
shennongmin 4:962bf18523f4 6 2014/10/8
shennongmin 4:962bf18523f4 7
shennongmin 4:962bf18523f4 8 Modified version
shennongmin 4:962bf18523f4 9 V1.0 released the first version of ESP8266 library
shennongmin 4:962bf18523f4 10
shennongmin 4:962bf18523f4 11
shennongmin 4:962bf18523f4 12
shennongmin 4:962bf18523f4 13 */
shennongmin 4:962bf18523f4 14
shennongmin 4:962bf18523f4 15 #ifndef __UARTWIFI_H__
shennongmin 4:962bf18523f4 16 #define __UARTWIFI_H__
shennongmin 4:962bf18523f4 17 #include <Arduino.h>
shennongmin 4:962bf18523f4 18 //#include "NilRTOS.h"
shennongmin 4:962bf18523f4 19 #include <SoftwareSerial.h>
shennongmin 4:962bf18523f4 20
shennongmin 4:962bf18523f4 21 #define _DBG_RXPIN_ 2
shennongmin 4:962bf18523f4 22 #define _DBG_TXPIN_ 3
shennongmin 4:962bf18523f4 23
shennongmin 4:962bf18523f4 24 #define debugBaudRate 9600
shennongmin 4:962bf18523f4 25
shennongmin 4:962bf18523f4 26
shennongmin 4:962bf18523f4 27 //#define UNO //uncomment this line when you use it with UNO board
shennongmin 4:962bf18523f4 28 #define MEGA //uncomment this line when you use it with MEGA board
shennongmin 4:962bf18523f4 29
shennongmin 4:962bf18523f4 30
shennongmin 4:962bf18523f4 31 #define DEBUG
shennongmin 4:962bf18523f4 32
shennongmin 4:962bf18523f4 33
shennongmin 4:962bf18523f4 34 #ifdef UNO
shennongmin 4:962bf18523f4 35 #define _cell Serial
shennongmin 4:962bf18523f4 36 #define DebugSerial mySerial
shennongmin 4:962bf18523f4 37
shennongmin 4:962bf18523f4 38 #endif
shennongmin 4:962bf18523f4 39 #ifdef MEGA
shennongmin 4:962bf18523f4 40 #define _cell Serial1
shennongmin 4:962bf18523f4 41 #define DebugSerial Serial
shennongmin 4:962bf18523f4 42 #endif
shennongmin 4:962bf18523f4 43
shennongmin 4:962bf18523f4 44
shennongmin 4:962bf18523f4 45
shennongmin 4:962bf18523f4 46
shennongmin 4:962bf18523f4 47 #ifdef UNO
shennongmin 4:962bf18523f4 48 extern SoftwareSerial mySerial;
shennongmin 4:962bf18523f4 49
shennongmin 4:962bf18523f4 50 #endif
shennongmin 4:962bf18523f4 51
shennongmin 4:962bf18523f4 52
shennongmin 4:962bf18523f4 53 //The way of encrypstion
shennongmin 4:962bf18523f4 54 #define OPEN 0
shennongmin 4:962bf18523f4 55 #define WEP 1
shennongmin 4:962bf18523f4 56 #define WAP_PSK 2
shennongmin 4:962bf18523f4 57 #define WAP2_PSK 3
shennongmin 4:962bf18523f4 58 #define WAP_WAP2_PSK 4
shennongmin 4:962bf18523f4 59
shennongmin 4:962bf18523f4 60 //Communication mode
shennongmin 4:962bf18523f4 61 #define TCP 1
shennongmin 4:962bf18523f4 62 #define tcp 1
shennongmin 4:962bf18523f4 63 #define UDP 0
shennongmin 4:962bf18523f4 64 #define udp 0
shennongmin 4:962bf18523f4 65
shennongmin 4:962bf18523f4 66 #define OPEN 1
shennongmin 4:962bf18523f4 67 #define CLOSE 0
shennongmin 4:962bf18523f4 68
shennongmin 4:962bf18523f4 69 //The type of initialized WIFI
shennongmin 4:962bf18523f4 70 #define STA 1
shennongmin 4:962bf18523f4 71 #define AP 2
shennongmin 4:962bf18523f4 72 #define AP_STA 3
shennongmin 4:962bf18523f4 73
shennongmin 4:962bf18523f4 74 #define SERIAL_TX_BUFFER_SIZE 128
shennongmin 4:962bf18523f4 75 #define SERIAL_RX_BUFFER_SIZE 128
shennongmin 4:962bf18523f4 76
shennongmin 4:962bf18523f4 77
shennongmin 4:962bf18523f4 78
shennongmin 4:962bf18523f4 79
shennongmin 4:962bf18523f4 80
shennongmin 4:962bf18523f4 81 class WIFI
shennongmin 4:962bf18523f4 82 {
shennongmin 4:962bf18523f4 83 public:
shennongmin 4:962bf18523f4 84
shennongmin 4:962bf18523f4 85 void begin(void);
shennongmin 4:962bf18523f4 86
shennongmin 4:962bf18523f4 87 //Initialize port
shennongmin 4:962bf18523f4 88 bool Initialize(byte mode, String ssid, String pwd, byte chl = 1, byte ecn = 2);
shennongmin 4:962bf18523f4 89 boolean ipConfig(byte type, String addr, int port, boolean a = 0, byte id = 0);
shennongmin 4:962bf18523f4 90
shennongmin 4:962bf18523f4 91 boolean Send(String str); //send data in sigle connection mode
shennongmin 4:962bf18523f4 92 boolean Send(byte id, String str); //send data int multiple connection mode
shennongmin 4:962bf18523f4 93
shennongmin 4:962bf18523f4 94 int ReceiveMessage(char *buf);
shennongmin 4:962bf18523f4 95
shennongmin 4:962bf18523f4 96 //String begin(void);
shennongmin 4:962bf18523f4 97 /*=================WIFI Function Command=================*/
shennongmin 4:962bf18523f4 98 void Reset(void); //reset the module
shennongmin 4:962bf18523f4 99 bool confMode(byte a); //set the working mode of module
shennongmin 4:962bf18523f4 100 boolean confJAP(String ssid , String pwd); //set the name and password of wifi
shennongmin 4:962bf18523f4 101 boolean confSAP(String ssid , String pwd , byte chl , byte ecn); //set the parametter of SSID, password, channel, encryption in AP mode.
shennongmin 4:962bf18523f4 102
shennongmin 4:962bf18523f4 103 String showMode(void); //inquire the current mode of wifi module
shennongmin 4:962bf18523f4 104 String showAP(void); //show the list of wifi hotspot
shennongmin 4:962bf18523f4 105 String showJAP(void); //show the name of current wifi access port
shennongmin 4:962bf18523f4 106 boolean quitAP(void); //quit the connection of current wifi
shennongmin 4:962bf18523f4 107 String showSAP(void); //show the parameter of ssid, password, channel, encryption in AP mode
shennongmin 4:962bf18523f4 108
shennongmin 4:962bf18523f4 109 /*================TCP/IP commands================*/
shennongmin 4:962bf18523f4 110 String showStatus(void); //inquire the connection status
shennongmin 4:962bf18523f4 111 String showMux(void); //show the current connection mode(sigle or multiple)
shennongmin 4:962bf18523f4 112 boolean confMux(boolean a); //set the connection mode(sigle:0 or multiple:1)
shennongmin 4:962bf18523f4 113 boolean newMux(byte type, String addr, int port); //create new tcp or udp connection (sigle connection mode)
shennongmin 4:962bf18523f4 114 boolean newMux(byte id, byte type, String addr, int port); //create new tcp or udp connection (multiple connection mode)(id:0-4)
shennongmin 4:962bf18523f4 115 void closeMux(void); //close tcp or udp (sigle connection mode)
shennongmin 4:962bf18523f4 116 void closeMux(byte id); //close tcp or udp (multiple connection mode)
shennongmin 4:962bf18523f4 117 String showIP(void); //show the current ip address
shennongmin 4:962bf18523f4 118 boolean confServer(byte mode, int port); //set the parameter of server
shennongmin 4:962bf18523f4 119
shennongmin 4:962bf18523f4 120 String m_rev;
shennongmin 4:962bf18523f4 121
shennongmin 4:962bf18523f4 122 };
shennongmin 4:962bf18523f4 123
shennongmin 4:962bf18523f4 124 #endif