Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sunkaimr committed Mar 13, 2022
1 parent 90db728 commit 6c9387f
Show file tree
Hide file tree
Showing 21 changed files with 1,426 additions and 36 deletions.
1,346 changes: 1,335 additions & 11 deletions README.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion bin/blank.bin

This file was deleted.

Binary file removed bin/boot_v1.6.bin
Binary file not shown.
Binary file removed bin/esp_init_data_default.bin
Binary file not shown.
Binary file removed bin/user1.4096.new.6.bin
Binary file not shown.
Binary file added media/1647010030561.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/1647010372224.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/1647010714554.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/1647011242001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/1647011758296.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/748e893faf3d6670f482f3dc569691f9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/a8462ee24318e5431c4eaf7ebf526cae.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions plug2.0/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ BINODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/bin
OBINS := $(GEN_BINS:%=$(BINODIR)/%)

CCFLAGS += \
-O3 \
-g \
-Wpointer-arith \
-Wundef \
Expand Down
8 changes: 4 additions & 4 deletions plug2.0/app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# a generated lib/image xxx.a ()
#
TARGET = eagle
#FLAVOR = release
FLAVOR = debug
FLAVOR = release
#FLAVOR = debug

#EXTRA_CCFLAGS += -u

Expand Down Expand Up @@ -46,11 +46,11 @@ TARGET_LDFLAGS = \
--text-section-literals

ifeq ($(FLAVOR),debug)
TARGET_LDFLAGS += -g -O2
TARGET_LDFLAGS += -g -O3
endif

ifeq ($(FLAVOR),release)
TARGET_LDFLAGS += -g -O0
TARGET_LDFLAGS += -g -O3
endif

