cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with acquisition of IP address of the Nucleo F746ZG

MZysk
Associate

Hello everyone!

I have some troubles with obtaining the correct IP address of my MCU.

I am running Nucleo F746ZG and I have set up LwIP stack with CubeMX. Also DHCP is turned on. DHCP server sets up "static" IP for my MCU which is 192.168.10.88. I can send UDP packet and ping my MCU using this IP, but when i would like to get that address automatically from MCU perspective I am getting 200.138.128.48 which is not correct.

I don't know what might be wrong. Perhaps some mismatch with endianess?

Here are most important bits of code.

void udpAPP_init(void)
{
	err_t		udpErr;
 
	udpPcb1_p = udp_new();
 
	if (udpPcb1_p != NULL)
	{
		udpErr = udp_bind(udpPcb1_p, gnetif.ip_addr.addr, 20);
 
		udp_recv(udpPcb1_p , udp_raw_recv, udpPcb1_p);
 
		size = sprintf(data, "Hello!\n\rHere's Nucleo F746ZG.\n\rUDP protocol status: enabled.\n\r");
 
		HAL_UART_Transmit(&huart3, data, size, HAL_MAX_DELAY);
 
		memset(data, 0, 75);
 
		if (udpErr == ERR_OK)
		{}
		else
		{}
	}
	else
	{}
}
 
 
 
static void udp_raw_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr_t *addr, u16_t port)
{	
                static struct pbuf	*ethTxBuffer_p_x;
		volatile char str_2[15];
		memcpy(str_2, ipaddr_ntoa(ipaddr.addr), 15);
 
		/* Sending the UDP reply. */
 
		ethTxBuffer_p_x = pbuf_alloc(PBUF_TRANSPORT, sizeof(str_2), PBUF_RAM);
		memcpy(ethTxBuffer_p_x->payload, str_2, sizeof(str_2));
 
	        if(ERR_OK == udp_sendto(udpPcb1_p, ethTxBuffer_p_x, addr, port))
	        {}
 
	       pbuf_free(ethTxBuffer_p_x);
 
	       pbuf_free(p);
}

0 REPLIES 0