This sample starts the network stack on the board’s Ethernet controller,
and leaves it to the net shell command. With no address set, the stack
takes link-local ones once the link is up, in 169.254.0.0/16 for IPv4 and
fe80::/64 for IPv6, so a host plugged in directly reaches it without a
DHCP server. It answers ping and ping6 from such a host.
shell> net ipv4
169.254.42.17/16
shell> net ipv6
fe80::4fb3:b042:fb94:5dbb
shell> net ping 169.254.10.1 2
reply from 169.254.10.1: seq=0 time=1 ms
reply from 169.254.10.1: seq=1 time=0 ms
2 sent, 2 received
shell> net ipv4 set 192.168.1.50/24 192.168.1.1
shell> net ipv4 clear
pbl samples samples/subsys/net/shell
every board
#include <stdio.h>
#include <pbl/console/console.h>
#include <pbl/net/net.h>
int main(void) {
int ret;
ret = pbl_net_init();
if (ret != 0) {
fprintf(stderr, "net: init failed (%d)\n", ret);
return ret;
}
printf("net: started, see the net command\n");
pbl_console_enable_prompt();
return 0;
}
net: started
Generated from PebbleOS 7416f78a1. This page is maintained in the pebbleos repository: docs/samples/subsys/net/shell.md.