Last active
January 31, 2025 12:09
-
-
Save mongonta0716/7d1e0a63412f2c832ee44884d95dede0 to your computer and use it in GitHub Desktop.
M5Stack ModuleLLMの/etc/rc.localでWiFiの接続を追加して、ステータスをLEDで分かるようにしたrc.local(追加部分のみ)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 下記のファイルを作成してください。(作成後、chmod +x /usr/local/m5stack/led.shを忘れずに) | |
# /usr/local/m5stack/led,sh | |
# 引数の数をチェック | |
if [ $# -ne 3 ] ; then | |
echo "Usage: $0 <brightness r> <brightneee g> <brigntness b>" | |
exit 1 | |
fi | |
echo $1 > /sys/class/leds/R/brightness | |
echo $2 > /sys/class/leds/G/brightness | |
echo $3 > /sys/class/leds/B/brightness | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 下記のファイルを作成してください。(作成後、chmod +x /usr/local/m5stack/led_test.shを忘れずに) | |
# /usr/local/m5stack/led_test.sh | |
# LEDのテスト用 指定した回数点滅します。 | |
for CNT in `seq 1 1 $1` | |
do | |
/usr/local/m5stack/led.sh 50 50 50 | |
sleep 0.5 | |
/usr/local/m5stack/led.sh 0 0 0 | |
sleep 0.5 | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USB-WiFiや有線LANの状態で接続状態次第でLEDの色を変えます。 | |
# 緑: 無線接続正常 | |
# 青: 有線接続正常 | |
# 黄: WiFi接続でなんらかのトラブル(ネットワークにつながらない) | |
# 赤: WiFiアダプタが見つからない | |
wpa_supplicant -i wlan0 -B -c /etc/wpa_supplicant.conf | |
WIFI_RESULT=$? | |
bash /usr/local/m5stack/led_test.sh 8 | |
if [ ${WIFI_RESULT} -eq 0 ] ; then | |
# 無線LANアダプタが存在した場合緑 | |
bash /usr/local/m5stack/led.sh 0 255 0 | |
ping -c 5 www.google.com | |
if [ $? -ne 0 ] ; then | |
# 無線は認識したがネットワーク不通は黄色 | |
bash /usr/local/m5stack/led.sh 255 255 0 | |
fi | |
else | |
ping -c 5 www.google.com | |
if [ $? -eq 0 ] ; then | |
# 有線の場合青 | |
bash /usr/local/m5stack/led.sh 0 0 255 | |
else | |
# 無線も有線もだめなときは赤 | |
bash /usr/local/m5stack/led.sh 255 0 0 | |
fi | |
fi | |
exit 0 # rc.localを0で終了しないとadb接続ができなくなるようです。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment