diff --git a/Makefile b/Makefile index 1d46090..e0f08e3 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,10 @@ ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py) ESPPORT ?= /dev/ttyUSB0 ESPBAUD ?= 460800 +# Build time Wifi Cfg +# STA_SSID ?= +# STA_PASS ?= + # --------------- chipset configuration --------------- # Pick your flash size: "512KB", "1MB", or "4MB" @@ -244,6 +248,14 @@ Q := @ vecho := @echo endif +ifneq ($(strip $(STA_SSID)),) +CFLAGS += -DSTA_SSID="$(STA_SSID)" +endif + +ifneq ($(strip $(STA_PASS)),) +CFLAGS += -DSTA_PASS="$(STA_PASS)" +endif + ifeq ("$(GZIP_COMPRESSION)","yes") CFLAGS += -DGZIP_COMPRESSION endif diff --git a/esp-link/log.c b/esp-link/log.c index ca8e0ad..1a9a985 100644 --- a/esp-link/log.c +++ b/esp-link/log.c @@ -162,8 +162,9 @@ void ICACHE_FLASH_ATTR dumpMem(void *addr, int len) { int off = 0; while (off < len) { os_printf("%p ", a); - for (int i=0; i<16 && off+i 0x20 && *a < 0x3f ? *a : '.'); diff --git a/esp-link/main.c b/esp-link/main.c index 980fc11..ccb596f 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -79,7 +79,19 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) { } #endif +# define VERS_STR_STR(V) #V +# define VERS_STR(V) VERS_STR_STR(V) +char* esp_link_version = VERS_STR(VERSION); + void user_rf_pre_init(void) { + system_set_os_print(DEBUG_SDK); +#if defined(STA_SSID) && defined(STA_PASS) + struct station_config stconf; + os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32); + os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64); + stconf.bssid_set = 0; + wifi_station_set_config_current(&stconf); +#endif } // address of espfs binary blob @@ -93,10 +105,6 @@ static char *flash_maps[] = { "2MB:1024/1024", "4MB:1024/1024" }; -# define VERS_STR_STR(V) #V -# define VERS_STR(V) VERS_STR_STR(V) -char* esp_link_version = VERS_STR(VERSION); - extern void app_init(void); extern void mqtt_client_init(void); diff --git a/include/espmissingincludes.h b/include/espmissingincludes.h index e5a20a0..82076ab 100644 --- a/include/espmissingincludes.h +++ b/include/espmissingincludes.h @@ -36,9 +36,21 @@ void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg); void ets_update_cpu_frequency(int freqmhz); -int os_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4))); -int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); +#ifdef SDK_DBG +#define DEBUG_SDK true +#else +#define DEBUG_SDK false +#endif + +int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__((format(printf, 3, 4))); +int os_printf_plus(const char *format, ...) __attribute__((format(printf, 1, 2))); + +#undef os_printf +#define os_printf(format, ...) \ + system_set_os_print(true); \ + os_printf_plus(format, ## __VA_ARGS__); \ + system_set_os_print(DEBUG_SDK); // int os_printf(const char *format, ...) + void pvPortFree(void *ptr); void *pvPortMalloc(size_t xWantedSize); diff --git a/serial/serbridge.c b/serial/serbridge.c index e713693..16e5c65 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -1,12 +1,6 @@ // Copyright 2015 by Thorsten von Eicken, see LICENSE.txt -#include "espmissingincludes.h" -#include "c_types.h" -#include "user_interface.h" -#include "espconn.h" -#include "mem.h" -#include "osapi.h" -#include "gpio.h" +#include "esp8266.h" #include "uart.h" #include "crc16.h" diff --git a/serial/uart.c b/serial/uart.c index 526c078..9b517c4 100644 --- a/serial/uart.c +++ b/serial/uart.c @@ -17,10 +17,7 @@ * ---------------------------------------------------------------------------- * Heavily modified and enhanced by Thorsten von Eicken in 2015 */ -#include "espmissingincludes.h" -#include "ets_sys.h" -#include "osapi.h" -#include "user_interface.h" +#include "esp8266.h" #include "uart.h" #ifdef UART_DBG