Merge branch 'master' into windows

Conflicts:
	Makefile
	cmd/handlers.c
	include/esp8266.h
	user/user_main.c
pull/47/head
Benjamin Runnels 9 years ago
commit 028e6e1239
  1. 17
      Makefile
  2. 12
      esp-link.vcxproj
  3. 50
      esp-link/cgi.c
  4. 3
      esp-link/cgi.h
  5. 8
      include/esp8266.h
  6. 17
      include/user_config.h
  7. 0
      mqtt/mqtt_cmd.c
  8. 0
      mqtt/mqtt_cmd.h
  9. 39
      rest/rest.c
  10. 1
      rest/rest.h

@ -10,6 +10,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
# Original from esphttpd and others... # Original from esphttpd and others...
#VERBOSE=1
# --------------- toolchain configuration --------------- # --------------- toolchain configuration ---------------
@ -128,6 +129,8 @@ GZIP_COMPRESSION ?= yes
COMPRESS_W_YUI ?= yes COMPRESS_W_YUI ?= yes
YUI-COMPRESSOR ?= yuicompressor-2.4.8.jar YUI-COMPRESSOR ?= yuicompressor-2.4.8.jar
# Optional Modules
MODULES ?=
# -------------- End of config options ------------- # -------------- End of config options -------------
@ -142,6 +145,17 @@ TARGET = httpd
# espressif tool to concatenate sections for OTA upload using bootloader v1.2+ # espressif tool to concatenate sections for OTA upload using bootloader v1.2+
APPGEN_TOOL ?= gen_appbin.py APPGEN_TOOL ?= gen_appbin.py
CFLAGS=
# set defines for optional modules
ifneq (,$(findstring mqtt,$(MODULES)))
CFLAGS += -DMQTT
endif
ifneq (,$(findstring rest,$(MODULES)))
CFLAGS += -DREST
endif
# which modules (subdirectories) of the project to include in compiling # which modules (subdirectories) of the project to include in compiling
LIBRARIES_DIR = libraries LIBRARIES_DIR = libraries
MODULES = espfs httpd user serial cmd mqtt esp-link MODULES = espfs httpd user serial cmd mqtt esp-link
@ -152,8 +166,9 @@ EXTRA_INCDIR = include . include/json
LIBS = c gcc hal phy pp net80211 wpa main lwip json LIBS = c gcc hal phy pp net80211 wpa main lwip json
# 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 \ CFLAGS += -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
-nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections \ -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections \
-Wno-unused-function \
-D__ets__ -DICACHE_FLASH -D_STDINT_H -Wno-address -DFIRMWARE_SIZE=$(ESP_FLASH_MAX) \ -D__ets__ -DICACHE_FLASH -D_STDINT_H -Wno-address -DFIRMWARE_SIZE=$(ESP_FLASH_MAX) \
-DMCU_RESET_PIN=$(MCU_RESET_PIN) -DMCU_ISP_PIN=$(MCU_ISP_PIN) \ -DMCU_RESET_PIN=$(MCU_RESET_PIN) -DMCU_ISP_PIN=$(MCU_ISP_PIN) \
-DLED_CONN_PIN=$(LED_CONN_PIN) -DLED_SERIAL_PIN=$(LED_SERIAL_PIN) \ -DLED_CONN_PIN=$(LED_CONN_PIN) -DLED_SERIAL_PIN=$(LED_SERIAL_PIN) \

