Added basic safe limit functionality

This commit is contained in:
2026-06-03 18:50:21 +01:00
parent 57869b16f7
commit 10520db877

9
app.py
View File

@ -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)