void vNet_SetAddress_M1(uint16_t addr) { uint8_t ip_addr[4], mac_addr[6]; // Translate and set the address eth_vNettoIP(addr, &ip_addr[0]); eth_SetIPAddress(&ip_addr[0]); // Set the MAC Address #if(AUTO_MAC) eth_vNettoMAC(addr, mac_addr); W5x00.setMACAddress(mac_addr); #else W5x00.setMACAddress((uint8_t*)MAC_ADDRESS); #endif // Set the IP W5x00.setIPAddress(stack.ip); W5x00.setGatewayIp(stack.gateway); W5x00.setSubnetMask(stack.subnetmask); vNet_Begin_M1(UDP_SOCK); // Start listen on socket // Include debug functionalities, if required #if(VNET_DEBUG) uint8_t addrval[6]; // Print MAC address W5x00.getMACAddress(addrval); VNET_LOG("(MAC)<"); for(U8 i=0; i<6; i++) { VNET_LOG(addrval[i],HEX); VNET_LOG(","); } VNET_LOG(">\r\n"); // Print IP address W5x00.getIPAddress(addrval); VNET_LOG("(IP)<"); for(U8 i=0; i<4; i++) { VNET_LOG(addrval[i],HEX); VNET_LOG(","); } VNET_LOG(">\r\n"); #endif }
void vNet_SetAddress_M1(uint16_t addr) { uint8_t ip_addr[4]; // Translate and set the address eth_vNettoIP(addr, &ip_addr[0]); eth_SetIPAddress(&ip_addr[0]); // Get the MAC Address from the Wifi controller and set it // into the uIP stack U8* mac_addr_hw = zg_get_mac(); memcpy(mac_addr, mac_addr_hw, 6); vNet_Begin_M1(0); // Start listen on socket }