Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@1:52cad7057640, 2016-05-28 (annotated)
- Committer:
- gauresh2798
- Date:
- Sat May 28 15:18:17 2016 +0000
- Revision:
- 1:52cad7057640
- Parent:
- 0:c359fee24b6c
- Child:
- 2:d5c9337fdce1
commit 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gauresh2798 | 0:c359fee24b6c | 1 | /* |
gauresh2798 | 0:c359fee24b6c | 2 | NOTE: |
gauresh2798 | 0:c359fee24b6c | 3 | Devices or pins are added in the library[EDUVANCE_WIFI_SHIELD.cpp] |
gauresh2798 | 0:c359fee24b6c | 4 | HTML PART IS THERE IN sendpage() |
gauresh2798 | 0:c359fee24b6c | 5 | RESPONSE IS IN ReadWebData() |
gauresh2798 | 0:c359fee24b6c | 6 | */ |
gauresh2798 | 0:c359fee24b6c | 7 | #include "mbed.h" |
gauresh2798 | 0:c359fee24b6c | 8 | #include "EDUVANCE_WIFI_SHIELD.h" |
gauresh2798 | 0:c359fee24b6c | 9 | //All the initializations must be done in proper order for reliable functioning |
gauresh2798 | 0:c359fee24b6c | 10 | //connect pin 3 and 4 of ESP_COMM_CTRL HEADER TO SCL AND SDA respectively (ON THE SHIELD) |
gauresh2798 | 0:c359fee24b6c | 11 | /* |
gauresh2798 | 0:c359fee24b6c | 12 | ESP_COMM_CTRL |
gauresh2798 | 0:c359fee24b6c | 13 | (1) (2) |
gauresh2798 | 0:c359fee24b6c | 14 | (3) (4) |
gauresh2798 | 0:c359fee24b6c | 15 | (5) (6) |
gauresh2798 | 0:c359fee24b6c | 16 | (7) (8) |
gauresh2798 | 0:c359fee24b6c | 17 | */ |
gauresh2798 | 0:c359fee24b6c | 18 | |
gauresh2798 | 0:c359fee24b6c | 19 | //FOR STATION MODE SSID, PASSWORD ARE NEEDED |
gauresh2798 | 0:c359fee24b6c | 20 | char ssid_main[32]="@@@@@@@"; |
gauresh2798 | 0:c359fee24b6c | 21 | char pwd_main[32]="@@@@@@@@@@@@@"; |
gauresh2798 | 0:c359fee24b6c | 22 | int port_main=8266; |
gauresh2798 | 0:c359fee24b6c | 23 | |
gauresh2798 | 0:c359fee24b6c | 24 | //SELECT MODES: STATION=10 AND AP=20 |
gauresh2798 | 1:52cad7057640 | 25 | |
gauresh2798 | 0:c359fee24b6c | 26 | int run1=1; |
gauresh2798 | 0:c359fee24b6c | 27 | int main() { |
gauresh2798 | 0:c359fee24b6c | 28 | |
gauresh2798 | 0:c359fee24b6c | 29 | //SET THE BAUD RATE OF UARTS TO DISPLAY MESSAGE ON COMPUTER AND TO INPUT TO AT COMMANDS TO ESP |
gauresh2798 | 0:c359fee24b6c | 30 | setbaudrate(115200); |
gauresh2798 | 0:c359fee24b6c | 31 | |
gauresh2798 | 0:c359fee24b6c | 32 | //SEND THE SSID, PASSWORD AND USER DEFINED PORT ADDRESS TO THE LIBRARY |
gauresh2798 | 0:c359fee24b6c | 33 | get_ssid_pass(ssid_main,pwd_main,port_main); |
gauresh2798 | 0:c359fee24b6c | 34 | |
gauresh2798 | 0:c359fee24b6c | 35 | /* |
gauresh2798 | 0:c359fee24b6c | 36 | START SERVER |
gauresh2798 | 0:c359fee24b6c | 37 | THE FUNCTION RETURNS THE VALUE 10 IF THE ABOVE GIVEN SSID IS ACTIVE NEARBY |
gauresh2798 | 0:c359fee24b6c | 38 | OR ELSE IT RETURNS 20. |
gauresh2798 | 0:c359fee24b6c | 39 | */ |
gauresh2798 | 0:c359fee24b6c | 40 | modeselector=startserver(); |
gauresh2798 | 0:c359fee24b6c | 41 | |
gauresh2798 | 0:c359fee24b6c | 42 | if(modeselector==10){ |
gauresh2798 | 0:c359fee24b6c | 43 | //CONFIGUR IN STATION MODE AND GET A VALID IP ADDRESS FROM SERVER |
gauresh2798 | 0:c359fee24b6c | 44 | StationConfig(); |
gauresh2798 | 0:c359fee24b6c | 45 | } |
gauresh2798 | 0:c359fee24b6c | 46 | else if(modeselector==20){ |
gauresh2798 | 0:c359fee24b6c | 47 | //CONFIGUR IN AP MODE AND GENERATE A WIFI ACCESS POINT (HOTSPOT) WITH VALID IP ADDRESS |
gauresh2798 | 0:c359fee24b6c | 48 | ApConfig(); |
gauresh2798 | 0:c359fee24b6c | 49 | |
gauresh2798 | 0:c359fee24b6c | 50 | } |
gauresh2798 | 0:c359fee24b6c | 51 | |
gauresh2798 | 0:c359fee24b6c | 52 | //DO THIS OPERATION CONTINUOUSLY |
gauresh2798 | 0:c359fee24b6c | 53 | while(1){ |
gauresh2798 | 0:c359fee24b6c | 54 | //DISPLAY A STATIC WEBPAGE AND GET THE VALUES SET BY USER ON IT. |
gauresh2798 | 0:c359fee24b6c | 55 | if(modeselector==10){ |
gauresh2798 | 0:c359fee24b6c | 56 | |
gauresh2798 | 0:c359fee24b6c | 57 | request_fetch_station(); |
gauresh2798 | 0:c359fee24b6c | 58 | } |
gauresh2798 | 0:c359fee24b6c | 59 | else if(modeselector==20){ |
gauresh2798 | 0:c359fee24b6c | 60 | |
gauresh2798 | 0:c359fee24b6c | 61 | request_fetch_ap(); |
gauresh2798 | 0:c359fee24b6c | 62 | |
gauresh2798 | 0:c359fee24b6c | 63 | } |
gauresh2798 | 0:c359fee24b6c | 64 | |
gauresh2798 | 0:c359fee24b6c | 65 | } |
gauresh2798 | 0:c359fee24b6c | 66 | } |