XE300 PowerfailDetect function

Dear GL.iNet, is there a cmdline way to check if power has failed (i.e. that the router is running on battery)?

If you use 4.x firmware, please refer to GL.iNet SDK4.0 API-DOCS. The system.mcu.charging_status is battery status.

Hello, thanks for your response. Wouldn’t that just say the battery is charging or not, which could toggle even with stable AC power? What I would like is to know if the AC power is absent (if so, send a text message alert to base).

As an aside, is an upgrade to firmware guaranteed to not affect settings and SMS support?
Cheers, Brian

The battery will show as charged when there is an external power supply.
Your configuration cannot be kept for major version upgrade.
@luochongjun Can you give the commands that are available on 3.x?

Thanks again for responding. Yes, could you provide the link to the XE300-Puli-specific firmware 3.x documentation please? Also could you say when the XE300 Puli began shipping with 4.x firmware? Cheers, Brian

GL-XE300 (Puli) Docs
4.x firmware for XE300 will be released in this month.

OK, could you provide the link to the XE300-Puli-specific firmware 3.x documentation please?
Cheers, Brian

Uh, we didn’t write it…

Is there a “system.mcu.charging_status” function (or equivalent) in the firmware 3.x for the XE300 Puli?
Cheers, Brian

Yes, It should have the API.
@luochongjun Do you remember this API?

Actually what I would like is the bash cmdline specification for the “system.mcu.charging_status” function (or equivalent) in the firmware 3.x for the XE300 Puli, Cheers, Brian

The 3.x firmware documentation doesn’t help, BUT for those who would like to know, taken from: https://forum.gl-inet.com/t/gl-mfi-gpio-how-to-read-battery-status/7246/8, “on my GL-XE300, you should manually run /usr/bin/xe300_mcu to get /tmp/mcu_data”, i.e. the GL.iNet XE300 Puli battery status is written to file /tmp/mcu_data by executing /usr/bin/xe300-mcu.

So at the bash cmdline on my XE300:
$ /usr/bin/xe300-mcu; /bin/cat /tmp/mcu_data ; /bin/echo “”
{“T”:37.5,“P”:100,“C”:1,“N”:0}
$

Therefore in a bash script on my XE300:
battery_status=$(/usr/bin/xe300-mcu; /bin/cat /tmp/mcu_data)
battery_T=“$(/bin/echo ${battery_status} | /usr/bin/cut -d, -f1 | /usr/bin/cut -d: -f2)”
battery_P=“$(/bin/echo ${battery_status} | /usr/bin/cut -d, -f2 | /usr/bin/cut -d: -f2)”
battery_C=“$(/bin/echo ${battery_status} | /usr/bin/cut -d, -f3 | /usr/bin/cut -d: -f2)”
battery_N=“$(/bin/echo ${battery_status} | /usr/bin/cut -d, -f4 | /usr/bin/cut -d: -f2 | /usr/bin/cut -d} -f1)”

Now the XE300 router can be made to respond to a power failure in a graduated fashion according to its battery charge status and percentage charge, happy days, Brian
PS: Anyone know what ‘battery_N’ stands for?

1 Like