0.9.3 improvements
This commit is contained in:
@@ -16,6 +16,7 @@ XTENSA_TOOLS_ROOT ?= /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin
|
|||||||
|
|
||||||
#Extra Tensilica includes from the ESS VM
|
#Extra Tensilica includes from the ESS VM
|
||||||
SDK_EXTRA_INCLUDES ?= /opt/Espressif/include
|
SDK_EXTRA_INCLUDES ?= /opt/Espressif/include
|
||||||
|
SDK_EXTRA_LIBS ?= /opt/Espressif/arch/lib
|
||||||
|
|
||||||
# base directory of the ESP8266 SDK package, absolute
|
# base directory of the ESP8266 SDK package, absolute
|
||||||
SDK_BASE ?= /opt/Espressif/ESP8266_SDK
|
SDK_BASE ?= /opt/Espressif/ESP8266_SDK
|
||||||
@@ -28,6 +29,7 @@ ESPPORT ?= /dev/ttyUSB0
|
|||||||
TARGET = httpd
|
TARGET = httpd
|
||||||
|
|
||||||
# which modules (subdirectories) of the project to include in compiling
|
# which modules (subdirectories) of the project to include in compiling
|
||||||
|
#MODULES = driver user lwip/api lwip/app lwip/core lwip/core/ipv4 lwip/netif
|
||||||
MODULES = driver user
|
MODULES = driver user
|
||||||
EXTRA_INCDIR = include \
|
EXTRA_INCDIR = include \
|
||||||
. \
|
. \
|
||||||
@@ -35,13 +37,15 @@ EXTRA_INCDIR = include \
|
|||||||
$(SDK_EXTRA_INCLUDES)
|
$(SDK_EXTRA_INCLUDES)
|
||||||
|
|
||||||
# libraries used in this project, mainly provided by the SDK
|
# libraries used in this project, mainly provided by the SDK
|
||||||
LIBS = c gcc hal phy net80211 lwip wpa main
|
LIBS = c gcc hal phy pp net80211 wpa main lwip
|
||||||
|
|
||||||
# compiler flags using during compilation of source files
|
# compiler flags using during compilation of source files
|
||||||
CFLAGS = -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH
|
CFLAGS = -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
||||||
|
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \
|
||||||
|
-DLWIP_OPEN_SRC -Wno-address
|
||||||
|
|
||||||
# linker flags used to generate the main object file
|
# linker flags used to generate the main object file
|
||||||
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
|
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -L$(SDK_EXTRA_LIBS)
|
||||||
|
|
||||||
# linker script used for the above linkier step
|
# linker script used for the above linkier step
|
||||||
LD_SCRIPT = eagle.app.v6.ld
|
LD_SCRIPT = eagle.app.v6.ld
|
||||||
@@ -141,7 +145,7 @@ flash: $(FW_FILE_1) $(FW_FILE_2)
|
|||||||
-$(ESPTOOL) --port $(ESPPORT) write_flash 0x40000 firmware/0x40000.bin
|
-$(ESPTOOL) --port $(ESPPORT) write_flash 0x40000 firmware/0x40000.bin
|
||||||
|
|
||||||
webpages.espfs: html/ mkespfsimage/mkespfsimage
|
webpages.espfs: html/ mkespfsimage/mkespfsimage
|
||||||
cd html; find | ../mkespfsimage/mkespfsimage > ../webpages.espfs; cd ..
|
cd html; find | ../mkespfsimage/mkespfsimage > ../webpages.espfs; cd ..
|
||||||
|
|
||||||
mkespfsimage/mkespfsimage: mkespfsimage/
|
mkespfsimage/mkespfsimage: mkespfsimage/
|
||||||
make -C mkespfsimage
|
make -C mkespfsimage
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#ifndef ESPMISSINGINCLUIDES_H
|
#ifndef ESPMISSINGINCLUDES_H
|
||||||
#define ESPMISSINGINCLUIDES_H
|
#define ESPMISSINGINCLUDES_H
|
||||||
|
|
||||||
#include <ets_sys.h>
|
#include <ets_sys.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
//Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere.
|
//Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere.
|
||||||
//MOST OF THESE ARE GUESSED! but they seem to swork and shut up the compiler.
|
//MOST OF THESE ARE GUESSED! but they seem to swork and shut up the compiler.
|
||||||
|
typedef struct espconn espconn;
|
||||||
|
|
||||||
int atoi(const char *nptr);
|
int atoi(const char *nptr);
|
||||||
void ets_install_putc1(void *routine);
|
void ets_install_putc1(void *routine);
|
||||||
@@ -33,4 +35,9 @@ void *pvPortZalloc(size_t);
|
|||||||
void uart_div_modify(int no, unsigned int freq);
|
void uart_div_modify(int no, unsigned int freq);
|
||||||
void vPortFree(void *ptr);
|
void vPortFree(void *ptr);
|
||||||
void *vPortMalloc(size_t xWantedSize);
|
void *vPortMalloc(size_t xWantedSize);
|
||||||
|
uint8 wifi_get_opmode(void);
|
||||||
|
uint32 system_get_time();
|
||||||
|
int os_random();
|
||||||
|
int rand(void);
|
||||||
|
void ets_bzero(void *s, size_t n);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ int htoxl(int in) {
|
|||||||
size_t compressHeatshrink(char *in, int insize, char *out, int outsize, int level) {
|
size_t compressHeatshrink(char *in, int insize, char *out, int outsize, int level) {
|
||||||
char *inp=in;
|
char *inp=in;
|
||||||
char *outp=out;
|
char *outp=out;
|
||||||
int len;
|
size_t len;
|
||||||
int ws[]={5, 6, 8, 11, 13};
|
int ws[]={5, 6, 8, 11, 13};
|
||||||
int ls[]={3, 3, 4, 4, 4};
|
int ls[]={3, 3, 4, 4, 4};
|
||||||
HSE_poll_res pres;
|
HSE_poll_res pres;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Some random cgi routines.
|
|||||||
#include "cgi.h"
|
#include "cgi.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "espmissingincludes.h"
|
#include "espmissingincludes.h"
|
||||||
|
#include <ip_addr.h>
|
||||||
|
|
||||||
//cause I can't be bothered to write an ioGetLed()
|
//cause I can't be bothered to write an ioGetLed()
|
||||||
static char currLedState=0;
|
static char currLedState=0;
|
||||||
|
|||||||
+15
-6
@@ -28,9 +28,9 @@ typedef struct {
|
|||||||
char enc;
|
char enc;
|
||||||
} ApData;
|
} ApData;
|
||||||
|
|
||||||
//Scan resolt
|
//Scan result
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char scanInProgress;
|
char scanInProgress; //if 1, don't access the underlying stuff from the webpage.
|
||||||
ApData **apData;
|
ApData **apData;
|
||||||
int noAps;
|
int noAps;
|
||||||
} ScanResultData;
|
} ScanResultData;
|
||||||
@@ -46,7 +46,6 @@ void ICACHE_FLASH_ATTR wifiScanDoneCb(void *arg, STATUS status) {
|
|||||||
os_printf("wifiScanDoneCb %d\n", status);
|
os_printf("wifiScanDoneCb %d\n", status);
|
||||||
if (status!=OK) {
|
if (status!=OK) {
|
||||||
cgiWifiAps.scanInProgress=0;
|
cgiWifiAps.scanInProgress=0;
|
||||||
wifi_station_disconnect(); //test HACK
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +64,16 @@ void ICACHE_FLASH_ATTR wifiScanDoneCb(void *arg, STATUS status) {
|
|||||||
//Allocate memory for access point data
|
//Allocate memory for access point data
|
||||||
cgiWifiAps.apData=(ApData **)os_malloc(sizeof(ApData *)*n);
|
cgiWifiAps.apData=(ApData **)os_malloc(sizeof(ApData *)*n);
|
||||||
cgiWifiAps.noAps=n;
|
cgiWifiAps.noAps=n;
|
||||||
|
os_printf("Scan done: found %d APs\n", n);
|
||||||
|
|
||||||
//Copy access point data to the static struct
|
//Copy access point data to the static struct
|
||||||
n=0;
|
n=0;
|
||||||
bss_link = (struct bss_info *)arg;
|
bss_link = (struct bss_info *)arg;
|
||||||
while (bss_link != NULL) {
|
while (bss_link != NULL) {
|
||||||
|
if (n>=cgiWifiAps.noAps) {
|
||||||
|
os_printf("Huh? I have more than the allocated %d aps!\n", cgiWifiAps.noAps);
|
||||||
|
break;
|
||||||
|
}
|
||||||
cgiWifiAps.apData[n]=(ApData *)os_malloc(sizeof(ApData));
|
cgiWifiAps.apData[n]=(ApData *)os_malloc(sizeof(ApData));
|
||||||
cgiWifiAps.apData[n]->rssi=bss_link->rssi;
|
cgiWifiAps.apData[n]->rssi=bss_link->rssi;
|
||||||
cgiWifiAps.apData[n]->enc=bss_link->authmode;
|
cgiWifiAps.apData[n]->enc=bss_link->authmode;
|
||||||
@@ -78,7 +82,6 @@ void ICACHE_FLASH_ATTR wifiScanDoneCb(void *arg, STATUS status) {
|
|||||||
bss_link = bss_link->next.stqe_next;
|
bss_link = bss_link->next.stqe_next;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
os_printf("Scan done: found %d APs\n", n);
|
|
||||||
//We're done.
|
//We're done.
|
||||||
cgiWifiAps.scanInProgress=0;
|
cgiWifiAps.scanInProgress=0;
|
||||||
}
|
}
|
||||||
@@ -86,14 +89,17 @@ void ICACHE_FLASH_ATTR wifiScanDoneCb(void *arg, STATUS status) {
|
|||||||
|
|
||||||
//Routine to start a WiFi access point scan.
|
//Routine to start a WiFi access point scan.
|
||||||
static void ICACHE_FLASH_ATTR wifiStartScan() {
|
static void ICACHE_FLASH_ATTR wifiStartScan() {
|
||||||
int x;
|
// int x;
|
||||||
|
if (cgiWifiAps.scanInProgress) return;
|
||||||
cgiWifiAps.scanInProgress=1;
|
cgiWifiAps.scanInProgress=1;
|
||||||
|
/*
|
||||||
x=wifi_station_get_connect_status();
|
x=wifi_station_get_connect_status();
|
||||||
if (x!=STATION_GOT_IP) {
|
if (x!=STATION_GOT_IP) {
|
||||||
//Unit probably is trying to connect to a bogus AP. This messes up scanning. Stop that.
|
//Unit probably is trying to connect to a bogus AP. This messes up scanning. Stop that.
|
||||||
os_printf("STA status = %d. Disconnecting STA...\n", x);
|
os_printf("STA status = %d. Disconnecting STA...\n", x);
|
||||||
wifi_station_disconnect();
|
wifi_station_disconnect();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
wifi_station_scan(NULL, wifiScanDoneCb);
|
wifi_station_scan(NULL, wifiScanDoneCb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +143,7 @@ static void ICACHE_FLASH_ATTR resetTimerCb(void *arg) {
|
|||||||
int x=wifi_station_get_connect_status();
|
int x=wifi_station_get_connect_status();
|
||||||
if (x==STATION_GOT_IP) {
|
if (x==STATION_GOT_IP) {
|
||||||
//Go to STA mode. This needs a reset, so do that.
|
//Go to STA mode. This needs a reset, so do that.
|
||||||
|
os_printf("Got IP. Going into STA mode..\n");
|
||||||
wifi_set_opmode(1);
|
wifi_set_opmode(1);
|
||||||
system_restart();
|
system_restart();
|
||||||
} else {
|
} else {
|
||||||
@@ -150,6 +157,7 @@ static void ICACHE_FLASH_ATTR resetTimerCb(void *arg) {
|
|||||||
static void ICACHE_FLASH_ATTR reassTimerCb(void *arg) {
|
static void ICACHE_FLASH_ATTR reassTimerCb(void *arg) {
|
||||||
int x;
|
int x;
|
||||||
static ETSTimer resetTimer;
|
static ETSTimer resetTimer;
|
||||||
|
os_printf("Try to connect to AP....\n");
|
||||||
wifi_station_disconnect();
|
wifi_station_disconnect();
|
||||||
wifi_station_set_config(&stconf);
|
wifi_station_set_config(&stconf);
|
||||||
wifi_station_connect();
|
wifi_station_connect();
|
||||||
@@ -180,11 +188,12 @@ int ICACHE_FLASH_ATTR cgiWiFiConnect(HttpdConnData *connData) {
|
|||||||
|
|
||||||
os_strncpy((char*)stconf.ssid, essid, 32);
|
os_strncpy((char*)stconf.ssid, essid, 32);
|
||||||
os_strncpy((char*)stconf.password, passwd, 64);
|
os_strncpy((char*)stconf.password, passwd, 64);
|
||||||
|
os_printf("Try to connect to AP %s pw %s\n", essid, passwd);
|
||||||
|
|
||||||
//Schedule disconnect/connect
|
//Schedule disconnect/connect
|
||||||
os_timer_disarm(&reassTimer);
|
os_timer_disarm(&reassTimer);
|
||||||
os_timer_setfn(&reassTimer, reassTimerCb, NULL);
|
os_timer_setfn(&reassTimer, reassTimerCb, NULL);
|
||||||
#if 0
|
#if 1
|
||||||
os_timer_arm(&reassTimer, 1000, 0);
|
os_timer_arm(&reassTimer, 1000, 0);
|
||||||
|
|
||||||
httpdRedirect(connData, "connecting.html");
|
httpdRedirect(connData, "connecting.html");
|
||||||
|
|||||||
+6
-1
@@ -131,6 +131,7 @@ EspFsFile ICACHE_FLASH_ATTR *espFsOpen(char *fileName) {
|
|||||||
//Yay, this is the file we need!
|
//Yay, this is the file we need!
|
||||||
p+=h.nameLen; //Skip to content.
|
p+=h.nameLen; //Skip to content.
|
||||||
r=(EspFsFile *)os_malloc(sizeof(EspFsFile)); //Alloc file desc mem
|
r=(EspFsFile *)os_malloc(sizeof(EspFsFile)); //Alloc file desc mem
|
||||||
|
// os_printf("Alloc %p\n", r);
|
||||||
if (r==NULL) return NULL;
|
if (r==NULL) return NULL;
|
||||||
r->header=(EspFsHeader *)hpos;
|
r->header=(EspFsHeader *)hpos;
|
||||||
r->decompressor=h.compression;
|
r->decompressor=h.compression;
|
||||||
@@ -186,6 +187,7 @@ int ICACHE_FLASH_ATTR espFsRead(EspFsFile *fh, char *buff, int len) {
|
|||||||
unsigned int elen, rlen;
|
unsigned int elen, rlen;
|
||||||
char ebuff[16];
|
char ebuff[16];
|
||||||
heatshrink_decoder *dec=(heatshrink_decoder *)fh->decompData;
|
heatshrink_decoder *dec=(heatshrink_decoder *)fh->decompData;
|
||||||
|
// os_printf("Alloc %p\n", dec);
|
||||||
while(decoded<len) {
|
while(decoded<len) {
|
||||||
//Feed data into the decompressor
|
//Feed data into the decompressor
|
||||||
//ToDo: Check ret val of heatshrink fns for errors
|
//ToDo: Check ret val of heatshrink fns for errors
|
||||||
@@ -216,9 +218,12 @@ void ICACHE_FLASH_ATTR espFsClose(EspFsFile *fh) {
|
|||||||
if (fh==NULL) return;
|
if (fh==NULL) return;
|
||||||
#ifdef EFS_HEATSHRINK
|
#ifdef EFS_HEATSHRINK
|
||||||
if (fh->decompressor==COMPRESS_HEATSHRINK) {
|
if (fh->decompressor==COMPRESS_HEATSHRINK) {
|
||||||
heatshrink_decoder_free((heatshrink_decoder*)fh->decompData);
|
heatshrink_decoder *dec=(heatshrink_decoder *)fh->decompData;
|
||||||
|
heatshrink_decoder_free(dec);
|
||||||
|
// os_printf("Freed %p\n", dec);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// os_printf("Freed %p\n", fh);
|
||||||
os_free(fh);
|
os_free(fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "osapi.h"
|
#include "osapi.h"
|
||||||
#include "heatshrink_config_httpd.h"
|
#include "heatshrink_config_httpd.h"
|
||||||
#define malloc(x) os_malloc(x)
|
|
||||||
#define memset(x,y,z) os_memset(x,y,z)
|
#define memset(x,y,z) os_memset(x,y,z)
|
||||||
#define memcpy(x,y,z) os_memcpy(x,y,z)
|
#define memcpy(x,y,z) os_memcpy(x,y,z)
|
||||||
#include "../lib/heatshrink/heatshrink_decoder.c"
|
#include "../lib/heatshrink/heatshrink_decoder.c"
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#ifndef HTTPD_H
|
#ifndef HTTPD_H
|
||||||
#define HTTPD_H
|
#define HTTPD_H
|
||||||
#include <ip_addr.h>
|
|
||||||
#include <c_types.h>
|
#include <c_types.h>
|
||||||
|
#include "lwip/ip_addr.h"
|
||||||
#include <espconn.h>
|
#include <espconn.h>
|
||||||
|
|
||||||
#define HTTPD_CGI_MORE 0
|
#define HTTPD_CGI_MORE 0
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ HttpdBuiltInUrl builtInUrls[]={
|
|||||||
|
|
||||||
void user_init(void) {
|
void user_init(void) {
|
||||||
stdoutInit();
|
stdoutInit();
|
||||||
|
os_printf("HTTPD EXAMPLE START\n");
|
||||||
ioInit();
|
ioInit();
|
||||||
httpdInit(builtInUrls, 80);
|
httpdInit(builtInUrls, 80);
|
||||||
os_printf("\nReady\n");
|
os_printf("\nReady\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user