My device uses the Notecarrier F with a Swan. The Feather_PWR switch is in the “Switched” position, so the Swan can be put to sleep using the ATTN pin. The Swan should be reading from some sensors, then sending a sleep request to the Notecard. Most of the time, this works but occasionally, the script can get stuck, e.g. if a sensor reading fails.
Is there any way to either reset or power cycle the Swan remotely, via the Notehub?
Thanks in advance!
Hi @ChronovaEngineering and welcome to the Blues community!
Would you mind posting a snippet of your code where it can get “stuck”? There may be a better solution we can come up with instead of resetting the Swan. That being said, you can try using the
NVIC_SystemReset(); method to perform a software reset.
For context, the device was sending sensor data to the Notehub for several days without issue but is now only showing “periodic inbound sync due” events. (See attached pic)
During prototyping, I found that if the sensors were disconnected, the script on the Swan would never reach the sleep request part in loop(), which is why I suspect a similar issue has happened in the field. Unfortunately, the device is in a rather remote location, so I was really hoping to try remotely rebooting it before trekking out to retrieve it.
As for exactly where the code freezes, I suspect it’s either where the sensors get initialised or whilst reading the sensors later in setup(). I can’t post most of the code publicly for commercial reasons but would be happy to send it privately if needed.
A colleague just reminded me of another option you have to remotely restart the host. If you look in the Reserved Environment Variables list, you’ll see:
If Feather PWR is
SWITCHED and the DFU dip switch is
OFF on the Notecarrier F, set the
_restart_host to any new value to restart the host.
Hope that helps!
That’s exactly the feature I was looking for! I’ll give that a go.
I’ve tried using the _restart_host environment variables and got the Notecard to attempt a host restart but I receive a “can’t restart host: dfu type not specified” response.
I tried adding some different _dfu_enabled values (usb:0;high:0;normal:0;low:0;dead:0 and usb:1;high:1;normal:1;low:1;dead:0) alternately but received the same response. You mentioned the DFU dip switch would need to be “Off” on the Notecarrier. I didn’t change the switch position before deploying the device, so this is probably still in the default “On” position - I’m guessing that’s where the issue lies.
Is there any workaround you would suggest or is a manual reset the only option? No worries if so, I’ll know to watch out for it in the future!
With the DFU dip switch enabled, you are set up to use the more flexible/efficient method of firmware updating: Notecard Outboard Firmware Update. However, this does require some API calls to be in your original firmware (see that link for details).
Ah, got it, thanks again for your help!
In the end, the device battery actually ran out overnight, then recharged enough to reconnect in the morning, which did the trick rebooting everything anyway.
Your advice is greatly appreciated - I’ll know what safety features to add to future devices now.