-
Notifications
You must be signed in to change notification settings - Fork 81
PYFW-389: Support MDNS #183
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
Conversation
Hi Géza, are these changes relevant only for the development firmware (development firmware api)? Your changes shouldn't be merged into publish branch (which contains production firmware api)? |
@jirikrepl : this belongs to a feature which has not been released yet. |
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.
A few edits with one minor question (second comment)
MDNS.add_service("_myservice", MDNS.PROTO_UDP, 1234, txt= (("board","esp32"),("u","user"),("p","password"))) | ||
|
||
|
||
# Wait some time and remove 1 service |
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.
Second comment: Please be specific with the amount of time needed to wait e.g. 'Wait for approximately 10 seconds' and also what service needs to be removed
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.
It is up to the user to decide. The "remove 1 service" means in the next line we remove 1 service, but I agree it can be confusing, I will correct this.
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.
Okey, so go for 'Set the wait-time and remove the chosen service (shown in the next line)'
|
||
# Wait some time and remove 1 service | ||
time.sleep(60) | ||
# Remove a service, it will not be advertised |
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.
Third comment: When a service is removed, it will no longer be advertised
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.
Fixed.
```python | ||
import time | ||
from network import MDNS | ||
# As a first step connection to network should be estbalished, e.g. via WLAN |
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.
Fourth comment: First, connect to the chosen network e.g. via WLAN
Note for Geza: Do we use WLANs? I thought we used LPWANs?
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.
Answered above.
|
||
#### MDNS.set_name(\*, hostname=None, instance_name=None) | ||
|
||
Sets the hostname and instance name of this device to be advertised. |
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.
Sixth comment: Sets the hostname and instance name of the device that is going to be advertised
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 used "this" here because it is the current device where this application is running, not another one.
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 would still use 'Sets the hostname and instance name of the device that is going to be advertised i.e. the current device that the application is running on' because 'this' reads a bit strangely
|
||
## MDNS_Query class | ||
|
||
The `MDNS_Query` aggregates all the properties of an entry of a successfull query session: |
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.
11th comment: The MDNS_Query
aggregates all of the properties of a successful query session entry:
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.
Fixed.
* `instance_name` is the instance_name of the service | ||
* `addr` is the IPv4 address belonging to the service | ||
* `port` is the port number belonging to the service | ||
* `txt`is the TXT entries from the advertisement. The TXT entry is a (key, value) tuple, several TXT entries can be included in an advertisement. |
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.
9th comment: txt`is the TXT entries from the advertisement. The TXT entry is a (key, value) tuple, and several TXT entries can be included in an advertisement.
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.
Fixed.
# Perform a query for 2000 ms | ||
q = MDNS.query(2000, "_http", MDNS.PROTO_TCP) | ||
|
||
# Print out query's result |
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.
Fifth comment: Print out the query's result
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.
Fixed.
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.
only two more comments :D
@@ -25,10 +25,9 @@ MDNS.add_service("_http", MDNS.PROTO_TCP, 80) | |||
# Add an UDP service to advertise | |||
MDNS.add_service("_myservice", MDNS.PROTO_UDP, 1234, txt= (("board","esp32"),("u","user"),("p","password"))) | |||
|
|||
|
|||
# Wait some time and remove 1 service | |||
# Wait some time |
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.
1 comment - 'Wait some time. You are able to set the amount of time you must wait by altering the code below'
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 rephrase it to show what is the purpose of waiting here.
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.
It's not the purpose that I think folks will have a problem with, it's more that you need to either state approximately how long they might have to wait or how they set that amount of time. 'Wait some time' needs more clarification.
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.
This line actually does nothing important, it can be completely removed and from functional point of view nothing changes. The example code showing a possible use-case of the new feature, which is:
- Advertise the services
- Wait (doesn't matter how long, we cannot advice anything here, this is just an example)
- Stop advertising 1 of the 2 services
I think the audience of this documentation, who are familiar with Python will not be confused.
|
||
#### MDNS.set_name(\*, hostname=None, instance_name=None) | ||
|
||
Sets the hostname and instance name of this device to be advertised. |
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 would still use 'Sets the hostname and instance name of the device that is going to be advertised i.e. the current device that the application is running on' because 'this' reads a bit strangely
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.
Looks good to me!
No description provided.