[i=s] 本帖最后由 zhongzsp 于 2025-4-4 22:46 编辑 [/i]<br />
<br />
<h3>前言</h3>
<p>绿联设备刷了 fnOS 系统以后,设备的 Led 灯默认为跑马灯状态,没办法实现 Led 灯的功能。</p>
<p>有一个大佬弄了一个工具,大家可以通过代码去控制</p>
<p>大佬的 github 开源的代码在这里</p>
<p>https://github.com/miskcoo/ugreen_leds_controller</p>
<h3>fnOS中开启SSH功能</h3>
<p>在系统的“系统设置”里面找到“SSH”然后打开这个功能</p>
<h3>使用工具连接 fnOS</h3>
<p>我这里用 mac 为例</p>
<p>在 mac 中使用终端就可以直接连接 fnOS</p>
<blockquote>
<p>ssh 用户名@192.168.X.X</p>
</blockquote>
<p>直接在终端使用使用以上的代码然后输入密码就可以直接连接</p>
<h3>下载 ugren_leds_cli 工具</h3>
<pre><code>#切换到 root
sudo -i
下载 ugreen_leds_cli 工具
cd /usr/bin
wget https://github.com/miskcoo/ugreen_leds_controller/releases/download/v0.1-debian12/ugreen_leds_cli
chmod +x ugreen_leds_cli
</code></pre>
<h3>试试看工具能不能用</h3>
<pre><code>#检查功能能不能用
./ugreen_leds_cli all -off
</code></pre>
<h3>如果遇到问题</h3>
<pre><code>#如果报以下错误
Err: fail to open the I2C device.
Please check that (1) you have the root permission;
and (2) the i2c-dev module is loaded.
就执行下面的代码
sudo modprobe i2c-dev
</code></pre>
<h3>控制代码</h3>
<p>大家可以根据用代码去控制</p>
<pre><code>Usage: ugreen_leds_cli [LED-NAME...] [-on] [-off] [-(blink|breath) T_ON T_OFF]
[-color R G B] [-brightness BRIGHTNESS] [-status]
LED_NAME: separated by white space, possible values are
{ power, netdev, disk[1-8], all }.
-on / -off: turn on / off corresponding LEDs.
-blink / -breath: set LED to the blink / breath mode. This
mode keeps the LED on for T_ON millseconds and then
keeps it off for T_OFF millseconds.
T_ON and T_OFF should belong to [0, 65535].
-color: set the color of corresponding LEDs.
R, G and B should belong to [0, 255].
-brightness: set the brightness of corresponding LEDs.
BRIGHTNESS should belong to [0, 255].
-status: display the status of corresponding LEDs.
</code></pre>
<h3>案例</h3>
<pre><code># 打开所有的 LED 灯
ugreen_leds_cli all -on
关闭所有的 LED 灯
ugreen_leds_cli all -off
打开开机灯
ugreen_leds_cli power -on
设置开机灯颜色为红色
ugreen_leds_cli power -color 255 0 0
设置开机灯亮度 最高为 255
ugreen_leds_cli power -brightness 30
开机灯 power 网络灯 netdev 硬盘灯 disk1 disk2 disk3 以此类推
</code></pre>
<p>下次再分享脚本来控制 LED 灯实现对应的功能。</p> |