Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Change the IP of Teensy 4.1 using UDP (again)

  1. #1

    Change the IP of Teensy 4.1 using UDP (again)

    Using an SPI with the teensy 3,2, I can change the IP relative easily from say 192.168.1.236 to .237 but when I do it with the 4.1, it does not respond to the new IP address.

    This code works for me with Teensy3.2 Any suggestions?. It's not a deal breaker but would be nice to get it to work.

    Thanks,

    Simon

    Udp.stop();
    Ethernet.begin(mac, new_ip);
    Udp.begin(localPort);

    PS: Asked before but no one responded.

  2. #2
    you are stopping udp but not ethernet, I don't know if you can actually change that live?
    In my project I do reboot teensy after applying any change, so it restarts fresh with all the new settings saved in memory.
    I don't know if that's a possible workaround for you. The command I use is CPU_RESTART;

  3. #3
    Hi,
    Thanks. I can actually write the ip to flash and re-start but I was hoping to be able to just change it without loosing other variables etc. It DOES work with the Teensy 3.2 and the WizIO over SPI so I was just wondering if anyone had an idea. It's not a deal breaker.

    Obviously I am using the native ethernet headers. Also seems to hang when you check if the cable is plugged in (if it isn't) but the 3.2 didn't. Again not a deal breaker just would like it to work.

    Maybe I should digging into the sources :-)

    Thanks
    Simon

  4. #4
    Quote Originally Posted by SimonWakley View Post
    Hi,
    Thanks. I can actually write the ip to flash and re-start but I was hoping to be able to just change it without loosing other variables etc. It DOES work with the Teensy 3.2 and the WizIO over SPI so I was just wondering if anyone had an idea. It's not a deal breaker.

    Obviously I am using the native ethernet headers. Also seems to hang when you check if the cable is plugged in (if it isn't) but the 3.2 didn't. Again not a deal breaker just would like it to work.

    Maybe I should digging into the sources :-)

    Thanks
    Simon
    yes, the cable requirement is also a bug of the native library, there is a workaround but you have to change the library:
    https://github.com/vjmuzik/NativeEthernet/issues/12

  5. #5
    Senior Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    312
    You should be able to call Ethernet.setlocalIP() (https://www.arduino.cc/en/Reference/EthernetSetLocalIP)

    Note: Iíve got another library, QNEthernet, that doesnít block when thereís no cable attached. Itís based on lwIP, as an alternative.

  6. #6
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    412
    This is worth a read.
    Seems that IwIP was developed for use in embedded systems (sounds familiar).
    @shawn how does IwIP compare with uIP?

  7. #7
    Senior Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    312
    Iíve never used uIP. Looks like it was made by the same author, though, so Iím imagining itís similar in feel. According to that article, it also looks like it was written for 8- and 16-bit systems.
    Last edited by shawn; 09-20-2021 at 05:29 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •