Skip to content

Commit 4726fcc

Browse files
Show how to use a static IP
1 parent be4344e commit 4726fcc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ int main() {
5555
// "my network password",
5656
// NSAPI_SECURITY_WPA2);
5757

58+
// To use a static IP instead of DHCP, uncomment the below block and fill in IP settings.
59+
// const SocketAddress ip(nsapi_addr_t{NSAPI_IPv4, {192, 168, 1, 20}}, 0);
60+
// const SocketAddress netmask(nsapi_addr_t{NSAPI_IPv4, {255, 255, 255, 0}}, 0);
61+
// const SocketAddress gateway(nsapi_addr_t{NSAPI_IPv4, {192, 168, 1, 1}}, 0);
62+
// network->set_network(ip, netmask, gateway);
63+
5864
auto ret = network->connect();
5965
if(ret != NSAPI_ERROR_OK) {
6066
printf("Failed to initialize networking. Error: %d", ret);

0 commit comments

Comments
 (0)