@ -39,12 +39,12 @@
<IntDir>build</IntDir> <IntDir>build</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<NMakeBuildCommandLine>espmake flash</NMakeBuildCommandLine> <NMakeBuildCommandLine>espmake all wiflash</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>espmake clean all</NMakeReBuildCommandLine> <NMakeReBuildCommandLine>espmake clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>espmake clean</NMakeCleanCommandLine> <NMakeCleanCommandLine>espmake clean</NMakeCleanCommandLine>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<NMakeBuildCommandLine>espmake all wiflash</NMakeBuildCommandLine> <NMakeBuildCommandLine>espmake clean all wiflash</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>espmake clean all</NMakeReBuildCommandLine> <NMakeReBuildCommandLine>espmake clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>espmake clean</NMakeCleanCommandLine> <NMakeCleanCommandLine>espmake clean</NMakeCleanCommandLine>
</PropertyGroup> </PropertyGroup>
@ -65,8 +65,8 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="cmd\cmd.c" /> <ClCompile Include="cmd\cmd.c" />
<ClCompile Include="cmd\handlers.c" /> <ClCompile Include="cmd\handlers.c" />
<ClCompile Include="cmd\mqtt_cmd.c" /> <ClCompile Include="mqtt\mqtt_cmd.c" />
<ClCompile Include="cmd\rest.c" /> <ClCompile Include="rest\rest.c" />
<ClCompile Include="cmd\tcpclient.c" /> <ClCompile Include="cmd\tcpclient.c" />
<ClCompile Include="espfs\espfs.c" /> <ClCompile Include="espfs\espfs.c" />
<ClCompile Include="espfs\mkespfsimage\main.c" /> <ClCompile Include="espfs\mkespfsimage\main.c" />
@ -111,8 +111,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="cmd\cmd.h" /> <ClInclude Include="cmd\cmd.h" />
<ClInclude Include="cmd\mqtt_cmd.h" /> <ClInclude Include="mqtt\mqtt_cmd.h" />
<ClInclude Include="cmd\rest.h" /> <ClInclude Include="rest\rest.h" />
<ClInclude Include="cmd\tcpclient.h" /> <ClInclude Include="cmd\tcpclient.h" />
<ClInclude Include="espfs\espfs.h" /> <ClInclude Include="espfs\espfs.h" />
<ClInclude Include="espfs\espfsformat.h" /> <ClInclude Include="espfs\espfsformat.h" />

@ -12,11 +12,15 @@ Some random cgi routines.
* Heavily modified and enhanced by Thorsten von Eicken in 2015 * Heavily modified and enhanced by Thorsten von Eicken in 2015
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
*/ */
#include <esp8266.h>
#include "cgi.h" #include "cgi.h"
#include "espfs.h" static char* chipIdStr = "";
char* ICACHE_FLASH_ATTR system_get_chip_id_str(){
if (os_strlen(chipIdStr) == 0) {
chipIdStr = (char*)os_zalloc(9);
os_sprintf(chipIdStr, "%06x", system_get_chip_id());
}
return chipIdStr;
}
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
jsonHeader(HttpdConnData *connData, int code) { jsonHeader(HttpdConnData *connData, int code) {
@ -28,6 +32,44 @@ jsonHeader(HttpdConnData *connData, int code) {
httpdEndHeaders(connData); httpdEndHeaders(connData);
} }
uint8_t ICACHE_FLASH_ATTR
UTILS_StrToIP(const char* str, void *ip){
/* The count of the number of bytes processed. */
int i;
/* A pointer to the next digit to process. */
const char * start;
start = str;
for (i = 0; i < 4; i++) {
/* The digit being processed. */
char c;
/* The value of this byte. */
int n = 0;
while (1) {
c = *start;
start++;
if (c >= '0' && c <= '9') {
n *= 10;
n += c - '0';
}
/* We insist on stopping at "." if we are still parsing
the first, second, or third numbers. If we have reached
the end of the numbers, we will allow any character. */
else if ((i < 3 && c == '.') || i == 3) {
break;
}
else {
return 0;
}
}
if (n >= 256) {
return 0;
}
((uint8_t*)ip)[i] = n;
}
return 1;
}
#define TOKEN(x) (os_strcmp(token, x) == 0) #define TOKEN(x) (os_strcmp(token, x) == 0)
#if 0 #if 0
// Handle system information variables and print their value, returns the number of // Handle system information variables and print their value, returns the number of

@ -1,9 +1,12 @@
#ifndef CGI_H #ifndef CGI_H
#define CGI_H #define CGI_H
#include <esp8266.h>
#include "httpd.h" #include "httpd.h"
void jsonHeader(HttpdConnData *connData, int code); void jsonHeader(HttpdConnData *connData, int code);
int cgiMenu(HttpdConnData *connData); int cgiMenu(HttpdConnData *connData);
uint8_t UTILS_StrToIP(const char* str, void *ip);
char* system_get_chip_id_str();
#endif #endif

@ -19,14 +19,6 @@
#include "espmissingincludes.h" #include "espmissingincludes.h"
#include "uart_hw.h" #include "uart_hw.h"
extern char* esp_link_version;
void ICACHE_FLASH_ATTR init(void);
inline char* ICACHE_FLASH_ATTR system_get_chip_id_str(){
char *chipId = (char*)os_zalloc(9);
os_sprintf(chipId, "%06x", system_get_chip_id());
return chipId;
}
#ifdef __WIN32__ #ifdef __WIN32__
#include <_mingw.h> #include <_mingw.h>

@ -1,8 +1,13 @@
#ifndef _USER_CONFIG_H_ #ifndef _USER_CONFIG_H_
#define _USER_CONFIG_H_ #define _USER_CONFIG_H_
#include <c_types.h>
#ifdef __WIN32__
#include <_mingw.h>
#endif
//#define CMD_DBG
#define MQTT_RECONNECT_TIMEOUT 5 // seconds #define MQTT_RECONNECT_TIMEOUT 5 // seconds
#define MQTT_BUF_SIZE 1024 #define MQTT_BUF_SIZE 512
#define QUEUE_BUFFER_SIZE 512
#define MQTT_HOST "10.0.0.220" // "mqtt.yourdomain.com" or ip "10.0.0.1" #define MQTT_HOST "10.0.0.220" // "mqtt.yourdomain.com" or ip "10.0.0.1"
#define MQTT_PORT 1883 #define MQTT_PORT 1883
@ -17,4 +22,12 @@
#define PROTOCOL_NAMEv31 // MQTT version 3.1 compatible with Mosquitto v0.15/ #define PROTOCOL_NAMEv31 // MQTT version 3.1 compatible with Mosquitto v0.15/
//PROTOCOL_NAMEv311 // MQTT version 3.11 compatible with https://eclipse.org/paho/clients/testing/ //PROTOCOL_NAMEv311 // MQTT version 3.11 compatible with https://eclipse.org/paho/clients/testing/
extern char* esp_link_version;
extern uint8_t UTILS_StrToIP(const char* str, void *ip);
extern void ICACHE_FLASH_ATTR init(void);
extern char* ICACHE_FLASH_ATTR system_get_chip_id_str();
#endif #endif

@ -392,42 +392,3 @@ fail:
os_printf("\n"); os_printf("\n");
return 0; return 0;
} }
uint8_t ICACHE_FLASH_ATTR
UTILS_StrToIP(const char* str, void *ip)
{
/* The count of the number of bytes processed. */
int i;
/* A pointer to the next digit to process. */
const char * start;
start = str;
for (i = 0; i < 4; i++) {
/* The digit being processed. */
char c;
/* The value of this byte. */
int n = 0;
while (1) {
c = * start;
start++;
if (c >= '0' && c <= '9') {
n *= 10;
n += c - '0';
}
/* We insist on stopping at "." if we are still parsing
the first, second, or third numbers. If we have reached
the end of the numbers, we will allow any character. */
else if ((i < 3 && c == '.') || i == 3) {
break;
}
else {
return 0;
}
}
if (n >= 256) {
return 0;
}
((uint8_t*)ip)[i] = n;
}
return 1;
}

@ -36,6 +36,5 @@ typedef struct {
uint32_t REST_Setup(CmdPacket *cmd); uint32_t REST_Setup(CmdPacket *cmd);
uint32_t REST_Request(CmdPacket *cmd); uint32_t REST_Request(CmdPacket *cmd);
uint32_t REST_SetHeader(CmdPacket *cmd); uint32_t REST_SetHeader(CmdPacket *cmd);
uint8_t UTILS_StrToIP(const char* str, void *ip);
#endif /* MODULES_INCLUDE_API_H_ */ #endif /* MODULES_INCLUDE_API_H_ */
Loading…
Cancel
Save