Skip to content

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

Merged
merged 3 commits into from
Dec 3, 2019
Merged

Conversation

husigeza
Copy link
Contributor

No description provided.

@husigeza husigeza changed the base branch from publish to development-publish November 29, 2019 11:49
@jirkadev jirkadev requested review from lilycey and jirkadev November 29, 2019 12:27
@jirkadev
Copy link
Contributor

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

@husigeza
Copy link
Contributor Author

@jirikrepl : this belongs to a feature which has not been released yet.

Copy link
Contributor

@lilycey lilycey left a 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
Copy link
Contributor

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

Copy link
Contributor Author

@husigeza husigeza Nov 29, 2019

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.

Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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:
Copy link
Contributor

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:

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@lilycey lilycey left a 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
Copy link
Contributor

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'

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@husigeza husigeza Nov 30, 2019

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:

  1. Advertise the services
  2. Wait (doesn't matter how long, we cannot advice anything here, this is just an example)
  3. 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.
Copy link
Contributor

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

Copy link
Contributor

@lilycey lilycey left a 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!

@husigeza husigeza merged commit b01cbd3 into pycom:development-publish Dec 3, 2019
@husigeza husigeza deleted the PYFW-389 branch December 3, 2019 16:49
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.

4 participants