-
• #2
Try checking out: Tropubleshooting: My code works when I'm connected via Bluetooth but stops when I disconnect
Short answer: just add
Bluetooth.setConsole(true)
inonInit
to force the console to Bluetooth regardless. -
• #3
Thanx. I’ll give it a go.
-
• #4
What a coincidence: Just wanted to post a new conversation with a similar, if not exactly the same issue:
RAK8212: ReferenceError: "RDY" is not defined
I wrote a small data logger that reads temperature values from the BME280 and sends it via Quectel BG96 modem to an IoT dashboard (Cayenne myDevices).
The code is written "Direct to Flash (Execute at boot)".As long I stay connected with the (native) Espruino IDE via Bluetooth LE, everything goes well. The code creates a socket connection to the IoT dashboard, and data is sent periodically.
But as soon as I power cycle the RAK8212 and stay disconnected, the code starts, but then somehow the code execution is interrupted.
I then tried to catch and store exceptions:
// Deal with any uncaught exceptions process.on('uncaughtException', function (err) { console.log('Error', err); errorStore = err; });
One of the errors found is
ReferenceError: "RDY" is not definedI think I guess what happens: As long as I am connected via Bluetooth LE, then the JavaScript interpreter/console is attached to the serial interface "Bluetooth". But as soon as the RAK8212 runs without something being connected to it, neither via USB nor with Bluetooth LE, then the JavaScript interpreter/console is attached to "Serial1". Unfortunately, when communicating with the modem, "Serial1" is connected with the modem. When the modem has finished booting up, it outputs "RDY" and this is interpreted by the JavaScript interpreter/console. I don't know if there is actually even more malicious interference between modem and JavaScript interpreter/console.
The good news: If I use the following code, everything runs well, even without being connected to the RAK8212:
function onInit() { Bluetooth.setConsole(true); // Don't want to have console on "Serial1" that is used for modem. setupExternalHardware(startDataLogger); }
Actually, that is the thing that Gordon recommended :)
This is probably the same on other nRF52832 based devices. Currently I'm using the bluetooth web ide to talk to the RAK8212 module. That works fine. Where things go wrong is when I have code running that is talking to the BG96 and I disconnect from bluetooth. The code talking to the BG96 no longer seems to work. Similarly, when I save() the code and have it startup, things don't seem to work as they should. 'work' meaning the code seems to execute, but comms with the BG96 have been interrupted.
Also what might be compounding the problem is that I have an analog input in use which is on port D28 (serial rxd) and there is a comment in the code that mentions a logic 1 on the rxd (D28) will cause the serial port to be re-routed to pins D28/29.
I'm not fully understanding the logic as to where the console and Serial1 streams end up in the various use cases and if there's a simple solution to force the logic.