mrdunk / esp8266_mdns

mDNS queries and responses on esp8266
MIT License
77 stars 16 forks source link

query example #8

Closed pyxiscloud closed 7 years ago

pyxiscloud commented 7 years ago

hello, mrdunk please post some example how to get ip by mdns query?

for example i want to get ip address for "raspberrypi.local", how can i get it?

thank you sir

mrdunk commented 7 years ago

there are already examples included with the library. this one should do what you want: https://github.com/mrdunk/esp8266_mdns/tree/master/examples/mdns_test

change the line #define QUESTION_SERVICE "_mqtt._tcp.local" to #define QUESTION_SERVICE "raspberrypi.local"

pyxiscloud commented 7 years ago

thank you but i'm thinking there is a bug in wireshark i see packet with zero's:

138615 22:17:59.732157 NODE-E12635.Dlink 224.0.0.251 MDNS 54 Standard query 0x0000

0000 d8 30 62 61 0c b3 18 fe 34 e1 26 35 08 00 45 00 0010 00 28 00 03 00 00 ff 11 18 d3 c0 a8 01 4b e0 00 0020 00 fb 14 e9 14 e9 00 14 33 05 00 00 00 00 00 00 0030 00 00 00 00 00 00

the query are zero values

mrdunk commented 7 years ago

Yes, you are correct. The data_size variable was not getting updated when adding Queries and Answers to an mDNS packet leading to empty packets being sent.

The following release should fix this: https://github.com/mrdunk/esp8266_mdns/releases/tag/v1.1.2 Please test and confirm it works for you.

It should appear in the Arduino IDE in ~1 day. Until then you can download manually.

Thanks for noticing this.

171 9.606418731 192.168.192.21 224.0.0.251 MDNS 76 Standard query 0x0000 PTR _mqtt._tcp.local, "QM" question

0000 01 00 5e 00 00 fb 5c cf 7f 12 69 65 08 00 45 00 0010 00 3e 00 05 00 00 ff 11 59 f0 c0 a8 c0 15 e0 00 0020 00 fb 14 e9 14 e9 00 2a 68 22 00 00 00 00 00 01 0030 00 00 00 00 00 00 05 5f 6d 71 74 74 04 5f 74 63 0040 70 05 6c 6f 63 61 6c 00 00 0c 00 01

pyxiscloud commented 7 years ago

still the same, maybe its not updated

0000 d8 30 62 61 0c b3 18 fe 34 e1 26 35 08 00 45 00 0010 00 28 00 04 00 00 ff 11 18 d2 c0 a8 01 4b e0 00 0020 00 fb 14 e9 14 e9 00 14 33 05 00 00 00 00 00 00 0030 00 00 00 00 00 00

mrdunk commented 7 years ago

Yes, apologies. I was still calculating the data_size variable incorrectly. This worked for my test case (_mqtt._tcp.local) but not for targets with less words (eg oneword.local).

I believe this is now fixed in v1.1.3. https://github.com/mrdunk/esp8266_mdns/releases/tag/v1.1.3

Thank you for your patience. dunk.