Skip to content

Commit

Permalink
Merge pull request #36 from pando85/main
Browse files Browse the repository at this point in the history
Improve documentation format and install instructions
  • Loading branch information
lsochanowski authored Oct 23, 2023
2 parents 4f9e67c + be77154 commit 948151f
Show file tree
Hide file tree
Showing 9 changed files with 466 additions and 200 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

## 1.0.191

* Tested in CZ-TAW1B
* Kernel updated

## 1.0.166

* Add new topics

## 1.0.159

* Removed a2wmain watch
* Start ssh and www from script
* Home Assistant MQTT Discovery https://www.home-assistant.io/docs/mqtt/discovery/

## 1.0.150

* Moved buttons handling from GoHeishaMon to separate script ( in this way , if GoHeishaMon will
crash it is still possible to go back to orginal via 3 buttons)
77 changes: 77 additions & 0 deletions GPIO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# GPIO

| Pin Number | Direction (Input/Output) | Function/Usage |
| ---------- | ------------------------ | ---------------- |
| 0 | Input | Reset Button |
| 1 | Input | WPS Button |
| 2 | Output | Blue Mid LED |
| 3 | Output | Green Bottom LED |
| 13 | Output | Green Mid LED |
| 15 | Output | Red Mid LED |
| 16 | Input | Check Button |

## LEDs

### white

```bash
echo high > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
```

### blue

```bash
echo high > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo low > /sys/class/gpio/gpio15/direction
```

### green

```bash
echo low > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo low > /sys/class/gpio/gpio15/direction
```

### red

```bash
echo low > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
```

### off

```bash
echo low > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo low > /sys/class/gpio/gpio15/direction
```

### yellow

```bash
echo low > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
```

### purple

```bash
echo high > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
```

### blue bright

```bash
echo high > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo low > /sys/class/gpio/gpio15/direction
```
2 changes: 1 addition & 1 deletion OS/RootFS/etc/gh/nextboot.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rm /etc/gh/config
/usr/bin/usb_mount.sh
cp /mnt/usb/GoHeishaMonConfig.new /etc/gh/config
/usr/bin/usb_umount.sh
/usr/bin/usb_umount.sh

reload_config
/etc/init.d/dropbear start
Expand Down
10 changes: 6 additions & 4 deletions OS/RootFS/etc/rc.button/wps
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
logger "the button was ${BUTTON} and the action was ${ACTION}"

for dir in /var/run/hostapd-*; do
[ -d "$dir" ] || continue
hostapd_cli -p "$dir" wps_pbc
done
[ "${ACTION}" = "released" ] || exit 0

. /lib/functions.sh

logger "$BUTTON pressed for $SEEN seconds"
9 changes: 7 additions & 2 deletions OS/RootFS/etc/rc.local
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

echo "START WATCHDOG =====" > /dev/ttyS0
logger "Start watchdog"
echo 300 > /proc/sys/kernel/panic
echo 0 > /proc/sys/kernel/panic_on_oops

(/usr/bin/check_buttons.sh > /dev/null 2>&1) &

logger -t rc.local "Execute nextboot.sh"
/etc/gh/nextboot.sh

logger -t rc.local "Clean nextboot.sh"
echo "" > /etc/gh/nextboot.sh
echo "START GoHeishaMon APL=====" > /dev/ttyS0

logger -t rc.local "Start GoHeishaMon"
/usr/bin/GoHeishaMon_MIPSUPX > /dev/ttyS0

#/usr/bin/a2wmain > /dev/ttyS0
#exit 0
111 changes: 54 additions & 57 deletions OS/RootFS/usr/bin/check_buttons.sh
Original file line number Diff line number Diff line change
@@ -1,78 +1,75 @@
#!/bin/ash

#LED
GOHEISHAMON_BIN=/usr/bin/GoHeishaMon_MIPSUPX

logger -t check_buttons.sh "Init GPIOs"

# LED
echo 2 > /sys/class/gpio/export
echo 3 > /sys/class/gpio/export
echo 13 > /sys/class/gpio/export
echo 15 > /sys/class/gpio/export

