update rt-thread bsp and add webnet from tian_chunyu

it is OK
This commit is contained in:
xuedongliang
2022-06-22 13:31:35 +08:00
22 changed files with 281 additions and 50 deletions

View File

@@ -19,4 +19,5 @@ menu "Applications"
source "$APP_DIR/Applications/knowing_app/Kconfig"
source "$APP_DIR/Applications/sensor_app/Kconfig"
source "$APP_DIR/Applications/embedded_database_app/Kconfig"
source "$APP_DIR/Applications/webnet/Kconfig"
endmenu

View File

@@ -0,0 +1,92 @@
menuconfig APP_USING_WEBNET
bool "WebNet: A lightweight, customizable, embeddable Web Server for RT-Thread"
default n
if APP_USING_WEBNET
config PKG_WEBNET_PATH
string
default "/packages/iot/webnet"
config WEBNET_PORT
int "Server listen port"
default 80
range 0 65535
config WEBNET_CONN_MAX
int "Maximum number of server connections"
default 16
range 1 100
config WEBNET_ROOT
string "Server root directory"
default "/webnet"
menu "Select supported modules"
config WEBNET_USING_LOG
bool "LOG: Enable output log support"
default n
config WEBNET_USING_AUTH
bool "AUTH: Enable basic HTTP authentication support"
default n
config WEBNET_USING_CGI
bool "CGI: Enable Common Gateway Interface support"
default n
config WEBNET_USING_ASP
bool "ASP: Enable Active Server Pages support"
default n
config WEBNET_USING_SSI
bool "SSI: Enable Server Side Includes support"
default n
config WEBNET_USING_INDEX
bool "INDEX: Enable list all the file in the directory support"
default n
config WEBNET_USING_ALIAS
bool "ALIAS: Enable alias support"
default n
config WEBNET_USING_DAV
bool "DAV: Enable Web-based Distributed Authoring and Versioning support"
default n
config WEBNET_USING_UPLOAD
bool "UPLOAD: Enable upload file support"
default n
config WEBNET_USING_GZIP
bool "GZIP: Enable compressed file support by GZIP"
default n
config WEBNET_CACHE_LEVEL
int "CACHE: Configure cache level(0:disable 1:use Last-Modified 2:use Cache-Control)"
default 0
range 0 2
if WEBNET_CACHE_LEVEL = 2
config WEBNET_CACHE_MAX_AGE
int "Cache-Control time in seconds"
default 1800
endif
endmenu
config WEBNET_USING_SAMPLES
bool "Enable webnet samples"
default n
select WEBNET_USING_ASP
select WEBNET_USING_AUTH
select WEBNET_USING_CGI
select WEBNET_USING_INDEX
select WEBNET_USING_ALIAS
select WEBNET_USING_SSI
select WEBNET_USING_UPLOAD
endif

View File

@@ -0,0 +1,14 @@
import os
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

View File

@@ -436,11 +436,13 @@ int DeleteATAgent(ATAgentType agent)
PrivMutexDelete(&agent->lock);
}
#endif
#ifdef ADD_XIZI_FETURES
if (agent->entm_rx_notice) {
printf("delete agent entm_rx_notice = %d\n",agent->entm_rx_notice);
PrivSemaphoreDelete(&agent->entm_rx_notice);
}
#else
#endif
#ifdef ADD_XIZI_FETURES
if (agent->rsp_sem) {
printf("delete agent rsp_sem = %d\n",agent->rsp_sem);

View File

@@ -74,7 +74,11 @@ struct ATAgent
char entm_recv_buf[ENTM_RECV_MAX];
uint32 entm_recv_len;
enum ReceiveMode receive_mode;
#ifdef ADD_XIZI_FETURES
int entm_rx_notice;
#else
sem_t entm_rx_notice;
#endif
};
typedef struct ATAgent *ATAgentType;

View File

@@ -2,7 +2,8 @@ import os
Import('RTT_ROOT')
from building import *
SOURCES = []
SOURCES = ['adapter_bluetooth.c'] + SOURCES
if GetDepend(['CONNECTION_ADAPTER_BLUETOOTH']):
SOURCES = ['adapter_bluetooth.c'] + SOURCES
objs = []
cwd = GetCurrentDir()
path = [cwd]

View File

@@ -0,0 +1,19 @@
import os
Import('RTT_ROOT')
from building import *
SOURCES = []
if GetDepend(['CONNECTION_ADAPTER_ETHERNET']):
SOURCES = ['adapter_ethernet.c'] + SOURCES
objs = []
cwd = GetCurrentDir()
path = [cwd]
group = DefineGroup('ethernet', SOURCES, depend = [], CPPPATH = [cwd])
objs = objs + group
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

View File

@@ -97,28 +97,33 @@ int AdapterEthernetTest(void)
AdapterDeviceSetUp(adapter);
const char *ip = "10.10.100.50";
const char *port = "12345";
const char *ip = "192.168.131.26";
const char *port = "9999";
enum NetRoleType net_role = CLIENT;//SERVER
enum IpType ip_type = IPV4;
AdapterDeviceConnect(adapter, net_role, ip, port, ip_type);
printf("ready to test data transfer\n");
PrivTaskDelay(2000);
len = strlen(ethernet_msg);
for (i = 0;i < 10; i ++) {
printf("AdapterEthernetTest send %s\n", ethernet_msg);
AdapterDeviceSend(adapter, ethernet_msg, len);
PrivTaskDelay(4000);
}
while (1) {
AdapterDeviceRecv(adapter, ethernet_recv_msg, 128);
printf("AdapterEthernetTest recv %s\n", ethernet_recv_msg);
memset(ethernet_recv_msg, 0, 128);
}
#endif
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(AdapterEthernetTest,a ethernet adpter sample);
#elif definded ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterEthernetTest, AdapterEthernetTest, show adapter ethernet information);
#endif

View File

@@ -29,5 +29,7 @@ if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
config ADAPTER_HFA21_DRIVER
string "HFA21 device uart driver path"
default "/dev/uart3"
endif

View File

@@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = []
if GetDepend(['ADAPTER_HFA21_ETHERNET']):
src += ['hfa21_ethernet.c']
group = DefineGroup('connection ethernet hfa21', src, depend = [], CPPPATH = [cwd])
Return('group')

View File

@@ -72,7 +72,7 @@ static int Hfa21EthernetOpen(struct Adapter *adapter)
/*step2: init AT agent*/
if (!adapter->agent) {
char *agent_name = "ethernet_uart_client";
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
if (0 != InitATAgent(agent_name, adapter->fd, 512)) {
printf("at agent init failed !\n");
return -1;
}
@@ -168,19 +168,20 @@ static int Hfa21EthernetSetUp(struct Adapter *adapter)
Hfa21EthernetInitAtCmd(adapter->agent);
/*Step3 : FEPHY enable phy function*/
/*Step3 : FEPHY enable phy function*/
ret = AtCmdConfigAndCheck(adapter->agent, HFA21_ETHERNET_AT_FEPHY_CMD, HFA21_ETHERNET_OK_REPLY);
if (ret < 0) {
goto __exit;
}
PrivTaskDelay(2000);
/*Step4 : FVEW disable WANN function, ethernet work at LANN mode*/
ret = AtCmdConfigAndCheck(adapter->agent, HFA21_ETHERNET_AT_DISABLE_WANN_CMD, HFA21_ETHERNET_OK_REPLY);
if (ret < 0) {
goto __exit;
}
/*Step5 : RELD enable F-AT cmd*/
PrivTaskDelay(2000);
ret = AtCmdConfigAndCheck(adapter->agent, HFA21_ETHERNET_AT_RELD_CMD, HFA21_ETHERNET_OK_REPLY);
if (ret < 0) {
goto __exit;
@@ -195,13 +196,13 @@ static int Hfa21EthernetSetUp(struct Adapter *adapter)
if (ret < 0) {
goto __exit;
}
PrivTaskDelay(2000);
/*Step7 : AT+WANN check if get ip、netmask、gateway*/
ret = AtCmdConfigAndCheck(adapter->agent, HFA21_ETHERNET_AT_WANN_CMD, HFA21_ETHERNET_OK_REPLY);
if (ret < 0) {
goto __exit;
}
PrivTaskDelay(2000);
/*Step8 : AT+Z reboot hfa21 device*/
ret = AtCmdConfigAndCheck(adapter->agent, HFA21_ETHERNET_AT_REBOOT_CMD, HFA21_ETHERNET_OK_REPLY);
if (ret < 0) {
@@ -209,7 +210,6 @@ static int Hfa21EthernetSetUp(struct Adapter *adapter)
}
PrivTaskDelay(10000);
return ret;
__exit:
@@ -365,6 +365,7 @@ static int Hfa21EthernetConnect(struct Adapter *adapter, enum NetRoleType net_ro
}
adapter->net_role = net_role;
PrivTaskDelay(2000);
/*Step3 : AT+Z reboot hfa21 device*/
ret = AtCmdConfigAndCheck(adapter->agent, HFA21_ETHERNET_AT_REBOOT_CMD, HFA21_ETHERNET_OK_REPLY);

View File

@@ -0,0 +1,19 @@
import os
Import('RTT_ROOT')
from building import *
SOURCES = []
if GetDepend(['CONNECTION_ADAPTER_NB']):
SOURCES = ['adapter_nbiot.c'] + SOURCES
objs = []
cwd = GetCurrentDir()
path = [cwd]
group = DefineGroup('nb', SOURCES, depend = [], CPPPATH = [cwd])
objs = objs + group
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

View File

@@ -25,6 +25,8 @@
extern AdapterProductInfoType BC28Attach(struct Adapter *adapter);
#endif
#define ADAPTER_NBIOT_NAME "nbiot"
static int AdapterNbiotRegister(struct Adapter *adapter)
{
int ret = 0;
@@ -95,7 +97,13 @@ int opennb(void)
return 0;
}
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, opennb, opennb, show adapter nb information);
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(opennb,open nb sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, opennb, opennb, show adapter nb information);
#endif
int closenb(void)
{
int ret = 0;
@@ -113,8 +121,13 @@ int closenb(void)
return 0;
}
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, closenb, closenb, show adapter nb information);
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(closenb,close nb sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, closenb, closenb, show adapter nb information);
#endif
int connectnb(int argc, char *argv[])
{
const char *send_msg = argv[1];
@@ -133,7 +146,12 @@ int closenb(void)
return 0;
}
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, connectnb, connectnb, show adapter nb information);
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(connectnb,connect nb test);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, connectnb, connectnb, show adapter nb information);
#endif
int sendnb(int argc, char *argv[])
{
@@ -154,7 +172,12 @@ int closenb(void)
return 0;
}
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendnb, sendnb, show adapter nb information);
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(sendnb,send nb test);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendnb, sendnb, show adapter nb information);
#endif
int recvnb(void)
{
@@ -167,5 +190,9 @@ int closenb(void)
return 0;
}
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvnb, recvnb, show adapter nb information);
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(recvnb,receive nb test);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvnb, recvnb, show adapter nb information);
#endif

View File

@@ -36,5 +36,13 @@ if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
config ADAPTER_BC28_DRIVER
string "BC28 device uart driver path"
default "/dev/uart2"
config ADAPTER_BC28_PIN_DRIVER
string "BC28 device pin driver path"
default "/dev/pin"
config ADAPTER_BC28_RESETPIN
string "BC28 RESET pin number"
default "100"
endif

View File

@@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = []
if GetDepend(['ADAPTER_BC28']):
src += ['bc28.c']
group = DefineGroup('connection nb bc28', src, depend = [], CPPPATH = [cwd])
Return('group')

View File

@@ -490,7 +490,7 @@ static int BC28Open(struct Adapter *adapter)
/*step2: init AT agent*/
if (!adapter->agent) {
char *agent_name = "niot_device";
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
if (0 != InitATAgent(agent_name, adapter->fd, 512)) {
PrivClose(adapter->fd);
PrivMutexDelete(&nbiot_lock);
printf("at agent init failed !\n");

View File

@@ -2,7 +2,8 @@ import os
Import('RTT_ROOT')
from building import *
SOURCES = []
SOURCES = ['adapter_wifi.c'] + SOURCES
if GetDepend(['CONNECTION_ADAPTER_WIFI']):
SOURCES = ['adapter_wifi.c'] + SOURCES
objs = []
cwd = GetCurrentDir()
path = [cwd]

View File

@@ -195,3 +195,12 @@ void PrivFree(void *pointer)
free(pointer);
}
/*********************kernel**********************/
void PrivTaskenterCritical()
{
rt_enter_critical();
}
void PrivTaskexitCritical()
{
rt_exit_critical();
}

View File

@@ -38,6 +38,7 @@
#include <dfs_posix.h>
#include <dfs.h>
#include<sys/ioctl.h>
#include <sys/select.h>
#ifdef RT_USING_POSIX_TERMIOS
#include <posix_termios.h>
#endif
@@ -60,7 +61,7 @@
#ifdef __cplusplus
extern "C" {
#endif
typedef signed char bool;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
@@ -77,7 +78,7 @@ typedef unsigned long long uint64;
#endif
#define OPE_INT 0x0000
#define OPE_CFG 0x0001
#define OPE_CFG 0x0001
#define NAME_NUM_MAX 32
@@ -96,6 +97,9 @@ typedef unsigned long long uint64;
#define SERIAL_RB_BUFSZ 128
#endif
#define TRUE (1)
#define FALSE (0)
struct PinDevIrq
{
int irq_mode;//< RISING/FALLING/HIGH/LOW
@@ -197,6 +201,13 @@ void *PrivCalloc(size_t count, size_t size);
void PrivFree(void *pointer);
/*********************kernel**********************/
void PrivTaskenterCritical();
void PrivTaskexitCritical();
#ifdef __cplusplus
}
#endif