Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By rudy
#78975 IPAddress myip = (192, 168, 100, 110); instead should have been
IPAddress myip (192, 168, 100, 110); without the =

=====================Original Post===================================
I'm having a problem IP address assignment. I am not doing anything different than I have done before but it seems that it isn't working the way I thought it should.

Code: Select allIPAddress myip = (192, 168, 100, 110);
Serial.println("IP address entered as: IPAddress myip = (192, 168, 100, 110)");

Serial.print("IP address in IPAddress format: ");
Serial.println(myip);

Serial.print("Octet by octet, (myip[x]);: ");
Serial.print(myip[0]);
Serial.print(".");
Serial.print(myip[1]);
Serial.print(".");
Serial.print(myip[2]);
Serial.print(".");
Serial.println(myip[3]);


And the output is the following.

Code: Select allIP address entered as: IPAddress myip = (192, 168, 100, 110)
IP address in IPAddress format: 110.0.0.0
Octet by octet, (myip[x]);: 110.0.0.0


I'm glad to see the 110 but all the rest is wrong. Can anyone explain to me what is wrong with this?
Last edited by rudy on Thu Nov 01, 2018 9:04 pm, edited 1 time in total.
User avatar
By rudy
#78979 That didn't change the output. I think the real problem is not in the printing, but the initial save of the IP. When each byte is being printed out with this
Code: Select allSerial.print("Octet by octet, (myip[x]);: ");
Serial.print(myip[0]);
Serial.print(".");
Serial.print(myip[1]);
Serial.print(".");
Serial.print(myip[2]);
Serial.print(".");
Serial.println(myip[3]);
Serial.println();


The values are also wrong. I get printed out 110.0.0.0 and it should be 110.100.168.192

This really isn't a printing issue for me. The real problem is that I am using the saved IP as a destination for a UDP packet send. And it wasn't getting to my computer's IP.

Code: Select allIPAddress RelayIP = (192, 168, 100, 110);

    Udp.beginPacket(RelayIP, 5000);     // RelayIP, ComputerIP, whatever
    Udp.write(replyPacket);
    Udp.endPacket();


I wasn't getting anything to the computer, the packet wasn't showing up with Wireshark. I think it was blocked by my router (not sure) because the destination IP was 0.0.0.110