You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/protocols/mdns/README.md
+82-6Lines changed: 82 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,88 @@ Shows how to use mDNS to advertise lookup services and hosts
10
10
- GPIO0 (BOOT Button) is initialized as pulled-up input that can be monitored for button press
11
11
- Example task is started to check if the button is pressed so it can execute the mDNS queries defined
12
12
13
-
##Running the example
13
+
### Configure the project
14
14
15
-
- Run `make menuconfig` to configure the access point's SSID and Password and the default device mDNS host name and instance name
16
-
- Run `make flash monitor` to build and upload the example to your board and connect to it's serial terminal
17
-
- Wait for WiFi to connec to your access point
18
-
- You can now ping the device at `[hostname].local` and browse for `_http._tcp` on the same network to find the advertised service
19
-
- Pressing the BOOT button will start quring the local network for the predefined in `check_button` hosts and services
15
+
```
16
+
make menuconfig
17
+
```
18
+
19
+
* Set `Default serial port` under `Serial flasher config`.
20
+
* Set `WiFi SSID` and `WiFi Password` for the board to connect to AP.
21
+
* Set `mDNS Hostname` as host name prefix for the device and its instance name in `mDNS Instance Name`
22
+
* Disable `Resolve test services` to prevent the example from querying defined names/services on startup (cause warnings in example logs, as illustrated below)
23
+
24
+
### Build and Flash
25
+
26
+
Build the project and flash it to the board, then run monitor tool to view serial output:
27
+
28
+
```
29
+
make -j4 flash monitor
30
+
```
31
+
- Wait for WiFi to connect to your access point
32
+
- You can now ping the device at `[board-hostname].local`, where `[board-hostname]` is a string created from preconfigured hostname (`esp32-mdns` by default) and last 3 bytes from device MAC address. Please check the serial output log for the specific board-hostname (`esp32-mdns_80FFFF` in the log below)
33
+
- You can also browse for `_http._tcp` on the same network to find the advertised service
34
+
- Pressing the BOOT button will start querying the local network for the predefined in `check_button` hosts and services
35
+
36
+
37
+
(To exit the serial monitor, type ``Ctrl-]``.)
38
+
39
+
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
40
+
41
+
## Example Output
42
+
```
43
+
I (0) cpu_start: Starting scheduler on APP CPU.
44
+
I (276) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
45
+
I (276) mdns-test: mdns hostname set to: [esp32-mdns_80FFFF]
46
+
I (286) wifi: wifi driver task: 3ffc2fa4, prio:23, stack:3584, core=0
47
+
I (286) wifi: wifi firmware version: a3be639
48
+
I (286) wifi: config NVS flash: enabled
49
+
I (296) wifi: config nano formating: disabled
50
+
I (296) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
51
+
I (306) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
52
+
I (336) wifi: Init dynamic tx buffer num: 32
53
+
I (336) wifi: Init data frame dynamic rx buffer num: 32
_Static_assert(sizeof(c_config_hostname) <CONFIG_MAIN_TASK_STACK_SIZE/2, "Configured mDNS name consumes more than half of the stack. Please select a shorter host name or extend the main stack size please.");
102
+
constsize_tconfig_hostname_len=sizeof(c_config_hostname) -1; // without term char
103
+
charhostname[config_hostname_len+1+3*2+1]; // adding underscore + 3 digits + term char
104
+
uint8_tmac[6];
105
+
106
+
// adding 3 LSBs from mac addr to setup a board specific name
0 commit comments