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.
Revision 2:01696b00d551, committed 2015-12-27
- Comitter:
- nasrullah
- Date:
- Sun Dec 27 18:36:29 2015 +0000
- Parent:
- 1:e9d1c42a73ae
- Commit message:
- This program esp8266MOD wifi module communication with nucleo f446re, just receive data from esp via serial1 in nucleo (PA_9,PA_10). before run this program just be sure your esp has been connected to AP near you..have fun...
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Feb 28 06:52:34 2014 +0000
+++ b/main.cpp Sun Dec 27 18:36:29 2015 +0000
@@ -1,21 +1,84 @@
#include "mbed.h"
+#include <string>
-//------------------------------------
-// Hyperterminal configuration
-// 9600 bauds, 8-bit data, no parity
-//------------------------------------
+Serial pc(USBTX, USBRX);
+Serial esp(PA_9,PA_10);
-Serial pc(SERIAL_TX, SERIAL_RX);
-
-DigitalOut myled(LED1);
+
+Timer t;
-int main() {
- int i = 1;
- pc.printf("Hello World !\n");
- while(1) {
- wait(1);
- pc.printf("This program runs since %d seconds.\n", i++);
- myled = !myled;
- }
+int count,ended,timeout;
+char buf[1024];
+char snd[255];
+
+void getreply(),SendCMD();
+
+int main()
+{
+
+//int a=34;
+//int cm=1;
+//int mode=1;
+//int port=333;
+
+//char ssid[10]="reborn",psd[15]="sempakkoyak";
+esp.baud(115200);
+pc.baud(115200);
+//pc.puts("Hi! this uses type anytihing\r\n");
+//esp.printf("%s\r\n");
+//esp.printf("AT+RST\r\n");
+//wait(10);
+//esp.printf("AT\r\n");
+//wait(2);
+//esp.printf("AT+CWMODE=3\r\n");
+//wait(2);
+//esp.printf("AT+CWJAP=%c%s%c,%c%s%c\r\n",a,ssid,a,a,psd,a);
+//wait(10);
+//esp.printf("AT+CIPMUX=%i\r\n",cm);
+//wait(5);
+//esp.printf("AT+CIPSERVER=%i,%i\r\n",mode,port);
+//wait(10);
+ strcpy(snd,"AT+CWLAP\r\n");
+ SendCMD();
+
+ //wait(5);
+ //strcpy(snd,"AT+CWLAP\r\n");
+ // SendCMD();
+ //timeout=3;
+ //wait(10);
+ // getreply();
+ // pc.printf(buf);
+while(1)
+{
+
+
+ timeout=3;
+ getreply();
+ pc.printf(buf);
+
}
-
\ No newline at end of file
+
+}
+
+void SendCMD()
+{
+ esp.printf("%s", snd);
+}
+
+void getreply()
+{
+ memset(buf, '\0', sizeof(buf));
+ t.start();
+ ended=0;count=0;
+ while(!ended) {
+ if(esp.readable()) {
+ buf[count] = esp.getc();count++;
+ }
+ if(t.read() > timeout) {
+ ended = 1;t.stop();t.reset();
+ }
+ }
+}
+
+
+
--- a/mbed.bld Fri Feb 28 06:52:34 2014 +0000 +++ b/mbed.bld Sun Dec 27 18:36:29 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ed8466a608b4 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file