Skip to content
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

Merged
merged 23 commits into from
Nov 26, 2017
Merged

WIP: Improve psk handling #118

merged 23 commits into from
Nov 26, 2017

Conversation

ggravlingen
Copy link
Member

This closes #96 given that you have either aiocoap or libcoap installed.

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

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

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

@ggravlingen ggravlingen changed the title Improve psk handling WIP: Improve psk handling Nov 18, 2017
psk = yield from api_factory.generate_psk(sys.argv[2])
conf = load_json(CONFIG_FILE)

try:
Copy link
Member Author

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?

Copy link
Collaborator

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!

Copy link
Member Author

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.

@@ -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'
Copy link
Member Author

@ggravlingen ggravlingen Nov 18, 2017

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']

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Member Author

@ggravlingen ggravlingen Nov 18, 2017

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.

Copy link
Collaborator

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?

Copy link
Member Author

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

@coveralls
Copy link

coveralls commented Nov 18, 2017

Coverage Status

Coverage decreased (-3.3%) to 59.912% when pulling da2f34d on improve_psk into 4ba3f79 on master.

@coveralls
Copy link

coveralls commented Nov 25, 2017

Coverage Status

Coverage decreased (-3.9%) to 59.351% when pulling bf43ec2 on improve_psk into 4ba3f79 on master.

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage decreased (-2.06%) to 59.416% when pulling 89b63c4 on improve_psk into a076775 on master.

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage decreased (-2.06%) to 59.416% when pulling 0c749fb on improve_psk into a076775 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.06%) to 59.416% when pulling 0c749fb on improve_psk into a076775 on master.

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage decreased (-2.06%) to 59.416% when pulling f5c82f2 on improve_psk into a076775 on master.

example_color.py Outdated

run()
asyncio.get_event_loop().run_until_complete(run())

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

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage decreased (-2.06%) to 59.416% when pulling 10df4e8 on improve_psk into a076775 on master.

@coveralls
Copy link

coveralls commented Nov 26, 2017

Coverage Status

Coverage decreased (-2.06%) to 59.416% when pulling 10df4e8 on improve_psk into a076775 on master.

@ggravlingen ggravlingen merged commit 8902f2e into master Nov 26, 2017
@ggravlingen ggravlingen deleted the improve_psk branch November 26, 2017 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytradfri 4.0.0 not working
4 participants