@@ -263,6 +263,26 @@ void printLocalTime(bool extraData=false) {
263
263
}
264
264
}
265
265
266
+ void calcURLs () {
267
+ // Set the URL's
268
+ #if defined(URL_HOSTNAME)
269
+ if (httpPort != 80 ) {
270
+ sprintf (httpURL, " http://%s:%d/" , URL_HOSTNAME, httpPort);
271
+ } else {
272
+ sprintf (httpURL, " http://%s/" , URL_HOSTNAME);
273
+ }
274
+ sprintf (streamURL, " http://%s:%d/" , URL_HOSTNAME, streamPort);
275
+ #else
276
+ Serial.println (" Setting httpURL" );
277
+ if (httpPort != 80 ) {
278
+ sprintf (httpURL, " http://%d.%d.%d.%d:%d/" , ip[0 ], ip[1 ], ip[2 ], ip[3 ], httpPort);
279
+ } else {
280
+ sprintf (httpURL, " http://%d.%d.%d.%d/" , ip[0 ], ip[1 ], ip[2 ], ip[3 ]);
281
+ }
282
+ sprintf (streamURL, " http://%d.%d.%d.%d:%d/" , ip[0 ], ip[1 ], ip[2 ], ip[3 ], streamPort);
283
+ #endif
284
+ }
285
+
266
286
void WifiSetup () {
267
287
// Feedback that we are now attempting to connect
268
288
flashLED (300 );
@@ -389,6 +409,7 @@ void WifiSetup() {
389
409
Serial.printf (" IP address: %d.%d.%d.%d\r\n " ,ip[0 ],ip[1 ],ip[2 ],ip[3 ]);
390
410
Serial.printf (" Netmask : %d.%d.%d.%d\r\n " ,net[0 ],net[1 ],net[2 ],net[3 ]);
391
411
Serial.printf (" Gateway : %d.%d.%d.%d\r\n " ,gw[0 ],gw[1 ],gw[2 ],gw[3 ]);
412
+ calcURLs ();
392
413
// Flash the LED to show we are connected
393
414
for (int i = 0 ; i < 5 ; i++) {
394
415
flashLED (50 );
@@ -434,6 +455,7 @@ void WifiSetup() {
434
455
gw = WiFi.gatewayIP ();
435
456
strcpy (apName, stationList[0 ].ssid );
436
457
Serial.printf (" IP address: %d.%d.%d.%d\r\n " ,ip[0 ],ip[1 ],ip[2 ],ip[3 ]);
458
+ calcURLs ();
437
459
// Flash the LED to show we are connected
438
460
for (int i = 0 ; i < 5 ; i++) {
439
461
flashLED (150 );
@@ -693,21 +715,6 @@ void setup() {
693
715
// Now we have a network we can start the two http handlers for the UI and Stream.
694
716
startCameraServer (httpPort, streamPort);
695
717
696
- #if defined(URL_HOSTNAME)
697
- if (httpPort != 80 ) {
698
- sprintf (httpURL, " http://%s:%d/" , URL_HOSTNAME, httpPort);
699
- } else {
700
- sprintf (httpURL, " http://%s/" , URL_HOSTNAME);
701
- }
702
- sprintf (streamURL, " http://%s:%d/" , URL_HOSTNAME, streamPort);
703
- #else
704
- if (httpPort != 80 ) {
705
- sprintf (httpURL, " http://%d.%d.%d.%d:%d/" , ip[0 ], ip[1 ], ip[2 ], ip[3 ], httpPort);
706
- } else {
707
- sprintf (httpURL, " http://%d.%d.%d.%d/" , ip[0 ], ip[1 ], ip[2 ], ip[3 ]);
708
- }
709
- sprintf (streamURL, " http://%d.%d.%d.%d:%d/" , ip[0 ], ip[1 ], ip[2 ], ip[3 ], streamPort);
710
- #endif
711
718
if (critERR.length () == 0 ) {
712
719
Serial.printf (" \r\n Camera Ready!\r\n Use '%s' to connect\r\n " , httpURL);
713
720
Serial.printf (" Stream viewer available at '%sview'\r\n " , streamURL);
0 commit comments