[SOLVED] Is it possible to disable setup button activation of listen mode?

Is it possible to disable listen mode? On the product I’m building, the user will have access to the mode button so they can enter DFU mode or safe mode if things go wrong, but the button is used by the application for stuff, sometimes including being held.

Not sure if I fully understand what you are trying to do but you could try WiFi.connect(WIFI_CONNECT_SKIP_LISTEN); or WiFi.listen(false);

Close, but I think the first option disables automatic listen mode (if the device cannot connect to any network), and the second leaves listen mode. When the user holds the button, neither option will prevent the device from entering listen mode.

@HossBoss, you may be able to exploit the System Events and the button_status or button_click events to prevent the button mode entry. I haven’t verified this. :grinning:

@peekay123, that was a good launch point. The events themselves weren’t able to help, but while I was digging in the firmware source to see how the button presses were wired up, I noticed they were interrupt driven, at least on the Photon. The solution is a hack, but it’s pretty clean for a hack. The trade off is that I won’t receive system events for button status/click. Also once it’s disabled it cannot be enabled again.

void setup() {
    detachInterrupt(BTN); //disconnect the setup button from the system interrupt handler
    RGB.control(true);
}

void loop() {
    RGB.color(RGB_COLOR_YELLOW);
    delay(500);
    RGB.color(RGB_COLOR_CYAN);
    delay(500);
}
1 Like