Confirming that Serial1 does not have _options when it is set as boot console but when later calling setup() it creates it.
Also resuming console works when just attached to serial without sending any data. And when it went to sleep while attached and not removed, it resumes when any key is pressed (then first character is lost). Quick and dirty code
function resumeConsole(serial){serial.setup(38400,{rx:D22,tx:D23});serial.setConsole();}
function pauseConsole(serial){
Bluetooth.setConsole(1);if(serial._options){serial.unsetup()};D22.mode("input_pulldown");
setWatch(()=>{setTimeout(()=>{resumeConsole(serial)},300)},D22,{debounce:10,edge:'rising'})
}
After calling pauseConsole(Serial1) it goes to sleep and I can remove serial adapter and when later reattached, it resumes.
So last piece of puzzle is to figure out when console is idle for x minutes. Is there some timestamp of last console input? Otherwise I can at least periodically check whether serial is current console (process.env.CONSOLE) and if not then pause it.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Confirming that Serial1 does not have _options when it is set as boot console but when later calling setup() it creates it.
Also resuming console works when just attached to serial without sending any data. And when it went to sleep while attached and not removed, it resumes when any key is pressed (then first character is lost). Quick and dirty code
After calling
pauseConsole(Serial1)
it goes to sleep and I can remove serial adapter and when later reattached, it resumes.So last piece of puzzle is to figure out when console is idle for x minutes. Is there some timestamp of last console input? Otherwise I can at least periodically check whether serial is current console (process.env.CONSOLE) and if not then pause it.