@@ -359,11 +359,10 @@ void updateDisplay()
359359 if (iconsRadio & ICON_MAC_ADDRESS)
360360 {
361361 char macAddress[5 ];
362- #ifdef COMPILE_BT
363- sprintf (macAddress, " %02X%02X" , unitMACAddress[4 ], unitMACAddress[5 ]);
364- #else
365- sprintf (macAddress, " %02X%02X" , 0 , 0 ); // If BT is not available, print zeroes
366- #endif
362+ const uint8_t * rtkMacAddress = getMacAddress ();
363+
364+ // Print only last two digits of MAC
365+ sprintf (macAddress, " %02X%02X" , rtkMacAddress[4 ], rtkMacAddress[5 ]);
367366 oled.setFont (QW_FONT_5X7); // Set font to smallest
368367 oled.setCursor (0 , 3 );
369368 oled.print (macAddress);
@@ -404,12 +403,10 @@ void updateDisplay()
404403 else if (iconsRadio & ICON_MAC_ADDRESS_2DIGIT)
405404 {
406405 char macAddress[5 ];
406+ const uint8_t * rtkMacAddress = getMacAddress ();
407+
407408 // Print only last two digits of MAC
408- #ifdef COMPILE_BT
409- sprintf (macAddress, " %02X" , unitMACAddress[5 ]);
410- #else
411- sprintf (macAddress, " %02X" , 0 ); // If BT is not available, print zeroes
412- #endif
409+ sprintf (macAddress, " %02X%02X" , rtkMacAddress[4 ], rtkMacAddress[5 ]);
413410 oled.setFont (QW_FONT_5X7); // Set font to smallest
414411 oled.setCursor (14 , 3 );
415412 oled.print (macAddress);
@@ -1845,9 +1842,6 @@ void paintSystemTest()
18451842
18461843 int charHeight = 7 ;
18471844
1848- char macAddress[5 ];
1849- sprintf (macAddress, " %02X%02X" , unitMACAddress[4 ], unitMACAddress[5 ]);
1850-
18511845 drawFrame (); // Outside edge
18521846
18531847 // Test SD, accel, batt, GNSS, mux
@@ -1923,6 +1917,11 @@ void paintSystemTest()
19231917 oled.print (" FAIL" );
19241918 }
19251919
1920+ // Get the last two digits of MAC
1921+ char macAddress[5 ];
1922+ const uint8_t * rtkMacAddress = getMacAddress ();
1923+ sprintf (macAddress, " %02X%02X" , rtkMacAddress[4 ], rtkMacAddress[5 ]);
1924+
19261925 // Display MAC address
19271926 oled.setCursor (xOffset, yOffset + (5 * charHeight) ); // x, y
19281927 oled.print (macAddress);
@@ -2512,15 +2511,16 @@ void paintKeyProvisionFail(uint16_t displayTime)
25122511
25132512 // The MAC address is characters long so we have to split it onto two lines
25142513 char hardwareID[13 ];
2515- sprintf (hardwareID, " %02X%02X%02X" , unitMACAddress[0 ], unitMACAddress[1 ], unitMACAddress[2 ]);
2514+ const uint8_t * rtkMacAddress = getMacAddress ();
2515+ sprintf (hardwareID, " %02X%02X%02X" , rtkMacAddress[0 ], rtkMacAddress[1 ], rtkMacAddress[2 ]);
25162516 String macAddress = String (hardwareID);
25172517
25182518 y += fontHeight;
25192519 textX = x - (oled.getStringWidth (macAddress) / 2 );
25202520 oled.setCursor (textX, y);
25212521 oled.print (hardwareID);
25222522
2523- sprintf (hardwareID, " %02X%02X%02X" , unitMACAddress [3 ], unitMACAddress [4 ], unitMACAddress [5 ]);
2523+ sprintf (hardwareID, " %02X%02X%02X" , rtkMacAddress [3 ], rtkMacAddress [4 ], rtkMacAddress [5 ]);
25242524 macAddress = String (hardwareID);
25252525
25262526 y += fontHeight;
@@ -2543,3 +2543,14 @@ void paintEspNowPaired()
25432543{
25442544 displayMessage (" ESP-Now Paired" , 2000 );
25452545}
2546+
2547+ const uint8_t * getMacAddress ()
2548+ {
2549+ static const uint8_t zero[6 ] = {0 , 0 , 0 , 0 , 0 , 0 };
2550+
2551+ if (bluetoothState != BT_OFF)
2552+ return btMACAddress;
2553+ else if (wifiState != WIFI_OFF)
2554+ return wifiMACAddress;
2555+ return zero;
2556+ }
0 commit comments