Revert "MDIO added"

This commit is contained in:
James YS Kim
2018-07-25 18:33:15 +09:00
committed by GitHub
parent 8ebd860b08
commit b8e3c63cff
19 changed files with 1356 additions and 1893 deletions

View File

@ -1,16 +1,3 @@
/*******************************************************************************************************************************************************
* Copyright <20><>I 2016 <WIZnet Co.,Ltd.>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the <20><><EFBFBD><EFBFBD>Software<72><65><EFBFBD><EFBFBD>),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED <20><><EFBFBD><EFBFBD>AS IS<49><53><EFBFBD><EFBFBD>, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************************************************************************************************/
/**
@file httpd.c
@brief functions associated http processing
@ -21,7 +8,6 @@
#include "socket.h"
#include "httpParser.h"
/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/

View File

@ -1,16 +1,3 @@
/*******************************************************************************************************************************************************
* Copyright <20><>I 2016 <WIZnet Co.,Ltd.>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the <20><><EFBFBD><EFBFBD>Software<72><65><EFBFBD><EFBFBD>),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED <20><><EFBFBD><EFBFBD>AS IS<49><53><EFBFBD><EFBFBD>, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************************************************************************************************/
/**
@file httpd.h
@brief Define Constants and fucntions associated with HTTP protocol.
@ -18,7 +5,6 @@
#include <stdint.h>
#ifndef __HTTPPARSER_H__
#define __HTTPPARSER_H__

View File

@ -1,16 +1,3 @@
/*******************************************************************************************************************************************************
* Copyright <20><>I 2016 <WIZnet Co.,Ltd.>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the <20><><EFBFBD><EFBFBD>Software<72><65><EFBFBD><EFBFBD>),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED <20><><EFBFBD><EFBFBD>AS IS<49><53><EFBFBD><EFBFBD>, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************************************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -22,7 +9,6 @@
#include "httpParser.h"
#include "httpUtil.h"
#ifdef _USE_SDCARD_
#include "ff.h" // header file for FatFs library (FAT file system)
#endif
@ -368,13 +354,13 @@ static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf
#endif
}
#ifdef _USE_FLASH_
if(HTTPSock_Status[get_seqnum].storage_type == DATAFLASH) addr = start_addr;
if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH) addr = start_addr;
#endif
}
else // remained parts
{
#ifdef _USE_FLASH_
if(HTTPSock_Status[get_seqnum].storage_type == DATAFLASH)
if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH)
{
addr = HTTPSock_Status[get_seqnum].file_start + HTTPSock_Status[get_seqnum].file_offset;
}
@ -431,7 +417,7 @@ static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf
#endif
#ifdef _USE_FLASH_
else if(HTTPSock_Status[get_seqnum].storage_type == DATAFLASH)
else if(HTTPSock_Status[get_seqnum]->storage_type == DATAFLASH)
{
// Data read from external data flash memory
read_from_flashbuf(addr, &buf[0], send_len);
@ -558,9 +544,6 @@ static void http_process_handler(uint8_t s, st_http_request * p_http_request)
// Find the User registered index for web content
if(find_userReg_webContent(uri_buf, &content_num, &file_len))
{
content_found = 1; // Web content found in code flash memory
content_addr = (uint32_t)content_num;
HTTPSock_Status[get_seqnum].storage_type = CODEFLASH;
@ -584,7 +567,6 @@ static void http_process_handler(uint8_t s, st_http_request * p_http_request)
content_found = 1;
HTTPSock_Status[get_seqnum]->storage_type = DATAFLASH;
; // To do
printf("file len : %d\r\n", file_len);
}
#endif
else
@ -693,11 +675,7 @@ void reg_httpServer_webContent(uint8_t * content_name, uint8_t * content)
name_len = strlen((char *)content_name);
content_len = strlen((char *)content);
//web_content[total_content_cnt].content_name = malloc(name_len+1);
web_content[total_content_cnt].content_name = malloc(name_len+1);
strcpy((char *)web_content[total_content_cnt].content_name, (const char *)content_name);
web_content[total_content_cnt].content_len = content_len;
web_content[total_content_cnt].content = content;

View File

@ -1,23 +1,9 @@
/*******************************************************************************************************************************************************
* Copyright <20><>I 2016 <WIZnet Co.,Ltd.>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the <20><><EFBFBD><EFBFBD>Software<72><65><EFBFBD><EFBFBD>),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED <20><><EFBFBD><EFBFBD>AS IS<49><53><EFBFBD><EFBFBD>, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************************************************************************************************/
/**
@file httpServer.h
@brief Define constants and functions related HTTP Web server.
*/
#include <stdint.h>
#include "W7500x_wztoe.h"
#ifndef __HTTPSERVER_H__
#define __HTTPSERVER_H__
@ -92,7 +78,7 @@ typedef struct _st_http_socket
typedef struct _httpServer_webContent
{
uint8_t content_name[20];
uint8_t * content_name;
uint32_t content_len;
uint8_t * content;
}httpServer_webContent;

View File

