8000 Add MDNS support to Pico W · netroy/circuitpython@c13ca95 · GitHub
[go: up one dir, main page]

Skip to content

Commit c13ca95

Browse files
committed
Add MDNS support to Pico W
This adds both cpy-MAC.local and circuitpython.local support. Fixes adafruit#7214
1 parent ad2d190 commit c13ca95

File tree

16 files changed

+521
-43
lines changed

16 files changed

+521
-43
lines changed

.gitmodules

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,12 @@
312312
url = https://github.com/adafruit/esp32-camera/
313313
[submodule "ports/raspberrypi/lib/cyw43-driver"]
314314
path = ports/raspberrypi/lib/cyw43-driver
315-
url = https://github.com/georgerobotics/cyw43-driver.git
315+
url = https://github.com/adafruit/cyw43-driver.git
316+
branch = circuitpython8
316317
[submodule "ports/raspberrypi/lib/lwip"]
317318
path = ports/raspberrypi/lib/lwip
318-
url = https://github.com/lwip-tcpip/lwip.git
319+
url = https://github.com/adafruit/lwip.git
320+
branch = circuitpython8
319321
[submodule "lib/mbedtls"]
320322
path = lib/mbedtls
321323
url = https://github.com/ARMmbed/mbedtls.git

locale/circuitpython.pot

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ msgstr ""
106106
msgid "%q in use"
107107
msgstr ""
108108

109-
#: py/obj.c py/objstr.c py/objstrunicode.c
109+
#: py/objstr.c py/objstrunicode.c
110110
msgid "%q index out of range"
111111
msgstr ""
112112

@@ -171,7 +171,7 @@ msgstr ""
171171
msgid "%q must be an int"
172172
msgstr ""
173173

174-
#: py/argcheck.c
174+
#: py/argcheck.c py/obj.c
175175
msgid "%q must be of type %q"
176176
msgstr ""
177177

@@ -1663,6 +1663,10 @@ msgstr ""
16631663
msgid "Operation timed out"
16641664
msgstr ""
16651665

1666+
#: ports/raspberrypi/common-hal/mdns/Server.c
1667+
msgid "Out of MDNS service slots"
1668+
msgstr ""
1669+
16661670
#: ports/espressif/common-hal/espidf/__init__.c ports/espressif/esp_error.c
16671671
msgid "Out of memory"
16681672
msgstr ""
@@ -2192,6 +2196,7 @@ msgid "Unable to read color palette data"
21922196
msgstr ""
21932197

21942198
#: ports/espressif/common-hal/mdns/Server.c
2199+
#: ports/raspberrypi/common-hal/mdns/Server.c
21952200
msgid "Unable to start mDNS query"
21962201
msgstr ""
21972202

@@ -3153,7 +3158,7 @@ msgid "index is out of bounds"
31533158
msgstr ""
31543159

31553160
#: extmod/ulab/code/numpy/numerical.c extmod/ulab/code/ulab_tools.c
3156-
#: ports/espressif/common-hal/pulseio/PulseIn.c py/obj.c
3161+
#: ports/espressif/common-hal/pulseio/PulseIn.c
31573162
#: shared-bindings/bitmaptools/__init__.c
31583163
msgid "index out of range"
31593164
msgstr ""
@@ -3405,10 +3410,12 @@ msgid "loopback + silent mode not supported by peripheral"
34053410
msgstr ""
34063411

34073412
#: ports/espressif/common-hal/mdns/Server.c
3413+
#: ports/raspberrypi/common-hal/mdns/Server.c
34083414
msgid "mDNS already initialized"
34093415
msgstr ""
34103416

34113417
#: ports/espressif/common-hal/mdns/Server.c
3418+
#: ports/raspberrypi/common-hal/mdns/Server.c
34123419
msgid "mDNS only works with built-in WiFi"
34133420
msgstr ""
34143421

ports/raspberrypi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ SRC_SDK_CYW43 := \
4747

4848
SRC_LWIP := \
4949
shared/netutils/netutils.c \
50+
$(wildcard lib/lwip/src/apps/mdns/*.c) \
5051
$(wildcard lib/lwip/src/core/*.c) \
5152
$(wildcard lib/lwip/src/core/ipv4/*.c) \
5253
lib/lwip/src/netif/ethernet.c \

ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CIRCUITPY_SSL = 1
1515
CIRCUITPY_SSL_MBEDTLS = 1
1616
CIRCUITPY_HASHLIB = 1
1717
CIRCUITPY_WEB_WORKFLOW = 1
18-
CIRCUITPY_MDNS = 0
18+
CIRCUITPY_MDNS = 1
1919
CIRCUITPY_SOCKETPOOL = 1
2020
CIRCUITPY_WIFI = 1
2121

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2022 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "shared-bindings/mdns/RemoteService.h"
28+
29+
#include "shared-bindings/ipaddress/IPv4Address.h"
30+
31+
const char *common_hal_mdns_remoteservice_get_service_type(mdns_remoteservice_obj_t *self) {
32+
return self->service_name;
33+
}
34+
35+
const char *common_hal_mdns_remoteservice_get_protocol(mdns_remoteservice_obj_t *self) {
36+
return self->protocol;
37+
}
38+
39+
const char *common_hal_mdns_remoteservice_get_instance_name(mdns_remoteservice_obj_t *self) {
40+
return self->instance_name;
41+
}
42+
43+
const char *common_hal_mdns_remoteservice_get_hostname(mdns_remoteservice_obj_t *self) {
44+
return self->hostname;
45+
}
46+
47+
mp_int_t common_hal_mdns_remoteservice_get_port(mdns_remoteservice_obj_t *self) {
48+
return self->port;
49+
}
50+
51+
uint32_t mdns_remoteservice_get_ipv4_address(mdns_remoteservice_obj_t *self) {
52+
return self->ipv4_address;
53+
}
54+
55+
mp_obj_t common_hal_mdns_remoteservice_get_ipv4_address(mdns_remoteservice_obj_t *self) {
56+
uint32_t addr = mdns_remoteservice_get_ipv4_address(self);
57+
if (addr == 0) {
58+
return mp_const_none;
59+
}
60+
return common_hal_ipaddress_new_ipv4address(addr);
61+
}
62+
63+
void common_hal_mdns_remoteservice_deinit(mdns_remoteservice_obj_t *self) {
64+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2022 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#pragma once
28+
29+
#include "lwip/apps/mdns.h"
30+
31+
typedef struct {
32+
mp_obj_base_t base;
33+
uint32_t ipv4_address;
34+
uint16_t port;
35+
char protocol[5]; // RFC 6763 Section 7.2 - 4 bytes + 1 for NUL
36+
char service_name[17]; // RFC 6763 Section 7.2 - 16 bytes + 1 for NUL
37+
char instance_name[64]; // RFC 6763 Section 7.2 - 63 bytes + 1 for NUL
38+
char hostname[64]; // RFC 6762 Appendix A - 63 bytes for label + 1 for NUL
39+
mp_obj_t next;
40+
} mdns_remoteservice_obj_t;

0 commit comments

Comments
 (0)
0