You are reading a single comment by @fanoush and its replies. Click here to read the full conversation.
  • The automatic switching can bite you also in other cases.
    I had similar issue but in the other way so I had to do Serial1.setConsole(1) (or LoopbackA as I wanted Serial1 disabled).
    The issue is that there is no such thing/event as 'connection to bluetooth console', there is only connection to whole device. So if I have my custom BLE service and someone connects to it the Espruino console is switched too even if nobody is using/reading it. And additionally it seems that if nobody reads the output that espuino prints to Bluetooth console (my debug console.log() calls) some buffers gets filled soon and espruino gets stuck. If I disconnect from my service soon enough and connect Web IDE the output is drained from the buffers and shown in Web IDE, and my stuck/batched espruino code resumes. If I don't do it soon it just hangs and needs reset.

    It surprised me first but after thinking about it, is now clear because console is done via just another BLE service so it is not known which service/characteristics will client use after connection so Espruino console is switched on connection event. It theory this could be changed to do the switch only after first read/write to Nordic Serial service.

About

Avatar for fanoush @fanoush started