@ -1,16 +1,3 @@
/*******************************************************************************************************************************************************
* Copyright <20><>I 2016 <WIZnet Co.,Ltd.>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the <20><><EFBFBD><EFBFBD>Software<72><65><EFBFBD><EFBFBD>),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED <20><><EFBFBD><EFBFBD>AS IS<49><53><EFBFBD><EFBFBD>, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************************************************************************************************/
/**
* @file httpUtil.c
* @brief HTTP Server Utilities
@ -25,17 +12,13 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "W7500x_gpio.h"
#include "httpServer.h"
#include "httpParser.h"
#include "httpUtil.h"
#include "wizchip_conf.h"
uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len)
{
uint8_t ret = HTTP_OK;
uint16_t len = 0;
if(predefined_get_cgi_processor(uri_name, buf, &len))
{
;
@ -60,7 +43,7 @@ uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_reque
uint8_t ret = HTTP_OK;
uint16_t len = 0;
uint8_t val = 0;
if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len))
{
;
@ -80,140 +63,3 @@ uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_reque
if(ret) *file_len = len;
return ret;
}
uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len)
{
uint8_t ret = 1; // ret = 1 means 'uri_name' matched
uint8_t cgibuf[14] = {0, };
int8_t cgi_dio = -1;
int8_t cgi_ain = -1;
uint8_t i;
if(strcmp((const char *)uri_name, "todo.cgi") == 0)
{
// to do
;//make_json_todo(buf, len);
}
else if(strcmp((const char *)uri_name, "get_netinfo.cgi") == 0)
{
make_json_netinfo(buf, len);
}
else
{
;
}
return ret;
}
uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len)
{
uint8_t ret = 1; // ret = '1' means 'uri_name' matched
uint8_t val = 0;
if(strcmp((const char *)uri_name, "todo.cgi") == 0)
{
// to do
;//val = todo(uri);
//*len = sprintf((char *)buf, "%d", val);
}
// Digital I/O; dio_s, dio_d
else if(strcmp((const char *)uri_name, "set_LED.cgi") == 0)
{
val = set_LED(uri);
*len = sprintf((char *)buf, "%d", val);
}
else
{
ret = 0;
}
return ret;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pre-defined Get CGI functions
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Example of make_jason function */
//void make_json_dio(uint8_t * buf, uint16_t * len, uint8_t pin)
//{
// uint8_t pin_state = Chip_GPIO_GetPinState(LPC_GPIO, dio_ports[pin], dio_pins[pin]);
// uint8_t pin_dir = Chip_GPIO_GetPinDIR(LPC_GPIO, dio_ports[pin], dio_pins[pin]);
// *len = sprintf((char *)buf, "DioCallback({\"dio_p\":\"%d\",\
// \"dio_s\":\"%d\",\
// \"dio_d\":\"%d\"\
// });",
// pin, // Digital io pin number
// pin_state, // Digital io status
// pin_dir // Digital io directions
// );
//}
void make_json_netinfo(uint8_t * buf, uint16_t * len)
{
wiz_NetInfo netinfo;
ctlnetwork(CN_GET_NETINFO, (void*) &netinfo);
// DHCP: 1 - Static, 2 - DHCP
*len = sprintf((char *)buf, "NetinfoCallback({\"mac\":\"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\",\
\"ip\":\"%d.%d.%d.%d\",\
\"gw\":\"%d.%d.%d.%d\",\
\"sn\":\"%d.%d.%d.%d\",\
\"dns\":\"%d.%d.%d.%d\",\
\"dhcp\":\"%d\"\
});",
netinfo.mac[0], netinfo.mac[1], netinfo.mac[2], netinfo.mac[3], netinfo.mac[4], netinfo.mac[5],
netinfo.ip[0], netinfo.ip[1], netinfo.ip[2], netinfo.ip[3],
netinfo.gw[0], netinfo.gw[1], netinfo.gw[2], netinfo.gw[3],
netinfo.sn[0], netinfo.sn[1], netinfo.sn[2], netinfo.sn[3],
netinfo.dns[0], netinfo.dns[1], netinfo.dns[2], netinfo.dns[3],
netinfo.dhcp
);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pre-defined Set CGI functions
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int8_t set_LED(uint8_t * uri)
{
uint8_t * param;
uint8_t pin = 0, val = 0;
if((param = get_http_param_value((char *)uri, "pin"))) // GPIO; D0 ~ D15
{
pin = (uint8_t)ATOI(param, 10);
if(pin > 15) return -1;
if((param = get_http_param_value((char *)uri, "val"))) // State; high(off)/low(on)
{
val = (uint8_t)ATOI(param, 10);
}
if(pin == RED)
{
if(val == 0) GPIO_ResetBits(GPIOC, GPIO_Pin_0); // Low(On)
else GPIO_SetBits(GPIOC, GPIO_Pin_0);// High(off)
}
else if(pin == GREEN)
{
if(val == 0) GPIO_ResetBits(GPIOC, GPIO_Pin_4); // Low(On)
else GPIO_SetBits(GPIOC, GPIO_Pin_4);// High(off)
}
else if(pin == BLUE)
{
if(val == 0) GPIO_ResetBits(GPIOC, GPIO_Pin_5); // Low(On)
else GPIO_SetBits(GPIOC, GPIO_Pin_5);// High(off)
}
}
return pin;
}

View File

@ -1,16 +1,3 @@
/*******************************************************************************************************************************************************
* Copyright <20><>I 2016 <WIZnet Co.,Ltd.>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the <20><><EFBFBD><EFBFBD>Software<72><65><EFBFBD><EFBFBD>),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED <20><><EFBFBD><EFBFBD>AS IS<49><53><EFBFBD><EFBFBD>, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************************************************************************************************/
/**
* @file httpUtil.h
* @brief Header File for HTTP Server Utilities
@ -25,27 +12,13 @@
#ifndef __HTTPUTIL_H__
#define __HTTPUTIL_H__
#include "httpServer.h"
#include "httpParser.h"
#define RED 0
#define GREEN 4
#define BLUE 5
uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len);
uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len);
uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len);
uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * len);
// Pre-defined Get CGI functions
void make_json_netinfo(uint8_t * buf, uint16_t * len);
//void make_json_LEDR(uint8_t * buf, uint16_t * len);
// Pre-defined Set CGI functions
//int8_t set_diodir(uint8_t * uri);
//int8_t set_diostate(uint8_t * uri);
int8_t set_LED(uint8_t * uri);
#endif

File diff suppressed because one or more lines are too long