@@ -130,7 +130,53 @@ void loop() {
130130 * which might not guarantee the correct functioning of the ConnectionHandler
131131 * object.
132132 */
133- conMan.check();
133+ if (conMan.check() != NetworkConnectionState::CONNECTED) {
134+ return;
135+ }
136+
137+ #if !defined(BOARD_HAS_LORA)
138+ Client &client = conMan.getClient();
139+ /* arduino.tips */
140+ IPAddress ip = IPAddress(104, 21, 62, 246);
141+ int port = 80;
142+
143+ Serial.println("\nStarting connection to server...");
144+ /* if you get a connection, report back via serial: */
145+ if (!client.connect(ip, port)) {
146+ Serial.println("unable to connect to server");
147+ return;
148+ }
149+
150+ Serial.println("connected to server");
151+ /* Make a HTTP request: */
152+ size_t w = client.println("GET /asciilogo.txt HTTP/1.1");
153+ w += client.println("Host: arduino.tips");
154+ w += client.println("User-Agent: Arduino");
155+ w += client.println("Connection: close");
156+ w += client.println();
157+ Serial.print("Write size is ");
158+ Serial.println(w);
159+
160+ /* if there are incoming bytes available from the server,
161+ * read them and print them:
162+ */
163+ while (client.connected()) {
164+ size_t len = client.available();
165+ if (len) {
166+ uint8_t buff[len];
167+ client.read(buff, len);
168+ Serial.write(buff, len);
169+ }
170+ delay(0);
171+ }
172+
173+ /* if the server's disconnected, stop the client: */
174+ Serial.println();
175+ Serial.println("disconnecting from server.");
176+ client.stop();
177+ delay(1000);
178+ #endif
179+
134180}
135181
136182void onNetworkConnect() {
0 commit comments