add gpio_shutdown plugin and yaml configuration file

This commit is contained in:
tomellericcardo 2019-11-13 21:32:49 +01:00
parent a213b1cd7e
commit 56aec1e8e3
2 changed files with 33 additions and 0 deletions

30
gpio_shutdown.py Normal file
View File

@ -0,0 +1,30 @@
import pwnagotchi.plugins as plugins
import logging
import RPi.GPIO as GPIO
import pwnagotchi
class GPIOShutdown(plugins.Plugin):
__author__ = 'tomelleri.riccardo@gmail.com'
__version__ = '1.0.0'
__license__ = 'GPL3'
__description__ = 'GPIO Shutdown plugin'
def shutdown(self, channel):
logging.warning('Received shutdown command from GPIO')
pwnagotchi.shutdown()
def on_loaded(self):
logging.info('GPIO Shutdown plugin loaded')
shutdown_gpio = self.options['gpio']
GPIO.setmode(GPIO.BCM)
GPIO.setup(shutdown_gpio, GPIO.IN, GPIO.PUD_UP)
GPIO.add_event_detect(shutdown_gpio, GPIO.FALLING, callback = self.shutdown)
logging.info("Added shutdown command to GPIO %d", shutdown_gpio)

3
gpio_shutdown.yml Normal file
View File

@ -0,0 +1,3 @@
gpio_shutdown:
enabled: false
gpio: 21