Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- Serial.begin(9600);
- WiFi.mode(WIFI_AP);
- WiFi.softAP("myap", "mypass");
- WiFi.softAPConfig(IP, IP, mask);
- server.begin();
- }
- void loop() {
- WiFiClient client = server.available();
- if (!client) {
- return;
- }
- String request = client.readStringUntil('r');
- Serial.println("From STA: " + request);
- client.println("DATA 1r"); // data 1
- client.println("DATA 2r"); // data 2
- client.flush();
- client.stop();
- }
- void setup() {
- Serial.begin(9600);
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, pass);
- while (WiFi.status() != WL_CONNECTED) {
- Serial.print(".");
- delay(300);
- }
- }
- void loop() {
- client.connect(server, 80);
- client.print("DATA 3 r");
- String answer = client.readStringUntil('r');
- Serial.println("From AP: " + answer);
- client.flush();
- client.stop();
- }
- From STA: DATA 3
- From STA: DATA 3
- From STA: DATA 3
- .
- .
- .
- From AP: DATA 1
- From AP: DATA 1
- From AP: DATA 1
- .
- .
- .
- 0-> loop start
- 1-> Client Connect
- 2-> Get Request Client -> (async (not waiting request))
- 3-> send client "data 1" -> Send OKAY (async)
- 4-> send client "data 2" -> Send Okay (async)
- 5-> client disconnect -> (because need new clients connect (1) ) -> max 8 client.
- 6-> loop again.
- 0-> loop start
- 1-> server connect (async)
- 2-> send server "data 3" -> (async)
- 3-> get "data" from server -> only works first data.!! (async)
- (This problem.) im need get all data.
- 4-> show data in Serial -> (async)
- 5-> disconnect from server (because) server-> allows 1 connection at the same time
- 6-> loop again
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement