-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Improve psk handling #118
Conversation
example_async.py
Outdated
parser.add_argument('-H', '--hostname', dest='host', required=True, | ||
help='IP Address of your Tradfri gateway') | ||
parser.add_argument('-K', '--key', dest='key', required=False, | ||
help='Key found on your Tradfri gateway') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
example_async.py
Outdated
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-H', '--hostname', dest='host', required=True, | ||
help='IP Address of your Tradfri gateway') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
psk = yield from api_factory.generate_psk(sys.argv[2]) | ||
conf = load_json(CONFIG_FILE) | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lwis these lines (or something along the line of these lines) will appear in all examples. Should I extract this to a class instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we risk making the examples too complex if we make reference to other files. And this doesn't really belong in the main lib. Not sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree and was unsure myself, hence reaching out. Let's keep it as is for now.
pytradfri/api/libcoap_api.py
Outdated
@@ -149,7 +149,6 @@ def generate_psk(self, security_key): | |||
if not self._psk: | |||
existing_psk_id = self._psk_id | |||
|
|||
self._psk_id = 'Client_identity' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lwis I believe this is the reason users may have experienced problems. I got this back from the gateway when debugging. We would expect 9090 to be pytradfri in current version and uuid.uuid4().hex in proposed update of the lib.
{'9090': 'Client_identity'}
['coap-client', '-u', 'Client_identity', '-k', 'XYZ', '-v', '0', '-m', 'post', '-f', '-', 'coaps://192.168.0.129:5684/15011/9063']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarification: the output above is from before I removed the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can generate the psk then we don't need to make a copy of the id at all. I was under the impression that only the Client_identity user could generate psk's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right in that Client_identity user generates psk but we also expect 9090 to contain the identity we want a psk for: https://pbs.twimg.com/media/DNeWn9WXkAI4R6b.png:large
It works as expected in the aiocoap api but not in the libcoap api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the request method broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure, libcoap seems to work fine if the key has already been generated and is available in the file (json or in the gateway_psk.txt file.)
1 similar comment
example_color.py
Outdated
|
||
run() | ||
asyncio.get_event_loop().run_until_complete(run()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines after class or function definition, found 1
This closes #96 given that you have either aiocoap or libcoap installed.