modify webserver function using mongoose.a(compile using arm-none-eabi-gcc (15:6.3.1+svn253039-1build1) 6.3.1 20170620)

This commit is contained in:
Liu_Weichao 2023-12-13 14:30:40 +08:00
parent 9a97e9dd94
commit 9bc206fd0b
12 changed files with 97 additions and 23 deletions

View File

@ -22,9 +22,13 @@ extern void ApplicationOtaTaskInit(void);
extern int OtaTask(void);
#endif
#ifdef USE_MONGOOSE
extern int webserver(void);
#endif
int main(void)
{
printf("Hello, world! \n");
printf("\nHello, world!\n");
FrameworkInit();
#ifdef APPLICATION_OTA
ApplicationOtaTaskInit();
@ -33,6 +37,11 @@ int main(void)
#ifdef OTA_BY_PLATFORM
OtaTask();
#endif
#ifdef USE_MONGOOSE
webserver();
#endif
return 0;
}
// int cppmain(void);

View File

@ -1,3 +1,6 @@
menuconfig USE_MONGOOSE
bool "Use mongoose as webserver"
default n
default y
select BSP_USING_SDIO
select BSP_USING_W5500
select BSP_USING_ETHERNET

View File

@ -1,3 +1,3 @@
SRC_FILES += project.c
SRC_FILES += webserver_project.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1 @@
mongoose.a基于工具链arm-none-eabi-gcc (15:6.3.1+svn253039-1build1) 6.3.1 20170620编译而来若使用的arm工具链版本存在差异或使用的是RISC-V工具链则需重新编译mongoose.a避免遇到异常问题。

View File

@ -1,3 +0,0 @@
SRC_FILES += mongoose.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -8,6 +8,26 @@
// any other URI serves static files from s_root_dir
// Data and results are JSON strings
/**
* @file webserver_project.c
* @brief support webserver_project for XiUOS
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023-11-07
*/
/*************************************************
File name: webserver_project.c
Description: support webserver_project for XiUOS
Others:
History:
1. Date: 2023-11-07
Author: AIIT XUOS Lab
Modification:
1support xishutong-arm32 board, using W5500 to support webserver.
*************************************************/
#include "ip_addr.h"
#include "mongoose.h"
#include "netdev.h"
@ -19,11 +39,12 @@ static const char* s_root_dir = "webserver";
static const char* s_enable_hexdump = "no";
static const char* s_ssi_pattern = "#.html";
static const char* device_type = "Edu-ARM32";
static const char* web_version = "XUOS Webserver 1.0";
static const char* device_type = "xishutong-arm32";
static const char* web_version = "XiUOS WebServer 1.0";
static int enable_4g = 0;
static struct netdev* p_netdev;
static pthread_t tid;
static struct config {
char *ip, *mask, *gw, *dns;
@ -104,11 +125,11 @@ static void fn(struct mg_connection* c, int ev, void* ev_data, void* fn_data)
(void)fn_data;
}
static void* do_webserver_demo(void* none)
static void* do_webserver(void* args)
{
p_netdev = netdev_get_by_name("wz");
if (p_netdev == NULL) {
MG_INFO(("Did nto find wz netdev, use default.\n"));
MG_INFO(("Did not find wz netdev, use default.\n"));
p_netdev = NETDEV_DEFAULT;
}
MG_INFO(("Use Netdev %s", p_netdev->name));
@ -119,7 +140,7 @@ static void* do_webserver_demo(void* none)
struct mg_mgr mgr; // Event manager
// mg_log_set(MG_LL_INFO); // Set to 3 to enable debug
mg_log_set(MG_LL_DEBUG); // Set to 3 to enable debug
mg_log_set(MG_LL_ERROR); // Set to 3 to enable debug
mg_mgr_init(&mgr); // Initialise event manager
mg_http_listen(&mgr, s_http_addr, fn, NULL); // Create HTTP listener
for (;;)
@ -128,15 +149,24 @@ static void* do_webserver_demo(void* none)
return NULL;
}
int webserver_demo(int argc, char* argv[])
int webserver(void)
{
pthread_t tid = -1;
char* params[3] = {"LwipNetworkActive", "-e", "1"};
extern void LwipNetworkActive(int argc, char* argv[]);
LwipNetworkActive(3, params);
pthread_attr_t attr;
attr.schedparam.sched_priority = 30;
attr.stacksize = 0x2000;
PrivTaskCreate(&tid, &attr, do_webserver_demo, NULL);
char task_name[] = "do_webserver";
pthread_args_t args;
args.pthread_name = task_name;
PrivTaskCreate(&tid, &attr, &do_webserver, (void *)&args);
PrivTaskStartup(&tid);
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(5), Webserver, webserver_demo, webserver for project);
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(5),
Webserver, webserver, webserver for project);

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file lorawan_gateway_update.c
* @brief support lorawan-gateway update function
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023-11-29
*/
/*************************************************
File name: lorawan_gateway_update.c
Description: support lorawan-gateway update function
Others:
History:
1. Date: 2023-11-29
Author: AIIT XUOS Lab
Modification:
1first version.
*************************************************/

View File

@ -25,6 +25,7 @@ menuconfig BSP_USING_ETHERNET
menuconfig BSP_USING_W5500
bool "Using W5500 ethernet device"
default n
select BSP_USING_ETHERNET
select BSP_USING_LWIP
select BSP_USING_SPI
select BSP_USING_SPI1
@ -55,7 +56,7 @@ menuconfig BSP_USING_SPI
menuconfig BSP_USING_SDRAM
bool "Using SDRAM IS42S16400J"
default y
default n
if BSP_USING_SDRAM
source "$BSP_DIR/third_party_driver/sdram/Kconfig"
endif

View File

@ -303,7 +303,7 @@ static int GpioPinIndex(uint16_t pin)
int ret = 0;
for (; ret <= MAX_PIN_INDEX; ret++) { // ret must be 16-bit
if ((0x0001U << ret) & pin) {
KPrintf("the int pin is %d\n", ret);
// KPrintf("the int pin is %d\n", ret);
return ret;
}
};

View File

@ -214,9 +214,9 @@ static struct SdioDevDone dev_done = {
static int MountSDCardFs(enum FilesystemType fs_type)
{
if (MountFilesystem(SDIO_BUS_NAME, SDIO_DEVICE_NAME, SDIO_DRIVER_NAME, fs_type, "/") == 0)
KPrintf("Sd card mount to '/'");
KPrintf("Sd card mount to '/'\n");
else
KPrintf("Sd card mount to '/' failed!");
KPrintf("Sd card mount to '/' failed!\n");
return 0;
}
@ -291,7 +291,7 @@ int MountSDCard()
{
int sd_card_task = 0;
sd_card_task = KTaskCreate("sd_card", SdCardTask, NONE,
SD_CARD_STACK_SIZE, 8);
SD_CARD_STACK_SIZE, 17);
if (sd_card_task < 0) {
KPrintf("sd_card_task create failed ...%s %d.\n", __FUNCTION__, __LINE__);
return ERROR;

View File

@ -78,7 +78,7 @@ char lwip_eth0_gwaddr[20] = { 192, 168, 130, 1 };
char lwip_eth1_ipaddr[20] = { 192, 168, 131, 88 };
char lwip_eth1_netmask[20] = { 255, 255, 254, 0 };
char lwip_eth1_gwaddr[20] = { 192, 168, 130, 1 };
char lwip_eth1_gwaddr[20] = { 192, 168, 131, 1 };
char lwip_flag = 0;
@ -256,11 +256,11 @@ err_t sys_mbox_new(sys_mbox_t* mbox, int size)
}
#endif /* SYS_STATS */
if (*mbox < 0) {
lw_print("lw: [%s] alloc %d mbox %p failed\n", __func__, size, mbox);
lw_error("lw: [%s] alloc %d mbox %p failed\n", __func__, size, mbox);
return ERR_MEM;
}
lw_print("lw: [%s] alloc %d mbox %p ok!\n", __func__, size, mbox);
// lw_print("lw: [%s] alloc %d mbox %p ok!\n", __func__, size, mbox);
return ERR_OK;
}