#link
# link
echo 10 > /sys/class/gpio/export

#buttons
# buttons
echo 0 > /sys/class/gpio/export
echo 1 > /sys/class/gpio/export
echo 16 > /sys/class/gpio/export

while true; do
# press == `hi`
ButtonReset=`awk '/gpio-0 /{print $5}' /sys/kernel/debug/gpio`
# press == `hi`
ButtonWPS=`awk '/gpio-1 /{print $5}' /sys/kernel/debug/gpio`
# press == `lo`
ButtonCheck=`awk '/gpio-16 /{print $5}' /sys/kernel/debug/gpio`
# Pin for communication by serial port
CNCNTLink=`awk '/gpio-10 /{print $5}' /sys/kernel/debug/gpio`

while :
do

ButtonReset=`awk '/gpio-0 /{print $5}' /sys/kernel/debug/gpio`
ButtonWPS=`awk '/gpio-1 /{print $5}' /sys/kernel/debug/gpio`
ButtonCheck=`awk '/gpio-16 /{print $5}' /sys/kernel/debug/gpio`
CNCNTLink=`awk '/gpio-10 /{print $5}' /sys/kernel/debug/gpio`

#bwhite
if [ "$ButtonReset" = 'lo' ] && [ "$ButtonWPS" = 'lo' ] && [ "$ButtonCheck" = 'hi' ] ; then
echo high > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
fi

#blue
if [ "$ButtonReset" = 'hi' ] || [ "$ButtonWPS" = 'hi' ] || [ "$ButtonCheck" = 'lo' ] ; then
echo high > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo low > /sys/class/gpio/gpio15/direction
fi

#yellow
if [ "$ButtonReset" = 'hi' ] && [ "$ButtonWPS" = 'hi' ] ; then
echo low > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
fi
if [ "$ButtonReset" = 'hi' ] && [ "$ButtonCheck" = 'lo' ] ;then
echo low > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
fi
if [ "$ButtonWPS" = 'hi' ] && [ "$ButtonCheck" = 'lo' ] ; then
echo low > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
fi
# GoHeishaMon running
if [ $(ps | grep "$GOHEISHAMON_BIN" | wc -l) -gt 1 ]; then
# white LED
echo high > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
else
# off LED
echo low > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo low > /sys/class/gpio/gpio15/direction
fi

#fw side switch
if [ "$ButtonReset" = 'hi' ] && [ "$ButtonWPS" = 'hi' ] && [ "$ButtonCheck" = 'lo' ] ; then
echo low > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
fwupdate sw > /dev/null 2>&1
sync
reboot
fi
if [ "$ButtonReset" = 'hi' ] && [ "$ButtonWPS" = 'lo' ] && [ "$ButtonCheck" = 'hi' ] ; then
# yellow LED
echo low > /sys/class/gpio/gpio2/direction
echo high > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
logger -t check_buttons.sh "Restart GoHeishaMon"
kill $(ps | grep "$GOHEISHAMON_BIN" | head -n1 | awk '{ print $1 }')
$GOHEISHAMON_BIN > /dev/ttyS0 &
fi

if [ "$CNCNTLink" = 'hi' ] ; then
echo low > /sys/class/gpio/gpio3/direction
fi
if [ "$CNCNTLink" = 'lo' ] ; then
echo high > /sys/class/gpio/gpio3/direction
fi
# fw side switch
if [ "$ButtonReset" = 'hi' ] && [ "$ButtonWPS" = 'hi' ] && [ "$ButtonCheck" = 'lo' ] ; then
# red LED
echo low > /sys/class/gpio/gpio2/direction
echo low > /sys/class/gpio/gpio13/direction
echo high > /sys/class/gpio/gpio15/direction
fwupdate sw > /dev/null 2>&1
sync
reboot
fi

sleep 1
if [ "$CNCNTLink" = 'hi' ] ; then
echo low > /sys/class/gpio/gpio3/direction
fi
if [ "$CNCNTLink" = 'lo' ] ; then
echo high > /sys/class/gpio/gpio3/direction
fi

sleep 1
done

exit 0
Loading

0 comments on commit 948151f

Please sign in to comment.