Added SOFTAP hard-coded settings

Set the values of SOFTAP config straight in the Makefile
pull/84/head
KatAst 9 years ago
parent 59d4bdf99e
commit ff5a74b20a
  1. 73
      Makefile
  2. 982
      esp-link/cgiwifi.c
  3. 22
      esp-link/main.c

@ -4,6 +4,7 @@
# Makefile heavily adapted to esp-link and wireless flashing by Thorsten von Eicken # Makefile heavily adapted to esp-link and wireless flashing by Thorsten von Eicken
# Lots of work, in particular to support windows, by brunnels # Lots of work, in particular to support windows, by brunnels
# Original from esphttpd and others... # Original from esphttpd and others...
# Added support for SOFTAP hard-coded configuration by KatAst
# VERBOSE=1 # VERBOSE=1
# #
# Start by setting the directories for the toolchain a few lines down # Start by setting the directories for the toolchain a few lines down
@ -22,6 +23,34 @@
# STA_SSID ?= # STA_SSID ?=
# STA_PASS ?= # STA_PASS ?=
# The SOFTAP configuration can be hard-coded here, the minimum parameters to set are AP_SSID && AP_PASS
# The AP SSID has to be at least 8 characters long, same for AP PASSWORD
# The AP AUTH MODE can be set to ( default = AUTH_WPA_WPA2_PSK )
# AUTH_OPEN = 0,
# AUTH_WEP,
# AUTH_WPA_PSK,
# AUTH_WPA2_PSK,
# AUTH_WPA_WPA2_PSK
# SSID hidden default 0, ( 0 | 1 )
# Max connections default 4, ( 1 ~ 4 )
# Beacon interval default 100, ( 100 ~ 60000ms )
AP_SSID ?=esp-link-test
AP_PASS ?=esp-link-test
# AP_AUTH_MODE ?=AUTH_WPA_WPA2_PSK
# AP_SSID_HIDDEN ?=0
# AP_MAX_CONN ?=3
# AP_BEACON_INTERVAL ?=150
# If CHANGE_TO_STA is set to "yes" the esp-link module will switch to station mode
# once successfully connected to an access point. Else it will stay in STA+AP mode.
CHANGE_TO_STA ?= no
# hostname or IP address for wifi flashing
ESP_HOSTNAME ?= esp-link
# --------------- toolchain configuration --------------- # --------------- toolchain configuration ---------------
# Base directory for the compiler. Needs a / at the end. # Base directory for the compiler. Needs a / at the end.
@ -30,7 +59,7 @@ XTENSA_TOOLS_ROOT ?= $(abspath ../esp-open-sdk/xtensa-lx106-elf/bin)/
# Base directory of the ESP8266 SDK package, absolute # Base directory of the ESP8266 SDK package, absolute
# Typically you'll download from Espressif's BBS, http://bbs.espressif.com/viewforum.php?f=5 # Typically you'll download from Espressif's BBS, http://bbs.espressif.com/viewforum.php?f=5
SDK_BASE ?= $(abspath ../esp_iot_sdk_v1.5.0) SDK_BASE ?= $(abspath ../esp-open-sdk/esp_iot_sdk_v1.5.0)
# Esptool.py path and port, only used for 1-time serial flashing # Esptool.py path and port, only used for 1-time serial flashing
# Typically you'll use https://github.com/themadinventor/esptool # Typically you'll use https://github.com/themadinventor/esptool
@ -39,15 +68,6 @@ ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py)
ESPPORT ?= /dev/ttyUSB0 ESPPORT ?= /dev/ttyUSB0
ESPBAUD ?= 460800 ESPBAUD ?= 460800
# The Wifi station configuration can be hard-coded here, which makes esp-link come up in STA+AP
# mode trying to connect to the specified AP *only* if the flash wireless settings are empty!
# This happens on a full serial flash and avoids having to hunt for the AP...
# STA_SSID ?=
# STA_PASS ?=
# hostname or IP address for wifi flashing
ESP_HOSTNAME ?= esp-link
# --------------- chipset configuration --------------- # --------------- chipset configuration ---------------
# Pick your flash size: "512KB", "1MB", or "4MB" # Pick your flash size: "512KB", "1MB", or "4MB"
@ -64,14 +84,9 @@ LED_CONN_PIN ?= 0
# GPIO pin used for "serial activity" LED, active low # GPIO pin used for "serial activity" LED, active low
LED_SERIAL_PIN ?= 14 LED_SERIAL_PIN ?= 14
# --------------- esp-link config options --------------- # --------------- esp-link modules config options ---------------
# If CHANGE_TO_STA is set to "yes" the esp-link module will switch to station mode
# once successfully connected to an access point. Else it will stay in AP+STA mode.
CHANGE_TO_STA ?= yes
# Optional Modules # Optional Modules mqtt
MODULES ?= mqtt rest syslog MODULES ?= mqtt rest syslog
# --------------- esphttpd config options --------------- # --------------- esphttpd config options ---------------
@ -268,6 +283,30 @@ ifneq ($(strip $(STA_PASS)),)
CFLAGS += -DSTA_PASS="$(STA_PASS)" CFLAGS += -DSTA_PASS="$(STA_PASS)"
endif endif
ifneq ($(strip $(AP_SSID)),)
CFLAGS += -DAP_SSID="$(AP_SSID)"
endif
ifneq ($(strip $(AP_PASS)),)
CFLAGS += -DAP_PASS="$(AP_PASS)"
endif
ifneq ($(strip $(AP_AUTH_MODE)),)
CFLAGS += -DAP_AUTH_MODE="$(AP_AUTH_MODE)"
endif
ifneq ($(strip $(AP_SSID_HIDDEN)),)
CFLAGS += -DAP_SSID_HIDDEN="$(AP_SSID_HIDDEN)"
endif
ifneq ($(strip $(AP_MAX_CONN)),)
CFLAGS += -DAP_MAX_CONN="$(AP_MAX_CONN)"
endif
ifneq ($(strip $(AP_BEACON_INTERVAL)),)
CFLAGS += -DAP_BEACON_INTERVAL="$(AP_BEACON_INTERVAL)"
endif
ifeq ("$(GZIP_COMPRESSION)","yes") ifeq ("$(GZIP_COMPRESSION)","yes")
CFLAGS += -DGZIP_COMPRESSION CFLAGS += -DGZIP_COMPRESSION
endif endif

File diff suppressed because it is too large Load Diff

@ -123,28 +123,6 @@ void user_init(void) {
os_printf("\n\n** %s\n", esp_link_version); os_printf("\n\n** %s\n", esp_link_version);
os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*");
#if defined(STA_SSID) && defined(STA_PASS)
int x = wifi_get_opmode() & 0x3;
if (x == 2) {
// we only force the STA settings when a full flash of the module has been made, which
// resets the wifi settings not to have anything configured
struct station_config stconf;
wifi_station_get_config(&stconf);
if (os_strlen((char*)stconf.ssid) == 0 && os_strlen((char*)stconf.password) == 0) {
os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32);
os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64);
#ifdef CGIWIFI_DBG
os_printf("Wifi pre-config trying to connect to AP %s pw %s\n",
(char*)stconf.ssid, (char*)stconf.password);
#endif
wifi_set_opmode(3); // sta+ap, will switch to sta-only 15 secs after connecting
stconf.bssid_set = 0;
wifi_station_set_config(&stconf);
}
}
#endif
// Status LEDs // Status LEDs
statusInit(); statusInit();
serledInit(); serledInit();

Loading…
Cancel
Save