add page to reboot modem
This commit is contained in:
parent
a1b690cad7
commit
c4c5603a3c
@ -56,5 +56,13 @@ for line in usb_slots:lines() do
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pwr_gpio = s:option(Value, "gpio", translate("Power GPIO"))
|
||||||
|
pwr_gpio.rmempty = true
|
||||||
|
|
||||||
|
gpio_down = s:option(Value,"gpio_down",translate("GPIO Down Value"))
|
||||||
|
|
||||||
|
|
||||||
|
gpio_up = s:option(Value,"gpio_up",translate("GPIO Up Value"))
|
||||||
usb_slots:close()
|
usb_slots:close()
|
||||||
return m
|
return m
|
||||||
|
@ -832,6 +832,40 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RebootModem extends ModemConfig {
|
||||||
|
constructor(cfg_id){
|
||||||
|
super(cfg_id,"<%:Reboot Modem%>");
|
||||||
|
this.config_name = "reboot_caps";
|
||||||
|
this.get_action = "get_reboot_caps";
|
||||||
|
this.set_action = "do_reboot";
|
||||||
|
this.get_config();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cb_get(){
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
render(){
|
||||||
|
var soft_reboot_caps = this.config.soft_reboot_caps;
|
||||||
|
var hard_reboot_caps = this.config.hard_reboot_caps;
|
||||||
|
if (soft_reboot_caps) {
|
||||||
|
this.soft_reboot_btn = this.createBTN("<%:Soft Reboot%>",() => {
|
||||||
|
this.set_config('{"mothod":"soft"}');
|
||||||
|
});
|
||||||
|
this.fieldset.appendChild(this.soft_reboot_btn);
|
||||||
|
}
|
||||||
|
if (hard_reboot_caps) {
|
||||||
|
this.hard_reboot_btn = this.createBTN("<%:Hard Reboot%>",() => {
|
||||||
|
this.set_config('{"method":"hard"}');
|
||||||
|
});
|
||||||
|
this.fieldset.appendChild(this.hard_reboot_btn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Select_Modem {
|
class Select_Modem {
|
||||||
constructor(){
|
constructor(){
|
||||||
this.modem_selector = document.getElementById('modem_selector');
|
this.modem_selector = document.getElementById('modem_selector');
|
||||||
@ -902,7 +936,8 @@
|
|||||||
"RatPrefer": {"class": RatPrefer, "name":"<%:Rat Prefer%>"},
|
"RatPrefer": {"class": RatPrefer, "name":"<%:Rat Prefer%>"},
|
||||||
"IMEI": {"class": IMEI, "name": "<%:Set IMEI%>"},
|
"IMEI": {"class": IMEI, "name": "<%:Set IMEI%>"},
|
||||||
"NeighborCell": {"class": NeighborCell, "name": "<%:Neighbor Cell%>"},
|
"NeighborCell": {"class": NeighborCell, "name": "<%:Neighbor Cell%>"},
|
||||||
"LockBand": {"class": Lockband, "name":"<%:Lock Band%>"}
|
"LockBand": {"class": Lockband, "name":"<%:Lock Band%>"},
|
||||||
|
"RebootModem": {"class": RebootModem, "name":"<%:Reboot Modem%>"}
|
||||||
}
|
}
|
||||||
constructor(){
|
constructor(){
|
||||||
super();
|
super();
|
||||||
|
@ -295,3 +295,51 @@ get_info()
|
|||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
soft_reboot()
|
||||||
|
{
|
||||||
|
at_command="AT+CFUN=1,1"
|
||||||
|
echo "at $at_port $at_command" > /tmp/555/value
|
||||||
|
}
|
||||||
|
|
||||||
|
hard_reboot()
|
||||||
|
{
|
||||||
|
#get power_gpio_pin
|
||||||
|
source /lib/functions.sh
|
||||||
|
config_load qmodem
|
||||||
|
config_foreach get_gpio_by_slot modem-slot
|
||||||
|
gpio="/sys/class/gpio/$gpio/value"
|
||||||
|
[ ! -f "$gpio" ] || [ -z "$gpio_up" ] || [ -z "$gpio_down" ] && {
|
||||||
|
soft_reboot
|
||||||
|
m_debug "gpio not found, failback to soft reboot"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
echo $gpio_down > $gpio
|
||||||
|
sleep 1
|
||||||
|
echo $gpio_up > $gpio
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
get_gpio_by_slot()
|
||||||
|
{
|
||||||
|
local cfg="$1"
|
||||||
|
config_get slot "$cfg" slot
|
||||||
|
if [ "$modem_slot" = "$slot" ];then
|
||||||
|
config_get gpio "$cfg" gpio
|
||||||
|
config_get gpio_up "$cfg" gpio_up
|
||||||
|
config_get gpio_down "$cfg" gpio_down
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_reboot_caps()
|
||||||
|
{
|
||||||
|
source /lib/functions.sh
|
||||||
|
config_load qmodem
|
||||||
|
config_foreach get_gpio_by_slot modem-slot
|
||||||
|
json_init
|
||||||
|
json_add_object "reboot_caps"
|
||||||
|
json_add_int "soft_reboot_caps" "1"
|
||||||
|
[ -n "$gpio" ] && [ -n "$gpio_up" ] && [ -n "$gpio_down" ] && json_add_int "hard_reboot_caps" "1"
|
||||||
|
json_close_object
|
||||||
|
json_dump
|
||||||
|
}
|
||||||
|
@ -7,6 +7,8 @@ sms_at_port=$(uci get qmodem.$config_section.sms_at_port)
|
|||||||
vendor=$(uci get qmodem.$config_section.manufacturer)
|
vendor=$(uci get qmodem.$config_section.manufacturer)
|
||||||
platform=$(uci get qmodem.$config_section.platform)
|
platform=$(uci get qmodem.$config_section.platform)
|
||||||
define_connect=$(uci get qmodem.$config_section.define_connect)
|
define_connect=$(uci get qmodem.$config_section.define_connect)
|
||||||
|
modem_path=$(uci get qmodem.$config_section.path)
|
||||||
|
modem_slot=$(basename $modem_path)
|
||||||
[ -z "$define_connect" ] && {
|
[ -z "$define_connect" ] && {
|
||||||
define_connect="1"
|
define_connect="1"
|
||||||
}
|
}
|
||||||
@ -129,6 +131,22 @@ case $method in
|
|||||||
get_sms 10 /tmp/cache_sms_$2
|
get_sms 10 /tmp/cache_sms_$2
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
"get_reboot_caps")
|
||||||
|
get_reboot_caps
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
"do_reboot")
|
||||||
|
reboot_method=$(echo $3 |jq -r '.method')
|
||||||
|
echo $3 > /tmp/555/reboot
|
||||||
|
case $reboot_method in
|
||||||
|
"hard")
|
||||||
|
hard_reboot
|
||||||
|
;;
|
||||||
|
"soft")
|
||||||
|
soft_reboot
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
"send_sms")
|
"send_sms")
|
||||||
cmd_json=$3
|
cmd_json=$3
|
||||||
phone_number=$(echo $cmd_json | jq -r '.phone_number')
|
phone_number=$(echo $cmd_json | jq -r '.phone_number')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user