COMPONENTS_eagle.app.v6 = \
Expand Down
1 change: 1 addition & 0 deletions plug2.0/app/include/user_http.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef enum {

typedef enum {
HTTP_CODE_None,
HTTP_CODE_Continue,
HTTP_CODE_SwitchingProtocols,
HTTP_CODE_Ok,
HTTP_CODE_Created,
Expand Down
2 changes: 1 addition & 1 deletion plug2.0/app/include/user_plug.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typedef struct tagPLUG_TIME_POINT

typedef enum
{
REPET_ONCE = 0x00, /* 执行一次 */
REPET_ONCE = 0x00, /* 执行一次 */
REPET_MON = 0x01, /* 每周一 */
REPET_TUE = 0x02, /* 每周二 */
REPET_WED = 0x04, /* 每周三 */
Expand Down
2 changes: 1 addition & 1 deletion plug2.0/app/include/user_web.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


#define WEB_MAX_FD 2 //最大可接受连接数并发(根据空闲栈大小来调整,不建议将该值调大,除非你有更好的优化方案来节省内存)
#define WEB_CONTINUE_TMOUT 1 //连接超时时间,超过该时间未进行数据交互将主动断开连接
#define WEB_CONTINUE_TMOUT 5 //连接超时时间,超过该时间未进行数据交互将主动断开连接

VOID WEB_StartWebServerTheard( VOID );
VOID WEB_StopWebServerTheard( VOID );
Expand Down
81 changes: 73 additions & 8 deletions plug2.0/app/user/user_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ HTTP_ROUTER_MAP_S stHttpRouterMap[HTTP_ROUTER_MAP_MAX];
const CHAR szHttpCodeMap[][5] =
{
"999",
"100",
"101",
"200",
"201",
Expand All @@ -41,6 +42,7 @@ const CHAR szHttpCodeMap[][5] =
const CHAR szHttpStatusMap[][20] =
{
"None",
"Continue",
"Switching Protocols",
"OK",
"Created",
Expand Down Expand Up @@ -108,6 +110,9 @@ const CHAR szHttpCacheControlStr[][20] =
const CHAR aGzipSuffix[HTTP_ENCODING_Buff+1][5] = {".gz",""};

UINT HTTP_RequestInit( HTTP_CTX *pstCtx );
UINT HTTP_SendOnce( HTTP_CTX *pstCtx );
UINT HTTP_SendContinue( HTTP_CTX *pstCtx );
UINT HTTP_SetResponseBody( HTTP_CTX *pstCtx, CHAR* pcBody );


INT32 HTTP_ParsingHttpHead( HTTP_CTX *pstCtx, CHAR * pcData, UINT32 uiLen )
Expand Down Expand Up @@ -590,6 +595,7 @@ UINT HTTP_RouterHandle( HTTP_CTX *pstCtx )
UINT uiRet = 0;
UINT uiLoop = 0;
CHAR *pcValue = NULL;
CHAR *pcHeader = NULL;
UINT i = 0;

if ( NULL == pstCtx )
Expand All @@ -607,18 +613,32 @@ UINT HTTP_RouterHandle( HTTP_CTX *pstCtx )
goto end;
}

if ( (pstCtx->stReq.eMethod == HTTP_METHOD_POST ||
pstCtx->stReq.eMethod == HTTP_METHOD_PUT ) &&
pstCtx->stReq.eProcess == RES_Process_GotHeader )
if ( pstCtx->stReq.szURL[0] == 0 )
{
uiRet = OK;
LOG_OUT(LOGOUT_INFO, "szURL is NULL");
uiRet = FAIL;
goto end;
}

if ( pstCtx->stReq.szURL[0] == 0 )
if ( (pstCtx->stReq.eMethod == HTTP_METHOD_POST ||
pstCtx->stReq.eMethod == HTTP_METHOD_PUT ) &&
pstCtx->stReq.eProcess == RES_Process_GotHeader)
{
LOG_OUT(LOGOUT_INFO, "szURL is NULL");
uiRet = FAIL;
pcHeader = HTTP_GetReqHeader(&pstCtx->stReq.stHeader[0], "Expect");
if ( pcHeader != NULL && strcmp(pcHeader, "100-continue") == 0 )
{
uiRet = HTTP_SendContinue(pstCtx);
if ( uiRet != OK )
{
LOG_OUT( LOGOUT_ERROR, "send continue failed");
goto end;
}
LOG_OUT( LOGOUT_INFO, "response clinet: HTTP/1.1 100 Continue");

return uiRet;
}

uiRet = OK;
goto end;
}

Expand All @@ -630,7 +650,6 @@ UINT HTTP_RouterHandle( HTTP_CTX *pstCtx )
}

// websocket 协议的特殊处理
CHAR* pcHeader = NULL;
pcHeader = HTTP_GetReqHeader(&pstCtx->stReq.stHeader[0], "Upgrade");
if ( pcHeader != NULL && strcmp(pcHeader, "websocket") == 0 )
{
Expand Down Expand Up @@ -869,6 +888,46 @@ UINT HTTP_SendOnce( HTTP_CTX *pstCtx )
return OK;
}

UINT HTTP_SendContinue( HTTP_CTX *pstCtx )
{
UINT uiRet = 0;
UINT uiLen = 0;
CHAR* pcLength = NULL;

if ( pstCtx == NULL )
{
LOG_OUT(LOGOUT_ERROR, "pstCtx is NULL.");
return FAIL;
}

HTTP_Malloc(pstCtx, HTTP_BUF_512);

uiRet = HTTP_SetResponseBody(pstCtx, "HTTP/1.1 100 Continue");
if ( uiRet != OK )
{
LOG_OUT( LOGOUT_ERROR, "set response body failed");
return FAIL;
}

if( pstCtx->stResp.uiBodyLen != pstCtx->stResp.uiPos - pstCtx->stResp.uiHeaderLen )
{
pstCtx->stResp.uiBodyLen = pstCtx->stResp.uiPos - pstCtx->stResp.uiHeaderLen;
}

pstCtx->stResp.uiSendCurLen = pstCtx->stResp.uiPos;
pstCtx->stResp.uiSendTotalLen = pstCtx->stResp.uiSendCurLen + 1;

//LOG_OUT(LOGOUT_DEBUG, "[%s]", pstCtx->stResp.pcResponBody);

uiRet = WEB_WebSend(pstCtx);
if ( uiRet != OK )
{
LOG_OUT(LOGOUT_ERROR, "send failed");
return FAIL;
}

return OK;
}

UINT HTTP_SetResponseBody( HTTP_CTX *pstCtx, CHAR* pcBody )
{
Expand All @@ -881,6 +940,12 @@ UINT HTTP_SetResponseBody( HTTP_CTX *pstCtx, CHAR* pcBody )
return FAIL;
}

if ( pstCtx->stResp.pcResponBody == NULL )
{
LOG_OUT(LOGOUT_ERROR, "pstCtx->stResp.pcResponBody:%p", pstCtx->stResp.pcResponBody);
return FAIL;
}

pstCtx->stResp.uiBodyLen = snprintf(
pstCtx->stResp.pcResponBody + pstCtx->stResp.uiPos,
pstCtx->stResp.uiSendBufLen - pstCtx->stResp.uiPos,
Expand Down
12 changes: 6 additions & 6 deletions plug2.0/app/user/user_httpHandle.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ HTTP_FILE_S* HTTP_FileOpen( CHAR *pcFileName )
return NULL;
}

pstFile->pcName = pstHtmlData->szName;
pstFile->pcName = pstHtmlData->szName;
pstFile->eStatus = STATUS_Open;
pstFile->uiAddr = pstHtmlData->uiAddr;
pstFile->uiLength = pstHtmlData->uiLength;
pstFile->uiPos = 0;
pstFile->eType = pstHtmlData->eType;
pstFile->uiAddr = pstHtmlData->uiAddr;
pstFile->uiLength = pstHtmlData->uiLength;
pstFile->uiPos = 0;
pstFile->eType = pstHtmlData->eType;
pstFile->eEncode = pstHtmlData->eEncode;
return pstFile;
}
Expand Down Expand Up @@ -202,7 +202,7 @@ UINT HTTP_SendFile( HTTP_CTX *pstCtx, HTTP_FILE_S* pstFile )
//首次发送时发送http头部
if ( pstCtx->stResp.uiSentLen == 0 )
{
pstCtx->stResp.eHttpCode = HTTP_CODE_Ok;
pstCtx->stResp.eHttpCode = HTTP_CODE_Ok;
pstCtx->stResp.eContentType = pstFile->eType;
pstCtx->stResp.eCacheControl = HTTP_CACHE_CTL_TYPE_MaxAge_1y;

Expand Down
4 changes: 2 additions & 2 deletions plug2.0/app/user/user_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ VOID PLUG_SystemSetDataDeInit( VOID )
CHAR szMac[20] = {};

g_stPLUG_SystemSet.bRelayStatus = 0;
g_stPLUG_SystemSet.ucWifiMode = WIFI_MODE_SOFTAP;
g_stPLUG_SystemSet.ucWifiMode = WIFI_MODE_STATION;
g_stPLUG_SystemSet.bSmartConfigFlag = FALSE;
#if IS_WELL
g_stPLUG_SystemSet.eRelayPowerUp = PWUP_OFF;
Expand Down Expand Up @@ -1094,7 +1094,7 @@ UINT PLUG_MarshalJsonHtmlData( CHAR* pcBuf, UINT uiBufLen )
cJSON_AddNumberToObject( pJsonsub, "Addr", pstHtmlData->uiAddr);
cJSON_AddNumberToObject( pJsonsub, "Length", pstHtmlData->uiLength);
cJSON_AddStringToObject( pJsonsub, "Type", szHttpContentTypeStr[pstHtmlData->eType]);
cJSON_AddStringToObject( pJsonsub, "eEncode", szHttpEncodingStr[pstHtmlData->eEncode]);
cJSON_AddStringToObject( pJsonsub, "Encode", szHttpEncodingStr[pstHtmlData->eEncode]);

cJSON_AddItemToArray(pJsonArry, pJsonsub);
}
Expand Down
4 changes: 2 additions & 2 deletions plug2.0/app/user/user_web.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ STATIC VOID WEB_WebHandleTask( VOID *Para )
else if ( 0 == iRet )
{
pstCtx->uiCostTime ++;
//LOG_OUT(LOGOUT_DEBUG, "select timeout, uiCostTime:%d", pstCtx->uiCostTime);
LOG_OUT(LOGOUT_DEBUG, "select timeout, uiCostTime:%d", pstCtx->uiCostTime);

if ( pstCtx->uiCostTime >= pstCtx->uiTimeOut )
{
//LOG_OUT(LOGOUT_DEBUG, "recv timeout closed", pstCtx->iClientFd);
LOG_OUT(LOGOUT_DEBUG, "recv timeout closed", pstCtx->iClientFd);
goto end;
}
continue;
Expand Down

0 comments on commit 6c9387f

Please sign in to comment.