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 3:24f12bc2b76d, committed 2018-07-02
- Comitter:
- nikitoslav
- Date:
- Mon Jul 02 09:17:05 2018 +0000
- Parent:
- 2:f149c178dd58
- Child:
- 4:e584e034f9e1
- Commit message:
- 5
Changed in this revision
| ESP8266.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ESP8266.lib Wed Jun 27 10:33:32 2018 +0000 +++ b/ESP8266.lib Mon Jul 02 09:17:05 2018 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/nikitoslav/code/ESP8266/#3518f7c570de +https://os.mbed.com/users/nikitoslav/code/ESP8266/#72756a2b1a87
--- a/main.cpp Wed Jun 27 10:33:32 2018 +0000
+++ b/main.cpp Mon Jul 02 09:17:05 2018 +0000
@@ -2,8 +2,8 @@
#include <string>
#include "ESP8266.h"
-int localOutPort = 3001;
-int localInPort = 3002;
+int localOutPort = 49100;
+int localInPort = 49101;
Serial console(USBTX,USBRX);
ESP8266 wifi(PF_7,PF_6,localOutPort,localInPort);
@@ -14,7 +14,7 @@
Thread listeningThread;
void onReceive(void);
-void processReceivedData(string);
+void processReceivedData(string, char*, int);
int main() {
console.baud(9600);
@@ -22,7 +22,7 @@
console.printf("Your IP is: %s\n",wifi.getIPAddress());
else
console.printf("Can not connect to the Wi-Fi router\n");
- wifi.send("privetFromESP8266",17,"192.168.0.103",8000);
+ // wifi.send("privetFromESP8266",17,"192.168.0.103",8000);
listeningThread.start(onReceive);
}
@@ -43,11 +43,14 @@
buf += buffer[i];
}
console.printf("Data: %s\n",buf);
- processReceivedData(buf);
+ processReceivedData(buf,IP,port);
}
}
}
-void processReceivedData(string data) {
-
+void processReceivedData(string data, char* IP, int port) {
+ if (port == localOutPort) {
+ string msg = "?HiClientImARobotClapeyron|hardvers|0.1?";
+ if (data == "HiRobotClapeyronImAClient") wifi.send(msg.c_str(),msg.length(),IP,localInPort);
+ }
}
\ No newline at end of file