Merge pull request #3 from tomellericcardo/gpio_shutdown_plugin

add gpio_shutdown plugin and yaml configuration file
This commit is contained in:
evilsocket 2019-12-07 14:21:56 +02:00 committed by GitHub
commit 4ca7b58040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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