Skip to content

Commit 2f2f5d5

Browse files
committed
WiFi: Get new ESP-NOW channel via menuRadio
1 parent 5a672e7 commit 2f2f5d5

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ void wifiDisplayNetworkData() {}
213213
void wifiDisplaySoftApStatus() {}
214214
bool wifiEspNowOff(const char * fileName, uint32_t lineNumber) {return true;}
215215
bool wifiEspNowOn(const char * fileName, uint32_t lineNumber) {return false;}
216+
void wifiEspNowSetChannel(WIFI_CHANNEL_t channel) {}
216217
uint32_t wifiGetStartTimeout() {return 0;}
217218
#define WIFI_IS_RUNNING() 0
218219
int wifiNetworkCount() {return 0;}

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,13 @@ void wifiDisplayState()
546546
}
547547
}
548548

549+
//*********************************************************************
550+
// Set the ESP-NOW channel
551+
void wifiEspNowSetChannel(WIFI_CHANNEL_t channel)
552+
{
553+
wifi.espNowSetChannel(channel);
554+
}
555+
549556
//*********************************************************************
550557
// Stop ESP-NOW
551558
// Inputs:

Firmware/RTK_Everywhere/menuMain.ino

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -693,15 +693,24 @@ void menuRadio()
693693
}
694694
else if (settings.enableEspNow == true && incoming == 4)
695695
{
696-
if (WIFI_IS_RUNNING() == false)
696+
if (getNewSetting("Enter the WiFi channel to use for ESP-NOW communication", 1, 14,
697+
&settings.wifiChannel) == INPUT_RESPONSE_VALID)
697698
{
698-
if (getNewSetting("Enter the WiFi channel to use for ESP-NOW communication", 1, 14,
699-
&settings.wifiChannel) == INPUT_RESPONSE_VALID)
700-
espNowSetChannel(settings.wifiChannel);
701-
}
702-
else
703-
{
704-
systemPrintln("ESP-NOW channel can't be modified while WiFi is active.");
699+
wifiEspNowSetChannel(settings.wifiChannel);
700+
if (settings.wifiChannel)
701+
{
702+
if (settings.wifiChannel == wifiChannel)
703+
systemPrintf("WiFi is already on channel %d.", settings.wifiChannel);
704+
else
705+
{
706+
if (wifiSoftApRunning || wifiStationRunning)
707+
systemPrintf("Restart WiFi to use channel %d.", settings.wifiChannel);
708+
else if (wifiEspNowRunning)
709+
systemPrintf("Restart ESP-NOW to use channel %d.", settings.wifiChannel);
710+
else
711+
systemPrintf("Please start ESP-NOW to use channel %d.", settings.wifiChannel);
712+
}
713+
}
705714
}
706715
}
707716
else if (settings.enableEspNow == true && incoming == 5 && settings.debugEspNow == true)

0 commit comments

Comments
 (0)