<LAN Module with W5500 V12> - How to assign a fixed IP(static IP)(no-DHCP) address in Blockly or MicroPython?



  • Background:
    platform: Windows 10
    code framework: UiFlow(v1.9.5)

    M5Stack: M5Stack core2 for AWS(firm: UiFlow core2 v1.10.3)
    module: LAN(SKU: K012-B-V12)

    Hello everyone!
    Using M5Stack core2 and LAN module, I am trying to remotely control a machine with a fixed IP address in the factory with a 1:1 wired LAN connection.

    Question:
    Is it possible to assign a fixed IP address in Blockly or MicroPython to the LAN module?

    0_1660733093633_ss12106.png

    Even if I select [Modules->LAN_Base->Init block] to initialize the LAN module in Blockly, No Python code is generated to assign a fixed IP.

    0_1660733430444_ss12110.png

    Thank you,
    yuza_tipo



  • Hello @yuza_tipo

    there is a lan.get_if_config() function which returns the current IP etc. as a 4 tuple like this ('192.168.x.x', '255.255.255.0', '192.168.x.1', '8.8.8.8').

    I also found there is a lan.set_if_config() function but when I feed the above 4 tuple as argument I get an error that the function takes 5 positional parameter, but only 2 are given. I tried many other ways to format the 4 arguments, but all I got are different error messages.

    Thanks
    Felix

    Edit: corrected incorrect lan.get_ip_config() - should be lan.get_if_config() (same for set)



  • Thank you for your prompt reply... @felmue

    The example you posted [https://community.m5stack.com/topic/4376/] helped me get started with this module.
    #UiFlow built-in sample was not a core2 compatible screen and did not work. :-(

    I tried [lan.get_if_config()] you suggested with the shell of [Windows 10, Thonny(v4.0.0.b3)].

    0_1660820335050_12120.png

    While doing other trial and error, It seems that [libs/ethernet/wiznet5k.py] and [libs/ethernet/wiznet5k_dhcp.py] were running behind [lan = module.get(module.LANBASE)].

    If we can operate here directly..., can't you read [libs/ethernet/wiznet5k.py]? :-<

    Thank you,
    yuza_tipo



  • i same set up with @yuza_tipo but i use UiFlow v1.10.5
    i try run "module.get(module.LANBASE)" on putty serial, and getting error like this.

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "module.py", line 64, in get
    File "<string>", line 1, in <module>
    File "modules/_lan_base.py", line 33, in init
    File "libs/ethernet/wiznet5k.py", line 181, in init
    AssertionError: Failed to configure DHCP Server!

    Anyone have solution for this problem ?
    Thanks in advance.