🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+21
View File
@@ -0,0 +1,21 @@
#
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-gpioled
PKG_VERSION:=1.0.1-20230809
PKG_RELEASE:=1
PKG_MAINTAINER:=<https://github.com/animegasan>
LUCI_TITLE:=LuCI for GPIO LED
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+coreutils-sleep +screen +bash
LUCI_DESCRIPTION:=LuCI support for GPIO LED Configuration
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
+23
View File
@@ -0,0 +1,23 @@
# LuCI support for GPIO LED Configuration
## Customize device GPIO LED behavior with LuCI.
<a target="_blank" href="https://github.com/animegasan/luci-app-gpioled/releases"><img src="https://img.shields.io/github/downloads/animegasan/luci-app-gpioled/total?label=Total%20Download&labelColor=blue&style=for-the-badge"></a>
This project is a continuation project of <a href="https://github.com/lutfailham96/s905x-gpio" target="_blank">GPIO controller for Amlogic S905X devices</a>.
By taking advantage of GPIOID, some additional functionality is provided for LED behavior.
* Internet Detector : Service to detect whether internet is running or not.
* Application Detector : Service to detect whether desired application is running or not with a notification using IR Blaster LED.
* Power LED : Service for set Power LED blink mode.
## Table of GPIO ID
| Device | Power | IR Blaster | Ethernet | Searcher |
| ------ | ----- | ---------- | -------- | -------- |
| HG680P R1GB | 483, 484 | 480 | 481, 482| <a href="https://www.facebook.com/arif.kholid" target="_blank">Mohammad Arif</a> |
| HG680P R2GB | 425, 426 | 507 | 506, 510| <a href="https://github.com/animegasan" target="_blank">animegasan</a> |
## List app for Application Detector
* Cloudflared
* ZeroTier
@@ -0,0 +1,51 @@
module("luci.controller.gpioled", package.seeall)
function index()
entry({"admin", "system", "gpioled"},alias("admin", "system", "gpioled", "settings"),_("GPIO LED Configuration"), 60).dependent = true
entry({"admin", "system", "gpioled", "settings"}, cbi("gpioled/settings"), _("Settings"), 1).leaf = true
entry({"admin", "system", "gpioled", "logs"}, cbi("gpioled/logs"), _("Logs"), 2).leaf = true
entry({"admin", "system", "gpioled", "id_status"}, call("id_status"))
entry({"admin", "system", "gpioled", "ad_status"}, call("ad_status"))
entry({"admin", "system", "gpioled", "ad_mon"}, call("ad_mon"))
entry({"admin", "system", "gpioled", "pwr_status"}, call("pwr_status"))
entry({"admin", "system", "gpioled", "get_log"}, call("get_log"))
end
function id_status()
local e = {}
e.running = luci.sys.call("pgrep -f /usr/share/gpioled/id >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function ad_status()
local e = {}
e.running = luci.sys.call("pgrep -f /usr/share/gpioled/ad >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function ad_mon()
local e = {}
local f = luci.sys.exec("uci get gpioled.service.ad_app")
f = f:trim()
local running = luci.sys.exec("uci get " .. f)
e.running = running:trim()
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function pwr_status()
local e = {}
local running = luci.sys.exec("uci get gpioled.service.pwr_mode")
e.running = running:trim()
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function get_log()
local fs = require("nixio.fs")
local lf = "/tmp/gpioled.log"
local l = fs.readfile(lf) or "Log file not found."
luci.http.prepare_content("text/plain")
luci.http.write(l)
end
@@ -0,0 +1,12 @@
local m, s;
m = SimpleForm("logview")
m.reset = false
m.submit = false
s = m:field(TextValue, "conf")
s.rmempty = true
s.rows = 20
s.template = "gpioled/logs"
s.readonly = "readonly"
return m
@@ -0,0 +1,104 @@
local m, s, o
m = Map("gpioled")
m.title = translate("GPIO LED Settings")
m.description = translate("Customize device GPIO LED behavior.<br><br>"..
"1. Internet Detector: Functions for detect whether internet is running or not.<br>" ..
"2. Application Detector: Functions for detect whether desired application is running or not with a notification using IR Blaster LED.<br>"..
"3. Power LED: Function for set Power LED blink mode.<br>"..
[[<br/><br/><a href="https://github.com/animegasan" target="_blank">Powered by animegasan</a>]])
--- global
s = m:section(TypedSection, "global", translate("Global Setting"))
s.addremove = false
s.anonymous = true
---- status
o = s:option(DummyValue, "status", translate("Internet Detector"))
o.template = "gpioled/id-status"
o.value = translate("Collecting data...")
o = s:option(DummyValue, "status", translate("Application Detector"))
o.template = "gpioled/ad-status"
o.value = translate("Collecting data...")
o = s:option(DummyValue, "status", translate("Power LED Blink Mode"))
o.template = "gpioled/pwr-status"
o.value = translate("Collecting data...")
---- enable
o = s:option(MultiValue, "enable", translate("Enable Service"))
o:value("id",translate("Internet Detector"))
o:value("ad",translate("Application Detector"))
o.widget = "checkbox"
o.default = nil
---- device
o = s:option(ListValue, "device", translate("Device"))
o:value("HG680PR1", translate("HG680P RAM 1GB"))
o:value("HG680PR2", translate("HG680P RAM 2GB"))
o.default = nil
--- service
s = m:section(TypedSection, "service", translate("Service Setting"))
s.addremove = false
s.anonymous = true
--- internet detector service
s:tab("id", translate("Internet Detector"))
---- color led on
o = s:taboption("id", ListValue, "id_il", translate("Internet On"),
translate("LED color when internet is running"))
o:value("green", translate("Green"))
o:value("red", translate("Red"))
o:value("yellow", translate("Yellow"))
o.default = "green"
---- color led off
o = s:taboption("id", ListValue, "id_io", translate("Internet Off"),
translate("LED color when internet is not running"))
o:value("green", translate("Green"))
o:value("red", translate("Red"))
o:value("yellow", translate("Yellow"))
o.default = "red"
---- mode
o = s:taboption("id", ListValue, "id_mode", translate("Blink Mode"))
o:value("0.1", translate("Fast"))
o:value("1", translate("Normal"))
o:value("2", translate("Slow"))
o:value("0", translate("Static"))
o.default = "1"
--- application detector service
s:tab("ad", translate("Application Detector"))
---- application
o = s:taboption("ad", ListValue, "ad_app", translate("Application"),
translate("Application want to monitoring"))
o:value("cloudflared.config.enabled", translate("Cloudflare"))
o:value("openclash.config.enabled", translate("OpenClash"))
o:value("zerotier.sample_config.enabled", translate("ZeroTier"))
o.default = nil
---- status application
o = s:taboption("ad", DummyValue, "status", translate("Status"), translate("Status of application being monitored"))
o.template = "gpioled/ad-mon"
o.value = translate("Collecting data...")
---- mode
o = s:taboption("ad", ListValue, "ad_mode", translate("Blink Mode"))
o:value("0.1", translate("Fast"))
o:value("1", translate("Normal"))
o:value("2", translate("Slow"))
o:value("0", translate("Static"))
o.default = "1"
--- power led
s:tab("pwr", translate("Power LED"))
---- color
o = s:taboption("pwr", ListValue, "pwr_color", translate("LED Color"))
o:value("green", translate("Green"))
o:value("red", translate("Red"))
o:value("yellow", translate("Yellow"))
o.default = "green"
---- mode
o = s:taboption("pwr", ListValue, "pwr_mode", translate("Blink Mode"))
o:value("0.1", translate("Fast"))
o:value("1", translate("Normal"))
o:value("2", translate("Slow"))
o:value("0", translate("Static"))
o.default = "0"
m.apply_on_parse = true
m.on_after_apply = function(map)
luci.sys.exec("/etc/init.d/gpioled restart")
end
return m
@@ -0,0 +1,22 @@
<script type="text/javascript">
//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[system]], [[gpioled]], [[ad_mon]])%>', null,
function (x, data) {
var tb = document.getElementById('ad_mon');
if (data && tb) {
var runningValue = data.running.trim();
if (runningValue === '1') {
tb.innerHTML = '<b><font color=green>Running</font></b>';
} else if (runningValue === '0') {
tb.innerHTML = '<b><font color=red>Stopped</font></b>';
} else {
tb.innerHTML = '<b><font color=orange>Application not installed</font></b>';
}
}
}
);
//]]>
</script>
<%+cbi/valueheader%>
<font id="ad_mon"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
<%+cbi/valuefooter%>
@@ -0,0 +1,20 @@
<script type="text/javascript">
//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[system]], [[gpioled]], [[ad_status]])%>', null,
function (x, data) {
var tb = document.getElementById('ad_status');
if (data && tb) {
if (data.running) {
var links = '<b><font color=green><%:Running%></font></b>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<b><font color=red><%:Stopped%></font></b>';
}
}
}
);
//]]>
</script>
<%+cbi/valueheader%>
<font id="ad_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
<%+cbi/valuefooter%>
@@ -0,0 +1,20 @@
<script type="text/javascript">
//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[system]], [[gpioled]], [[id_status]])%>', null,
function (x, data) {
var tb = document.getElementById('id_status');
if (data && tb) {
if (data.running) {
var links = '<b><font color=green><%:Running%></font></b>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<b><font color=red><%:Stopped%></font></b>';
}
}
}
);
//]]>
</script>
<%+cbi/valueheader%>
<font id="id_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
<%+cbi/valuefooter%>
@@ -0,0 +1,14 @@
<%+cbi/valueheader%>
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly"></textarea>
<script type="text/javascript">
//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[system]], [[gpioled]], [[get_log]])%>', null,
function (x, data) {
var tb = document.getElementById('cbid.logview.1.conf');
if (x.responseText && tb) {
tb.value = x.responseText;
}
}
);
//]]>
</script>
@@ -0,0 +1,24 @@
<script type="text/javascript">
//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[system]], [[gpioled]], [[pwr_status]])%>', null,
function (x, data) {
var tb = document.getElementById('pwr_status');
if (data && tb) {
var runningValue = data.running.trim();
if (runningValue === '0.1') {
tb.innerHTML = '<b><font color=orange>Fast</font></b>';
} else if (runningValue === '1') {
tb.innerHTML = '<b><font color=orange>Normal</font></b>';
} else if (runningValue === '2') {
tb.innerHTML = '<b><font color=orange>Slow</font></b>';
} else if (runningValue === '0') {
tb.innerHTML = '<b><font color=orange>Static</font></b>';
}
}
}
);
//]]>
</script>
<%+cbi/valueheader%>
<font id="pwr_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
<%+cbi/valuefooter%>
+13
View File
@@ -0,0 +1,13 @@
config global 'global'
option enable ''
option device ''
config service 'service'
option id_il 'green'
option id_io 'red'
option id_mode '1'
option ad_app ''
option ad_mode '1'
option pwr_color 'green'
option pwr_mode '0'
+52
View File
@@ -0,0 +1,52 @@
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=99
STOP=10
CONF=gpioled
GD=/usr/share/gpioled/gd
PWR=/usr/share/gpioled/pwr
ID=/usr/share/gpioled/id
AD=/usr/share/gpioled/ad
service_triggers() {
procd_add_reload_trigger $CONF
}
start_service() {
config_load $CONF
config_get enable global enable
procd_open_instance
$GD start
screen -dmS gpio_pwr $PWR
if [ "$enable" == "id" ]; then
screen -dmS gpio_id $ID
fi
if [ "$enable" == "ad" ]; then
screen -dmS gpio_ad $AD
fi
if [ "$enable" == "id ad" ]; then
screen -dmS gpio_id $ID
screen -dmS gpio_ad $AD
fi
}
stop_service() {
session_list=$(screen -ls | awk '/[0-9]+\./ {print $1}')
for session in $session_list; do
screen -X -S $session quit
done
$GD stop
procd_close_instance
}
restart_service() {
stop_service
start_service
}
reload_service() {
restart
}
@@ -0,0 +1,17 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-gpioled.json" ] && {
cat > /usr/share/ucitrack/luci-app-gpioled.json << EEOF
{
"config": "gpioled",
"init": "gpioled"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@gpioled[-1]
add ucitrack gpioled
set ucitrack.@gpioled[-1].init=gpioled
commit ucitrack
EOF
rm -rf /tmp/luci*
exit 0
@@ -0,0 +1,89 @@
#!/bin/bash
# Environment GPIOLED
source /usr/share/gpioled/env
function application() {
echo "$TIMESTAMP [$d] $d1" >>$LOG_FILE
while :; do
MONITORING=$(uci get $AAD 2>/dev/null)
if [ "$MONITORING" == "uci: Entry not found" ]; then
if [ "$APP_NOT_FOUND" = false ]; then
APP_NOT_FOUND=true
fi
MONITORING=2
elif [[ "$MONITORING" =~ ^[0-9]+$ ]]; then
if [ "$APP_FOUND" = false ]; then
echo "$TIMESTAMP [$d] $d2" >>$LOG_FILE
echo "$TIMESTAMP [$d] $d4" >>$LOG_FILE
echo "$TIMESTAMP [$d] $d5" >>$LOG_FILE
APP_FOUND=true
fi
MONITORING=$(uci get $AAD)
else
if [ "$APP_INVALID" = false ]; then
echo "$TIMESTAMP [$d] $d2" >>$LOG_FILE
echo "$TIMESTAMP [$d] $d3" >>$LOG_FILE
APP_INVALID=true
break
fi
MONITORING=2
fi
if [ "$MONITORING" -eq 1 ]; then
if [ "$APP_SUCCESS" = false ]; then
echo "$TIMESTAMP [$d] $d7" >>$LOG_FILE
APP_SUCCESS=true
APP_FAIL=false
fi
if [ "$APPON" = false ]; then
APPON=true
fi
elif [ "$MONITORING" -eq 0 ]; then
if [ "$APP_FAIL" = false ]; then
echo "$TIMESTAMP [$d] $d6" >>$LOG_FILE
APP_SUCCESS=false
APP_FAIL=true
fi
if [ "$APPOFF" = false ]; then
APPOFF=true
fi
fi
if [ "$APPON" = true ]; then
if [ "$MAD" = "0" ]; then
echo "1" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
APPON=false
elif [ "$MAD" = "0.1" ]; then
echo "1" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
echo "0" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
APPON=false
elif [ "$MAD" = "1" ]; then
echo "1" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
echo "0" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
APPON=false
elif [ "$MAD" = "2" ]; then
echo "1" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
echo "0" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
APPON=false
fi
fi
if [ "$APPOFF" = true ]; then
echo "0" >/sys/class/gpio/gpio$GIRB/value
sleep $MAD
APPOFF=false
fi
done
}
case "${1}" in
*)
application
;;
esac
@@ -0,0 +1,71 @@
#!/bin/bash
# Global environment
GPIOBASE=/sys/class/gpio
DEVICE=$(uci get gpioled.global.device)
LOG_FILE=/tmp/gpioled.log
TIMESTAMP=$(date +'%d-%m-%Y %H:%M:%S')
if [ "$DEVICE" = "HG680PR1" ]; then
GPWR1=483
GPWR2=484
GETH1=481
GETH2=482
GIRB=480
elif [ "$DEVICE" = "HG680PR2" ]; then
GPWR1=425
GPWR2=426
GETH1=506
GETH2=510
GIRB=507
fi
# Info GPIO Device service
a="GPIO Export"
a1="Start $a..."
a2="Device $DEVICE"
a3="Export GPIO $DEVICE successfully"
b="GPIO Unexport"
b1="Start $b..."
b2="Device $DEVICE"
b3="Unexport GPIO $DEVICE successfully"
# Power LED service
c="Power LED"
c1="Start $c..."
c2="Service started successfully"
CPWR=$(uci get gpioled.service.pwr_color)
MPWR=$(uci get gpioled.service.pwr_mode)
# Application Detector service
AAD=$(uci get gpioled.service.ad_app)
MAD=$(uci get gpioled.service.ad_mode)
APP_FOUND=false
APP_NOT_FOUND=false
APP_INVALID=false
APP_SUCCESS=false
APP_FAIL=false
APPON=false
APPOFF=false
d="Application Detector"
d1="Start $d..."
d2="Check application availability..."
d3="Application not found. Is it installed?"
d4="Application installed. Start service..."
d5="Service started successfully"
d6="Status application [Stopped]"
d7="Status application [Running]"
# Internet Detector service
CIDL=$(uci get gpioled.service.id_il)
CIDO=$(uci get gpioled.service.id_io)
MID=$(uci get gpioled.service.id_mode)
INET_SUCCESS=false
INET_FAIL=false
INETON=false
INETOFF=false
e="Internet Detector"
e1="Start $e..."
e2="Service started successfully"
e3="Status internet [Disconnected]"
e4="Status internet [Connected]"
@@ -0,0 +1,55 @@
#!/bin/bash
# Environment GPIOLED
source /usr/share/gpioled/env
function create_gpio() {
echo "$TIMESTAMP [$a] $a1" >>$LOG_FILE
printf "$TIMESTAMP [$a] $a1\n"
echo "$TIMESTAMP [$a] $a2" >>$LOG_FILE
printf "$TIMESTAMP [$a] $a2\n"
echo $GPWR1 >$GPIOBASE/export
echo out >$GPIOBASE/gpio$GPWR1/direction
echo $GPWR2 >$GPIOBASE/export
echo out >$GPIOBASE/gpio$GPWR2/direction
echo $GETH1 >$GPIOBASE/export
echo out >$GPIOBASE/gpio$GETH1/direction
echo $GETH2 >$GPIOBASE/export
echo out >$GPIOBASE/gpio$GETH2/direction
echo $GIRB >$GPIOBASE/export
echo out >$GPIOBASE/gpio$GIRB/direction
echo "$TIMESTAMP [$a] $a3" >>$LOG_FILE
printf "$TIMESTAMP [$a] $a3\n"
}
function remove_gpio() {
echo "$TIMESTAMP [$b] $b1" >>$LOG_FILE
printf "$TIMESTAMP [$b] $b1\n"
echo "$TIMESTAMP [$b] $b2" >>$LOG_FILE
printf "$TIMESTAMP [$b] $b2\n"
echo $GPWR1 >$GPIOBASE/unexport
echo $GPWR2 >$GPIOBASE/unexport
echo $GETH1 >$GPIOBASE/unexport
echo $GETH2 >$GPIOBASE/unexport
echo $GIRB >$GPIOBASE/unexport
echo "$TIMESTAMP [$b] $b3" >>$LOG_FILE
printf "$TIMESTAMP [$b] $b3\n"
}
function usage() {
printf "Use start to run $a service\n"
printf "Use stop to run $b service\n"
}
case "${1}" in
start)
create_gpio
;;
stop)
remove_gpio
;;
*)
usage
;;
esac
+187
View File
@@ -0,0 +1,187 @@
#!/bin/bash
# Environment GPIOLED
source /usr/share/gpioled/env
function internet() {
echo "$TIMESTAMP [$e] $e1" >>$LOG_FILE
echo "$TIMESTAMP [$e] $e2" >>$LOG_FILE
while :; do
CONNECTION=$(ping -q -c 1 -W 1 8.8.8.8 >/dev/null 2>&1 && echo "OK" || echo "Fail")
if [ "$CONNECTION" = "OK" ]; then
if [ "$INET_SUCCESS" = false ]; then
echo "$TIMESTAMP [$e] $e4" >>$LOG_FILE
INET_SUCCESS=true
INET_FAIL=false
fi
if [ "$INETON" = false ]; then
INETON=true
fi
elif [ "$CONNECTION" = "Fail" ]; then
if [ "$INET_FAIL" = false ]; then
echo "$TIMESTAMP [$e] $e3" >>$LOG_FILE
INET_SUCCESS=false
INET_FAIL=true
fi
if [ "$INETOFF" = false ]; then
INETOFF=true
fi
fi
if [ "$INETON" = true ]; then
if [ "$CIDL" = "red" ]; then
if [ "$MID" = "0" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "0.1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "2" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
fi
elif [ "$CIDL" = "yellow" ]; then
if [ "$MID" = "0" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "0.1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "2" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
fi
elif [ "$CIDL" = "green" ]; then
if [ "$MID" = "0" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "0.1" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "1" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
elif [ "$MID" = "2" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETON=false
fi
fi
fi
if [ "$INETOFF" = true ]; then
if [ "$CIDO" = "red" ]; then
if [ "$MID" = "0" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "0.1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "2" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
fi
elif [ "$CIDO" = "yellow" ]; then
if [ "$MID" = "0" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "0.1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "1" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "2" ]; then
echo "1" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
fi
elif [ "$CIDO" = "green" ]; then
if [ "$MID" = "0" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "0.1" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "1" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
elif [ "$MID" = "2" ]; then
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "1" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
echo "0" >/sys/class/gpio/gpio$GETH1/value && echo "0" >/sys/class/gpio/gpio$GETH2/value
sleep $MID
INETOFF=false
fi
fi
fi
done
}
case "${1}" in
*)
internet
;;
esac
@@ -0,0 +1,79 @@
#!/bin/bash
# Environment GPIOLED
source /usr/share/gpioled/env
function power() {
echo "$TIMESTAMP [$c] $c1" >>$LOG_FILE
echo "$TIMESTAMP [$c] $c2" >>$LOG_FILE
while :; do
if [ "$CPWR" = "red" ]; then
if [ "$MPWR" = "0" ]; then
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "0.1" ]; then
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "1" ]; then
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "2" ]; then
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
fi
elif [ "$CPWR" = "yellow" ]; then
if [ "$MPWR" = "0" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "0.1" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "1" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "2" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "1" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
fi
elif [ "$CPWR" = "green" ]; then
if [ "$MPWR" = "0" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "0.1" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "1" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
elif [ "$MPWR" = "2" ]; then
echo "1" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
echo "0" >/sys/class/gpio/gpio$GPWR1/value && echo "0" >/sys/class/gpio/gpio$GPWR2/value
sleep $MPWR
fi
fi
done
}
case "${1}" in
*)
power
;;
esac
@@ -0,0 +1,11 @@
{
"luci-app-gpioled": {
"description": "Grant UCI access for luci-app-gpioled",
"read": {
"uci": [ "gpioled" ]
},
"write": {
"uci": [ "gpioled" ]
}
}
}