From 10520db877fc9b7d6a9b2af2ff9383f8a91ef627 Mon Sep 17 00:00:00 2001 From: Tango Date: Wed, 3 Jun 2026 18:50:21 +0100 Subject: [PATCH] Added basic safe limit functionality --- app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app.py b/app.py index 8d6d664..5928bfc 100644 --- a/app.py +++ b/app.py @@ -75,6 +75,9 @@ def transmit(): if pin != app.config['pin']: return {'success': False, 'message': 'Unauthorised'}, 401 + if intensity > app.config['limit']: + return {'success': False, 'message': 'Exceeded Safe Limit'}, 406 + # Send the data to WHSPAH tx: whspah.Transmitter = app.config['transmitter'] tx.transmit(txID, channel, action, intensity, lucal) @@ -92,6 +95,8 @@ if __name__ == '__main__': parser.add_argument('--pin', type=int, default=random.randint(1000, 9999), help='The authorisation pin, defaults to a random number '+ 'between 1000 and 9999') + parser.add_argument('--limit', type=int, default=99, + help='The same limit for intensity.') args = parser.parse_args() # Sets the logging version based on --debug @@ -107,6 +112,10 @@ if __name__ == '__main__': app.config['pin'] = args.pin print(f'Running with pin {args.pin}.') + # Configure Limit + app.config['limit'] = args.limit + print(f'Running with safe limit {args.limit}.') + if args.debug: # If in debug mode, run Flask's built in server app.run(host=args.ip, port=args.port, debug=True)