How to get IPAddress as dhcp with UIPEthernet library?

Hello, it's first post so I may many mistake. sorry.

I want use Arduino as SNMP Agent. My arduino's Ethernet shield is W5100.

So I got this library (https://github.com/CrientClash/Arduino-Snmp-Agent) for SNMP Agent function.

And I found that I have to set IPAddress, so I wrote this code for getting IPAddress as dhcp.

#include <UIPEthernet.h> // https://github.com/UIPEthernet/UIPEthernet

EthernetClient client;

void setup() {
  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 
   
  Serial.begin(9600);
  int ret = Ethernet.begin(mac);
  Serial.println("ret =" + String(ret));
  Serial.print("localIP: ");
  Serial.println(Ethernet.localIP());
  Serial.print("subnetMask: ");
  Serial.println(Ethernet.subnetMask());
  Serial.print("gatewayIP: ");
  Serial.println(Ethernet.gatewayIP());
  Serial.print("dnsServerIP: ");
  Serial.println(Ethernet.dnsServerIP());

  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print("-");
  }
  Serial.println("");
}

void loop() {
}

But I can only get "0.0.0.0" as local IPAddress.

If I change the library to "Ethernet" from "UIPEthernet", I can get correct IPAddress and I can get responce from my ping.

I need to use "UIPEthernet" library because the SNMP Agent library needs this library.

Can I get the IPAddress as dhcp with "UIPEthernet" ?

UIPEthernet is not for Wiznet chips like W5100

Thank you for advice, Juraj!

In this page (GitHub - UIPEthernet/UIPEthernet: UIPEthernet library for Arduino IDE,Eclipse with arduino plugin and MBED/SMeshStudio (AVR,STM32F,ESP8266,Intel ARC32, Nordic nRF51, Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet W5100 Ethernet library API.), there are this information.


UIPEthernet library for Arduinos (Atmel AVR-s,Atmel SAM3X8E ARM Cortex-M3,STM32F series,ESP8266,Intel ARC32(Genuino101),Nordic nRF51(RFduino),Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip compatible with Wiznet W5100 API

I'm not native English speaker so I may be misunderstanding, but I think that the W5100 can use this library.

Is my thinking not correct?

siksmtt:
Thank you for advice, Juraj!

In this page (GitHub - UIPEthernet/UIPEthernet: UIPEthernet library for Arduino IDE,Eclipse with arduino plugin and MBED/SMeshStudio (AVR,STM32F,ESP8266,Intel ARC32, Nordic nRF51, Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet W5100 Ethernet library API.), there are this information.


UIPEthernet library for Arduinos (Atmel AVR-s,Atmel SAM3X8E ARM Cortex-M3,STM32F series,ESP8266,Intel ARC32(Genuino101),Nordic nRF51(RFduino),Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip compatible with Wiznet W5100 API

I'm not native English speaker so I may be misunderstanding, but I think that the W5100 can use this library.

Is my thinking not correct?

it is 100% not compatible with W5100 hardware. I maintain it now, but I don't have a right to change the title.

It was meant as "compatible with Wiznet W5100 Arduino Ethernet library API", with emphasis on API

Thank you, Juraj!

Okay, I'm understand. I'll search other way for SNMP connection.

I'm very glad because I got advice from keeper like you.