Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this script , a loop need to be added to checks if the input from the Arduino matches a specific value,

I need help with this script , a loop need to be added to checks if the input from the Arduino matches a specific value, and if it does, it sends an Authy OneTouch request to the user with the specified ID, waits 8 seconds, and then checks the approval status of the request. If the approval status is "approved", it turns on the LED lights for 5 seconds, and if not, it prints "no".

the script needs to be modified to include a mechanism to stop the loop once the user has approved the request. One approach is to include a timer that will terminate the loop after a certain amount of time (e.g., 10 seconds), even if the user has not yet approved the request. Another approach is to use a flag variable to track whether the user has approved the request and exit the loop once the flag is set to true.

this code can be tested on a vm so please do it and post picture of working code to make sure the code actually works , i'd appreciate it

from authy.api import AuthyApiClient import time import sys import io

# GPIO.setmode(GPIO.BCM) # GPIO.setup(17, GPIO.OUT) # GPIO.setup(27, GPIO.OUT)

# arduino = serial.Serial('/dev/ttyACM0', 9600) # arduino_data = arduino.readline()

data = [] for i in range(50): # b = arduino.readline() # string_n = b.decode() # string = string_n.rstrip() # data.append(s) # time.sleep(0.1)

# print("Adam[1] or Rachel[2]?") s = str() s = input('Type user tag:') print(s)

if s == " 21 F8 7C 26": authy_api = AuthyApiClient('jtJEfq9PPAdHOALNrt8FsVescO1C6RrZ')

response = authy_api.one_touch.send_request( 593152871, # adam "Requesting login for Encation", seconds_to_expire=120)

if response.ok(): print(response.get_uuid()) else: print(response.errors())

time.sleep(8) # you may need to remove this to test your loop

old_stdout = sys.stdout sys.stdout = buffer = io.StringIO()

if response.ok(): status = authy_api.one_touch.get_approval_status(response.get_uuid()) print(status.content)

sys.stdout = old_stdout

statuscontent = buffer.getvalue() print(statuscontent) index = statuscontent.find("approved")

# INSERT LOOP HERE

if index != -1: print('yes') # GPIO.output(17, True) # GPIO.output(27, True) # time.sleep(5) # GPIO.output(17, False) # GPIO.output(27, False) else: print('no')

if s == " D3 99 12 2E": authy_api = AuthyApiClient('jtJEfq9PPAdHOALNrt8FsVescO1C6RrZ')

response = authy_api.one_touch.send_request( 596467975, # rachel "Requesting login for Encation", seconds_to_expire=120)

if response.ok(): print(response.get_uuid()) else: print(response.errors())

time.sleep(8) # you may need to remove this to test your loop

old_stdout = sys.stdout sys.stdout = buffer = io.StringIO()

if response.ok(): status = authy_api.one_touch.get_approval_status(response.get_uuid()) print(status.content)

sys.stdout = old_stdout statuscontent = buffer.getvalue() print(statuscontent) index = statuscontent.find("approved") print(index)

# INSERT LOOP HERE

if index != -1: print('yes') # GPIO.output(17, True) # GPIO.output(27, True) # time.sleep(5) # GPIO.output(17, False) # GPIO.output(27, False) else: print('no')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

=+employee to take on the international assignment?

Answered: 1 week ago

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago