Skip to content

Commit 6491643

Browse files
committed
zephyr: Enable IPv6 networking in addition to IPv4.
1 parent ee3615d commit 6491643

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

zephyr/main.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,16 @@ static char *stack_top;
6767
static char heap[MICROPY_HEAP_SIZE];
6868

6969
void init_zephyr(void) {
70+
// TODO: Make addresses configurable
7071
#ifdef CONFIG_NET_IPV4
71-
// TODO: Make address configurable
72-
static struct in_addr in4addr_my = { { { 192, 0, 2, 1 } } };
72+
static struct in_addr in4addr_my = {{{192, 0, 2, 1}}};
7373
net_if_ipv4_addr_add(net_if_get_default(), &in4addr_my, NET_ADDR_MANUAL, 0);
7474
#endif
75+
#ifdef CONFIG_NET_IPV6
76+
// 2001:db8::1
77+
static struct in6_addr in6addr_my = {{{0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}};
78+
net_if_ipv6_addr_add(net_if_get_default(), &in6addr_my, NET_ADDR_MANUAL, 0);
79+
#endif
7580
}
7681

7782
int real_main(void) {

zephyr/prj_base.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ CONFIG_MAIN_STACK_SIZE=4096
88
# Networking config
99
CONFIG_NETWORKING=y
1010
CONFIG_NET_IPV4=y
11+
CONFIG_NET_IPV6=y
1112
CONFIG_TEST_RANDOM_GENERATOR=y
12-
CONFIG_NET_NBUF_RX_COUNT=4
13+
CONFIG_NET_NBUF_RX_COUNT=5

0 commit comments

Comments
 (0)