DHCP doesn't work when using AP+STA

mchahnmchahn Long Beach, CA

I'm using miot ESP-8266EX (on D1 mini). I just downloaded it yesterday and it was very easy to start using and my simple apps work great.

I'm now trying to get AP+STA access working from just the conf files. My app is ...

#include "fw/src/miot_app.h"
enum miot_app_init_result miot_app_init(void) {
  return MIOT_APP_INIT_SUCCESS;
}

My conf_vendor.json is ...

{
  "wifi": {
    "sta": {
      "enable": true,
      "ssid": "hahn-fi",
      "pass": "<pwd>",
      "ip": "",
      "netmask": "",
      "gw": ""
    },
    "ap": {
      "enable": true,
      "ssid": "eridien_XY_??????",
      "pass": "<pwd>",
      "hidden": false,
      "channel": 6,
      "max_connections": 2,
      "ip": "192.168.4.1",
      "netmask": "255.255.255.0",
      "gw": "192.168.4.1",
      "dhcp_start": "192.168.4.2",
      "dhcp_end": "192.168.4.100",
      "keep_enabled": true,
      "trigger_on_gpio": -1
    }
  }
}

Each of STA and AP work by themselves when I set enable to false on the other. But if both are enabled as I show above the STA server works but I can't connect to the AP. I get a "DHCP lookup failed" error.

Is this supposed to work? If not can I do it from my app? I would really like for my customer to be able to use either one at any time for simplicity and flexibility.

Comments

  • rojerrojer Dublin, Ireland

    i cannot reproduce it. in my testing i can successfully connect to the AP of the device while it is also connected to another AP as a station.
    can you post the console log here?

  • mchahnmchahn Long Beach, CA

    This is with only the AP enabled. It works ...

    esp_miot_init        miot 1.0 (20161230-052345/???)
    esp_miot_init        Mongoose IoT Firmware 2016123005 (20161230-052345/???)
    esp_miot_init        SDK 2.0.0(656edbf), RAM: 48736 total, 45540 free
    esp_print_reset_info Reset cause: 6 (sys reset)
    fs_mount             Mounting FS: 131072 @ 0xdb000
    miot_sys_config_init MAC: 5ECF7FC3B2F0
    miot_sys_config_init WDT: 30 seconds
    bcn 0
    del if1
    usl
    mode : null
    miot_mdns_init       Listening on udp://:5353
    miot_wifi_set_mode   WiFi mode: AP
    mode : softAP(5e:cf:7f:c3:b2:f0)
    add if1
    dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
    bcn 100
    bcn 0
    del if1
    usl
    add if1
    dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
    bcn 100
    miot_wifi_setup_ap   WiFi AP IP: 192.168.4.1/255.255.255.0 gw 192.168.4.1, DHCP rmg_rpc_channel_uart  0x3fff1a74 UART0
    miot_console_init    console.log 2048
    miot_init            Init done, RAM: 39928 free, 39936 min free
    mongoose_poll        New heap free LWM: 39832
    mongoose_poll        New heap free LWM: 39808
    

    This is with both enabled ...

    esp_miot_init        miot 1.0 (20161230-051959/???)
    esp_miot_init        Mongoose IoT Firmware 2016123005 (20161230-051959/???)
    esp_miot_init        SDK 2.0.0(656edbf), RAM: 48736 total, 45540 free
    esp_print_reset_info Reset cause: 6 (sys reset)
    fs_mount             Mounting FS: 131072 @ 0xdb000
    miot_sys_config_init MAC: 5ECF7FC3B2F0
    miot_sys_config_init WDT: 30 seconds
    bcn 0
    del if1
    usl
    mode : null
    miot_mdns_init       Listening on udp://:5353
    miot_wifi_set_mode   WiFi mode: AP+STA
    mode : sta(5c:cf:7f:c3:b2:f0) + softAP(5e:cf:7f:c3:b2:f0)
    add if0
    add if1
    dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
    bcn 100
    bcn 0
    del if1
    add if1
    dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
    bcn 100
    miot_wifi_setup_ap   WiFi AP IP: 192.168.4.1/255.255.255.0 gw 192.168.4.1, DHCP range 192.168.4.2 - 192.168.4.100
    miot_wifi_setup_sta mg_rpc_channel_uart  0x3fff1fa4 UART0
    miot_console_init    console.log 2048
    miot_init            Init done, RAM: 38600 free, 38608 min free
    mongoose_poll        New heap free LWM: 38504
    scandone
    state: 0 -> 2 (b0)
    state: 2 -> 3 (0)
    mongoose_poll        New heap free LWM: 38392
    state: 3 -> 5 (10)
    add 0
    aid 4
    cnt
    
    connected with hahn-fi, channel 1
    dhcp client start...
    miot_wifi_on_change_cb Wifi: connected
    mongoose_poll        New heap free LWM: 37792
    ip:192.168.1.235,mask:255.255.255.0,gw:192.168.1.1
    miot_wifi_on_change_cb WiFi: ready, IP 192.168.1.235
    miot_mdns_hal_join_group Joining multicast group 224.0.0.251
    
  • rojerrojer Dublin, Ireland

    both logs seem entirely normal to me. the latter shows STA connecting and obtaining an IP, but neither shows any signs of clients connecting to the AP. can you show logs of that in both modes?

  • mchahnmchahn Long Beach, CA

    That was everything that came over the console. I'll try again but I can't right now because of this error ...

    Connecting to http://mongoose.cloud, user test
    Uploading sources (1924 bytes)
    The flag --repo is not given, going to use mongoose-iot repository
    Building...
    Make arguments: -j -f mongoose-iot/fw/platforms/esp8266/Makefile APP_MODULES=src APP_FS_PATH=fs APP_CONF_SCHEMA=src/conf_schema.yaml MIOT_PATH=mongoose-iot BUILD_DIR=build/objs FW_DIR=build/fw APP=miot GEN_DIR=build/gen PLATFORM=esp8266 FS_STAGING_DIR=build/fs APP_VERSION=1.0
    mongoose-iot/fw/platforms/esp8266/Makefile:8: /fw/docker_common.mk: No such file or directory
    mongoose-iot/fw/platforms/esp8266/Makefile:14: /common/platforms/esp/debug_coredump.mk: No such file or directory
    make: *** No rule to make target '/common/platforms/esp/debug_coredump.mk'.  Stop.
    Error: exit status 2
    Error: build failed
    
  • BetterAutomationsBetterAutomations Jacksonville, FL

    Did this ever get resolved? I will need AP+STA and a DHCP server.

  • rojerrojer Dublin, Ireland

    both AP and STA work fine for me in the AP+STA mode. as i said, i see nothing abnormal in the log posted by @mcahn.

Sign In or Register to comment.