mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2025-07-31 20:31:05 +00:00
first commit
This commit is contained in:
commit
fa343db334
154 changed files with 18186 additions and 0 deletions
1
project/inc/.gitignore
vendored
Normal file
1
project/inc/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build_info.h
|
210
project/inc/FreeRTOSConfig.h
Normal file
210
project/inc/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
|
||||
FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
|
||||
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
distribute a combined work that includes FreeRTOS without being obliged to
|
||||
provide the source code for proprietary components outside of the FreeRTOS
|
||||
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong?" *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, training, latest versions, license
|
||||
and contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool.
|
||||
|
||||
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
|
||||
the code with commercial support, indemnification, and middleware, under
|
||||
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
|
||||
provide a safety engineered and independently SIL3 certified version under
|
||||
the SafeRTOS brand: http://www.SafeRTOS.com.
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
|
||||
#include <stdint.h>
|
||||
extern uint32_t SystemCoreClock;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ ( ( uint32_t ) 1000 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 90 * 1024 ) ) // use HEAP5
|
||||
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 0
|
||||
#define configUSE_CO_ROUTINES 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_TIMERS 1
|
||||
|
||||
#define configMAX_PRIORITIES ( 11 )
|
||||
#define PRIORITIE_OFFSET ( 4 )
|
||||
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 0
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 0
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
|
||||
#if configGENERATE_RUN_TIME_STATS
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() //( ulHighFrequencyTimerTicks = 0UL )
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() xTickCount //ulHighFrequencyTimerTicks
|
||||
#undef configUSE_TRACE_FACILITY
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define portCONFIGURE_STATS_PEROID_VALUE 1000 //unit Ticks
|
||||
#endif
|
||||
|
||||
#define configTIMER_TASK_PRIORITY ( 1 )
|
||||
|
||||
#ifdef CONFIG_UVC
|
||||
#define configTIMER_QUEUE_LENGTH ( 20 )
|
||||
#else
|
||||
#define configTIMER_QUEUE_LENGTH ( 10 )
|
||||
#endif
|
||||
|
||||
#define configTIMER_TASK_STACK_DEPTH ( 512 ) //USE_MIN_STACK_SIZE modify from 512 to 256
|
||||
|
||||
#if (__IASMARM__ != 1)
|
||||
|
||||
extern void freertos_pre_sleep_processing(unsigned int *expected_idle_time);
|
||||
extern void freertos_post_sleep_processing(unsigned int *expected_idle_time);
|
||||
extern int freertos_ready_to_sleep();
|
||||
|
||||
/* Enable tickless power saving. */
|
||||
#define configUSE_TICKLESS_IDLE 1
|
||||
|
||||
/* In wlan usage, this value is suggested to use value less than 80 milliseconds */
|
||||
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2
|
||||
|
||||
/* It's magic trick that let us can use our own sleep function */
|
||||
#define configPRE_SLEEP_PROCESSING( x ) ( freertos_pre_sleep_processing(&x) )
|
||||
|
||||
#define configPOST_SLEEP_PROCESSING( x ) ( freertos_post_sleep_processing(&x) )
|
||||
|
||||
/* It's magic trick that let us can enable/disable tickless dynamically */
|
||||
#define traceLOW_POWER_IDLE_BEGIN(); do { \
|
||||
if (!freertos_ready_to_sleep()) { \
|
||||
mtCOVERAGE_TEST_MARKER(); \
|
||||
break; \
|
||||
}
|
||||
|
||||
// portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );
|
||||
|
||||
#define traceLOW_POWER_IDLE_END(); } while (0);
|
||||
|
||||
/* It's FreeRTOS related feature but it's not included in FreeRTOS design. */
|
||||
#define configUSE_WAKELOCK_PMU 1
|
||||
|
||||
#endif // #if (__IASMARM__ != 1)
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_pcTaskGetTaskName 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
|
||||
/* Cortex-M specific definitions. */
|
||||
#ifdef __NVIC_PRIO_BITS
|
||||
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||
#else
|
||||
#define configPRIO_BITS 4 /* 15 priority levels */
|
||||
#endif
|
||||
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||
function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x0f
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
||||
|
||||
|
||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
//#define RTK_MODE_TIMER
|
||||
|
||||
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
30
project/inc/feep_config.h
Normal file
30
project/inc/feep_config.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* feep_config.h
|
||||
*
|
||||
* Created on: 06 нояб. 2016 г.
|
||||
* Author: PVV
|
||||
*/
|
||||
|
||||
#ifndef _INC_FEEP_CONFIG_H_
|
||||
#define _INC_FEEP_CONFIG_H_
|
||||
|
||||
#define FEEP_ID_WIFI_CFG 0x5730 // id:'0W', type: struct wlan_fast_reconnect
|
||||
#define FEEP_ID_WIFI_AP_CFG 0x5731 // id:'1W', type: struct rtw_wifi_config_t
|
||||
#define FEEP_ID_UART_CFG 0x5530 // id:'0U', type: UART_LOG_CONF
|
||||
#define FEEP_ID_LWIP_CFG 0x4C30 // id:'0L', type: struct atcmd_lwip_conf
|
||||
#define FEEP_ID_DHCP_CFG 0x4430 // id:'0D', type: struct _sdhcp_cfg
|
||||
|
||||
typedef struct _sdhcp_cfg {
|
||||
u8 mode; // =0 dhcp off, =1 - dhcp on, =2 Static ip, =3 - auto
|
||||
u32 ip;
|
||||
u32 mask;
|
||||
u32 gw;
|
||||
}dhcp_cfg;
|
||||
|
||||
/*
|
||||
#define FEEP_WRITE_WIFI_CFG(x) flash_write_cfg(x, FEEP_ID_WIFI_CFG, sizeof(struct wlan_fast_reconnect))
|
||||
#define FEEP_READ_WIFI_CFG(x) flash_read_cfg(x, FEEP_ID_WIFI_CFG, sizeof(struct wlan_fast_reconnect))
|
||||
*/
|
||||
|
||||
|
||||
#endif /* _INC_FEEP_CONFIG_H_ */
|
381
project/inc/lwipopts.h
Normal file
381
project/inc/lwipopts.h
Normal file
|
@ -0,0 +1,381 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file lwipopts.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 07-October-2011
|
||||
* @brief lwIP Options Configuration.
|
||||
* This file is based on Utilities\lwip_v1.3.2\src\include\lwip\opt.h
|
||||
* and contains the lwIP configuration for the STM32F2x7 demonstration.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "platform_opts.h"
|
||||
|
||||
/**
|
||||
* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first
|
||||
* local TCP/UDP pcb (default==0). This can prevent creating predictable port
|
||||
* numbers after booting a device.
|
||||
*/
|
||||
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1
|
||||
|
||||
#define WIFI_LOGO_CERTIFICATION_CONFIG 1 //for ping 10k test buffer setting
|
||||
/**
|
||||
* MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
|
||||
* instead of the lwip internal allocator. Can save code size if you
|
||||
* already use it.
|
||||
*/
|
||||
#define MEM_LIBC_MALLOC 1
|
||||
/**
|
||||
* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.
|
||||
* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution
|
||||
* speed and usage from interrupts!
|
||||
*/
|
||||
#define MEMP_MEM_MALLOC 1
|
||||
|
||||
/**
|
||||
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
|
||||
* critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
/* Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
|
||||
should be used instead */
|
||||
#define LWIP_COMPAT_MUTEX 1
|
||||
|
||||
#define ETHARP_TRUST_IP_MAC 0
|
||||
#define IP_REASSEMBLY 1
|
||||
#define IP_FRAG 1
|
||||
#define ARP_QUEUEING 0
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
|
||||
* field.
|
||||
*/
|
||||
#define LWIP_NETIF_HOSTNAME 1
|
||||
#define LWIP_NETIF_HOSTNAME_SIZE 16
|
||||
/**
|
||||
* netif0: DEF_HOSTNAME "0", netif1: DEF_HOSTNAME "1", ..
|
||||
*/
|
||||
#define DEF_HOSTNAME "rtl871x"
|
||||
|
||||
/**
|
||||
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
|
||||
* use lwIP facilities.
|
||||
*/
|
||||
#define NO_SYS 0
|
||||
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
#define MEM_ALIGNMENT 4
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define MEM_SIZE (10*1024) //for ping 10k test
|
||||
#else
|
||||
#define MEM_SIZE (5*1024)
|
||||
#endif
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 100
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 6
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 10
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 5
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#define MEMP_NUM_TCP_SEG 20
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 10
|
||||
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define PBUF_POOL_SIZE 30 //for ping 10k test
|
||||
#else
|
||||
#define PBUF_POOL_SIZE 20
|
||||
#endif
|
||||
|
||||
/* IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.*/
|
||||
#if WIFI_LOGO_CERTIFICATION_CONFIG
|
||||
#define IP_REASS_MAX_PBUFS 30 //for ping 10k test
|
||||
#else
|
||||
#define IP_REASS_MAX_PBUFS 10
|
||||
#endif
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
#define PBUF_POOL_BUFSIZE 500
|
||||
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#define TCP_SND_BUF (5*TCP_MSS)
|
||||
|
||||
/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
|
||||
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
|
||||
|
||||
#define TCP_SND_QUEUELEN (4* TCP_SND_BUF/TCP_MSS)
|
||||
|
||||
/* TCP receive window. */
|
||||
#define TCP_WND (4*TCP_MSS) // (2*TCP_MSS)
|
||||
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define LWIP_ICMP 1
|
||||
|
||||
/* ---------- ARP options ----------- */
|
||||
#define LWIP_ARP 1
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
|
||||
turning this on does currently not work. */
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
/* ---------- DNS options ---------- */
|
||||
#define LWIP_DNS 1
|
||||
|
||||
/* ---------- UPNP options --------- */
|
||||
#define LWIP_UPNP 0
|
||||
|
||||
/* Support Multicast */
|
||||
#define LWIP_IGMP 1
|
||||
#define LWIP_RAND() Rand()
|
||||
|
||||
/* Support TCP Keepalive */
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
/*LWIP_UART_ADAPTER==1: Enable LWIP_UART_ADAPTER when CONFIG_GAGENT is enabled,
|
||||
because some GAGENT functions denpond on the following macro definitions.*/
|
||||
#if CONFIG_EXAMPLE_UART_ADAPTER
|
||||
#define LWIP_UART_ADAPTER 1
|
||||
#else
|
||||
#define LWIP_UART_ADAPTER 0
|
||||
#endif
|
||||
|
||||
#if LWIP_UART_ADAPTER
|
||||
#undef LWIP_SO_SNDTIMEO
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
#undef SO_REUSE
|
||||
#define SO_REUSE 1
|
||||
|
||||
#undef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
#define TCP_KEEPIDLE_DEFAULT 10000UL
|
||||
#define TCP_KEEPINTVL_DEFAULT 1000UL
|
||||
#define TCP_KEEPCNT_DEFAULT 10U
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#undef LWIP_SO_SNDTIMEO
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
|
||||
#undef SO_REUSE
|
||||
#define SO_REUSE 1
|
||||
|
||||
#undef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 10
|
||||
|
||||
#undef MEMP_NUM_TCP_PCB
|
||||
#define MEMP_NUM_TCP_PCB (MEMP_NUM_NETCONN)
|
||||
|
||||
#undef MEMP_NUM_UDP_PCB
|
||||
#define MEMP_NUM_UDP_PCB (MEMP_NUM_NETCONN)
|
||||
|
||||
#undef TCP_WND
|
||||
#define TCP_WND (4*TCP_MSS)
|
||||
|
||||
#define TCP_KEEPIDLE_DEFAULT 10000UL
|
||||
#define TCP_KEEPINTVL_DEFAULT 1000UL
|
||||
#define TCP_KEEPCNT_DEFAULT 10U
|
||||
|
||||
#define ERRNO 1
|
||||
#endif
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#define LWIP_STATS 0
|
||||
#define LWIP_PROVIDE_ERRNO 1
|
||||
|
||||
|
||||
/*
|
||||
--------------------------------------
|
||||
---------- Checksum options ----------
|
||||
--------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
The STM32F2x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
|
||||
- To use this feature let the following define uncommented.
|
||||
- To disable it and process by CPU comment the the checksum.
|
||||
*/
|
||||
//Do checksum by lwip - WLAN nic does not support Checksum offload
|
||||
//#define CHECKSUM_BY_HARDWARE
|
||||
|
||||
|
||||
#ifdef CHECKSUM_BY_HARDWARE
|
||||
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 0
|
||||
/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 0
|
||||
/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 0
|
||||
/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 0
|
||||
/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 0
|
||||
#else
|
||||
/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
|
||||
#define CHECKSUM_GEN_IP 1
|
||||
/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
|
||||
#define CHECKSUM_GEN_UDP 1
|
||||
/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
|
||||
#define CHECKSUM_GEN_TCP 1
|
||||
/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
|
||||
#define CHECKSUM_CHECK_IP 1
|
||||
/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
|
||||
#define CHECKSUM_CHECK_UDP 1
|
||||
/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------------------
|
||||
---------- Sequential layer options ----------
|
||||
----------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
|
||||
*/
|
||||
#define LWIP_NETCONN 1
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
---------- Socket options ----------
|
||||
------------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
|
||||
*/
|
||||
#define LWIP_SOCKET 1
|
||||
|
||||
/*
|
||||
-----------------------------------
|
||||
---------- DEBUG options ----------
|
||||
-----------------------------------
|
||||
*/
|
||||
|
||||
#define LWIP_DEBUG 0
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
---------- OS options ----------
|
||||
---------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
|
||||
* The stack size value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define TCPIP_THREAD_STACKSIZE 1000
|
||||
/**
|
||||
* TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
|
||||
* The queue size value itself is platform-dependent, but is passed to
|
||||
* sys_mbox_new() when tcpip_init is called.
|
||||
*/
|
||||
#define TCPIP_MBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
|
||||
* NETCONN_RAW. The queue size value itself is platform-dependent, but is passed
|
||||
* to sys_mbox_new() when the recvmbox is created.
|
||||
*/
|
||||
#define DEFAULT_RAW_RECVMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
|
||||
* The queue size value itself is platform-dependent, but is passed to
|
||||
* sys_mbox_new() when the acceptmbox is created.
|
||||
*/
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 6
|
||||
/**
|
||||
* DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread.
|
||||
* The stack size value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define DEFAULT_THREAD_STACKSIZE 500
|
||||
/**
|
||||
* TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
|
||||
* The priority value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#define TCPIP_THREAD_PRIO (configMAX_PRIORITIES - 2)
|
||||
|
||||
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
|
||||
* by your system, set this to 0 and include <sys/time.h> in cc.h */
|
||||
#if defined(_SYS__TIMEVAL_H_)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#endif
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
119
project/inc/main.h
Normal file
119
project/inc/main.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <autoconf.h>
|
||||
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
/* Header file declaration*/
|
||||
void wlan_network();
|
||||
|
||||
/* Interactive Mode */
|
||||
#define SERIAL_DEBUG_RX 1
|
||||
|
||||
/* WLAN and Netork */
|
||||
#define STA_MODE_SSID "ap" /* Set SSID here */
|
||||
#define AP_MODE_SSID "wlan_ap_ssid" /* Set SSID here */
|
||||
#define AP_DEFAULT_CH 6
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#define WLAN1_NAME "wlan1"
|
||||
#define WPA_PASSPHRASE "1234567890" /* Max 32 cahracters */
|
||||
#define WEP40_KEY {0x12, 0x34, 0x56, 0x78, 0x90}
|
||||
|
||||
#define ATVER_1 1 // For First AT command
|
||||
#define ATVER_2 2 // For UART Module AT command
|
||||
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#define ATCMD_VER ATVER_2
|
||||
#else
|
||||
#define ATCMD_VER ATVER_1
|
||||
#endif
|
||||
|
||||
#if ATCMD_VER == ATVER_2
|
||||
|
||||
extern unsigned char sta_ip[4], sta_netmask[4], sta_gw[4];
|
||||
extern unsigned char ap_ip[4], ap_netmask[4], ap_gw[4];
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define IP_ADDR0 sta_ip[0]
|
||||
#define IP_ADDR1 sta_ip[1]
|
||||
#define IP_ADDR2 sta_ip[2]
|
||||
#define IP_ADDR3 sta_ip[3]
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 sta_netmask[0]
|
||||
#define NETMASK_ADDR1 sta_netmask[1]
|
||||
#define NETMASK_ADDR2 sta_netmask[2]
|
||||
#define NETMASK_ADDR3 sta_netmask[3]
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 sta_gw[0]
|
||||
#define GW_ADDR1 sta_gw[1]
|
||||
#define GW_ADDR2 sta_gw[2]
|
||||
#define GW_ADDR3 sta_gw[3]
|
||||
|
||||
/*******************************************/
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define AP_IP_ADDR0 ap_ip[0]
|
||||
#define AP_IP_ADDR1 ap_ip[1]
|
||||
#define AP_IP_ADDR2 ap_ip[2]
|
||||
#define AP_IP_ADDR3 ap_ip[3]
|
||||
|
||||
/*NETMASK*/
|
||||
#define AP_NETMASK_ADDR0 ap_netmask[0]
|
||||
#define AP_NETMASK_ADDR1 ap_netmask[1]
|
||||
#define AP_NETMASK_ADDR2 ap_netmask[2]
|
||||
#define AP_NETMASK_ADDR3 ap_netmask[3]
|
||||
|
||||
/*Gateway Address*/
|
||||
#define AP_GW_ADDR0 ap_gw[0]
|
||||
#define AP_GW_ADDR1 ap_gw[1]
|
||||
#define AP_GW_ADDR2 ap_gw[2]
|
||||
#define AP_GW_ADDR3 ap_gw[3]
|
||||
|
||||
#else
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define IP_ADDR0 192
|
||||
#define IP_ADDR1 168
|
||||
#define IP_ADDR2 3
|
||||
#define IP_ADDR3 80
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 255
|
||||
#define NETMASK_ADDR1 255
|
||||
#define NETMASK_ADDR2 255
|
||||
#define NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 192
|
||||
#define GW_ADDR1 168
|
||||
#define GW_ADDR2 3
|
||||
#define GW_ADDR3 1
|
||||
|
||||
/*******************************************/
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define AP_IP_ADDR0 192
|
||||
#define AP_IP_ADDR1 168
|
||||
#define AP_IP_ADDR2 43
|
||||
#define AP_IP_ADDR3 1
|
||||
|
||||
/*NETMASK*/
|
||||
#define AP_NETMASK_ADDR0 255
|
||||
#define AP_NETMASK_ADDR1 255
|
||||
#define AP_NETMASK_ADDR2 255
|
||||
#define AP_NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define AP_GW_ADDR0 192
|
||||
#define AP_GW_ADDR1 168
|
||||
#define AP_GW_ADDR2 43
|
||||
#define AP_GW_ADDR3 1
|
||||
|
||||
#endif //#if ATCMD_VER == ATVER_2
|
||||
|
||||
#endif
|
251
project/inc/platform_autoconf.h
Normal file
251
project/inc/platform_autoconf.h
Normal file
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* Automatically generated by make menuconfig: don't edit
|
||||
*/
|
||||
#define AUTOCONF_INCLUDED
|
||||
|
||||
#define RTL8710AF
|
||||
//#define RTL8711AM
|
||||
/* Image1 on project */
|
||||
#define PRESENT_IMAGE1
|
||||
/* Image2 on project */
|
||||
#define PRESENT_IMAGE2
|
||||
/*
|
||||
* Target Platform Selection
|
||||
*/
|
||||
#define CONFIG_WITHOUT_MONITOR 1
|
||||
|
||||
#undef CONFIG_RTL8195A
|
||||
#define CONFIG_RTL8195A 1
|
||||
#undef CONFIG_FPGA
|
||||
#undef CONFIG_RTL_SIM
|
||||
#undef CONFIG_POST_SIM
|
||||
/*
|
||||
* < Mass Production Option
|
||||
*/
|
||||
#undef CONFIG_MP
|
||||
#undef CONFIG_CP
|
||||
#undef CONFIG_FT
|
||||
#define RTL8195A 1
|
||||
/* 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000? Hz,
|
||||
6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000? Hz */
|
||||
#define CONFIG_CPU_CLK 1
|
||||
//166.6MHZ - RUN/IDLE/SLP ~63/21/6.4 mA
|
||||
//83.3MHZ - RUN/IDLE/SLP ~55/15/6.4 mA
|
||||
//41.6MHZ - RUN/IDLE ~51/11 mA
|
||||
//20.8MHZ - RUN/IDLE ~49/9.5 mA
|
||||
//4MHZ - IDLE ~8 mA
|
||||
#undef CONFIG_FPGA_CLK
|
||||
#define CONFIG_SDR_CLK 1
|
||||
#define CONFIG_SDR_100MHZ 1
|
||||
#undef CONFIG_SDR_50MHZ
|
||||
#undef CONFIG_SDR_25MHZ
|
||||
#undef CONFIG_SDR_12_5MHZ
|
||||
#define SDR_CLOCK_SEL_VALUE (0)
|
||||
#define CONFIG_BOOT_PROCEDURE 1
|
||||
#define CONFIG_IMAGE_PAGE_LOAD 1
|
||||
#undef CONFIG_IMAGE_AUTO_LOAD
|
||||
#undef CONFIG_IMAGE_PAGE_LOAD
|
||||
//#define CONFIG_IMAGE_AUTO_LOAD 1
|
||||
//#define CONFIG_BOOT_TO_UPGRADE_IMG2 1
|
||||
#undef CONFIG_PERI_UPDATE_IMG
|
||||
#define CONFIG_BOOT_FROM_JTAG 1
|
||||
#undef CONFIG_ALIGNMENT_EXCEPTION_ENABLE
|
||||
#define CONFIG_KERNEL 1
|
||||
#define PLATFORM_FREERTOS 1
|
||||
#undef PLATFORM_UCOSII
|
||||
#undef PLATFORM_ECOS
|
||||
#undef CONFIG_TASK_SCHEDUL_DIS
|
||||
#define TASK_SCHEDULER_DISABLED (0)
|
||||
#define CONFIG_NORMALL_MODE 1
|
||||
#undef CONFIG_MEMORY_VERIFY_MODE
|
||||
#define CONFIG_TIMER_EN 1
|
||||
#define CONFIG_TIMER_NORMAL 1
|
||||
#undef CONFIG_TIMER_TEST
|
||||
#define CONFIG_TIMER_MODULE 1
|
||||
#define CONFIG_WDG 1
|
||||
#undef CONFIG_WDG_NON
|
||||
#define CONFIG_WDG_NORMAL 1
|
||||
#define CONFIG_WDG_ON_IDLE 10 // add pvvx: wdt on 10 s -> main.c + tasks.c
|
||||
#define CONFIG_GDMA_EN 1
|
||||
#define CONFIG_GDMA_NORMAL 1
|
||||
#undef CONFIG_GDMA_TEST
|
||||
#define CONFIG_GDMA_MODULE 1
|
||||
#define CONFIG_WIFI_EN 1
|
||||
#define CONFIG_WIFI_NORMAL 1
|
||||
#undef CONFIG_WIFI_TEST
|
||||
#define CONFIG_WIFI_MODULE 1
|
||||
#define CONFIG_GPIO_EN 1
|
||||
#define CONFIG_GPIO_NORMAL 1
|
||||
#undef CONFIG_GPIO_TEST
|
||||
#define CONFIG_GPIO_MODULE 1
|
||||
#if defined(CONFIG_INIC) || (CONFIG_SDIOD)
|
||||
#define CONFIG_SDIO_DEVICE_EN 1
|
||||
#define CONFIG_SDIO_DEVICE_NORMAL 1
|
||||
#undef CONFIG_SDIO_DEVICE_TEST
|
||||
#define CONFIG_SDIO_DEVICE_MODULE 1
|
||||
#else
|
||||
#undef CONFIG_SDIO_DEVICE_EN
|
||||
#endif
|
||||
#define CONFIG_SDIO_HOST_EN 1
|
||||
//#define CONFIG_USB_EN 1
|
||||
#undef CONFIG_USB_NORMAL
|
||||
#define CONFIG_USB_TEST 1
|
||||
#define CONFIG_USB_MODULE 1
|
||||
#define CONFIG_USB_VERIFY 1
|
||||
#undef CONFIG_USB_ROM_LIB
|
||||
//#define CONFIG_USB_DBGINFO_EN 1
|
||||
#if defined(CONFIG_INIC) || (CONFIG_USBD)
|
||||
#define DWC_DEVICE_ONLY 1
|
||||
#else
|
||||
#define DWC_HOST_ONLY 1
|
||||
#define CONFIG_USB_HOST_ONLY 1
|
||||
#endif
|
||||
#define CONFIG_SPI_COM_EN 1
|
||||
#define CONFIG_SPI_COM_NORMAL 1
|
||||
#undef CONFIG_SPI_COM_TEST
|
||||
#define CONFIG_SPI_COM_MODULE 1
|
||||
#define CONFIG_UART_EN 1
|
||||
#define CONFIG_UART_NORMAL 1
|
||||
#undef CONFIG_UART_TEST
|
||||
#define CONFIG_UART_MODULE 1
|
||||
#define CONFIG_I2C_EN 1
|
||||
#define CONFIG_I2C_NORMAL 1
|
||||
#undef CONFIG_I2C_TEST
|
||||
#define CONFIG_I2C_MODULE 1
|
||||
#undef CONFIG_DEBUG_LOG_I2C_HAL
|
||||
#undef CONFIG_PCM_EN
|
||||
#define CONFIG_I2S_EN 1
|
||||
#define CONFIG_I2S_NORMAL 1
|
||||
#undef CONFIG_I2S_TEST
|
||||
#define CONFIG_I2S_MODULE 1
|
||||
#undef CONFIG_DEBUG_LOG_I2S_HAL
|
||||
#define CONFIG_NFC_EN 1
|
||||
#define CONFIG_NFC_NORMAL 1
|
||||
#undef CONFIG_NFC_TEST
|
||||
#define CONFIG_NFC_MODULE 1
|
||||
#define CONFIG_SOC_PS_EN 1
|
||||
#define CONFIG_SOC_PS_NORMAL 1
|
||||
#undef CONFIG_SOC_PS_TEST
|
||||
#define CONFIG_SOC_PS_MODULE 1 // hal_soc_ps_monitor.c
|
||||
//#define CONFIG_SOC_PS_VERIFY 1 // hal_soc_ps_monitor.c
|
||||
#define CONFIG_CRYPTO_EN 1
|
||||
#define CONFIG_CRYPTO_NORMAL 1
|
||||
#undef CONFIG_CRYPTO_TEST
|
||||
#define CONFIG_CRYPTO_MODULE 1
|
||||
#define CONFIG_CRYPTO_STARTUP 1
|
||||
#define CONFIG_MII_EN 0 //1
|
||||
#define CONFIG_PWM_EN 1
|
||||
#define CONFIG_PWM_NORMAL 1
|
||||
#undef CONFIG_PWM_TEST
|
||||
#define CONFIG_PWM_MODULE 1
|
||||
#define CONFIG_EFUSE_EN 1 // common/mbed/targets/hal/rtl8195a/efuse_api.c
|
||||
#define CONFIG_EFUSE_NORMAL 1
|
||||
#undef CONFIG_EFUSE_TEST
|
||||
#define CONFIG_EFUSE_MODULE 1
|
||||
#ifdef RTL8711AM
|
||||
#define CONFIG_SDR_EN 1
|
||||
#endif
|
||||
#define CONFIG_SDR_NORMAL 1
|
||||
#undef CONFIG_SDR_TEST
|
||||
#define CONFIG_SDR_MODULE 1
|
||||
#define CONFIG_SPIC_EN 1
|
||||
#define CONFIG_SPIC_NORMAL 1
|
||||
#undef CONFIG_SPIC_TEST
|
||||
#define CONFIG_SPIC_MODULE 1
|
||||
#define CONFIG_ADC_EN 1
|
||||
//#define CONFIG_DAC_EN 1
|
||||
#define CONFIG_NOR_FLASH 1
|
||||
#undef CONFIG_SPI_FLASH
|
||||
#undef CONFIG_NAND_FLASH
|
||||
#undef CONFIG_NONE_FLASH
|
||||
#undef CONFIG_BTBX_EN
|
||||
|
||||
// add pvvx
|
||||
#define CONFIG_LOG_UART_EN 1
|
||||
|
||||
/*
|
||||
* < Engineer Mode Config
|
||||
*/
|
||||
#undef CONFIG_JTAG
|
||||
#undef CONFIG_COMPILE_FLASH_DOWNLOAD_CODE
|
||||
#undef CONIFG_COMPILE_EXTERNAL_SRAM_CALIBRATE
|
||||
#undef CONFIG_CMSIS_MATH_LIB_EN
|
||||
|
||||
/*
|
||||
* < Application Config
|
||||
*/
|
||||
#define CONFIG_NETWORK 1
|
||||
#define CONFIG_RTLIB_EN 1
|
||||
#define CONFIG_RTLIB_NORMAL 1
|
||||
#undef CONFIG_RTLIB_TEST
|
||||
#define CONFIG_RTLIB_MODULE 1
|
||||
|
||||
/*
|
||||
* < System Debug Message Config
|
||||
*/
|
||||
#define CONFIG_UART_LOG_HISTORY 1
|
||||
#undef CONFIG_CONSOLE_NORMALL_MODE
|
||||
#define CONFIG_CONSOLE_VERIFY_MODE 1
|
||||
|
||||
/* CONFIG_DEBUG_LOG:
|
||||
=0 Off all diag/debug msg,
|
||||
=1 Only errors,
|
||||
=2 errors + warning, (default)
|
||||
=3 errors + warning + info,
|
||||
=4 errors + warning + info + debug,
|
||||
=5 full */
|
||||
#define CONFIG_DEBUG_LOG 2
|
||||
#if CONFIG_DEBUG_LOG > 0
|
||||
//#define CONFIG_DEBUG_ERR_MSG 1
|
||||
#define CONFIG_DEBUG_LOG_ADC_HAL 1
|
||||
#define CONFIG_DEBUG_LOG_I2S_HAL 1
|
||||
//#undef CONFIG_DEBUG_WARN_MSG
|
||||
//#undef CONFIG_DEBUG_INFO_MSG
|
||||
#endif // CONFIG_DEBUG_LOG
|
||||
/*
|
||||
* < SDK Option Config
|
||||
*/
|
||||
#undef CONFIG_MBED_ENABLED
|
||||
#undef CONFIG_APP_DEMO
|
||||
|
||||
/*
|
||||
* < Select Chip Version
|
||||
*/
|
||||
#undef CONFIG_CHIP_A_CUT
|
||||
#define CONFIG_CHIP_B_CUT 1
|
||||
#undef CONFIG_CHIP_C_CUT
|
||||
#undef CONFIG_CHIP_E_CUT
|
||||
|
||||
/*
|
||||
* < Select toolchain
|
||||
*/
|
||||
#undef CONFIG_TOOLCHAIN_ASDK
|
||||
#undef CONFIG_TOOLCHAIN_ARM_GCC
|
||||
|
||||
/*
|
||||
* < Build Option
|
||||
*/
|
||||
#define CONFIG_LINK_ROM_LIB 1
|
||||
#undef CONFIG_LINK_ROM_SYMB
|
||||
#undef CONFIG_NORMAL_BUILD
|
||||
#undef CONFIG_RELEASE_BUILD
|
||||
#undef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
#undef CONFIG_LIB_BUILD_RAM
|
||||
#define CONFIG_RELEASE_BUILD_RAM_ALL 1
|
||||
#undef CONFIG_IMAGE_ALL
|
||||
#define CONFIG_IMAGE_SEPARATE 1
|
||||
|
||||
#if CONFIG_CPU_CLK < 6
|
||||
#define CPU_CLOCK_SEL_DIV5_3 0
|
||||
#define CPU_CLOCK_SEL_VALUE CONFIG_CPU_CLK
|
||||
#else
|
||||
#define CPU_CLOCK_SEL_DIV5_3 1
|
||||
#define CPU_CLOCK_SEL_VALUE (CONFIG_CPU_CLK-6)
|
||||
#endif
|
||||
|
||||
#if CPU_CLOCK_SEL_DIV5_3
|
||||
#define PLATFORM_CLOCK (200000000ul>>CPU_CLOCK_SEL_VALUE)
|
||||
#else
|
||||
#define PLATFORM_CLOCK (((200000000ul*5ul)/6ul)>>CPU_CLOCK_SEL_VALUE)
|
||||
#endif
|
||||
|
172
project/inc/platform_opts.h
Normal file
172
project/inc/platform_opts.h
Normal file
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
*This file contains general configurations for ameba platform
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __PLATFORM_OPTS_H__
|
||||
#define __PLATFORM_OPTS_H__
|
||||
|
||||
/*For MP mode setting*/
|
||||
#define SUPPORT_MP_MODE 0
|
||||
|
||||
/**
|
||||
* For AT cmd Log service configurations
|
||||
*/
|
||||
#define SUPPORT_LOG_SERVICE 0
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
#define LOG_SERVICE_BUFLEN 100 //can't larger than UART_LOG_CMD_BUFLEN(127)
|
||||
#define CONFIG_LOG_HISTORY 0
|
||||
#if CONFIG_LOG_HISTORY
|
||||
#define LOG_HISTORY_LEN 5
|
||||
#endif
|
||||
#define SUPPORT_INTERACTIVE_MODE 0 //on/off wifi_interactive_mode
|
||||
#define CONFIG_LOG_SERVICE_LOCK 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For interactive mode configurations, depends on log service
|
||||
*/
|
||||
#if SUPPORT_INTERACTIVE_MODE
|
||||
#define CONFIG_INTERACTIVE_MODE 1
|
||||
#define CONFIG_INTERACTIVE_EXT 0
|
||||
#else
|
||||
#define CONFIG_INTERACTIVE_MODE 0
|
||||
#define CONFIG_INTERACTIVE_EXT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For FreeRTOS tickless configurations
|
||||
*/
|
||||
#define FREERTOS_PMU_TICKLESS_PLL_RESERVED 0 // In sleep mode, 0: close PLL clock, 1: reserve PLL clock
|
||||
#define FREERTOS_PMU_TICKLESS_SUSPEND_SDRAM 1 // In sleep mode, 1: suspend SDRAM, 0: no act
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* For common flash usage
|
||||
*/
|
||||
#define AP_SETTING_SECTOR 0x000FE000
|
||||
#define UART_SETTING_SECTOR 0x000FC000
|
||||
#define FAST_RECONNECT_DATA (0x80000 - 0x1000)
|
||||
|
||||
/**
|
||||
* For Wlan configurations
|
||||
*/
|
||||
|
||||
#define CONFIG_WLAN 1
|
||||
#if CONFIG_WLAN
|
||||
#define CONFIG_LWIP_LAYER 1
|
||||
#define CONFIG_AT_USR 1 // add pvxx
|
||||
//#define CONFIG_AT_LWIP 1 // add pvxx
|
||||
//#define CONFIG_AT_SYS 1 // add pvxx
|
||||
//#define CONFIG_AT_WIFI 1 // add pvxx
|
||||
#define CONFIG_INIT_NET 1 // init lwip layer when start up
|
||||
#define CONFIG_WIFI_IND_USE_THREAD 0 // wifi indicate worker thread
|
||||
|
||||
//on/off relative commands in log service
|
||||
#define CONFIG_SSL_CLIENT 0
|
||||
#define CONFIG_WEBSERVER 0
|
||||
#define CONFIG_OTA_UPDATE 0
|
||||
#define CONFIG_BSD_TCP 0 //NOTE : Enable CONFIG_BSD_TCP will increase about 11KB code size
|
||||
#define CONFIG_AIRKISS 0 //on or off tencent airkiss
|
||||
#define CONFIG_UART_SOCKET 0 // Set: CONFIG_UART_EN, CONFIG_UART_SOCKET
|
||||
#define CONFIG_UART_XMODEM 0 //support uart xmodem upgrade or not
|
||||
#define CONFIG_TRANSPORT 0 //on or off the at command for transport socket
|
||||
|
||||
/* For WPS and P2P */
|
||||
#define CONFIG_ENABLE_WPS 0
|
||||
#define CONFIG_ENABLE_P2P 0
|
||||
#if CONFIG_ENABLE_P2P
|
||||
#define CONFIG_ENABLE_WPS_AP 1
|
||||
#undef CONFIG_WIFI_IND_USE_THREAD
|
||||
#define CONFIG_WIFI_IND_USE_THREAD 1
|
||||
#endif
|
||||
#if (CONFIG_ENABLE_P2P && ((CONFIG_ENABLE_WPS_AP == 0) || (CONFIG_ENABLE_WPS == 0)))
|
||||
#error "If CONFIG_ENABLE_P2P, need to define CONFIG_ENABLE_WPS_AP 1"
|
||||
#endif
|
||||
|
||||
/* For Simple Link */
|
||||
#define CONFIG_INCLUDE_SIMPLE_CONFIG 0
|
||||
|
||||
/*For wowlan service settings*/
|
||||
#define CONFIG_WOWLAN_SERVICE 0
|
||||
|
||||
#endif //end of #if CONFIG_WLAN
|
||||
/*******************************************************************************/
|
||||
|
||||
/**
|
||||
* For Ethernet configurations
|
||||
*/
|
||||
#define CONFIG_ETHERNET 0
|
||||
#if CONFIG_ETHERNET
|
||||
|
||||
#define CONFIG_LWIP_LAYER 1
|
||||
#define CONFIG_INIT_NET 1 //init lwip layer when start up
|
||||
|
||||
//on/off relative commands in log service
|
||||
#define CONFIG_SSL_CLIENT 0
|
||||
#define CONFIG_BSD_TCP 0 //NOTE : Enable CONFIG_BSD_TCP will increase about 11KB code size
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* For iNIC configurations
|
||||
*/
|
||||
#ifdef CONFIG_INIC //this flag is defined in IAR project
|
||||
#define CONFIG_INIC_EN 1 //enable iNIC mode
|
||||
#undef CONFIG_ENABLE_WPS
|
||||
#define CONFIG_ENABLE_WPS 1
|
||||
#undef CONFIG_INCLUDE_SIMPLE_CONFIG
|
||||
#define CONFIG_INCLUDE_SIMPLE_CONFIG 1
|
||||
#undef CONFIG_WOWLAN_SERVICE
|
||||
#define CONFIG_WOWLAN_SERVICE 1
|
||||
#undef LOG_SERVICE_BUFLEN
|
||||
#define LOG_SERVICE_BUFLEN 256
|
||||
#undef CONFIG_LWIP_LAYER
|
||||
#define CONFIG_LWIP_LAYER 0
|
||||
#undef CONFIG_OTA_UPDATE
|
||||
#define CONFIG_OTA_UPDATE 0
|
||||
#undef CONFIG_EXAMPLE_WLAN_FAST_CONNECT
|
||||
#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0
|
||||
#define CONFIG_INIC_SDIO_HCI 1 //for SDIO or USB iNIC
|
||||
#define CONFIG_INIC_USB_HCI 0
|
||||
#define CONFIG_INIC_CMD_RSP 1 //need to return msg to host
|
||||
#endif
|
||||
/******************End of iNIC configurations*******************/
|
||||
|
||||
/* For UART Module AT command example */
|
||||
#define CONFIG_EXAMPLE_UART_ATCMD 0
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#undef FREERTOS_PMU_TICKLESS_PLL_RESERVED
|
||||
#define FREERTOS_PMU_TICKLESS_PLL_RESERVED 1
|
||||
#undef CONFIG_OTA_UPDATE
|
||||
#define CONFIG_OTA_UPDATE 1
|
||||
#undef CONFIG_TRANSPORT
|
||||
#define CONFIG_TRANSPORT 1
|
||||
#undef LOG_SERVICE_BUFLEN
|
||||
#define LOG_SERVICE_BUFLEN 1600
|
||||
#undef CONFIG_LOG_SERVICE_LOCK
|
||||
#define CONFIG_LOG_SERVICE_LOCK 1
|
||||
#else
|
||||
#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 0
|
||||
#endif
|
||||
|
||||
//#define CONFIG_EXAMPLE_UART_ADAPTER 1
|
||||
//#define CONFIG_EXAMPLE_MDNS
|
||||
#define USE_FLASH_EEP 1
|
||||
#define CONFIG_WLAN_CONNECT_CB 1
|
||||
|
||||
//#define CONFIG_FATFS_EN 1 // FatFs & SD
|
||||
#ifdef CONFIG_FATFS_EN
|
||||
// fatfs version
|
||||
#define FATFS_R_10C
|
||||
// fatfs disk interface
|
||||
#define FATFS_DISK_USB 0
|
||||
#define FATFS_DISK_SD 1
|
||||
#undef CONFIG_SDIO_HOST_EN
|
||||
#define CONFIG_SDIO_HOST_EN 1
|
||||
#endif
|
||||
|
||||
#endif //__PLATFORM_OPTS_H__
|
96
project/inc/rtl8195a/c_types.h
Normal file
96
project/inc/rtl8195a/c_types.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2010 - 2011 Espressif System
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _C_TYPES_H_
|
||||
#define _C_TYPES_H_
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char sint8_t;
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed short sint16_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef signed long sint32_t;
|
||||
typedef signed long int32_t;
|
||||
typedef signed long long sint64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned long long u_int64_t;
|
||||
typedef float real32_t;
|
||||
typedef double real64_t;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned char u8;
|
||||
typedef signed char sint8;
|
||||
typedef signed char int8;
|
||||
typedef signed char s8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned short u16;
|
||||
typedef signed short sint16;
|
||||
typedef signed short s16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned int u32;
|
||||
typedef signed int sint32;
|
||||
typedef signed int s32;
|
||||
typedef int int32;
|
||||
typedef signed long long sint64;
|
||||
typedef unsigned long long uint64;
|
||||
typedef unsigned long long u64;
|
||||
typedef float real32;
|
||||
typedef double real64;
|
||||
|
||||
#define __le16 u16
|
||||
|
||||
typedef unsigned int size_t;
|
||||
typedef int ssize_t;
|
||||
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#define __packed __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#define LOCAL static
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif /* NULL */
|
||||
|
||||
/* probably should not put STATUS here */
|
||||
typedef enum {
|
||||
OK = 0,
|
||||
FAIL,
|
||||
PENDING,
|
||||
BUSY,
|
||||
CANCEL,
|
||||
} STATUS;
|
||||
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
|
||||
#define REG_SET_BIT(_r, _b) (*(volatile uint32_t*)(_r) |= (_b))
|
||||
#define REG_CLR_BIT(_r, _b) (*(volatile uint32_t*)(_r) &= ~(_b))
|
||||
|
||||
#define DMEM_ATTR
|
||||
#define SHMEM_ATTR
|
||||
|
||||
#ifdef ICACHE_FLASH
|
||||
#define ICACHE_FLASH_ATTR
|
||||
#define ICACHE_RODATA_ATTR
|
||||
#else
|
||||
#define ICACHE_FLASH_ATTR
|
||||
#define ICACHE_RODATA_ATTR
|
||||
#endif /* ICACHE_FLASH */
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef unsigned char bool;
|
||||
//#define BOOL bool
|
||||
#define true (1)
|
||||
#define false (0)
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
|
||||
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#endif /* _C_TYPES_H_ */
|
593
project/inc/rtl8195a/os.h
Normal file
593
project/inc/rtl8195a/os.h
Normal file
|
@ -0,0 +1,593 @@
|
|||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef OS_H
|
||||
#define OS_H
|
||||
|
||||
//#include "basic_types.h"
|
||||
#include <autoconf.h>
|
||||
#include "osdep_service.h"
|
||||
#include "freertos/wrapper.h"
|
||||
#include "utils/rom/rom_wps_os.h"
|
||||
|
||||
typedef void* xqueue_handle_t;
|
||||
|
||||
typedef long os_time_t;
|
||||
|
||||
typedef _timer os_timer;
|
||||
|
||||
/**
|
||||
* os_sleep - Sleep (sec, usec)
|
||||
* @sec: Number of seconds to sleep
|
||||
* @usec: Number of microseconds to sleep
|
||||
*/
|
||||
void os_sleep(os_time_t sec, os_time_t usec);
|
||||
|
||||
struct os_time {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
struct os_reltime {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
/**
|
||||
* os_get_time - Get current time (sec, usec)
|
||||
* @t: Pointer to buffer for the time
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_time(struct os_time *t);
|
||||
|
||||
int os_get_reltime(struct os_reltime *t);
|
||||
/* Helper macros for handling struct os_time */
|
||||
/* (&timeout->time, &tmp->time) */
|
||||
#define os_time_before(a, b) \
|
||||
((a)->sec < (b)->sec || \
|
||||
((a)->sec == (b)->sec && (a)->usec < (b)->usec))
|
||||
|
||||
#define os_time_sub(a, b, res) do { \
|
||||
(res)->sec = (a)->sec - (b)->sec; \
|
||||
(res)->usec = (a)->usec - (b)->usec; \
|
||||
if ((res)->usec < 0) { \
|
||||
(res)->sec--; \
|
||||
(res)->usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* os_mktime - Convert broken-down time into seconds since 1970-01-01
|
||||
* @year: Four digit year
|
||||
* @month: Month (1 .. 12)
|
||||
* @day: Day of month (1 .. 31)
|
||||
* @hour: Hour (0 .. 23)
|
||||
* @min: Minute (0 .. 59)
|
||||
* @sec: Second (0 .. 60)
|
||||
* @t: Buffer for returning calendar time representation (seconds since
|
||||
* 1970-01-01 00:00:00)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Note: The result is in seconds from Epoch, i.e., in UTC, not in local time
|
||||
* which is used by POSIX mktime().
|
||||
*/
|
||||
int os_mktime(int year, int month, int day, int hour, int min, int sec,
|
||||
os_time_t *t);
|
||||
|
||||
struct os_tm {
|
||||
int sec; /* 0..59 or 60 for leap seconds */
|
||||
int min; /* 0..59 */
|
||||
int hour; /* 0..23 */
|
||||
int day; /* 1..31 */
|
||||
int month; /* 1..12 */
|
||||
int year; /* Four digit year */
|
||||
};
|
||||
|
||||
int os_gmtime(os_time_t t, struct os_tm *tm);
|
||||
|
||||
/* Helpers for handling struct os_time */
|
||||
|
||||
/* Helpers for handling struct os_reltime */
|
||||
|
||||
static inline int os_reltime_before(struct os_reltime *a,
|
||||
struct os_reltime *b)
|
||||
{
|
||||
return os_time_before(a,b);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_sub(struct os_reltime *a, struct os_reltime *b,
|
||||
struct os_reltime *res)
|
||||
{
|
||||
os_time_sub(a,b,res);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_age(struct os_reltime *start,
|
||||
struct os_reltime *age)
|
||||
{
|
||||
struct os_reltime now;
|
||||
|
||||
os_get_time((struct os_time *)&now);
|
||||
os_reltime_sub(&now, start, age);
|
||||
}
|
||||
|
||||
|
||||
static inline int os_reltime_expired(struct os_reltime *now,
|
||||
struct os_reltime *ts,
|
||||
os_time_t timeout_secs)
|
||||
{
|
||||
struct os_reltime age;
|
||||
|
||||
os_reltime_sub(now, ts, &age);
|
||||
return (age.sec > timeout_secs) ||
|
||||
(age.sec == timeout_secs && age.usec > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* os_daemonize - Run in the background (detach from the controlling terminal)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_daemonize(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_daemonize_terminate - Stop running in the background (remove pid file)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
*/
|
||||
void os_daemonize_terminate(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_get_random - Get cryptographically strong pseudo random data
|
||||
* @buf: Buffer for pseudo random data
|
||||
* @len: Length of the buffer
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_random(unsigned char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* os_random - Get pseudo random value (not necessarily very strong)
|
||||
* Returns: Pseudo random value
|
||||
*/
|
||||
unsigned long os_random(void);
|
||||
|
||||
/**
|
||||
* os_rel2abs_path - Get an absolute path for a file
|
||||
* @rel_path: Relative path to a file
|
||||
* Returns: Absolute path for the file or %NULL on failure
|
||||
*
|
||||
* This function tries to convert a relative path of a file to an absolute path
|
||||
* in order for the file to be found even if current working directory has
|
||||
* changed. The returned value is allocated and caller is responsible for
|
||||
* freeing it. It is acceptable to just return the same path in an allocated
|
||||
* buffer, e.g., return strdup(rel_path). This function is only used to find
|
||||
* configuration files when os_daemonize() may have changed the current working
|
||||
* directory and relative path would be pointing to a different location.
|
||||
*/
|
||||
char * os_rel2abs_path(const char *rel_path);
|
||||
|
||||
/**
|
||||
* os_program_init - Program initialization (called at start)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is called when a programs starts. If there are any OS specific
|
||||
* processing that is needed, it can be placed here. It is also acceptable to
|
||||
* just return 0 if not special processing is needed.
|
||||
*/
|
||||
int os_program_init(void);
|
||||
|
||||
/**
|
||||
* os_program_deinit - Program deinitialization (called just before exit)
|
||||
*
|
||||
* This function is called just before a program exists. If there are any OS
|
||||
* specific processing, e.g., freeing resourced allocated in os_program_init(),
|
||||
* it should be done here. It is also acceptable for this function to do
|
||||
* nothing.
|
||||
*/
|
||||
void os_program_deinit(void);
|
||||
|
||||
/**
|
||||
* os_setenv - Set environment variable
|
||||
* @name: Name of the variable
|
||||
* @value: Value to set to the variable
|
||||
* @overwrite: Whether existing variable should be overwritten
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_setenv(const char *name, const char *value, int overwrite);
|
||||
|
||||
/**
|
||||
* os_unsetenv - Delete environent variable
|
||||
* @name: Name of the variable
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_unsetenv(const char *name);
|
||||
|
||||
/**
|
||||
* os_readfile - Read a file to an allocated memory buffer
|
||||
* @name: Name of the file to read
|
||||
* @len: For returning the length of the allocated buffer
|
||||
* Returns: Pointer to the allocated buffer or %NULL on failure
|
||||
*
|
||||
* This function allocates memory and reads the given file to this buffer. Both
|
||||
* binary and text files can be read with this function. The caller is
|
||||
* responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char * os_readfile(const char *name, size_t *len);
|
||||
|
||||
//#if 0
|
||||
/**
|
||||
* os_zalloc - Allocate and zero memory
|
||||
* @size: Number of bytes to allocate
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_zalloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_calloc - Allocate and zero memory for an array
|
||||
* @nmemb: Number of members in the array
|
||||
* @size: Number of bytes in each member
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* This function can be used as a wrapper for os_zalloc(nmemb * size) when an
|
||||
* allocation is used for an array. The main benefit over os_zalloc() is in
|
||||
* having an extra check to catch integer overflows in multiplication.
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
static inline void * os_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
return os_zalloc(nmemb * size);
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
static inline int os_memcmp_const(const void *a, const void *b, size_t len)
|
||||
{
|
||||
const u8 *aa = a;
|
||||
const u8 *bb = b;
|
||||
size_t i;
|
||||
u8 res;
|
||||
|
||||
for (res = 0, i = 0; i < len; i++)
|
||||
res |= aa[i] ^ bb[i];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following functions are wrapper for standard ANSI C or POSIX functions.
|
||||
* By default, they are just defined to use the standard function name and no
|
||||
* os_*.c implementation is needed for them. This avoids extra function calls
|
||||
* by allowing the C pre-processor take care of the function name mapping.
|
||||
*
|
||||
* If the target system uses a C library that does not provide these functions,
|
||||
* build_config.h can be used to define the wrappers to use a different
|
||||
* function name. This can be done on function-by-function basis since the
|
||||
* defines here are only used if build_config.h does not define the os_* name.
|
||||
* If needed, os_*.c file can be used to implement the functions that are not
|
||||
* included in the C library on the target system. Alternatively,
|
||||
* OS_NO_C_LIB_DEFINES can be defined to skip all defines here in which case
|
||||
* these functions need to be implemented in os_*.c file for the target system.
|
||||
*/
|
||||
|
||||
#ifdef OS_NO_C_LIB_DEFINES
|
||||
|
||||
/**
|
||||
* os_malloc - Allocate dynamic memory
|
||||
* @size: Size of the buffer to allocate
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_malloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_realloc - Re-allocate dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc()
|
||||
* @size: Size of the new buffer
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
* If re-allocation fails, %NULL is returned and the original buffer (ptr) is
|
||||
* not freed and caller is still responsible for freeing it.
|
||||
*/
|
||||
void * os_realloc(void *ptr, size_t size);
|
||||
|
||||
/**
|
||||
* os_free - Free dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc(); can be %NULL
|
||||
*/
|
||||
void os_free(void *ptr);
|
||||
|
||||
/**
|
||||
* os_memcpy - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst must not overlap. os_memmove() can be used with
|
||||
* overlapping memory.
|
||||
*/
|
||||
void * os_memcpy(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memmove - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst may overlap.
|
||||
*/
|
||||
void *os_memmove(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memset - Fill memory with a constant byte
|
||||
* @s: Memory area to be filled
|
||||
* @c: Constant byte
|
||||
* @n: Number of bytes started from s to fill with c
|
||||
* Returns: s
|
||||
*/
|
||||
void *os_memset(void *s, int c, size_t n);
|
||||
|
||||
/**
|
||||
* os_memcmp - Compare memory areas
|
||||
* @s1: First buffer
|
||||
* @s2: Second buffer
|
||||
* @n: Maximum numbers of octets to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_memcmp(const void *s1, const void *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strdup - Duplicate a string
|
||||
* @s: Source string
|
||||
* Returns: Allocated buffer with the string copied into it or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char *os_strdup(const char *s);
|
||||
|
||||
/**
|
||||
* os_strlen - Calculate the length of a string
|
||||
* @s: '\0' terminated string
|
||||
* Returns: Number of characters in s (not counting the '\0' terminator)
|
||||
*/
|
||||
size_t os_strlen(const char *s);
|
||||
|
||||
/**
|
||||
* os_strcasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcasecmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strchr - Locate the first occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strrchr - Locate the last occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strrchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strcmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strncpy - Copy a string
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Maximum number of characters to copy
|
||||
* Returns: dest
|
||||
*/
|
||||
char *os_strncpy(char *dest, const char *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_strstr - Locate a substring
|
||||
* @haystack: String (haystack) to search from
|
||||
* @needle: Needle to search from haystack
|
||||
* Returns: Pointer to the beginning of the substring or %NULL if not found
|
||||
*/
|
||||
char *os_strstr(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* os_snprintf - Print to a memory buffer
|
||||
* @str: Memory buffer to print into
|
||||
* @size: Maximum length of the str buffer
|
||||
* @format: printf format
|
||||
* Returns: Number of characters printed (not including trailing '\0').
|
||||
*
|
||||
* If the output buffer is truncated, number of characters which would have
|
||||
* been written is returned. Since some C libraries return -1 in such a case,
|
||||
* the caller must be prepared on that value, too, to indicate truncation.
|
||||
*
|
||||
* Note: Some C library implementations of snprintf() may not guarantee null
|
||||
* termination in case the output is truncated. The OS wrapper function of
|
||||
* os_snprintf() should provide this guarantee, i.e., to null terminate the
|
||||
* output buffer if a C library version of the function is used and if that
|
||||
* function does not guarantee null termination.
|
||||
*
|
||||
* If the target system does not include snprintf(), see, e.g.,
|
||||
* http://www.ijs.si/software/snprintf/ for an example of a portable
|
||||
* implementation of snprintf.
|
||||
*/
|
||||
int os_snprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
#else /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
#if !defined(CONFIG_PLATFORM_8195A) && !defined(CONFIG_PLATFORM_8711B)
|
||||
#ifdef CONFIG_MEM_MONITOR
|
||||
u8* os_malloc(u32 sz);
|
||||
void os_mfree(u8 *pbuf, u32 sz);
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) os_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#else
|
||||
#ifndef os_malloc
|
||||
#define os_malloc(sz) _rtw_malloc(sz)
|
||||
#endif
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) _rtw_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
extern void *os_zalloc(size_t size);
|
||||
extern char *os_strdup(const char *string_copy_from);
|
||||
|
||||
#ifndef os_sleep
|
||||
#define os_sleep(s, us) rtw_mdelay_os((s)*1000 + (us)/1000)
|
||||
#endif
|
||||
#ifndef os_memcpy
|
||||
#define os_memcpy(d, s, n) rtw_memcpy((void*)(d), ((void*)(s)), (n))
|
||||
#endif
|
||||
#ifndef os_memmove
|
||||
#define os_memmove(d, s, n) memmove((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_memset
|
||||
#define os_memset(pbuf, c, sz) rtw_memset(pbuf, c, sz)
|
||||
#endif
|
||||
#ifndef os_memcmp
|
||||
#define os_memcmp(s1, s2, n) rtw_memcmp(((void*)(s1)), ((void*)(s2)), (n))
|
||||
#endif
|
||||
#ifndef os_memcmp_p2p
|
||||
#define os_memcmp_p2p(s1, s2, n) memcmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_get_random_bytes
|
||||
#define os_get_random_bytes(d,sz) rtw_get_random_bytes(((void*)(d)), (sz))
|
||||
#endif
|
||||
#ifndef os_strlen
|
||||
#define os_strlen(s) strlen(s)
|
||||
#endif
|
||||
#ifndef os_strcasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strcasecmp(s1, s2) _stricmp((s1), (s2))
|
||||
#else
|
||||
#define os_strcasecmp(s1, s2) strcasecmp((s1), (s2))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_strncasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
|
||||
#else
|
||||
#define os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_init_timer
|
||||
#define os_init_timer(t, p, f, x, n) rtw_init_timer((t), (p), (f), (x), (n))
|
||||
#endif
|
||||
#ifndef os_set_timer
|
||||
#define os_set_timer(t, d) rtw_set_timer((t), (d))
|
||||
#endif
|
||||
#ifndef os_cancel_timer
|
||||
#define os_cancel_timer(t) rtw_cancel_timer(t)
|
||||
#endif
|
||||
#ifndef os_del_timer
|
||||
#define os_del_timer(t) rtw_del_timer(t)
|
||||
#endif
|
||||
#ifndef os_atoi
|
||||
#define os_atoi(s) rtw_atoi(s)
|
||||
#endif
|
||||
|
||||
#ifndef os_strchr
|
||||
#define os_strchr(s, c) strchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strcmp
|
||||
#define os_strcmp(s1, s2) strcmp((s1), (s2))
|
||||
#endif
|
||||
#ifndef os_strncmp
|
||||
#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_strncpy
|
||||
#define os_strncpy(d, s, n) strncpy((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_strrchr
|
||||
#define os_strrchr(s, c) strrchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strstr
|
||||
#define os_strstr(h, n) strstr((h), (n))
|
||||
#endif
|
||||
|
||||
#ifndef os_snprintf
|
||||
#ifdef _MSC_VER
|
||||
#define os_snprintf _snprintf
|
||||
#else
|
||||
#define os_snprintf snprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
|
||||
static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
return os_realloc(ptr, nmemb * size, nmemb * size);
|
||||
}
|
||||
|
||||
void *os_xqueue_create(unsigned long uxQueueLength, unsigned long uxItemSize) ;
|
||||
|
||||
int os_xqueue_receive(xqueue_handle_t xQueue, void * const pvBuffer, unsigned long xSecsToWait);
|
||||
|
||||
void os_xqueue_delete(xqueue_handle_t xQueue );
|
||||
|
||||
int os_xqueue_send(xqueue_handle_t xQueue, const void * const pvItemToQueue, unsigned long xSecsToWait);
|
||||
|
||||
|
||||
#endif /* OS_H */
|
204
project/inc/rtl8195a/queue.h
Normal file
204
project/inc/rtl8195a/queue.h
Normal file
|
@ -0,0 +1,204 @@
|
|||
#ifndef _SYS_QUEUE_H_
|
||||
#define _SYS_QUEUE_H_
|
||||
|
||||
#define QMD_SAVELINK(name, link)
|
||||
#define TRASHIT(x)
|
||||
|
||||
/*
|
||||
* Singly-linked List declarations.
|
||||
*/
|
||||
#define SLIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *slh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define SLIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#define SLIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
|
||||
|
||||
#define SLIST_FIRST(head) ((head)->slh_first)
|
||||
|
||||
#define SLIST_FOREACH(var, head, field) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
||||
for ((varp) = &SLIST_FIRST((head)); \
|
||||
((var) = *(varp)) != NULL; \
|
||||
(varp) = &SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_INIT(head) do { \
|
||||
SLIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
||||
SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
|
||||
SLIST_NEXT((slistelm), field) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
||||
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
|
||||
SLIST_FIRST((head)) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.sle_next); \
|
||||
if (SLIST_FIRST((head)) == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = SLIST_FIRST((head)); \
|
||||
while (SLIST_NEXT(curelm, field) != (elm)) \
|
||||
curelm = SLIST_NEXT(curelm, field); \
|
||||
SLIST_REMOVE_AFTER(curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_AFTER(elm, field) do { \
|
||||
SLIST_NEXT(elm, field) = \
|
||||
SLIST_NEXT(SLIST_NEXT(elm, field), field); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue declarations.
|
||||
*/
|
||||
#define STAILQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *stqh_first;/* first element */ \
|
||||
struct type **stqh_last;/* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define STAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).stqh_first }
|
||||
|
||||
#define STAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *stqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue functions.
|
||||
*/
|
||||
#define STAILQ_CONCAT(head1, head2) do { \
|
||||
if (!STAILQ_EMPTY((head2))) { \
|
||||
*(head1)->stqh_last = (head2)->stqh_first; \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_INIT((head2)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
|
||||
|
||||
#define STAILQ_FIRST(head) ((head)->stqh_first)
|
||||
|
||||
#define STAILQ_FOREACH(var, head, field) \
|
||||
for((var) = STAILQ_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = STAILQ_NEXT((var), field))
|
||||
|
||||
|
||||
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define STAILQ_INIT(head) do { \
|
||||
STAILQ_FIRST((head)) = NULL; \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
|
||||
if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
STAILQ_NEXT((tqelm), field) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
STAILQ_FIRST((head)) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
STAILQ_NEXT((elm), field) = NULL; \
|
||||
*(head)->stqh_last = (elm); \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? \
|
||||
NULL : \
|
||||
((struct type *)(void *) \
|
||||
((char *)((head)->stqh_last) - __offsetof(struct type, field))))
|
||||
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
|
||||
#define STAILQ_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
|
||||
if (STAILQ_FIRST((head)) == (elm)) { \
|
||||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = STAILQ_FIRST((head)); \
|
||||
while (STAILQ_NEXT(curelm, field) != (elm)) \
|
||||
curelm = STAILQ_NEXT(curelm, field); \
|
||||
STAILQ_REMOVE_AFTER(head, curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_HEAD(head, field) do { \
|
||||
if ((STAILQ_FIRST((head)) = \
|
||||
STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
|
||||
if ((STAILQ_NEXT(elm, field) = \
|
||||
STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_SWAP(head1, head2, type) do { \
|
||||
struct type *swap_first = STAILQ_FIRST(head1); \
|
||||
struct type **swap_last = (head1)->stqh_last; \
|
||||
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_FIRST(head2) = swap_first; \
|
||||
(head2)->stqh_last = swap_last; \
|
||||
if (STAILQ_EMPTY(head1)) \
|
||||
(head1)->stqh_last = &STAILQ_FIRST(head1); \
|
||||
if (STAILQ_EMPTY(head2)) \
|
||||
(head2)->stqh_last = &STAILQ_FIRST(head2); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_INSERT_CHAIN_HEAD(head, elm_chead, elm_ctail, field) do { \
|
||||
if ((STAILQ_NEXT(elm_ctail, field) = STAILQ_FIRST(head)) == NULL ) { \
|
||||
(head)->stqh_last = &STAILQ_NEXT(elm_ctail, field); \
|
||||
} \
|
||||
STAILQ_FIRST(head) = (elm_chead); \
|
||||
} while (0)
|
||||
|
||||
#endif /* !_SYS_QUEUE_H_ */
|
24
project/inc/rtl8195a/rom_wps_os.h
Normal file
24
project/inc/rtl8195a/rom_wps_os.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ROM_WPS_OS_H
|
||||
#define ROM_WPS_OS_H
|
||||
|
||||
#if defined(CONFIG_PLATFORM_8195A) || defined(CONFIG_PLATFORM_8711B)
|
||||
|
||||
#include <rom_wlan_ram_map.h>
|
||||
extern struct _rom_wlan_ram_map rom_wlan_ram_map;
|
||||
#define os_malloc(sz) rom_wlan_ram_map.rtw_malloc(sz)
|
||||
#define os_free(p, sz) rom_wlan_ram_map.rtw_mfree(((u8*)(p)), (sz))
|
||||
|
||||
#endif
|
||||
|
||||
extern u8 *WPS_realloc(u8 *old_buf, u32 old_sz, u32 new_sz);
|
||||
#define os_realloc(p, os, ns) WPS_realloc(((u8*)(p)),(os),(ns))
|
||||
|
||||
#endif /* ROM_WPS_OS_H */
|
15
project/inc/rtl8195a/rtl_common.h
Normal file
15
project/inc/rtl8195a/rtl_common.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (C)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __RTL_COMMON_H__
|
||||
#define __RTL_COMMON_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "c_types.h"
|
||||
|
||||
#endif
|
164
project/inc/rtl8195a/rtl_libc.h
Normal file
164
project/inc/rtl8195a/rtl_libc.h
Normal file
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* ROM calls
|
||||
*/
|
||||
|
||||
#ifndef _INC_RTL_LIBC_
|
||||
#define _INC_RTL_LIBC_
|
||||
|
||||
//#undef malloc
|
||||
#define malloc(size) pvPortMalloc(size)
|
||||
//#undef free
|
||||
#define free(pbuf) vPortFree(pbuf)
|
||||
|
||||
#define atoi(str) prvAtoi(str)
|
||||
|
||||
#define calloc(nelements, elementSize) calloc_freertos(nelements, elementSize)
|
||||
|
||||
#define snprintf rtl_snprintf
|
||||
#define sprintf rtl_sprintf
|
||||
#define printf rtl_printf
|
||||
#define vprintf rtl_vprintf
|
||||
#define vsnprintf rtl_vsnprintf
|
||||
#define vfprintf rtl_vfprintf
|
||||
#define memchr rtl_memchr
|
||||
#define memcmp rtl_memcmp
|
||||
#define memcpy rtl_memcpy
|
||||
#define memmove rtl_memmove
|
||||
#define memset rtl_memset
|
||||
#define strcat rtl_strcat
|
||||
#define strchr rtl_strchr
|
||||
#define strcmp rtl_strcmp
|
||||
#define strcpy rtl_strcpy
|
||||
#define strlen rtl_strlen
|
||||
#define strncat rtl_strncat
|
||||
#define strncmp rtl_strncmp
|
||||
#define strncpy rtl_strncpy
|
||||
#define strstr rtl_strstr
|
||||
#define strsep rtl_strsep
|
||||
#define strtok rtl_strtok
|
||||
|
||||
#define dtoi rtl_dtoi
|
||||
#define dtoui rtl_dtoui
|
||||
#define i2f rtl_i2f
|
||||
#define i2d rtl_i2d
|
||||
#define ui2f rtl_ui2f
|
||||
#define ui2d rtl_ui2d
|
||||
#define itoa rtl_itoa
|
||||
#define ltoa rtl_ltoa
|
||||
#define utoa rtl_utoa
|
||||
#define ultoa rtl_ultoa
|
||||
#define ftol rtl_ftol
|
||||
#define ftod rtl_ftod
|
||||
#define dtof rtl_dtof
|
||||
#define fadd rtl_fadd
|
||||
#define fsub rtl_fsub
|
||||
#define fmul rtl_fmul
|
||||
#define fdiv rtl_fdiv
|
||||
#define dadd rtl_dadd
|
||||
#define dsub rtl_dsub
|
||||
#define dmul rtl_dmul
|
||||
#define ddiv rtl_ddiv
|
||||
#define dcmpeq rtl_dcmpeq
|
||||
#define dcmplt rtl_dcmplt
|
||||
#define dcmple rtl_dcmple
|
||||
#define dcmpgt rtl_dcmpgt
|
||||
#define fcmplt rtl_fcmplt
|
||||
#define fcmpgt rtl_fcmpgt
|
||||
|
||||
#define fabsf rtl_fabsf
|
||||
#define fabs rtl_fabs
|
||||
#define cos_f32 rtl_cos_f32
|
||||
#define sin_f32 rtl_sin_f32
|
||||
|
||||
|
||||
#if 0
|
||||
extern void *calloc_freertos(size_t nelements, size_t elementSize);
|
||||
// ram_libc.c
|
||||
extern int rtl_snprintf(char *str, size_t size, const char *fmt, ...);
|
||||
extern int rtl_sprintf(char *str, const char *fmt, ...);
|
||||
extern int rtl_printf(const char *fmt, ...);
|
||||
extern int rtl_vprintf(const char *fmt, void *param);
|
||||
extern int rtl_vsnprintf(char *str, size_t size, const char *fmt, void *param);
|
||||
extern int rtl_vfprintf(FILE *fp, const char *fmt0, va_list ap);
|
||||
extern int rtl_memchr(const void *src_void, int c, size_t length);
|
||||
extern int rtl_memcmp(const void *m1, const void *m2, size_t n);
|
||||
extern int rtl_memcpy(void *dst0, const void *src0, size_t len0);
|
||||
extern int rtl_memmove(void *dst_void, const void *src_void, size_t length);
|
||||
extern int rtl_memset(void *m, int c, size_t n);
|
||||
extern char * rtl_strcat(char *s1, const char *s2);
|
||||
extern char * rtl_strchr(const char *s1, int i);
|
||||
extern int rtl_strcmp(const char *s1, const char *s2);
|
||||
extern char * rtl_strcpy(char *dst0, const char *src0);
|
||||
extern int rtl_strlen(const char *str);
|
||||
extern char * rtl_strncat(char *s1, const char *s2, size_t n);
|
||||
extern int rtl_strncmp(const char *s1, const char *s2, size_t n);
|
||||
extern char * rtl_strncpy(char *dst0, const char *src0, size_t count);
|
||||
extern char * rtl_strstr(const char *searchee, const char *lookfor);
|
||||
extern char * rtl_strsep(char **source_ptr, const char *delim);
|
||||
extern char * rtl_strtok(char *s, const char *delim);
|
||||
|
||||
//rtl_eabi_cast_ram.c
|
||||
extern int rtl_dtoi(double d);
|
||||
extern int rtl_dtoui(double d);
|
||||
extern float rtl_i2f(int val);
|
||||
extern int rtl_i2d(int val);
|
||||
extern float rtl_ui2f(unsigned int val);
|
||||
extern int rtl_ui2d(unsigned int val);
|
||||
extern char *rtl_itoa(int value, char *string, int radix);
|
||||
extern char *rtl_ltoa(int value, char *string, int radix);
|
||||
extern char *rtl_utoa(unsigned int value, char *string, int radix);
|
||||
extern char *rtl_ultoa(unsigned int value, char *string, int radix);
|
||||
extern int rtl_ftol(float f);
|
||||
extern int rtl_ftod(float f);
|
||||
extern float rtl_dtof(double d);
|
||||
extern float rtl_fadd(float a, float b);
|
||||
extern float rtl_fsub(float a, float b);
|
||||
extern float rtl_fmul(float a, float b);
|
||||
extern float rtl_fdiv(float a, float b);
|
||||
extern int rtl_dadd(double a, double b);
|
||||
extern int rtl_dsub(double a, double b);
|
||||
extern int rtl_dmul(double a, double b);
|
||||
extern int rtl_ddiv(double a, double b);
|
||||
extern int rtl_dcmpeq(double a, double b);
|
||||
extern int rtl_dcmplt(double a, double b);
|
||||
extern int rtl_dcmple(double a, double b);
|
||||
extern int rtl_dcmpgt(double a, double b);
|
||||
extern int rtl_fcmplt(float a, float b);
|
||||
extern int rtl_fcmpgt(float a, float b);
|
||||
|
||||
// rtl_math_ram.c
|
||||
extern float rtl_fabsf(float a);
|
||||
extern int rtl_fabs(double a);
|
||||
extern float rtl_cos_f32(float a);
|
||||
extern float rtl_sin_f32(float a);
|
||||
|
||||
// ram_pvvx_libc.c
|
||||
extern int snprintf(char *str, size_t size, const char *fmt, ...);
|
||||
extern int sprintf(char *str, const char *fmt, ...);
|
||||
extern int printf(const char *fmt, ...);
|
||||
extern int vprintf(const char *fmt, void *param);
|
||||
extern int vsnprintf(char *str, size_t size, const char *fmt, void *param);
|
||||
extern int vfprintf(FILE *fp, const char *fmt0, va_list ap);
|
||||
extern int memchr(const void *src_void, int c, size_t length);
|
||||
extern int memcmp(const void *m1, const void *m2, size_t n);
|
||||
extern int memcpy(void *dst0, const void *src0, size_t len0);
|
||||
extern int memmove(void *dst_void, const void *src_void, size_t length);
|
||||
extern int memset(void *m, int c, size_t n);
|
||||
extern char * strcat(char *s1, const char *s2);
|
||||
extern char * strchr(const char *s1, int i);
|
||||
extern int strcmp(const char *s1, const char *s2);
|
||||
extern char * strcpy(char *dst0, const char *src0);
|
||||
extern int strlen(const char *str);
|
||||
extern char * strncat(char *s1, const char *s2, size_t n);
|
||||
extern int strncmp(const char *s1, const char *s2, size_t n);
|
||||
extern char * strncpy(char *dst0, const char *src0, size_t count);
|
||||
extern char * strstr(const char *searchee, const char *lookfor);
|
||||
extern char * strsep(char **source_ptr, const char *delim);
|
||||
extern char * strtok(char *s, const char *delim);
|
||||
extern int sscanf(const char *buf, const char *fmt, ...);
|
||||
extern char toupper(char ch);
|
||||
extern int _stricmp (const char *s1, const char *s2);
|
||||
extern unsigned long long __aeabi_llsr(unsigned long long val, unsigned int shift);
|
||||
#endif
|
||||
|
||||
#endif // _INC_RTL_LIBC_
|
191
project/inc/tcpsrv/tcp_srv_conn.h
Normal file
191
project/inc/tcpsrv/tcp_srv_conn.h
Normal file
|
@ -0,0 +1,191 @@
|
|||
#ifndef __TCP_SERV_CONN_H__
|
||||
/***********************************
|
||||
* FileName: tcp_srv_conn.h
|
||||
* Tcp сервачек для ESP8266
|
||||
* PV` ver1.0 20/12/2014
|
||||
* PV` ver1.0 29/10/2016 для RTL87xx
|
||||
***********************************/
|
||||
#define __TCP_SERV_CONN_H__
|
||||
|
||||
//#include "user_interface.h"
|
||||
//#include "os_type.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#define mMIN(a, b) ((a < b)? a : b)
|
||||
|
||||
enum srvconn_state {
|
||||
SRVCONN_NONE =0,
|
||||
SRVCONN_CLOSEWAIT, // ожидает закрытия
|
||||
SRVCONN_CLIENT, // установка соединения (клиент)
|
||||
SRVCONN_LISTEN, // соединение открыто, ждет rx или tx
|
||||
SRVCONN_CONNECT, // соединение открыто, было rx или tx
|
||||
SRVCONN_CLOSED // соединение закрыто
|
||||
};
|
||||
|
||||
// приоритет pcb 1..127 1 - min, 127 - max
|
||||
#ifndef TCP_SRV_PRIO
|
||||
#define TCP_SRV_PRIO 99 //TCP_PRIO_MIN
|
||||
#endif
|
||||
|
||||
// максимальное кол-во TCP c TIME_WAIT
|
||||
#ifndef MAX_TIME_WAIT_PCB
|
||||
#define MAX_TIME_WAIT_PCB 10
|
||||
#endif
|
||||
|
||||
// кол-во одновременно открытых соединений по умолчанию
|
||||
#ifndef TCP_SRV_MAX_CONNECTIONS
|
||||
#define TCP_SRV_MAX_CONNECTIONS mMIN(MEMP_NUM_TCP_PCB, 10)
|
||||
#endif
|
||||
|
||||
// порт сервера по умолчанию
|
||||
#ifndef TCP_SRV_SERVER_PORT
|
||||
#define TCP_SRV_SERVER_PORT 80
|
||||
#endif
|
||||
|
||||
/* уровень вывода отладочной инфы по умолчанию
|
||||
#ifndef DEBUGSOO
|
||||
#define DEBUGSOO 2
|
||||
#endif
|
||||
*/
|
||||
|
||||
// время (сек), по умолчанию, ожидания запроса (передачи пакета) от клиента, до авто-закрытия соединения,
|
||||
// при = 0 заменяется на эти 5 сек.
|
||||
#ifndef TCP_SRV_RECV_WAIT
|
||||
#define TCP_SRV_RECV_WAIT 5
|
||||
#endif
|
||||
// время (сек), по умолчанию, до авто-закрытия соединения после приема или передачи,
|
||||
// при = 0 заменяется на эти 5 сек.
|
||||
#ifndef TCP_SRV_END_WAIT
|
||||
#define TCP_SRV_END_WAIT 5
|
||||
#endif
|
||||
|
||||
// время (в сек) до повтора закрытия соединения (исполняется до 3-х раз).
|
||||
#define TCP_SRV_CLOSE_WAIT 5 // 5 сек
|
||||
|
||||
// минимальный размер heap по умолчанию, при открытии нового соединения, при = 0 заменяется на это:
|
||||
#define TCP_SRV_MIN_HEAP_SIZE 14528 // самый минимум от 6Kb
|
||||
|
||||
// максимальный размер выделяемого буфера в heap для приема порции
|
||||
#ifndef TCP_SRV_SERVER_MAX_RXBUF
|
||||
#define TCP_SRV_SERVER_MAX_RXBUF (TCP_MSS*3) // 1460*2=2920, 1460*3=4380, 1460*4=5840
|
||||
#endif
|
||||
|
||||
// размер выделяемого буфера в heap для передачи при буферизированном выводе
|
||||
#ifndef TCP_SRV_SERVER_DEF_TXBUF
|
||||
#define TCP_SRV_SERVER_DEF_TXBUF (TCP_MSS*3) // 1460*2=2920, 1460*3=4380, 1460*4=5840
|
||||
#endif
|
||||
|
||||
#define ID_CLIENTS_PORT 3 // до 3-х clients
|
||||
#define tcpsrv_init_client1() tcpsrv_init(1) // tcp2uart_client
|
||||
#define tcpsrv_init_client2() tcpsrv_init(2) // mdb_tcp_client
|
||||
#define tcpsrv_init_client3() tcpsrv_init(3)
|
||||
|
||||
#define TCP_CLIENT_NEXT_CONNECT_S 5 // syscfg.tcp_client_twait // 5000 // через 5 сек
|
||||
#define TCP_CLIENT_MAX_CONNECT_RETRY 7 // до 7 раз с интервалом TCP_CLIENT_NEXT_CONNECT_MS
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Структура соединения
|
||||
//
|
||||
typedef struct t_tcpsrv_conn_flags {
|
||||
uint16 client: 1; //0001 данное соединение не сервер, а клиент!
|
||||
uint16 client_reconnect: 1; //0002 вечный реконнект
|
||||
uint16 srv_reopen: 1; //0004 открытие нового соединения более max_conn ведет к закрытию наиболее старого соединения.
|
||||
uint16 pcb_time_wait_free: 1; //0008 проверка на макс кол-во и уничтожение pcb с TIME_WAIT при вызове disconnect() (иначе pcb TIME_WAIT 60 сек http://www.serverframework.com/asynchronousevents/2011/01/time-wait-and-its-design-implications-for-protocols-and-scalable-servers.html)
|
||||
uint16 nagle_disabled: 1; //0010 выключение nagle
|
||||
uint16 rx_buf: 1; //0020 прием в буфер, используется ручное управление размером окна TCP
|
||||
uint16 rx_null: 1; //0040 отключение вызова func_received_data() и прием в null (устанавливается автоматически при вызове tcpsrv_disconnect())
|
||||
uint16 tx_null: 1; //0080 отключение вызова func_sent_callback() и передача в null (устанавливается автоматически при вызове tcpsrv_disconnect())
|
||||
uint16 wait_sent: 1; //0100 ожидет завершения/подтверждения передачи от lwip
|
||||
uint16 busy_bufo: 1; //0200 идет обработка bufo
|
||||
uint16 busy_bufi: 1; //0400 идет обработка bufi
|
||||
// далее идут биты не относящиеся к работе tcp_srv_conn
|
||||
uint16 user_flg1: 1; //0800 для нужд процедур уровнем выше (использован в tcp2uart.c)
|
||||
uint16 user_flg2: 1; //1000 для нужд процедур уровнем выше (пока свободен)
|
||||
uint16 user_option1: 1; //2000 для нужд процедур обработки переменных (использован для hexdump, xml_mdb в web_int_callbacks.c)
|
||||
uint16 user_option2: 1; //4000 для нужд процедур обработки переменных (использован для xml_mdb в web_int_callbacks.c)
|
||||
} __attribute__((packed)) tcpsrv_conn_flags;
|
||||
|
||||
typedef struct t_TCP_SERV_CONN {
|
||||
volatile tcpsrv_conn_flags flag;//+0 флаги соеднения
|
||||
enum srvconn_state state; //+4 состояние
|
||||
struct t_TCP_SERV_CFG *pcfg; //+8 указатель на базовую структуру сервера
|
||||
uint16 recv_check; //+12 счет тиков соединения в tcpsrv_poll
|
||||
uint16 remote_port; //+16 номер порта клиента
|
||||
union { //+20 ip клиента
|
||||
uint32 dw;
|
||||
uint8 b[4];
|
||||
} remote_ip;
|
||||
struct t_TCP_SERV_CONN *next; //+24 указатель на следующую структуру
|
||||
struct tcp_pcb *pcb; //+28 указатель на pcb в Lwip
|
||||
uint8 *pbufo; //+32 указатель на сегмент с передаваемыми данными
|
||||
uint8 *ptrtx; //+36 указатель на ещё не переданные данные
|
||||
uint8 *pbufi; //+40 указатель на сегмент буфера с принимаемыми данными
|
||||
uint16 sizeo; //+44 размер буфера передачи
|
||||
uint16 sizei; //+48 размер приемного буфера (кол-во принятых и ещё не обработанных байт)
|
||||
uint16 cntro; //+52 кол-во обработанных байт в буфере передачи
|
||||
uint16 cntri; //+56 кол-во обработанных байт в буфере приема
|
||||
uint16 unrecved_bytes; //+60 используется при ручном управлении TCP WIN / This can be used to throttle data reception
|
||||
// далее идут переменные не относящиеся к работе tcp_srv_conn
|
||||
uint8 *linkd; //+64 указатель на прилепленные данные пользователя (при закрытии соединения вызывается os_close(linkd), если linkd != NULL;
|
||||
} TCP_SERV_CONN;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Вызываемые функции пользователя (calback-и)
|
||||
//
|
||||
typedef void (*func_disconect_calback)(TCP_SERV_CONN *ts_conn); // соединение закрыто
|
||||
typedef err_t (*func_listen)(TCP_SERV_CONN *ts_conn); // новый клиент
|
||||
typedef err_t (*func_received_data)(TCP_SERV_CONN *ts_conn); // принято всего ts_conn->sizei байт, лежат в буфере по ts_conn->pbufi, по выходу принимается обработанных ts_conn->cntri;
|
||||
typedef err_t (*func_sent_callback)(TCP_SERV_CONN *ts_conn); // блок данных передан
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Структура конфигурации tcp сервера
|
||||
//
|
||||
typedef struct t_TCP_SERV_CFG {
|
||||
struct t_tcpsrv_conn_flags flag; // начальные флаги для соединения
|
||||
uint16 port; // номер порта (=1 - client)
|
||||
uint16 max_conn; // максимальное кол-во одновременных соединений, если client = кол-во повторов соединения
|
||||
uint16 conn_count; // кол-во текущих соединений, при инициализации прописывает 0, если client = счетчик повторов соединения
|
||||
uint16 min_heap; // минимальный размер heap при открытии нового соединения, при = 0 заменяется на 8192.
|
||||
uint16 time_wait_rec; // время (сек) ожидания запроса (передачи пакета) от клиента, до авто-закрытия соединения, по умолчанию TCP_SRV_RECV_WAIT сек.
|
||||
uint16 time_wait_cls; // время (сек) до авто-закрытия соединения после приема или передачи, по умолчанию TCP_SRV_END_WAIT сек.
|
||||
TCP_SERV_CONN * conn_links; // указатель на цепочку активных соединений, при инициализации или отсуствии активных соединений = NULL
|
||||
struct tcp_pcb *pcb; // начальный pcb [LISTEN] если сервер, иначе NULL
|
||||
func_disconect_calback func_discon_cb; // функция вызываемая после закрытия соединения, если = NULL - не вызывается
|
||||
func_listen func_listen; // функция вызываемая при присоединении клиента или коннекта к серверу, если = NULL - не вызывается
|
||||
func_sent_callback func_sent_cb; // функция вызываемая после передачи данных или наличию места в ip стеке для следушей передачи данных, если = NULL - не вызывается (+см. флаги)
|
||||
func_received_data func_recv; // функция вызываемая при приеме данных, если = NULL - не вызывается (+см. флаги)
|
||||
struct t_TCP_SERV_CFG *next; // следующий экземпляр структуры сервера/клиента
|
||||
}TCP_SERV_CFG;
|
||||
//--------------------------------------------------------------------------
|
||||
// Данные
|
||||
//
|
||||
extern TCP_SERV_CFG *phcfg; // указатель на цепочку TCP_SERV_CFG (стартовавших серверов)
|
||||
//--------------------------------------------------------------------------
|
||||
// Функции
|
||||
//
|
||||
err_t tcpsrv_int_sent_data(TCP_SERV_CONN * ts_conn, uint8 *psent, uint16 length); // передать length байт (внутрення функция - никаких проверок)
|
||||
void tcpsrv_disconnect(TCP_SERV_CONN * ts_conn); // закрыть соединение
|
||||
void tcpsrv_print_remote_info(TCP_SERV_CONN *ts_conn); // выводит remote_ip:remote_port [conn_count] os_printf("srv x.x.x.x:x [n] ")
|
||||
TCP_SERV_CFG * tcpsrv_server_port2pcfg(uint16 portn); // поиск структуры конфига по номеру порта
|
||||
TCP_SERV_CFG * tcpsrv_client_ip_port2conn(uint32 ip, uint16 portn); // поиск структуры конфига по номеру порта для клиента
|
||||
void tcpsrv_unrecved_win(TCP_SERV_CONN *ts_conn); // Восстановить размер TCP WIN, если используется ручное управление размером окна TCP
|
||||
|
||||
void tcpsrv_disconnect_calback_default(TCP_SERV_CONN *ts_conn);
|
||||
err_t tcpsrv_listen_default(TCP_SERV_CONN *ts_conn);
|
||||
err_t tcpsrv_sent_callback_default(TCP_SERV_CONN *ts_conn);
|
||||
err_t tcpsrv_received_data_default(TCP_SERV_CONN *ts_conn);
|
||||
|
||||
TCP_SERV_CFG *tcpsrv_init(uint16 portn);
|
||||
err_t tcpsrv_start(TCP_SERV_CFG *p);
|
||||
err_t tcpsrv_client_start(TCP_SERV_CFG * p, uint32 remote_ip, uint16 remote_port);
|
||||
err_t tcpsrv_close(TCP_SERV_CFG *p);
|
||||
err_t tcpsrv_close_port(uint16 portn);
|
||||
err_t tcpsrv_close_all(void);
|
||||
|
||||
char * tspsrv_error_msg(err_t err);
|
||||
char * tspsrv_tcp_state_msg(enum tcp_state state);
|
||||
char * tspsrv_srvconn_state_msg(enum srvconn_state state);
|
||||
|
||||
#endif // __TCP_SERV_CONN_H__
|
68
project/inc/user/main.h
Normal file
68
project/inc/user/main.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <autoconf.h>
|
||||
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
/* Header file declaration*/
|
||||
void wlan_network();
|
||||
|
||||
/* Interactive Mode */
|
||||
#define SERIAL_DEBUG_RX 1
|
||||
|
||||
|
||||
#define ATVER_1 1 // For First AT command
|
||||
#define ATVER_2 2 // For UART Module AT command
|
||||
|
||||
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||
#define ATCMD_VER ATVER_2
|
||||
#else
|
||||
#define ATCMD_VER ATVER_1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define IP_ADDR0 192
|
||||
#define IP_ADDR1 168
|
||||
#define IP_ADDR2 3
|
||||
#define IP_ADDR3 80
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 255
|
||||
#define NETMASK_ADDR1 255
|
||||
#define NETMASK_ADDR2 255
|
||||
#define NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 192
|
||||
#define GW_ADDR1 168
|
||||
#define GW_ADDR2 3
|
||||
#define GW_ADDR3 1
|
||||
|
||||
/*******************************************/
|
||||
|
||||
/*Static IP ADDRESS*/
|
||||
#define AP_IP_ADDR0 192
|
||||
#define AP_IP_ADDR1 168
|
||||
#define AP_IP_ADDR2 43
|
||||
#define AP_IP_ADDR3 1
|
||||
|
||||
/*NETMASK*/
|
||||
#define AP_NETMASK_ADDR0 255
|
||||
#define AP_NETMASK_ADDR1 255
|
||||
#define AP_NETMASK_ADDR2 255
|
||||
#define AP_NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define AP_GW_ADDR0 192
|
||||
#define AP_GW_ADDR1 168
|
||||
#define AP_GW_ADDR2 43
|
||||
#define AP_GW_ADDR3 1
|
||||
|
||||
|
||||
|
||||
#endif
|
64
project/inc/user/sys_cfg.h
Normal file
64
project/inc/user/sys_cfg.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* sys_cfg.h
|
||||
*
|
||||
* Created on: 17/04/17
|
||||
* Author: pvvx
|
||||
*/
|
||||
#ifndef __SYS_CFG_H__
|
||||
#define __SYS_CFG_H__
|
||||
#include "user_config.h"
|
||||
#define FEEP_ID_SYS_CFG 0x5359
|
||||
|
||||
struct sys_bits_config {
|
||||
uint16 hi_speed_enable : 1; //0 0x0000001 =1 Set CPU 160 MHz ...
|
||||
uint16 pin_clear_cfg_enable : 1; //1 0x0000002 =1 Проверять ножку RX на сброс конфигурации WiFi
|
||||
uint16 debug_print_enable : 1; //2 0x0000004 =1 Вывод отладочной информации на GPIO2
|
||||
uint16 web_time_wait_delete : 1; //3 0x0000008 =1 Закрывать соединение и убивать pcb c TIME_WAIT
|
||||
uint16 netbios_ena : 1; //4 0x0000010 =1 включить NetBios
|
||||
uint16 sntp_ena : 1; //5 0x0000020 =1 включить SNTP
|
||||
uint16 cdns_ena : 1; //6 0x0000040 =1 включить CAPDNS
|
||||
uint16 tcp2uart_reopen : 1; //7 0x0000080 =1 открытие нового соединения tcp2uart ведет к закрытию старого соединения (в режиме tcp2uart = сервер)
|
||||
uint16 mdb_reopen : 1; //8 0x0000100 =1 открытие нового соединения modbus ведет к закрытию старого соединения (в режиме modbus = сервер)
|
||||
};
|
||||
|
||||
#define SYS_CFG_HI_SPEED 0x0000001 // Set CPU 160 MHz ...
|
||||
#define SYS_CFG_PIN_CLR_ENA 0x0000002 // Проверять ножку RX на сброс конфигурации WiFi
|
||||
#define SYS_CFG_DEBUG_ENA 0x0000004 // Вывод отладочной информации на GPIO2
|
||||
#define SYS_CFG_TWPCB_DEL 0x0000008 // Закрывать соединение и убивать pcb c TIME_WAIT
|
||||
#define SYS_CFG_NETBIOS_ENA 0x0000010 // включить NetBios
|
||||
#define SYS_CFG_SNTP_ENA 0x0000020 // включить SNTP
|
||||
#define SYS_CFG_CDNS_ENA 0x0000040 // включить CAPDNS
|
||||
#define SYS_CFG_T2U_REOPEN 0x0000080 // открытие нового соединения tcp2uart ведет к закрытию старого соединения (сервер)
|
||||
#define SYS_CFG_MDB_REOPEN 0x0000100 // открытие нового соединения modbus ведет к закрытию старого соединения (сервер)
|
||||
|
||||
|
||||
struct SystemCfg { // структура сохранения системных настроек в Flash
|
||||
union {
|
||||
struct sys_bits_config b;
|
||||
uint16 w;
|
||||
}cfg;
|
||||
uint16 tcp_client_twait; // время (миллисек) до повтора соединения клиента
|
||||
#ifdef USE_TCP2UART
|
||||
uint16 tcp2uart_port; // номер порта TCP-UART (=0 - отключен)
|
||||
uint16 tcp2uart_twrec; // время (сек) стартового ожидания приема/передачи первого пакета, до авто-закрытия соединения
|
||||
uint16 tcp2uart_twcls; // время (сек) до авто-закрытия соединения после приема или передачи
|
||||
#endif
|
||||
#ifdef USE_WEB
|
||||
uint16 web_port; // номер порта WEB (=0 - отключен)
|
||||
uint16 web_twrec; // время (сек) стартового ожидания приема/передачи первого пакета, до авто-закрытия соединения
|
||||
uint16 web_twcls; // время (сек) до авто-закрытия соединения после приема или передачи
|
||||
#endif
|
||||
#ifdef USE_MODBUS
|
||||
uint16 mdb_port; // =0 - отключен
|
||||
uint16 mdb_twrec; // время (сек) стартового ожидания приема/передачи первого пакета, до авто-закрытия соединения
|
||||
uint16 mdb_twcls; // время (сек) до авто-закрытия соединения после приема или передачи
|
||||
uint8 mdb_id; // номер устройства ESP8266 по шине modbus
|
||||
#endif
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
extern void sys_write_cfg(void);
|
||||
|
||||
extern struct SystemCfg syscfg;
|
||||
|
||||
#endif // #define __SYS_CFG_H__
|
34
project/inc/user_config.h
Normal file
34
project/inc/user_config.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef _user_config_h_
|
||||
#define _user_config_h_
|
||||
|
||||
//#include "sdk/sdk_config.h"
|
||||
|
||||
#define SYS_VERSION "1.0.0"
|
||||
#define SDK_VERSION "3.5.3"
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Конфигурация для проекта MODBUS-RS-485
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
#define USE_WEB 80 // включить в трансялцию порт Web, если =0 - по умолчанию выключен
|
||||
#define WEBSOCKET_ENA 1 // включить WEBSOCKET
|
||||
|
||||
//#define USE_CPU_SPEED 166 // установить частоту CPU (по умолчанию 83)
|
||||
/*
|
||||
#define USE_NETBIOS 1 // включить в трансялцию драйвер NETBIOS, если =0 - по умолчанию выключен.
|
||||
|
||||
#define USE_SNTP 1 // включить в трансялцию драйвер SNTP, если =0 - по умолчанию выключен, = 1 - по умолчанию включен.
|
||||
|
||||
#define USE_RS485DRV // использовать RS-485 драйвер
|
||||
#define MDB_RS485_MASTER // Modbus RTU RS-485 master & slave
|
||||
#define USE_MODBUS 502 // включить в трансялцию Modbus TCP, если =0 - по умолчанию выключен
|
||||
#define MDB_ID_ESP 50 // номер устройства RTL на шине modbus
|
||||
|
||||
//#define USE_CAPTDNS 0 // включить в трансялцию DNS отвечающий на всё запросы клиента при соединении к AP модуля
|
||||
// указанием на данный WebHttp (http://aesp8266/), если =0 - по умолчанию выключен
|
||||
|
||||
*/
|
||||
|
||||
#endif // _user_config_h_
|
||||
|
||||
|
196
project/inc/web/web_srv.h
Normal file
196
project/inc/web/web_srv.h
Normal file
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* File: web_srv.h
|
||||
* Description: The web server configration.
|
||||
* Small WEB server ESP8266EX
|
||||
* Author: PV`
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_WEB_SRV_H_
|
||||
#define _INCLUDE_WEB_SRV_H_
|
||||
|
||||
#include "tcpsrv/tcp_srv_conn.h"
|
||||
#ifdef WEBSOCKET_ENA
|
||||
#include "websock.h"
|
||||
#endif
|
||||
|
||||
#define WEB_SVERSION "0.2.0"
|
||||
#define DEFAULT_WEB_PORT USE_WEB // 80
|
||||
|
||||
/****************************************************************************
|
||||
Section:
|
||||
Commands and Server Responses
|
||||
***************************************************************************/
|
||||
|
||||
// File type definitions
|
||||
typedef enum
|
||||
{
|
||||
HTTP_TXT = 0, // File is a text document
|
||||
HTTP_HTML, // File is HTML (extension .htm)
|
||||
HTTP_CGI, // File is HTML (extension .cgi)
|
||||
HTTP_XML, // File is XML (extension .xml)
|
||||
HTTP_CSS, // File is stylesheet (extension .css)
|
||||
HTTP_ICO, // File is ICO vnd.microsoft.icon
|
||||
HTTP_GIF, // File is GIF image (extension .gif)
|
||||
HTTP_PNG, // File is PNG image (extension .png)
|
||||
HTTP_JPG, // File is JPG image (extension .jpg)
|
||||
HTTP_SVG, // File is SVG image (extension .svg)
|
||||
HTTP_JAVA, // File is java (extension .js)
|
||||
HTTP_SWF, // File is ShockWave-Flash (extension .swf)
|
||||
HTTP_WAV, // File is audio (extension .wav)
|
||||
HTTP_PDF, // File is PDF (extension .pdf)
|
||||
HTTP_ZIP, // File is ZIP (extension .zip)
|
||||
HTTP_BIN, // File is BIN (extension .bin)
|
||||
HTTP_UNKNOWN // File type is unknown
|
||||
} HTTP_FILE_TYPE;
|
||||
|
||||
|
||||
// extended state data for each connection
|
||||
#define FileNameSize 64
|
||||
#define VarNameSize 64
|
||||
#define CmdNameSize 32
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 httpStatus; // Request method/status
|
||||
uint16 uri_len;
|
||||
uint16 head_len;
|
||||
uint16 cookie_len;
|
||||
uint8 pFilename[FileNameSize];
|
||||
uint8 *puri; // указатель на строку с переменными запроса к файлу
|
||||
uint8 *phead; // HTTP Headers
|
||||
uint8 *pcookie; // cookie
|
||||
uint8 *pcontent; // content
|
||||
uint32 content_len; //
|
||||
uint8 httpver; // версия HTTP клиента в BCD (0x00 = неизвестен; 0x09 = HTTP/0.9; 0x10 = HTTP/1.0; 0x11 = HTTP/1.1)
|
||||
uint8 fileType; // File type to return with Content-Type
|
||||
} HTTP_CONN;
|
||||
|
||||
|
||||
typedef void (* web_func_cb)(TCP_SERV_CONN *ts_conn);
|
||||
typedef uint32 (* web_func_disc_cb)(uint32 flg); // отложенная функция, когда соединение закрыто
|
||||
|
||||
typedef struct
|
||||
{
|
||||
web_func_disc_cb fnk;
|
||||
void * param;
|
||||
} WEB_SRV_QFNK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 webflag; // флаги для http/web сервера
|
||||
uint8 bffiles[4]; // четыре Files pointers для оработки вложенных файлов include
|
||||
uint32 udata_start; // udata "start=0x..."
|
||||
uint32 udata_stop; // udata "stop=0x..."
|
||||
uint8 *msgbuf; // указатель на текущий буфер вывода
|
||||
uint16 msgbuflen; // кол-во занятых байт в буфере msgbuf
|
||||
uint16 msgbufsize; // размер буфера
|
||||
web_func_cb func_web_cb; // calback функция у httpd для обработки приема/передачи кусками
|
||||
uint32 content_len; // размер файла для передачи (GET/POST) или приема, если принимается внешний файл (POST + SCB_RXDATA)
|
||||
web_func_disc_cb web_disc_cb; // функция вызываемая по закрытию соединения
|
||||
uint32 web_disc_par; // параметры функции вызываемой по закрытию соединения
|
||||
#ifdef WEBSOCKET_ENA
|
||||
WS_FRSTAT ws; // параметры websoc
|
||||
#endif
|
||||
uint8 fileType; // File type to return with Content-Type (if SCB_FCALBACK)
|
||||
} WEB_SRV_CONN;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WEBFS_MAX_HANDLE = 251,
|
||||
WEBFS_NODISK_HANDLE,
|
||||
WEBFS_WEBCGI_HANDLE,
|
||||
WEBFS_UPLOAD_HANDLE
|
||||
} WEBFS_NUM_HANDLE;
|
||||
|
||||
// webflag:
|
||||
|
||||
#define SCB_CLOSED 0x000001 // соединение закрыто
|
||||
#define SCB_DISCONNECT 0x000002 // выход на DISCONNECT
|
||||
#define SCB_FCLOSE 0x000004 // закрыть файлы
|
||||
#define SCB_FOPEN 0x000008 // файл(ы) открыт(ы)
|
||||
#define SCB_FCALBACK 0x000010 // file use ~calback~
|
||||
#define SCB_FGZIP 0x000020 // файл GZIP
|
||||
#define SCB_CHUNKED 0x000040 // передача шинковкой
|
||||
#define SCB_RETRYCB 0x000080 // вызвать повтор CalBack
|
||||
#define SCB_POST 0x000100 // POST
|
||||
#define SCB_GET 0x000200 // GET
|
||||
#define SCB_AUTH 0x000400 // необходима авторизация
|
||||
#define SCB_FINDCB 0x000800 // используется парсингом ~calback~
|
||||
#define SCB_RXDATA 0x001000 // прием данных (файла)
|
||||
#define SCB_HEAD_OK 0x002000 // заголовок HTTP принят и обработан
|
||||
#define SCB_BNDR 0x004000 // прилеплен Content-Type: multipart/form-data; boundary="..."
|
||||
#define SCB_REDIR 0x008000 // Redirect 302
|
||||
#define SCB_WEBSOC 0x010000 // WebSocket
|
||||
#define SCB_WSDATA 0x020000 // WebSocket data
|
||||
#define SCB_SYSSAVE 0x040000 // по закрытию соединения вызвать sys_write_cfg()
|
||||
|
||||
|
||||
#define SCB_OPEN 0
|
||||
|
||||
#define SetSCB(a) web_conn->webflag |= a
|
||||
#define FreeSCB() web_conn->webflag = SCB_FREE
|
||||
#define SetNextFunSCB(a) web_conn->func_web_cb = a
|
||||
#define ClrSCB(a) web_conn->webflag &= ~(a)
|
||||
#define CheckSCB(a) (web_conn->webflag & (a))
|
||||
|
||||
#define FreeSCB() web_conn->webflag = SCB_FREE
|
||||
#define OpenSCB() web_conn->webflag = SCB_OPEN
|
||||
|
||||
#define MAXLENBOUNDARY 64
|
||||
typedef struct s_http_upload
|
||||
{
|
||||
uint16 status;
|
||||
uint16 sizeboundary;
|
||||
uint8 boundary[MAXLENBOUNDARY+1];
|
||||
uint8 name[VarNameSize];
|
||||
uint8 filename[VarNameSize];
|
||||
#ifdef USE_OVERLAY
|
||||
uint32 segs; // кол-во сегментов оверлея // пока в web_conn->web_disc_par
|
||||
uint32 start; // адрес запуска оверлея
|
||||
#endif
|
||||
uint32 fsize;
|
||||
uint32 faddr;
|
||||
uint8 *pbndr;
|
||||
uint8 *pnext;
|
||||
} HTTP_UPLOAD;
|
||||
|
||||
typedef struct s_http_response
|
||||
{
|
||||
uint32 status;
|
||||
uint32 flag;
|
||||
const char * headers;
|
||||
const char * default_content;
|
||||
} HTTP_RESPONSE;
|
||||
|
||||
// HTTP_RESPONSE.flags:
|
||||
#define HTTP_RESP_FLG_END 0x8000
|
||||
#define HTTP_RESP_FLG_NONE 0x0000
|
||||
#define HTTP_RESP_FLG_FINDFILE 0x0001
|
||||
#define HTTP_RESP_FLG_REDIRECT 0x0002
|
||||
|
||||
#define tcp_put(a) web_conn->msgbuf[web_conn->msgbuflen++] = a
|
||||
#define tcp_htmlstrcpy(str, len) web_conn->msgbuflen += htmlcode(&web_conn->msgbuf[web_conn->msgbuflen], str, web_conn->msgbufsize - web_conn->msgbuflen - 1, len)
|
||||
//#define tcp_urlstrcpy(str, len) web_conn->msgbuflen += urlencode(&web_conn->msgbuf[web_conn->msgbuflen], str, web_conn->msgbufsize - web_conn->msgbuflen - 1, len)
|
||||
#define tcp_puts(...) web_conn->msgbuflen += rtl_sprintf((char *)&web_conn->msgbuf[web_conn->msgbuflen], __VA_ARGS__)
|
||||
#define tcp_puts_fd(...) web_conn->msgbuflen += rtl_sprintf((char *)&web_conn->msgbuf[web_conn->msgbuflen], __VA_ARGS__)
|
||||
/*
|
||||
#define tcp_puts_fd(fmt, ...) do { \
|
||||
static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
|
||||
web_conn->msgbuflen += rtl_sprintf((char *)&web_conn->msgbuf[web_conn->msgbuflen], (char *)flash_str, ##__VA_ARGS__); \
|
||||
} while(0)
|
||||
*/
|
||||
//#define tcp_strcpy(a) web_conn->msgbuflen += ets_strlen((char *)ets_strcpy((char *)&web_conn->msgbuf[web_conn->msgbuflen], (char *)a))
|
||||
#define tcp_strcpy(a) web_conn->msgbuflen += rom_xstrcpy((char *)&web_conn->msgbuf[web_conn->msgbuflen], (const char *)a)
|
||||
#define tcp_strcpy_fd(a) web_conn->msgbuflen += rom_xstrcpy((char *)&web_conn->msgbuf[web_conn->msgbuflen], (const char *)a)
|
||||
/*
|
||||
#define tcp_strcpy_fd(fmt) do { \
|
||||
static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
|
||||
web_conn->msgbuflen += rom_xstrcpy((char *)&web_conn->msgbuf[web_conn->msgbuflen], (char *)flash_str); \
|
||||
} while(0)
|
||||
*/
|
||||
uint32 ahextoul(uint8 *s);
|
||||
err_t webserver_init(uint16 portn);
|
||||
err_t webserver_close(uint16 portn);
|
||||
err_t webserver_reinit(uint16 portn);
|
||||
|
||||
#endif /* _INCLUDE_WEB_SRV_H_ */
|
49
project/inc/web/web_srv_int.h
Normal file
49
project/inc/web/web_srv_int.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* File: web_srv_int.h
|
||||
* Description: The web server configration.
|
||||
* Small WEB server ESP8266EX
|
||||
*
|
||||
* Author: PV` 12/2014
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_WEB_SRV_INT_H_
|
||||
#define _INCLUDE_WEB_SRV_INT_H_
|
||||
|
||||
#include "web_srv.h"
|
||||
|
||||
#define WEB_NAME_VERSION "PVs/0.2"
|
||||
|
||||
// #define WEBSOCKET_ENA 1
|
||||
|
||||
// lifetime (sec) of static responses as string 60*60*24*14=1209600"
|
||||
#define FILE_CACHE_MAX_AGE_SEC 3600 // время для кеша файлов, ставить 0 пока тест!
|
||||
|
||||
#define MAX_HTTP_HEAD_BUF 3070 // максимальный размер HTTP запроса (GET)
|
||||
|
||||
#define RESCHKS_SEND_SIZE 16
|
||||
#define RESCHKE_SEND_SIZE 8
|
||||
#define RESCHK_SEND_SIZE (RESCHKS_SEND_SIZE + RESCHKE_SEND_SIZE)
|
||||
|
||||
#define MIN_SEND_SIZE (256 + RESCHK_SEND_SIZE) // минимальный размер буфера для передачи файла
|
||||
#define MAX_SEND_SIZE ((TCP_MSS*4) + RESCHK_SEND_SIZE) // максимальный размер буфера для передачи 4*MSS = 5840 (MSS=1460)
|
||||
|
||||
#define HTTP_SEND_SIZE 384 // минимальный размер буфера для передачи заголовка HTTP
|
||||
#define SCB_SEND_SIZE 128 // минимальный резерв в буфере для callback
|
||||
|
||||
#define webfile bffiles[0] // File pointer for main file
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *pvar);
|
||||
void web_int_cookie(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn);
|
||||
void web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr);
|
||||
|
||||
void web_hexdump(TCP_SERV_CONN *ts_conn);
|
||||
bool web_inc_fopen(TCP_SERV_CONN *ts_conn, uint8 *cFile);
|
||||
bool web_inc_fclose(WEB_SRV_CONN *web_conn);
|
||||
|
||||
bool web_trim_bufi(TCP_SERV_CONN *ts_conn, uint8 *pdata, uint32 data_len);
|
||||
bool web_feee_bufi(TCP_SERV_CONN *ts_conn);
|
||||
//uint8 * head_find_ctr(HTTP_CONN *CurHTTP, const uint8 * c, int clen, int dlen);
|
||||
|
||||
#endif /* _INCLUDE_WEB_SRV_INT_H_ */
|
33
project/inc/web/web_utils.h
Normal file
33
project/inc/web/web_utils.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/******************************************************************************
|
||||
* FileName: web_utils.h
|
||||
* Alternate SDK
|
||||
* Author: PV`
|
||||
* (c) PV` 2015
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _INCLUDE_WEB_UTILS_H_
|
||||
#define _INCLUDE_WEB_UTILS_H_
|
||||
|
||||
int rom_atoi(const char *s);
|
||||
void copy_align4(void *ptrd, void *ptrs, uint32 len);
|
||||
uint32 hextoul(uint8 *s);
|
||||
uint32 ahextoul(uint8 *s);
|
||||
uint8 * cmpcpystr(uint8 *pbuf, uint8 *pstr, uint8 a, uint8 b, uint16 len);
|
||||
uint8 * web_strnstr(const uint8* buffer, const uint8* token, int n);
|
||||
bool base64decode(const uint8 *in, int len, uint8_t *out, int *outlen);
|
||||
size_t base64encode(char* target, size_t target_len, const char* source, size_t source_len);
|
||||
void strtomac(uint8 *s, uint8 *macaddr);
|
||||
//uint32 strtoip(uint8 *s); // ipaddr_addr();
|
||||
int urldecode(uint8 *d, uint8 *s, uint16 lend, uint16 lens);
|
||||
//int urlencode(uint8 *d, uint8 *s, uint16 lend, uint16 lens);
|
||||
int htmlcode(uint8 *d, uint8 *s, uint16 lend, uint16 lens);
|
||||
void print_hex_dump(uint8 *buf, uint32 len, uint8 k);
|
||||
// char* str_to_upper_case(char* text);
|
||||
uint32 str_array(uint8 *s, uint32 *buf, uint32 max_buf);
|
||||
uint32 str_array_w(uint8 *s, uint16 *buf, uint32 max_buf);
|
||||
uint32 str_array_b(uint8 *s, uint8 *buf, uint32 max_buf);
|
||||
char* word_to_lower_case(char* text);
|
||||
int rom_xstrcmp(char * pd, const char * ps);
|
||||
int rom_xstrcpy(char * pd, const char * ps);
|
||||
|
||||
#endif /* _INCLUDE_WEB_UTILS_H_ */
|
17
project/inc/web/web_websocket.h
Normal file
17
project/inc/web/web_websocket.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef _WEB_WEBSOCKET_H_
|
||||
/******************************************************************************
|
||||
* FileName: web_websocket.h
|
||||
* Description: websocket for web ESP8266
|
||||
* Author: PV`
|
||||
* (c) PV` 2016
|
||||
*******************************************************************************/
|
||||
#define _WEB_WEBSOCKET_H_
|
||||
#include "user_config.h"
|
||||
#ifdef WEBSOCKET_ENA
|
||||
#include "websock.h"
|
||||
|
||||
err_t websock_tx_close_err(TCP_SERV_CONN *ts_conn, uint32 err);
|
||||
bool websock_rx_data(TCP_SERV_CONN *ts_conn);
|
||||
|
||||
#endif // WEBSOCKET_ENA
|
||||
#endif /* _WEB_WEBSOCKET_H_ */
|
108
project/inc/web/websock.h
Normal file
108
project/inc/web/websock.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* File: websock.h
|
||||
* Small WEB server ESP8266EX
|
||||
* Author: PV`
|
||||
*/
|
||||
|
||||
#ifndef _WEBSOCK_H_
|
||||
#define _WEBSOCK_H_
|
||||
|
||||
//#define WS_NONBLOCK 0x02
|
||||
|
||||
/*
|
||||
0 1 2 3
|
||||
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
|
||||
+-+-+-+-+-------+-+-------------+-------------------------------+
|
||||
|F|R|R|R| опкод |М| Длина тела | Расширенная длина тела |
|
||||
|I|S|S|S|(4бита)|А| (7бит) | (2 байта) |
|
||||
|N|V|V|V| |С| |(если длина тела==126 или 127) |
|
||||
| |1|2|3| |К| | |
|
||||
| | | | | |А| | |
|
||||
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
|
||||
|4 5 6 7 |
|
||||
| Продолжение расширенной длины тела, если длина тела = 127 |
|
||||
+ - - - - - - - - - - - - - - - +-------------------------------+
|
||||
|8 9 10 11 |
|
||||
| | Ключ маски, если МАСКА = 1 |
|
||||
+-------------------------------+-------------------------------+
|
||||
|12 13 14 15 |
|
||||
| Ключ маски (продолжение) | Данные фрейма ("тело") |
|
||||
+-------------------------------- - - - - - - - - - - - - - - - +
|
||||
|16 17 18 19 |
|
||||
: Данные продолжаются ... :
|
||||
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
|
||||
| Данные продолжаются ... |
|
||||
+---------------------------------------------------------------+
|
||||
|
||||
*/
|
||||
|
||||
#define WS_FRAGMENT_FIN 0x80
|
||||
//#define WS_RSVD_BITS (7 << 4)
|
||||
#define WS_OPCODE_BITS 0x7F
|
||||
#define WS_OPCODE_CONTINUE 0x0 // фрейм-продолжение для фрагментированного сообщения
|
||||
#define WS_OPCODE_TEXT 0x1 // текстовый фрейм
|
||||
#define WS_OPCODE_BINARY 0x2 // двоичный фрейм
|
||||
#define WS_OPCODE_CLOSE 0x8 // закрытие соединения
|
||||
#define WS_OPCODE_PING 0x9
|
||||
#define WS_OPCODE_PONG 0xa
|
||||
#define WS_MASK_FLG (1 << 7)
|
||||
#define WS_SIZE1_BITS 0x7F
|
||||
|
||||
|
||||
#define WS_CLOSE_NORMAL 1000
|
||||
#define WS_CLOSE_GOING_AWAY 1001
|
||||
#define WS_CLOSE_PROTOCOL_ERROR 1002
|
||||
#define WS_CLOSE_NOT_ALLOWED 1003
|
||||
#define WS_CLOSE_RESERVED 1004
|
||||
#define WS_CLOSE_NO_CODE 1005
|
||||
#define WS_CLOSE_DIRTY 1006
|
||||
#define WS_CLOSE_WRONG_TYPE 1007
|
||||
#define WS_CLOSE_POLICY_VIOLATION 1008
|
||||
#define WS_CLOSE_MESSAGE_TOO_BIG 1009
|
||||
#define WS_CLOSE_UNEXPECTED_ERROR 1011
|
||||
|
||||
typedef struct _WS_FRSTAT
|
||||
{
|
||||
uint32 frame_len; // размер данных в заголовке фрейма
|
||||
uint32 cur_len; // счетчик обработанных данных
|
||||
union {
|
||||
unsigned char uc[4];
|
||||
unsigned int ud;
|
||||
} mask; // маска принимаемых данных
|
||||
uint8 status;
|
||||
uint8 flg;
|
||||
uint8 head_len;
|
||||
} WS_FRSTAT; // __attribute__((packed))
|
||||
|
||||
#define WS_FLG_MASK 0x01
|
||||
#define WS_FLG_FIN 0x02
|
||||
#define WS_FLG_CLOSE 0x04 // уже передано WS_CLOSE
|
||||
|
||||
enum WS_FRAME_STATE {
|
||||
sw_frs_none = 0,
|
||||
sw_frs_text,
|
||||
sw_frs_binary,
|
||||
sw_frs_close,
|
||||
sw_frs_ping,
|
||||
sw_frs_pong
|
||||
};
|
||||
|
||||
extern const uint8 WebSocketHTTPOkKey[]; // ICACHE_RODATA_ATTR = "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept:%s\r\n\r\n"
|
||||
extern const uint8 WebSocketAddKey[]; // ICACHE_RODATA_ATTR = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
#define sizeWebSocketAddKey 36
|
||||
#define maxsizeWebSocketKey 64
|
||||
#define minsizeWebSocketKey 8
|
||||
extern const uint8 *HTTPUpgrade; // = "Upgrade:";
|
||||
#define sizeHTTPUpgrade 8
|
||||
extern const uint8 *HTTPwebsocket; // = "websocket";
|
||||
#define sizeHTTPwebsocket 9
|
||||
extern const uint8 *HTTPSecWebSocketKey; // = "Sec-WebSocket-Key:";
|
||||
#define sizeHTTPSecWebSocketKey 18
|
||||
|
||||
|
||||
bool WebSocketAcceptKey(uint8* dkey, uint8* skey);
|
||||
void WebsocketMask(WS_FRSTAT *ws, uint8 *raw_data, uint32 raw_len);
|
||||
uint32 WebsocketHead(WS_FRSTAT *ws, uint8 *raw_data, uint32 raw_len);
|
||||
err_t WebsocketTxFrame(TCP_SERV_CONN *ts_conn, uint32 opcode, uint8 *raw_data, uint32 raw_len);
|
||||
|
||||
#endif /* _WEBSOCK_H_ */
|
116
project/inc/webfs/webfs.h
Normal file
116
project/inc/webfs/webfs.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*********************************************************************
|
||||
*
|
||||
* FileName: WEBFS.h
|
||||
* Basis of MPFS2 (Microchip File System).
|
||||
* WEBFS has its differences Based.
|
||||
*
|
||||
********************************************************************/
|
||||
#ifndef __WEBFS1_H
|
||||
#define __WEBFS1_H
|
||||
|
||||
#include "flash_eep.h"
|
||||
|
||||
extern uint32 _irom0_text_end;
|
||||
|
||||
#define WEBFS_DISK_FADDR 0x0D0000
|
||||
|
||||
#define WEBFS_DISK_ID 0x42455746 // заголовок WEBFiles.bin
|
||||
#define WEBFS_DISK_VER 0x0001 // версия
|
||||
|
||||
#define MAX_FILE_NAME_SIZE 64
|
||||
|
||||
#ifndef MAX_WEBFS_OPENFILES
|
||||
#define MAX_WEBFS_OPENFILES 31
|
||||
#endif
|
||||
|
||||
#define WEBFS_FLAG_ISZIPPED 0x0001 // Indicates a file is compressed with GZIP compression
|
||||
#define WEBFS_FLAG_HASINDEX 0x0002 // Indicates a file has an associated index of dynamic variables
|
||||
#define WEBFS_INVALID 0xffffffff // Indicates a position pointer is invalid
|
||||
#define WEBFS_INVALID_FAT 0xffff // Indicates an invalid FAT cache
|
||||
typedef uint32 WEBFS_PTR; // WEBFS Pointers are currently uint32s
|
||||
typedef uint8 WEBFS_HANDLE; // WEBFS Handles are currently stored as uint8s
|
||||
#define WEBFS_INVALID_HANDLE 0xff // Indicates that a handle is not valid
|
||||
|
||||
|
||||
// Stores each file handle's information
|
||||
// Handles are free when addr = WEBFS_INVALID
|
||||
typedef struct
|
||||
{
|
||||
WEBFS_PTR addr; // Current address in the file system
|
||||
uint32 bytesRem; // How many uint8s remain in this file
|
||||
#ifdef USE_MAX_IRAM
|
||||
uint32 fatID; // ID of which file in the FAT was accessed
|
||||
#else
|
||||
uint16 fatID; // ID of which file in the FAT was accessed
|
||||
#endif
|
||||
} WEBFS_STUB;
|
||||
|
||||
// Indicates the method for WEBFSSeek
|
||||
typedef enum
|
||||
{
|
||||
WEBFS_SEEK_START = 0, // Seek forwards from the front of the file
|
||||
WEBFS_SEEK_END, // Seek backwards from the end of the file
|
||||
WEBFS_SEEK_FORWARD, // Seek forward from the current position
|
||||
WEBFS_SEEK_REWIND // See backwards from the current position
|
||||
} WEBFS_SEEK_MODE;
|
||||
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32 id;
|
||||
uint16 ver;
|
||||
uint16 numFiles;
|
||||
uint32 disksize;
|
||||
} WEBFS_DISK_HEADER ;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32 blksize; // Length of file data - headlen
|
||||
uint16 headlen; // headlen (Length of File Name + 0)
|
||||
uint16 flags; // Flags for this file
|
||||
} WEBFS_FHEADER;
|
||||
|
||||
// Stores the data for an WEBFS1 FAT record
|
||||
typedef struct
|
||||
{
|
||||
uint32 string; // Pointer to the file name
|
||||
uint32 data; // Address of the file data
|
||||
uint32 len; // Length of file data
|
||||
#ifdef USE_MAX_IRAM
|
||||
uint32 flags; // Flags for this file
|
||||
#else
|
||||
uint16 flags; // Flags for this file
|
||||
#endif
|
||||
} WEBFS_FAT_RECORD ;
|
||||
|
||||
|
||||
void WEBFSInit(void);
|
||||
WEBFS_HANDLE WEBFSOpen(uint8* cFile);
|
||||
void WEBFSClose(WEBFS_HANDLE hWEBFS);
|
||||
|
||||
uint16 WEBFSGetArray(WEBFS_HANDLE hWEBFS, uint8* cData, uint16 wLen);
|
||||
|
||||
uint16 WEBFSGetFlags(WEBFS_HANDLE hWEBFS);
|
||||
uint32 WEBFSGetSize(WEBFS_HANDLE hWEBFS);
|
||||
uint32 WEBFSGetBytesRem(WEBFS_HANDLE hWEBFS);
|
||||
WEBFS_PTR WEBFSGetStartAddr(WEBFS_HANDLE hWEBFS);
|
||||
WEBFS_PTR WEBFSGetEndAddr(WEBFS_HANDLE hWEBFS);
|
||||
bool WEBFSGetFilename(WEBFS_HANDLE hWEBFS, uint8* cName, uint16 wLen);
|
||||
uint32 WEBFSGetPosition(WEBFS_HANDLE hWEBFS);
|
||||
uint32 WEBFS_max_size(void);
|
||||
uint32 WEBFS_curent_size(void);
|
||||
uint32 WEBFS_base_addr(void);
|
||||
|
||||
#ifdef USE_MAX_IRAM
|
||||
extern int isWEBFSLocked; // Lock WEBFS access during the upgrade
|
||||
extern uint32 numFiles;
|
||||
#else
|
||||
extern volatile bool isWEBFSLocked; // Lock WEBFS access during the upgrade
|
||||
extern uint16 numFiles;
|
||||
#endif
|
||||
|
||||
extern WEBFS_FAT_RECORD fatCache;
|
||||
extern WEBFS_STUB WEBFSStubs[MAX_WEBFS_OPENFILES+1];
|
||||
extern uint32 disk_base_addr;
|
||||
|
||||
#endif
|
67
project/inc/wifi_user_set.h
Normal file
67
project/inc/wifi_user_set.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* wifi_user_set.h
|
||||
*
|
||||
* Created on: 01/04/2017
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_USER_SET_H_
|
||||
#define _WIFI_USER_SET_H_
|
||||
|
||||
//=========================================
|
||||
//==== Wlan Config ========================
|
||||
#define DEF_WIFI_MODE RTW_MODE_STA // RTW_MODE_STA_AP, RTW_MODE_AP, RTW_MODE_STA
|
||||
#define DEF_WIFI_AP_STATIONS 3 // Max number of STAs, should be 1..3, default is 3
|
||||
#define DEF_WIFI_COUNTRY RTW_COUNTRY_RU
|
||||
#define DEF_WIFI_TX_PWR RTW_TX_PWR_PERCENTAGE_25 // RTW_TX_PWR_PERCENTAGE_75 // RTW_TX_PWR_PERCENTAGE_100
|
||||
#define DEF_WIFI_BGN RTW_NETWORK_BGN // rtw_network_mode_t
|
||||
#define DEF_WIFI_ST_SLEEP 0 // 0 - none, 1 - on
|
||||
//#define USE_NETBIOS 3 // 0 - off, 1 - ST, 2 - AP, 3 - AP+ST
|
||||
#define DEF_LOAD_CFG ( 0 \
|
||||
| BID_WIFI_AP_CFG \
|
||||
| BID_WIFI_ST_CFG \
|
||||
| BID_AP_DHCP_CFG \
|
||||
| BID_ST_DHCP_CFG \
|
||||
| BID_WIFI_CFG \
|
||||
)
|
||||
#define DEF_SAVE_CFG ( 0 \
|
||||
| BID_WIFI_AP_CFG \
|
||||
| BID_WIFI_ST_CFG \
|
||||
| BID_AP_DHCP_CFG \
|
||||
| BID_ST_DHCP_CFG \
|
||||
| BID_WIFI_CFG \
|
||||
)
|
||||
//==== Interface 0 - wlan0 = AP ===========
|
||||
#define DEF_AP_SSID "RTL871X"
|
||||
#define DEF_AP_PASSWORD "0123456789"
|
||||
#define DEF_AP_SECURITY RTW_SECURITY_WPA2_AES_PSK // RTW_SECURITY_OPEN, RTW_SECURITY_WEP_PSK
|
||||
#define DEF_AP_BEACON 100 // 100...6000 ms
|
||||
#define DEF_AP_CHANNEL 1 // 1..14
|
||||
#define DEF_AP_CHANNEL 1 // 1..14
|
||||
#define DEF_AP_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on
|
||||
#define DEF_AP_IP IP4ADDR(192,168,4,1)
|
||||
#define DEF_AP_MSK IP4ADDR(255,255,255,0)
|
||||
#define DEF_AP_GW IP4ADDR(192,168,4,1)
|
||||
#define DEF_AP_DHCP_START 2
|
||||
#define DEF_AP_DHCP_STOP 15
|
||||
//==== Interface 1 - wlan1 = STA ==========
|
||||
#define DEF_ST_SSID "HOMEAP"
|
||||
#define DEF_ST_PASSWORD "0123456789"
|
||||
#define DEF_ST_SECURITY RTW_SECURITY_WPA_WPA2_MIXED
|
||||
#define DEF_ST_BSSID { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } // If bssid set is not ff.ff.ff.ff.ff.ff,
|
||||
// station will connect to the router with both ssid[] and bssid[] matched.
|
||||
#define DEF_ST_CHANNEL 1 // 1..14
|
||||
#define DEF_ST_AUTORECONNECT 1 // 0 - none, 1..254 - count, 255 - all
|
||||
#define DEF_ST_RECONNECT_PAUSE 1 // 5 sec
|
||||
#define DEF_ST_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on, =2 Static ip, =3 - auto
|
||||
#define DEF_ST_IP IP4ADDR(192,168,1,100)
|
||||
#define DEF_ST_MSK IP4ADDR(255,255,255,0)
|
||||
#define DEF_ST_GW IP4ADDR(192,168,1,1)
|
||||
//==== Interface 2 - eth0 =================
|
||||
#define DEF_EH_DHCP_MODE 1 // =0 dhcp off, =1 - dhcp on
|
||||
#define DEF_EH_IP IP4ADDR(192,168,7,200)
|
||||
#define DEF_EH_MSK IP4ADDR(255,255,255,0)
|
||||
#define DEF_EH_GW IP4ADDR(192,168,7,1)
|
||||
//=========================================
|
||||
|
||||
#endif /* _WIFI_USER_SET_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue