Skip to content

Commit 5d42efb

Browse files
committed
Add displayFullIPAddress
1 parent e220fa3 commit 5d42efb

File tree

5 files changed

+49
-32
lines changed

5 files changed

+49
-32
lines changed

Firmware/RTK_Everywhere/Display.ino

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ void displayUpdate()
261261
paintLogging(&iconPropertyList);
262262
displaySivVsOpenShort(&iconPropertyList);
263263
displayBatteryVsEthernet(&iconPropertyList);
264+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
264265
setRadioIcons(&iconPropertyList);
265266
break;
266267
case (STATE_ROVER_NO_FIX):
@@ -269,6 +270,7 @@ void displayUpdate()
269270
paintLogging(&iconPropertyList);
270271
displaySivVsOpenShort(&iconPropertyList);
271272
displayBatteryVsEthernet(&iconPropertyList);
273+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
272274
setRadioIcons(&iconPropertyList);
273275
break;
274276
case (STATE_ROVER_FIX):
@@ -277,6 +279,7 @@ void displayUpdate()
277279
paintLogging(&iconPropertyList);
278280
displaySivVsOpenShort(&iconPropertyList);
279281
displayBatteryVsEthernet(&iconPropertyList);
282+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
280283
setRadioIcons(&iconPropertyList);
281284
break;
282285
case (STATE_ROVER_RTK_FLOAT):
@@ -285,6 +288,7 @@ void displayUpdate()
285288
paintLogging(&iconPropertyList);
286289
displaySivVsOpenShort(&iconPropertyList);
287290
displayBatteryVsEthernet(&iconPropertyList);
291+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
288292
setRadioIcons(&iconPropertyList);
289293
break;
290294
case (STATE_ROVER_RTK_FIX):
@@ -293,6 +297,7 @@ void displayUpdate()
293297
paintLogging(&iconPropertyList);
294298
displaySivVsOpenShort(&iconPropertyList);
295299
displayBatteryVsEthernet(&iconPropertyList);
300+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
296301
setRadioIcons(&iconPropertyList);
297302
break;
298303

@@ -309,27 +314,32 @@ void displayUpdate()
309314
paintLogging(&iconPropertyList);
310315
displaySivVsOpenShort(&iconPropertyList);
311316
displayBatteryVsEthernet(&iconPropertyList);
317+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
312318
setRadioIcons(&iconPropertyList);
313319
break;
314320
case (STATE_BASE_TEMP_SURVEY_STARTED):
315321
paintLogging(&iconPropertyList);
316322
displayBatteryVsEthernet(&iconPropertyList); // Top right
323+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
317324
setRadioIcons(&iconPropertyList);
318325
paintBaseTempSurveyStarted(&iconPropertyList);
319326
break;
320327
case (STATE_BASE_TEMP_TRANSMITTING):
321328
paintLogging(&iconPropertyList);
322329
displayBatteryVsEthernet(&iconPropertyList); // Top right
330+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
323331
setRadioIcons(&iconPropertyList);
324332
paintRTCM(&iconPropertyList);
325333
break;
326334
case (STATE_BASE_FIXED_NOT_STARTED):
327335
displayBatteryVsEthernet(&iconPropertyList); // Top right
336+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
328337
setRadioIcons(&iconPropertyList);
329338
break;
330339
case (STATE_BASE_FIXED_TRANSMITTING):
331340
paintLogging(&iconPropertyList);
332341
displayBatteryVsEthernet(&iconPropertyList); // Top right
342+
displayFullIPAddress(&iconPropertyList); // Bottom left - 128x64 only
333343
setRadioIcons(&iconPropertyList);
334344
paintRTCM(&iconPropertyList);
335345
break;
@@ -1771,11 +1781,11 @@ void paintConnectingToNtripCaster()
17711781
void paintIPAddress()
17721782
{
17731783
char ipAddress[16];
1774-
snprintf(ipAddress, sizeof(ipAddress), "%d.%d.%d.%d",
1784+
snprintf(ipAddress, sizeof(ipAddress), "%s",
17751785
#ifdef COMPILE_ETHERNET
1776-
ETH.localIP()[0], ETH.localIP()[1], ETH.localIP()[2], ETH.localIP()[3]);
1786+
ETH.localIP().toString());
17771787
#else // COMPILE_ETHERNET
1778-
0, 0, 0, 0);
1788+
"0.0.0.0");
17791789
#endif // COMPILE_ETHERNET
17801790

17811791
oled->setFont(QW_FONT_5X7); // Set font to smallest
@@ -1809,6 +1819,26 @@ void paintIPAddress()
18091819
}
18101820
}
18111821

1822+
void displayFullIPAddress(std::vector<iconPropertyBlinking> *iconList) // Bottom left - 128x64 only
1823+
{
1824+
if (present.display_type == DISPLAY_128x64)
1825+
{
1826+
char myAddress[16];
1827+
1828+
uint8_t networkType = networkGetType();
1829+
IPAddress ipAddress = networkGetIpAddress(networkType);
1830+
1831+
if (ipAddress != IPAddress((uint32_t)0))
1832+
{
1833+
snprintf(myAddress, sizeof(myAddress), "%s", ipAddress.toString());
1834+
1835+
oled->setFont(QW_FONT_5X7); // Set font to smallest
1836+
oled->setCursor(0, 55);
1837+
oled->print(ipAddress);
1838+
}
1839+
}
1840+
}
1841+
18121842
void paintMACAddress4digit(uint8_t xPos, uint8_t yPos)
18131843
{
18141844
char macAddress[5];
@@ -2091,7 +2121,7 @@ void displayWiFiConfig()
20912121

20922122
// Convert to string
20932123
char myIP[20] = {'\0'};
2094-
snprintf(myIP, sizeof(myIP), "%d.%d.%d.%d", myIpAddress[0], myIpAddress[1], myIpAddress[2], myIpAddress[3]);
2124+
snprintf(myIP, sizeof(myIP), "%s", myIpAddress.toString());
20952125

20962126
char myIPFront[displayMaxCharacters + 1]; // 1 for null terminator
20972127
char myIPBack[displayMaxCharacters + 1]; // 1 for null terminator
@@ -3018,7 +3048,7 @@ void displayConfigViaEthernet()
30183048

30193049
char ipAddress[16];
30203050
IPAddress localIP = ETH.localIP();
3021-
snprintf(ipAddress, sizeof(ipAddress), "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
3051+
snprintf(ipAddress, sizeof(ipAddress), "%s", localIP.toString());
30223052

30233053
int displayWidthChars = ((present.display_type == DISPLAY_128x64) ? 21 : 10);
30243054

Firmware/RTK_Everywhere/NTP.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ bool ntpProcessOneRequest(bool process, const timeval *recTv, const timeval *syn
509509

510510
if (ntpDiag != nullptr) // Add the packet size and remote IP/Port to the diagnostics
511511
{
512-
snprintf(ntpDiag, ntpDiagSize, "NTP request from: Remote IP: %d.%d.%d.%d Remote Port: %d\r\n", remoteIP[0],
513-
remoteIP[1], remoteIP[2], remoteIP[3], remotePort);
512+
snprintf(ntpDiag, ntpDiagSize, "NTP request from: Remote IP: %s Remote Port: %d\r\n",
513+
remoteIP.toString(), remotePort);
514514
}
515515

516516
if (packetDataSize >= NTPpacket::NTPpacketSize)

Firmware/RTK_Everywhere/TcpServer.ino

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ int32_t tcpServerClientSendData(int index, uint8_t *data, uint16_t length)
9393
if ((settings.debugTcpServer || PERIODIC_DISPLAY(PD_TCP_SERVER_CLIENT_DATA)) && (!inMainMenu))
9494
{
9595
PERIODIC_CLEAR(PD_TCP_SERVER_CLIENT_DATA);
96-
systemPrintf("TCP server wrote %d bytes to %d.%d.%d.%d\r\n", length, tcpServerClientIpAddress[index][0],
97-
tcpServerClientIpAddress[index][1], tcpServerClientIpAddress[index][2],
98-
tcpServerClientIpAddress[index][3]);
96+
systemPrintf("TCP server wrote %d bytes to %s\r\n", length, tcpServerClientIpAddress[index].toString());
9997
}
10098
}
10199

@@ -106,9 +104,8 @@ int32_t tcpServerClientSendData(int index, uint8_t *data, uint16_t length)
106104
if ((settings.debugTcpServer || PERIODIC_DISPLAY(PD_TCP_SERVER_CLIENT_DATA)) && (!inMainMenu))
107105
{
108106
PERIODIC_CLEAR(PD_TCP_SERVER_CLIENT_DATA);
109-
systemPrintf("TCP server breaking connection %d with client %d.%d.%d.%d\r\n", index,
110-
tcpServerClientIpAddress[index][0], tcpServerClientIpAddress[index][1],
111-
tcpServerClientIpAddress[index][2], tcpServerClientIpAddress[index][3]);
107+
systemPrintf("TCP server breaking connection %d with client %s\r\n", index,
108+
tcpServerClientIpAddress[index].toString());
112109
}
113110

114111
tcpServerClient[index]->stop();
@@ -241,8 +238,7 @@ bool tcpServerStart()
241238
tcpServer->begin();
242239
online.tcpServer = true;
243240
localIp = networkGetIpAddress(networkGetType());
244-
systemPrintf("TCP server online, IP address %d.%d.%d.%d:%d\r\n", localIp[0], localIp[1], localIp[2], localIp[3],
245-
settings.tcpServerPort);
241+
systemPrintf("TCP server online, IP address %s:%d\r\n", localIp.toString(), settings.tcpServerPort);
246242
return true;
247243
}
248244

@@ -308,9 +304,8 @@ void tcpServerStopClient(int index)
308304
systemPrintf("TCP Server: No data sent over %d seconds\r\n", TCP_SERVER_CLIENT_DATA_TIMEOUT / 1000);
309305
if (!connected)
310306
systemPrintf("TCP Server: Link to client broken\r\n");
311-
systemPrintf("TCP server client %d disconnected from %d.%d.%d.%d\r\n", index,
312-
tcpServerClientIpAddress[index][0], tcpServerClientIpAddress[index][1],
313-
tcpServerClientIpAddress[index][2], tcpServerClientIpAddress[index][3]);
307+
systemPrintf("TCP server client %d disconnected from %s\r\n", index,
308+
tcpServerClientIpAddress[index].toString());
314309
}
315310

