#!/bin/sh
#
# Copyright (C) 2016-2019, 2021 The slide-switch authors
# https://github.com/jefferyto/openwrt-slide-switch
#
# slide-switch is free software, licensed under the GNU General Public License v2.
#
# echo "BUTTON[$BUTTON], ACTION[$ACTION]" > /dev/console

#. /lib/functions/io-leds.sh

"/usr/sbin/slide-switch" update "$BUTTON" &

if [ -f "/var/.banButton" ]; then
    if [ "$ACTION" = "pressed" ]; then
        if [ "$BUTTON" = "led-on" ]; then
            touch /tmp/ban_button_led_on
        elif [ "$BUTTON" = "led-off" ]; then
            touch /tmp/ban_button_led_off
        elif [ "$BUTTON" = "mode-auto" ]; then
            touch /tmp/ban_button_mode_auto
        elif [ "$BUTTON" = "mode-ap" ]; then
            touch /tmp/ban_button_mode_ap
        fi
        return 0
    fi
fi

if [ "$ACTION" = "pressed" ]; then
    if [ "$BUTTON" = "led-on" ]; then
        echo "Switch Button(led-on) Pressed........." > /dev/console
##        led_power_state all 1
##        ucix set button.slide.ledswitch='on'
    elif [ "$BUTTON" = "led-off" ]; then
        echo "Switch Button(led-off) Pressed........." > /dev/console
##        led_power_state all 0
##        ucix set button.slide.ledswitch='off'
    elif [ "$BUTTON" = "mode-auto" ]; then
        echo "Switch Button(mode-auto) Pressed........." > /dev/console
#        ucix set button.slide.modeswitch='auto'
    elif [ "$BUTTON" = "mode-ap" ]; then
        echo "Switch Button(mode-ap) Pressed........." > /dev/console
#        ucix set button.slide.modeswitch='ap'
    fi
fi

return 0

