pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • PebbleOS
  • Mobile App
  • Examples
  • Index 01
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

PebbleOS

  • Overview
  • Start here
    • Getting started guide
  • Pebble Firmware
    • Overview
    • Playground
    • Application SDK
  • Development
    • The pbl CLI
    • Build system
    • Samples
      • Kernel
      • Subsystems
      • Drivers
      • Third-party
      • Rust
      • Benchmarks
    • Emulator and simulator
    • Testing
    • Debugging
    • Conventions
  • System
    • Architecture overview
    • Kernel
    • Drivers
    • Subsystems
    • Libraries
    • Third-party
  • Hardware
    • Boards
    • Board Add-ons
    • Programmers
  • Community
    • Contribution Guidelines
  • Reference
    • Reference
    • Kconfig options

Networking: Shell

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
Run:

pbl samples samples/subsys/net/shell

Boards:

every board

Sources

src/main.c
#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;
}

Output

net: started

Generated from PebbleOS 7416f78a1. This page is maintained in the pebbleos repository: docs/samples/subsys/net/shell.md.

Overview

  • Sources
  • Output