Skip to content

Commit 8c34f19

Browse files
committed
Stop the binding from rebooting if the binding UID is already set correctly
1 parent 43320c5 commit 8c34f19

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

src/Tx_main.cpp

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,6 @@ void HandleConfigMsg(mspPacket_t *packet)
189189

190190
void ProcessMSPPacketFromTX(mspPacket_t *packet)
191191
{
192-
if (packet->function == MSP_ELRS_BIND)
193-
{
194-
config.SetGroupAddress(packet->payload);
195-
DBG("MSP_ELRS_BIND = ");
196-
for (int i = 0; i < 6; i++)
197-
{
198-
DBG("%x", packet->payload[i]); // Debug prints
199-
DBG(",");
200-
}
201-
DBG(""); // Extra line for serial output readability
202-
config.Commit();
203-
// delay(500); // delay may not be required
204-
sendMSPViaEspnow(packet);
205-
// delay(500); // delay may not be required
206-
rebootTime = millis(); // restart to set SetSoftMACAddress
207-
}
208-
209192
switch (packet->function)
210193
{
211194
case MSP_SET_VTX_CONFIG:
@@ -215,35 +198,63 @@ void ProcessMSPPacketFromTX(mspPacket_t *packet)
215198
// transparently forward MSP packets via espnow to any subscribers
216199
sendMSPViaEspnow(packet);
217200
break;
201+
218202
case MSP_ELRS_SET_VRX_BACKPACK_WIFI_MODE:
219203
DBGLN("Processing MSP_ELRS_SET_VRX_BACKPACK_WIFI_MODE...");
220204
sendMSPViaEspnow(packet);
221205
break;
206+
222207
case MSP_ELRS_SET_TX_BACKPACK_WIFI_MODE:
223208
DBGLN("Processing MSP_ELRS_SET_TX_BACKPACK_WIFI_MODE...");
224209
RebootIntoWifi();
225210
break;
211+
226212
case MSP_ELRS_GET_BACKPACK_VERSION:
227213
DBGLN("Processing MSP_ELRS_GET_BACKPACK_VERSION...");
228214
SendVersionResponse();
229215
break;
216+
230217
case MSP_ELRS_BACKPACK_SET_HEAD_TRACKING:
231218
DBGLN("Processing MSP_ELRS_BACKPACK_SET_HEAD_TRACKING...");
232219
cachedHTPacket = *packet;
233220
cacheFull = true;
234221
sendMSPViaEspnow(packet);
235222
break;
223+
236224
case MSP_ELRS_BACKPACK_CRSF_TLM:
237225
DBGLN("Processing MSP_ELRS_BACKPACK_CRSF_TLM...");
238226
if (config.GetTelemMode() != BACKPACK_TELEM_MODE_OFF)
239227
{
240228
sendMSPViaEspnow(packet);
241229
}
242230
break;
231+
243232
case MSP_ELRS_BACKPACK_CONFIG:
244233
DBGLN("Processing MSP_ELRS_BACKPACK_CONFIG...");
245234
HandleConfigMsg(packet);
246235
break;
236+
237+
case MSP_ELRS_BIND:
238+
DBG("MSP_ELRS_BIND = ");
239+
for (int i = 0; i < 6; i++)
240+
{
241+
DBG("%x", packet->payload[i]); // Debug prints
242+
DBG(",");
243+
}
244+
DBG(""); // Extra line for serial output readability
245+
246+
// If the BIND address is different to our current one,
247+
// then we save it and reboot so it can take effect
248+
if (memcmp(packet->payload, config.GetGroupAddress(), 6) != 0)
249+
{
250+
config.SetGroupAddress(packet->payload);
251+
config.Commit();
252+
rebootTime = millis(); // restart to set SetSoftMACAddress
253+
return;
254+
}
255+
sendMSPViaEspnow(packet);
256+
break;
257+
247258
default:
248259
// transparently forward MSP packets via espnow to any subscribers
249260
sendMSPViaEspnow(packet);
@@ -352,8 +363,8 @@ void setup()
352363
Serial1.begin(115200);
353364
Serial1.setDebugOutput(true);
354365
#endif
355-
Serial.begin(460800);
356366
Serial.setRxBufferSize(4096);
367+
Serial.begin(460800);
357368

358369
options_init();
359370

targets/common.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ board_build.partitions = min_spiffs.csv
5959
upload_speed = 460800
6060
monitor_speed = 460800
6161
upload_resetmethod = nodemcu
62-
board_build.f_cpu = 240000000L
62+
board_build.f_cpu = 160000000L
6363
build_flags =
6464
-D PLATFORM_ESP32=1
6565

0 commit comments

Comments
 (0)