316311
// Shutdown the TCP server client link
@@ -431,9 +426,8 @@ void tcpServerUpdate()
431426
if (PERIODIC_DISPLAY(PD_TCP_SERVER_DATA) && (!inMainMenu))
432427
{
433428
PERIODIC_CLEAR(PD_TCP_SERVER_DATA);
434-
systemPrintf("TCP server client %d connected to %d.%d.%d.%d\r\n", index,
435-
tcpServerClientIpAddress[index][0], tcpServerClientIpAddress[index][1],
436-
tcpServerClientIpAddress[index][2], tcpServerClientIpAddress[index][3]);
429+
systemPrintf("TCP server client %d connected to %s\r\n", index,
430+
tcpServerClientIpAddress[index].toString());
437431
}
438432
}
439433

@@ -467,9 +461,8 @@ void tcpServerUpdate()
467461
if ((settings.debugTcpServer || PERIODIC_DISPLAY(PD_TCP_SERVER_DATA)) && (!inMainMenu))
468462
{
469463
PERIODIC_CLEAR(PD_TCP_SERVER_DATA);
470-
systemPrintf("TCP server client %d connected to %d.%d.%d.%d\r\n", index,
471-
tcpServerClientIpAddress[index][0], tcpServerClientIpAddress[index][1],
472-
tcpServerClientIpAddress[index][2], tcpServerClientIpAddress[index][3]);
464+
systemPrintf("TCP server client %d connected to %s\r\n", index,
465+
tcpServerClientIpAddress[index].toString());
473466
}
474467
}
475468
}

Firmware/RTK_Everywhere/menuSystem.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void menuSystem()
107107
systemPrintf("%02X:%02X:%02X:%02X:%02X:%02X\r\n", ethernetMACAddress[0], ethernetMACAddress[1],
108108
ethernetMACAddress[2], ethernetMACAddress[3], ethernetMACAddress[4], ethernetMACAddress[5]);
109109
systemPrint("Ethernet IP Address: ");
110-
systemPrintln(ETH.localIP());
110+
systemPrintln(ETH.localIP().toString());
111111
if (!settings.ethernetDHCP)
112112
{
113113
systemPrint("Ethernet DNS: ");

Firmware/RTK_Everywhere/support.ino

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,7 @@ void systemPrint(int value, uint8_t printType)
115115
// Pretty print IP addresses
116116
void systemPrint(IPAddress ipaddress)
117117
{
118-
systemPrint(ipaddress[0], DEC);
119-
systemPrint(".");
120-
systemPrint(ipaddress[1], DEC);
121-
systemPrint(".");
122-
systemPrint(ipaddress[2], DEC);
123-
systemPrint(".");
124-
systemPrint(ipaddress[3], DEC);
118+
systemPrint(ipaddress.toString());
125119
}
126120
void systemPrintln(IPAddress ipaddress)
127121
{

0 commit comments

Comments
 (0)