mirror of
https://github.com/ADElectronics/RTL00_WEB_WS2812.git
synced 2024-12-05 02:00:29 +00:00
1st
This commit is contained in:
parent
7f07f696e1
commit
c6c5eeed6f
1170 changed files with 608790 additions and 1 deletions
BIN
Firmware/.vs/RTLGDB/v14/.suo
Normal file
BIN
Firmware/.vs/RTLGDB/v14/.suo
Normal file
Binary file not shown.
1030
Firmware/.vs/config/applicationhost.config
Normal file
1030
Firmware/.vs/config/applicationhost.config
Normal file
File diff suppressed because it is too large
Load diff
BIN
Firmware/RTLGDB.VC.db
Normal file
BIN
Firmware/RTLGDB.VC.db
Normal file
Binary file not shown.
28
Firmware/RTLGDB.sln
Normal file
28
Firmware/RTLGDB.sln
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25420.1
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RTLGDB", "RTLGDB\RTLGDB.vcxproj", "{3D8B16B6-9763-48AD-A514-F45680E8613B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Debug|x64.ActiveCfg = Debug|Win32
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Debug|x64.Build.0 = Debug|Win32
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Release|x64.Build.0 = Release|x64
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{3D8B16B6-9763-48AD-A514-F45680E8613B}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
82
Firmware/RTLGDB/Assets/LinuxDebugger.xaml
Normal file
82
Firmware/RTLGDB/Assets/LinuxDebugger.xaml
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--Copyright, Microsoft Corporation, All rights reserved.-->
|
||||||
|
<Rule
|
||||||
|
Name="LinuxDebugger"
|
||||||
|
DisplayName="Remote GDB"
|
||||||
|
PageTemplate="debugger"
|
||||||
|
Order="300"
|
||||||
|
Description="Debugger options"
|
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||||
|
|
||||||
|
<!--Rule.Metadata>
|
||||||
|
<sys:Guid x:Key="DebugTargetTypeCommandGuid">FEEA6E9D-77D8-423F-9EDE-3970CBB76125</sys:Guid>
|
||||||
|
<sys:UInt32 x:Key="DebugTargetTypeCommandId">0x400</sys:UInt32>
|
||||||
|
<sys:String x:Key="DebugTargetDropdownEnum">AndroidDeviceID</sys:String>
|
||||||
|
</Rule.Metadata-->
|
||||||
|
<Rule.DataSource>
|
||||||
|
<DataSource Persistence="UserFile" />
|
||||||
|
</Rule.DataSource>
|
||||||
|
<Rule.Categories>
|
||||||
|
<Category Name="StartOptions" DisplayName="Start Options" Description="Start Options"/>
|
||||||
|
</Rule.Categories>
|
||||||
|
|
||||||
|
<StringProperty Name="RemoteHostName"
|
||||||
|
DisplayName="Remote Host Name"
|
||||||
|
Description="Host name or IP address of the remote machine"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="RemoteUserName"
|
||||||
|
DisplayName="Remote User Name"
|
||||||
|
Description="User Name for the remote machine"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="PrivateKey"
|
||||||
|
DisplayName="Private Key"
|
||||||
|
Description="Private Key for authentication in the remote machine"
|
||||||
|
Subtype="file"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="SecureShellExecutable"
|
||||||
|
DisplayName="Secure Shell Executable"
|
||||||
|
Description="Command to invoke a Secure Shell session to stream debuger session through, e.g. ssh or plink"
|
||||||
|
Subtype="file"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="RemoteWorkingDirectory"
|
||||||
|
DisplayName="Remote Working Directory"
|
||||||
|
Description="Remote root location where executable runs"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="RemoteExecutable"
|
||||||
|
DisplayName="Remote Executable"
|
||||||
|
Description="Name of the remote executable program"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="RemoteExecutableArguments"
|
||||||
|
DisplayName="Remote Executable Arguments"
|
||||||
|
Description="Optional, arguments to pass to the remote executable"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="RemoteDebuggerExecutable"
|
||||||
|
DisplayName="Remote Debugger Executable"
|
||||||
|
Description="Command to invoke remote debugger executable"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
</Rule>
|
63
Firmware/RTLGDB/Assets/LocalDebugger.xaml
Normal file
63
Firmware/RTLGDB/Assets/LocalDebugger.xaml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--Copyright, Microsoft Corporation, All rights reserved.-->
|
||||||
|
<Rule
|
||||||
|
Name="LocalDebugger"
|
||||||
|
DisplayName="Local GDB"
|
||||||
|
PageTemplate="debugger"
|
||||||
|
Order="200"
|
||||||
|
Description="Debugger options"
|
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||||
|
|
||||||
|
<!--Rule.Metadata>
|
||||||
|
<sys:Guid x:Key="DebugTargetTypeCommandGuid">FEEA6E9D-77D8-423F-9EDE-3970CBB76125</sys:Guid>
|
||||||
|
<sys:UInt32 x:Key="DebugTargetTypeCommandId">0x400</sys:UInt32>
|
||||||
|
<sys:String x:Key="DebugTargetDropdownEnum">AndroidDeviceID</sys:String>
|
||||||
|
</Rule.Metadata-->
|
||||||
|
<Rule.DataSource>
|
||||||
|
<DataSource Persistence="UserFile" />
|
||||||
|
</Rule.DataSource>
|
||||||
|
<Rule.Categories>
|
||||||
|
<Category Name="StartOptions" DisplayName="Start Options" Description="Start Options"/>
|
||||||
|
</Rule.Categories>
|
||||||
|
|
||||||
|
<StringProperty Name="LocalWorkingDirectory"
|
||||||
|
DisplayName="Local Working Directory"
|
||||||
|
Description="Local root location where executable runs"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
<ValueEditor EditorType="DefaultFolderPropertyEditor" DisplayName="<Browse...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="LocalExecutable"
|
||||||
|
DisplayName="Local Executable"
|
||||||
|
Description="Name of the local executable program"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="LocalExecutableArguments"
|
||||||
|
DisplayName="Local Executable Arguments"
|
||||||
|
Description="Optional, arguments to pass to the local executable"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="LocalDebuggerExecutable"
|
||||||
|
DisplayName="Local Debugger Executable"
|
||||||
|
Description="Full path to local gdb/lldb executable"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="LocalDebuggerServerAddress"
|
||||||
|
DisplayName="Local Debugger Server Address"
|
||||||
|
Description="Optional, local debugger server address if needed"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
</Rule>
|
57
Firmware/RTLGDB/Assets/OCDDebugger.xaml
Normal file
57
Firmware/RTLGDB/Assets/OCDDebugger.xaml
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--Copyright, Microsoft Corporation, All rights reserved.-->
|
||||||
|
<Rule
|
||||||
|
Name="OCDDebugger"
|
||||||
|
DisplayName="OCD GDB Debugger"
|
||||||
|
PageTemplate="debugger"
|
||||||
|
Order="100"
|
||||||
|
Description="Debugger options"
|
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||||
|
|
||||||
|
<Rule.DataSource>
|
||||||
|
<DataSource Persistence="UserFile" />
|
||||||
|
</Rule.DataSource>
|
||||||
|
<Rule.Categories>
|
||||||
|
<Category Name="StartOptions" DisplayName="Start Options" Description="Start Options"/>
|
||||||
|
</Rule.Categories>
|
||||||
|
|
||||||
|
<StringProperty Name="OCDDebuggerExecutable"
|
||||||
|
DisplayName="OCD Debugger Executable"
|
||||||
|
Description="Full path to OCD debugger executable"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="OCDDebuggerServerAddress"
|
||||||
|
DisplayName="OCD Debugger Server Address"
|
||||||
|
Description="OCD Debugger Server Address"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="OCDDebugBinary"
|
||||||
|
DisplayName="OCD Debug Binary"
|
||||||
|
Description="Location of binary file with debug symbols for OCD"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<StringProperty Name="OCDDebuggerSymbols"
|
||||||
|
DisplayName="OCD Debugger Symbols"
|
||||||
|
Description="Full path to debug symbols for binary"
|
||||||
|
F1Keyword="VC.Project.LinuxDebugger.PackagePath">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
-->
|
||||||
|
</Rule>
|
69
Firmware/RTLGDB/Assets/linux_nmake.xaml
Normal file
69
Firmware/RTLGDB/Assets/linux_nmake.xaml
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--Copyright, Microsoft Corporation, All rights reserved.-->
|
||||||
|
<Rule
|
||||||
|
Name="ConfigurationNMake"
|
||||||
|
DisplayName="NMake"
|
||||||
|
PageTemplate="generic"
|
||||||
|
Description="NMake"
|
||||||
|
SwitchPrefix="/"
|
||||||
|
Order="100"
|
||||||
|
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||||
|
<Rule.Categories>
|
||||||
|
<Category Name="General" DisplayName="General" Description="General" />
|
||||||
|
<Category Name="IntelliSense" DisplayName="IntelliSense" Description="IntelliSense" />
|
||||||
|
</Rule.Categories>
|
||||||
|
<Rule.DataSource>
|
||||||
|
<DataSource Persistence="ProjectFile" />
|
||||||
|
</Rule.DataSource>
|
||||||
|
<StringProperty Name="NMakeBuildCommandLine" DisplayName="Build Command Line"
|
||||||
|
Description="Specifies the command line to run for the 'Build' command."
|
||||||
|
IncludeInCommandLine="false"
|
||||||
|
Category="General"
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.BuildCommandLine">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultCommandPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
<StringProperty Name="NMakeReBuildCommandLine" DisplayName="Rebuild All Command Line"
|
||||||
|
Description="Specifies the command line to run for the 'Rebuild All' command."
|
||||||
|
IncludeInCommandLine="false"
|
||||||
|
Category="General"
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.ReBuildCommandLine">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultCommandPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
<StringProperty Name="NMakeCleanCommandLine" DisplayName="Clean Command Line"
|
||||||
|
Description="Specifies the command line to run for the 'Clean' command."
|
||||||
|
IncludeInCommandLine="false"
|
||||||
|
Category="General"
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.CleanCommandLine">
|
||||||
|
<StringProperty.ValueEditors>
|
||||||
|
<ValueEditor EditorType="DefaultCommandPropertyEditor" DisplayName="<Edit...>"/>
|
||||||
|
</StringProperty.ValueEditors>
|
||||||
|
</StringProperty>
|
||||||
|
<StringProperty Name="NMakeOutput" DisplayName="Output"
|
||||||
|
Description='Specifies the output file to generate.'
|
||||||
|
Category="General"
|
||||||
|
IncludeInCommandLine="false"
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.Output"/>
|
||||||
|
|
||||||
|
|
||||||
|
<StringListProperty Name="NMakePreprocessorDefinitions" DisplayName="Preprocessor Definitions" Category="IntelliSense" Switch="D"
|
||||||
|
Description="Specifies the preprocessor defines used by the source files."
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.PreprocessorDefinitions"/>
|
||||||
|
<StringListProperty Name="NMakeIncludeSearchPath" DisplayName="Include Search Path" Category="IntelliSense" Switch="I"
|
||||||
|
Description="Specifies the include search path for resolving included files." Subtype="folder"
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.IncludeSearchPath"/>
|
||||||
|
<StringListProperty Name="NMakeForcedIncludes" DisplayName="Forced Includes" Category="IntelliSense" Switch="FI"
|
||||||
|
Description="Specifies the files that are forced included." Subtype="folder"
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.ForcedIncludes"/>
|
||||||
|
<StringListProperty Name="NMakeAssemblySearchPath" DisplayName="Assembly Search Path" Category="IntelliSense" Switch="AI"
|
||||||
|
Description="Specifies the assembly search path for resolving used .NET assemblies." Subtype="folder"
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.AssemblySearchPath"/>
|
||||||
|
<StringListProperty Name="AdditionalSOSearchPaths" DisplayName="Additional Symbol Search Paths" Category="IntelliSense"
|
||||||
|
Description="Locations to identify "
|
||||||
|
F1Keyword="VC.Project.VCNMakeTool.AdditionalSOSearchPaths" />
|
||||||
|
<StringProperty Name="AdditionalOptions" DisplayName="Additional Options" Category="IntelliSense"
|
||||||
|
Description="Specifies additional compiler switches to be used by Intellisense when parsing C++ files" />
|
||||||
|
</Rule>
|
49
Firmware/RTLGDB/Debug/RTLGDB.log
Normal file
49
Firmware/RTLGDB/Debug/RTLGDB.log
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
===========================================================
|
||||||
|
Compile (Debug)
|
||||||
|
project/user_start.c
|
||||||
|
project/WS2812/ledfilters.c
|
||||||
|
project/WS2812/ledeffectsserver.c
|
||||||
|
project/web/web_int_callbacks.c
|
||||||
|
project/web/web_int_vars.c
|
||||||
|
===========================================================
|
||||||
|
Link (Debug)
|
||||||
|
===========================================================
|
||||||
|
Build names map file
|
||||||
|
Debug/obj/Debug.nmap
|
||||||
|
===========================================================
|
||||||
|
Create image1r (Debug/bin/ram_1.r.bin)
|
||||||
|
b:268438472 s:268438472 e:268446992
|
||||||
|
size 8520
|
||||||
|
append fw head b000
|
||||||
|
copy size 8520
|
||||||
|
===========================================================
|
||||||
|
Create image2ns (Debug/bin/ram_2.ns.bin)
|
||||||
|
b:268460032 s:268460032 e:268727448
|
||||||
|
size 267416
|
||||||
|
copy size 267416
|
||||||
|
===========================================================
|
||||||
|
Create image3 (SDRAM, Debug/bin/sdram.p.bin)
|
||||||
|
30000000 30000000
|
||||||
|
b:805306368 s:805306368 e:805306368
|
||||||
|
size 0
|
||||||
|
copy size 0
|
||||||
|
===========================================================
|
||||||
|
Make OTA image (Debug/bin/ota.bin)
|
||||||
|
size = 267448
|
||||||
|
|
||||||
|
checksum 1a71a99
|
||||||
|
|
||||||
|
===========================================================
|
||||||
|
Create image2p (Debug/bin/ram_2.p.bin)
|
||||||
|
b:268460032 s:268460032 e:268727448
|
||||||
|
size 267416
|
||||||
|
copy size 267416
|
||||||
|
===========================================================
|
||||||
|
Make Flash image (Debug/bin/ram_all.bin)
|
||||||
|
total 44 k, padding data 0, name Debug/bin/ram_all.bin
|
||||||
|
Original size zd
|
||||||
|
Padding size zd
|
||||||
|
-----------------------------------------------------------
|
||||||
|
Image (Debug/bin/ota.bin) size 267452 bytes
|
||||||
|
Image (Debug/bin/ram_all.bin) size 312504 bytes
|
||||||
|
===========================================================
|
BIN
Firmware/RTLGDB/Debug/bin/WEBFiles.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/WEBFiles.bin
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Debug/bin/ota.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/ota.bin
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Debug/bin/ram_1.p.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/ram_1.p.bin
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Debug/bin/ram_1.r.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/ram_1.r.bin
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Debug/bin/ram_2.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/ram_2.bin
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Debug/bin/ram_2.ns.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/ram_2.ns.bin
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Debug/bin/ram_2.p.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/ram_2.p.bin
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Debug/bin/ram_all.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/ram_all.bin
Normal file
Binary file not shown.
0
Firmware/RTLGDB/Debug/bin/sdram.bin
Normal file
0
Firmware/RTLGDB/Debug/bin/sdram.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/sdram.p.bin
Normal file
BIN
Firmware/RTLGDB/Debug/bin/sdram.p.bin
Normal file
Binary file not shown.
9
Firmware/RTLGDB/Debug/bin/web_vars.txt
Normal file
9
Firmware/RTLGDB/Debug/bin/web_vars.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
ws_filt_rbw_enbl
|
||||||
|
ws_filt_flick_enbl
|
||||||
|
ws_filt_fd_enbl
|
||||||
|
ws_filt_rbw_huesteps
|
||||||
|
ws_filt_rbw_cyclesteps
|
||||||
|
ws_filt_fd_cyclesteps
|
||||||
|
ws_filt_fd_min
|
||||||
|
ws_filt_fd_max
|
||||||
|
ws_filt_fd_chance
|
93015
Firmware/RTLGDB/Debug/obj/Debug.asm
Normal file
93015
Firmware/RTLGDB/Debug/obj/Debug.asm
Normal file
File diff suppressed because it is too large
Load diff
BIN
Firmware/RTLGDB/Debug/obj/Debug.axf
Normal file
BIN
Firmware/RTLGDB/Debug/obj/Debug.axf
Normal file
Binary file not shown.
3283
Firmware/RTLGDB/Debug/obj/Debug.nmap
Normal file
3283
Firmware/RTLGDB/Debug/obj/Debug.nmap
Normal file
File diff suppressed because it is too large
Load diff
1
Firmware/RTLGDB/Debug/obj/obj_list.lst
Normal file
1
Firmware/RTLGDB/Debug/obj/obj_list.lst
Normal file
File diff suppressed because one or more lines are too long
212
Firmware/RTLGDB/Project/FreeRTOSConfig.h
Normal file
212
Firmware/RTLGDB/Project/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
/*
|
||||||
|
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_STACK_TCM_HEAP 5 // RTL871xAx/RTL8195Ax Stack priority used TCM HEAP
|
||||||
|
#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 0
|
||||||
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
|
#define configQUEUE_REGISTRY_SIZE 0
|
||||||
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
|
|
||||||
|
#if configGENERATE_RUN_TIME_STATS
|
||||||
|
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||||
|
#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(uint32_t *expected_idle_time);
|
||||||
|
extern void freertos_post_sleep_processing(uint32_t *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 */
|
BIN
Firmware/RTLGDB/Project/WS2812 2017.12.14.zip
Normal file
BIN
Firmware/RTLGDB/Project/WS2812 2017.12.14.zip
Normal file
Binary file not shown.
BIN
Firmware/RTLGDB/Project/WS2812 2017.12.23.zip
Normal file
BIN
Firmware/RTLGDB/Project/WS2812 2017.12.23.zip
Normal file
Binary file not shown.
134
Firmware/RTLGDB/Project/WS2812/ledeffectsserver.c
Normal file
134
Firmware/RTLGDB/Project/WS2812/ledeffectsserver.c
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
#include "ledeffectsserver.h"
|
||||||
|
#include "ws2812.h"
|
||||||
|
#include <flash_api.h>
|
||||||
|
|
||||||
|
volatile uint32_t cfg_updated = 0;
|
||||||
|
ws2812_t *ws2812_cfg = NULL;
|
||||||
|
strip_handler_t strip;
|
||||||
|
SemaphoreHandle_t cfg_sema = NULL;
|
||||||
|
|
||||||
|
ctx_rainbow_t filt_rainbow;
|
||||||
|
ctx_fade_t filt_fade;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ledEffectsServer_Init()
|
||||||
|
{
|
||||||
|
cfg_sema = xSemaphoreCreateMutex();
|
||||||
|
|
||||||
|
ws2812_cfg = ws2812_Init(WS2812_LEDS_MAX);
|
||||||
|
if (ws2812_cfg == NULL)
|
||||||
|
{
|
||||||
|
printf("[%s] ws2812_Init() failed\n", __func__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
ledFilter_Init(&strip, ws2812_cfg);
|
||||||
|
|
||||||
|
ledFilter_InitRainbow(&filt_rainbow);
|
||||||
|
ledFilter_InitFade(&filt_fade);
|
||||||
|
|
||||||
|
ledFilter_SetDefualtValue(&strip, MAX_STRIP_BRIGHT);
|
||||||
|
filt_fade.enabled = 1;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if(xSemaphoreTake(cfg_sema, 5 * configTICK_RATE_HZ))
|
||||||
|
{
|
||||||
|
ledFilter_Rainbow(&filt_rainbow, &strip);
|
||||||
|
ledFilter_Fade(&filt_fade, &strip);
|
||||||
|
|
||||||
|
ws2812_Update(ws2812_cfg, strip.hsv_vals, strip.strip_len, strip.delay);
|
||||||
|
|
||||||
|
xSemaphoreGive(cfg_sema);
|
||||||
|
}
|
||||||
|
WDGRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
vTaskDelay(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
void ledEffectsServer_LoadConfigFromFlash()
|
||||||
|
{
|
||||||
|
flash_t flash;
|
||||||
|
|
||||||
|
printf("[%s] reading config from flash\n", __func__);
|
||||||
|
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||||
|
flash_stream_read(&flash, LED_SETTINGS_SECTOR, sizeof(strip_cfg), (uint8_t *)&strip_cfg);
|
||||||
|
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledEffectsServer_SaveConfigToFlash()
|
||||||
|
{
|
||||||
|
flash_t flash;
|
||||||
|
|
||||||
|
printf("[%s] saving config to flash\n", __func__);
|
||||||
|
|
||||||
|
cfg_updated = 0;
|
||||||
|
|
||||||
|
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||||
|
flash_erase_sector(&flash, LED_SETTINGS_SECTOR);
|
||||||
|
flash_stream_write(&flash, LED_SETTINGS_SECTOR, sizeof(strip_cfg), (uint8_t *)&strip_cfg);
|
||||||
|
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
struct blinken_cfg *blinken_get_config(void)
|
||||||
|
{
|
||||||
|
blinken_cfg_t *cfg = NULL;
|
||||||
|
|
||||||
|
if(strip_cfg.magic == BLINKEN_CFG_MAGIC)
|
||||||
|
{
|
||||||
|
cfg = malloc(sizeof(*cfg));
|
||||||
|
if(cfg != NULL)
|
||||||
|
{
|
||||||
|
memmove(cfg, &strip_cfg, sizeof(*cfg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int blinken_set_config(blinken_cfg_t *cfg)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
BaseType_t status;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
if(cfg == NULL || cfg->magic != BLINKEN_CFG_MAGIC)
|
||||||
|
{
|
||||||
|
result = -1;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = xSemaphoreTake(cfg_sema, 15 * configTICK_RATE_HZ);
|
||||||
|
if(status != pdTRUE)
|
||||||
|
{
|
||||||
|
printf("[%s] Timeout waiting for config sema.\n", __func__);
|
||||||
|
result = -1;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = init_handler(&handler, cfg, ws2812_cfg, true);
|
||||||
|
if(result == 0)
|
||||||
|
{
|
||||||
|
memmove(&strip_cfg, cfg, sizeof(strip_cfg));
|
||||||
|
save_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
xSemaphoreGive(cfg_sema);
|
||||||
|
|
||||||
|
error:
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
18
Firmware/RTLGDB/Project/WS2812/ledeffectsserver.h
Normal file
18
Firmware/RTLGDB/Project/WS2812/ledeffectsserver.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef _LEDEFFECTSSERVER_H_
|
||||||
|
#define _LEDEFFECTSSERVER_H_
|
||||||
|
|
||||||
|
#include "ledfilters.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Ïóáëè÷íûå êîíôèíãè ôèëüòðîâ
|
||||||
|
|
||||||
|
|
||||||
|
extern ctx_rainbow_t filt_rainbow;
|
||||||
|
extern ctx_fade_t filt_fade;
|
||||||
|
|
||||||
|
|
||||||
|
void ledEffectsServer_Init();
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _LEDEFFECTSSERVER_H_
|
||||||
|
|
209
Firmware/RTLGDB/Project/WS2812/ledfilters.c
Normal file
209
Firmware/RTLGDB/Project/WS2812/ledfilters.c
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
#include "ledfilters.h"
|
||||||
|
|
||||||
|
extern uint32_t cfg_updated;
|
||||||
|
|
||||||
|
#pragma region Áàçîâûå ôóíêöèè ïî ðàáîòå ñ ôèëüòðàìè
|
||||||
|
int32_t ledFilter_Init(strip_handler_t *strip, ws2812_t *ws2812)
|
||||||
|
{
|
||||||
|
if(strip->check != LEDFILTERS_CFG_CHECKWORD)
|
||||||
|
{
|
||||||
|
memset(strip, 0xff, sizeof(strip_handler_t));
|
||||||
|
strip->check = LEDFILTERS_CFG_CHECKWORD;
|
||||||
|
strip->strip_len = DEF_STRIP_LEN;
|
||||||
|
strip->delay = 10;
|
||||||
|
strip->brightness = MAX_STRIP_BRIGHT;
|
||||||
|
|
||||||
|
cfg_updated = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strip->strip_len > MAX_STRIP_LEN)
|
||||||
|
{
|
||||||
|
strip->strip_len = MAX_STRIP_LEN;
|
||||||
|
cfg_updated = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strip->delay > MAX_STRIP_DELAY)
|
||||||
|
{
|
||||||
|
strip->delay = MAX_STRIP_DELAY;
|
||||||
|
cfg_updated = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strip->brightness > MAX_STRIP_BRIGHT)
|
||||||
|
{
|
||||||
|
strip->brightness = MAX_STRIP_BRIGHT;
|
||||||
|
cfg_updated = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
strip->hsv_vals = malloc(sizeof(ws2812_hsv_t) * strip->strip_len);
|
||||||
|
if (strip->hsv_vals == NULL)
|
||||||
|
{
|
||||||
|
printf("[%s] malloc() failed\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(strip->hsv_vals, 0x0, sizeof(ws2812_hsv_t) * strip->strip_len);
|
||||||
|
|
||||||
|
ws2812_SetLen(ws2812, strip->strip_len);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledFilter_SetDefualtValue(strip_handler_t *strip, uint8_t val)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
for (i = 0; i < strip->strip_len; i++)
|
||||||
|
{
|
||||||
|
strip->hsv_vals[i].value = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Rainbow
|
||||||
|
void ledFilter_InitRainbow(ctx_rainbow_t *ctx)
|
||||||
|
{
|
||||||
|
if (ctx->valid != LEDFILTERS_CFG_CHECKWORD)
|
||||||
|
{
|
||||||
|
ctx->valid = LEDFILTERS_CFG_CHECKWORD;
|
||||||
|
ctx->hue_steps = WS2812_LEDS_MAX / 2; // Âî ñêîëüêî ñâåòîäèîäîâ âìåñòèòü âñþ ðàäóãó
|
||||||
|
ctx->cycle_steps = 1;
|
||||||
|
ctx->enabled = 1;
|
||||||
|
cfg_updated = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->curr_hue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledFilter_Rainbow(ctx_rainbow_t *ctx, strip_handler_t *strip)
|
||||||
|
{
|
||||||
|
uint32_t i, j;
|
||||||
|
ws2812_hsv_t tmp_hsv;
|
||||||
|
uint8_t tmp_hue;
|
||||||
|
|
||||||
|
if (ctx->enabled == 0) return;
|
||||||
|
|
||||||
|
tmp_hue = ctx->curr_hue;
|
||||||
|
tmp_hsv.sat = 255;
|
||||||
|
|
||||||
|
for (i = 0, j = ctx->hue_steps; i < strip->strip_len; i++)
|
||||||
|
{
|
||||||
|
if (i == j)
|
||||||
|
{
|
||||||
|
j += ctx->hue_steps;
|
||||||
|
tmp_hue = ctx->curr_hue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_hsv.hue = tmp_hue;
|
||||||
|
tmp_hsv.value = strip->hsv_vals[i].value;
|
||||||
|
strip->hsv_vals[i] = tmp_hsv;
|
||||||
|
tmp_hue += 255/ ctx->hue_steps;
|
||||||
|
tmp_hue %= 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->curr_hue += ctx->cycle_steps;
|
||||||
|
ctx->curr_hue %= 256;
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Fade
|
||||||
|
void ledFilter_InitFade(ctx_fade_t *ctx)
|
||||||
|
{
|
||||||
|
if (ctx->valid != LEDFILTERS_CFG_CHECKWORD)
|
||||||
|
{
|
||||||
|
ctx->valid = 1;
|
||||||
|
ctx->min = 0;
|
||||||
|
ctx->max = 255;
|
||||||
|
ctx->steps = LEDFILTERS_MAX_STEPS;
|
||||||
|
ctx->enabled = 1;
|
||||||
|
cfg_updated = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->steps == 0)
|
||||||
|
{
|
||||||
|
ctx->enabled = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->curr_val = 0;
|
||||||
|
ctx->curr_step = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledFilter_Fade(ctx_fade_t *ctx, strip_handler_t *strip)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
if (ctx->enabled == 0) return;
|
||||||
|
|
||||||
|
if (ctx->curr_val == 0)
|
||||||
|
{
|
||||||
|
for (i = 0; i < strip->strip_len; i++)
|
||||||
|
{
|
||||||
|
if (strip->hsv_vals[i].value > ctx->min)
|
||||||
|
{
|
||||||
|
if (strip->hsv_vals[i].value > (255 / ctx->steps))
|
||||||
|
strip->hsv_vals[i].value -= (255 / ctx->steps);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strip->hsv_vals[i].value = 0;
|
||||||
|
ctx->curr_step = ctx->steps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx->curr_step = ctx->steps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < strip->strip_len; i++)
|
||||||
|
{
|
||||||
|
if (strip->hsv_vals[i].value <= ctx->max)
|
||||||
|
{
|
||||||
|
if (strip->hsv_vals[i].value + (255 / ctx->steps) > ctx->max)
|
||||||
|
{
|
||||||
|
strip->hsv_vals[i].value = ctx->max;
|
||||||
|
ctx->curr_step = ctx->steps;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strip->hsv_vals[i].value += (255 / ctx->steps);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx->curr_step = ctx->steps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx->curr_step++;
|
||||||
|
|
||||||
|
if (ctx->curr_step >= ctx->steps)
|
||||||
|
{
|
||||||
|
if (ctx->curr_val) ctx->curr_val = 0;
|
||||||
|
else ctx->curr_val = 1;
|
||||||
|
ctx->curr_step = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Wave
|
||||||
|
void ledFilter_InitWave(ctx_wave_t *ctx)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledFilter_Wave(ctx_wave_t *ctx, strip_handler_t *strip)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Constant
|
||||||
|
void ledFilter_InitConstant(ctx_const_t *ctx)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledFilter_Constant(ctx_const_t *ctx, strip_handler_t *strip)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
82
Firmware/RTLGDB/Project/WS2812/ledfilters.h
Normal file
82
Firmware/RTLGDB/Project/WS2812/ledfilters.h
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
#ifndef _LEDFILTERS_H_
|
||||||
|
#define _LEDFILTERS_H_
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "macro_common.h"
|
||||||
|
#include <autoconf.h>
|
||||||
|
#include <platform_opts.h>
|
||||||
|
#include <platform_stdlib.h>
|
||||||
|
#include "device_lock.h"
|
||||||
|
#include "ws2812.h"
|
||||||
|
|
||||||
|
#define LEDFILTERS_CFG_CHECKWORD 0x4C414D50 // "LAMP"
|
||||||
|
#define LEDFILTERS_MAX_STEPS 250 // 255 MAX !
|
||||||
|
|
||||||
|
#define DEF_STRIP_LEN WS2812_LEDS_MAX
|
||||||
|
#define MAX_STRIP_LEN WS2812_LEDS_MAX
|
||||||
|
#define MAX_STRIP_BRIGHT 255
|
||||||
|
#define MAX_STRIP_DELAY 500
|
||||||
|
|
||||||
|
#pragma region Rainbow
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t enabled;
|
||||||
|
uint32_t valid;
|
||||||
|
uint32_t hue_steps; // кол.во светодиодов, в которое вместить радугу
|
||||||
|
uint8_t cycle_steps; // типа скорости
|
||||||
|
uint8_t curr_hue;
|
||||||
|
} ctx_rainbow_t;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Fade
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t enabled;
|
||||||
|
uint32_t valid;
|
||||||
|
uint32_t steps;
|
||||||
|
uint32_t min;
|
||||||
|
uint32_t max;
|
||||||
|
uint32_t curr_val;
|
||||||
|
int32_t curr_step;
|
||||||
|
} ctx_fade_t;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Wave
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t enabled;
|
||||||
|
uint32_t valid;
|
||||||
|
} ctx_wave_t;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Constant
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t enabled;
|
||||||
|
uint32_t valid;
|
||||||
|
} ctx_const_t;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t check;
|
||||||
|
ws2812_hsv_t *hsv_vals;
|
||||||
|
uint32_t strip_len;
|
||||||
|
uint32_t brightness;
|
||||||
|
uint32_t delay;
|
||||||
|
} strip_handler_t;
|
||||||
|
|
||||||
|
int32_t ledFilter_Init(strip_handler_t *strip, ws2812_t *ws2812);
|
||||||
|
|
||||||
|
void ledFilter_InitRainbow(ctx_rainbow_t *ctx);
|
||||||
|
void ledFilter_Rainbow(ctx_rainbow_t *ctx, strip_handler_t *strip);
|
||||||
|
void ledFilter_InitFade(ctx_fade_t *ctx);
|
||||||
|
void ledFilter_Fade(ctx_fade_t *ctx, strip_handler_t *strip);
|
||||||
|
void ledFilter_InitWave(ctx_wave_t *ctx);
|
||||||
|
void ledFilter_Wave(ctx_wave_t *ctx, strip_handler_t *strip);
|
||||||
|
|
||||||
|
void ledFilter_SetDefualtValue(strip_handler_t *strip, uint8_t val);
|
||||||
|
|
||||||
|
#endif // _LEDFILTERS_H_
|
329
Firmware/RTLGDB/Project/WS2812/ws2812.c
Normal file
329
Firmware/RTLGDB/Project/WS2812/ws2812.c
Normal file
|
@ -0,0 +1,329 @@
|
||||||
|
#include "ws2812.h"
|
||||||
|
|
||||||
|
/* Quick and dirty, we use one big DMA buffer for the whole strip length.
|
||||||
|
* TODO: use smaller DMA buffer and fill in bit patterns on the fly */
|
||||||
|
uint8_t dma_buffer[WS2812_DMABUF_LEN(WS2812_LEDS_MAX)];
|
||||||
|
|
||||||
|
/* scale uint8 value from range 2-255 to range 0-scale */
|
||||||
|
static inline uint8_t WS2812_Scale(uint8_t value, uint8_t scale)
|
||||||
|
{
|
||||||
|
uint32_t tmp;
|
||||||
|
|
||||||
|
tmp = value * scale;
|
||||||
|
tmp /= 256;
|
||||||
|
|
||||||
|
return (uint8_t)tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wake up waiting tasks when DMA transfer is complete
|
||||||
|
static void master_tr_done_callback(void *pdata, SpiIrq event)
|
||||||
|
{
|
||||||
|
BaseType_t task_woken, result;
|
||||||
|
ws2812_t *cfg;
|
||||||
|
|
||||||
|
task_woken = pdFALSE;
|
||||||
|
cfg = (ws2812_t *) pdata;
|
||||||
|
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
case SpiRxIrq:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SpiTxIrq:
|
||||||
|
result = xEventGroupSetBitsFromISR(cfg->events, BIT_DONE, &task_woken);
|
||||||
|
if(result == pdPASS)
|
||||||
|
{
|
||||||
|
portYIELD_FROM_ISR(task_woken);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DBG_8195A("WS2812: Unknown SPI irq event!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WS2812_HSV2RGB(ws2812_hsv_t *hsv, ws2812_rgb_t *rgb)
|
||||||
|
{
|
||||||
|
//uint8_t r, g, b;
|
||||||
|
uint8_t hue, sat, val;
|
||||||
|
uint8_t base, sector, offset;
|
||||||
|
uint8_t rise, fall;
|
||||||
|
|
||||||
|
// scale hue to range 0- 3*64. Makes subsequent calculations easier
|
||||||
|
hue = WS2812_Scale(hsv->hue, 192);
|
||||||
|
sat = hsv->sat;
|
||||||
|
val = hsv->value;
|
||||||
|
|
||||||
|
sector = hue / 64;
|
||||||
|
offset = hue % 64;
|
||||||
|
|
||||||
|
// get common white base level and remaining colour amplitude
|
||||||
|
base = 255 - sat;
|
||||||
|
|
||||||
|
rise = (offset * sat * 4) / 256;
|
||||||
|
fall = 255 - base - rise;
|
||||||
|
|
||||||
|
rise = (rise * val) / 256;
|
||||||
|
fall = (fall * val) / 256;
|
||||||
|
base = (base * val) / 256;
|
||||||
|
|
||||||
|
rgb->r = base;
|
||||||
|
rgb->g = base;
|
||||||
|
rgb->b = base;
|
||||||
|
|
||||||
|
switch (sector)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
rgb->r += fall;
|
||||||
|
rgb->g += rise;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
rgb->g += fall;
|
||||||
|
rgb->b += rise;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
rgb->r += rise;
|
||||||
|
rgb->b += fall;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert a RGB byte into SPI data stream with 2 bits per byte
|
||||||
|
static uint8_t *WS2812_RGB2PWM(uint8_t *dst, const uint8_t colour)
|
||||||
|
{
|
||||||
|
uint8_t cnt, data = colour;
|
||||||
|
|
||||||
|
for (cnt = 0; cnt < 4; cnt++)
|
||||||
|
{
|
||||||
|
switch (data & 0xC0)
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
*dst = WS2812_BITS_00;
|
||||||
|
break;
|
||||||
|
case 0x40:
|
||||||
|
*dst = WS2812_BITS_01;
|
||||||
|
break;
|
||||||
|
case 0x80:
|
||||||
|
*dst = WS2812_BITS_10;
|
||||||
|
break;
|
||||||
|
case 0xC0:
|
||||||
|
*dst = WS2812_BITS_11;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dst++;
|
||||||
|
data <<= 2;
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t WS2812_Tx(ws2812_t *cfg, uint16_t delay)
|
||||||
|
{
|
||||||
|
EventBits_t rcvd_events;
|
||||||
|
TickType_t timeout;
|
||||||
|
BaseType_t status;
|
||||||
|
|
||||||
|
// wait for any SPI transfer to finish
|
||||||
|
while(cfg->spi_master.state & SPI_STATE_TX_BUSY)
|
||||||
|
{
|
||||||
|
vTaskDelay(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// obey requested delay
|
||||||
|
if(delay > 0)
|
||||||
|
{
|
||||||
|
vTaskDelay(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
// lock the DMA buffer mutex while it is transferred
|
||||||
|
status = xSemaphoreTake(cfg->mutex, configTICK_RATE_HZ);
|
||||||
|
if(status != pdTRUE)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] Timeout waiting for config mutex.\n", __func__);
|
||||||
|
xSemaphoreGive(cfg->mutex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cfg->dma_buff == NULL || cfg->buff_len == 0)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] DMA buffer invalid\n", __func__);
|
||||||
|
xSemaphoreGive(cfg->mutex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xEventGroupClearBits(cfg->events, BIT_DONE);
|
||||||
|
spi_master_write_stream_dma(&cfg->spi_master, (char *)(cfg->dma_buff), cfg->buff_len);
|
||||||
|
|
||||||
|
timeout = 1000 / portTICK_PERIOD_MS;
|
||||||
|
rcvd_events = xEventGroupWaitBits(
|
||||||
|
cfg->events,
|
||||||
|
BIT_DONE, // wait for DMA TX done
|
||||||
|
pdTRUE, // clear event bit
|
||||||
|
pdFALSE, // do not wait for all bits to be set
|
||||||
|
timeout );
|
||||||
|
|
||||||
|
if(!(rcvd_events & BIT_DONE))
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] DMA timeout\n", __func__);
|
||||||
|
xSemaphoreGive(cfg->mutex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xSemaphoreGive(cfg->mutex);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ws2812_Update(ws2812_t *cfg, ws2812_hsv_t hsv_values[], uint32_t strip_len, uint16_t delay)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t *bufp;
|
||||||
|
uint16_t len;
|
||||||
|
BaseType_t status;
|
||||||
|
ws2812_rgb_t rgb;
|
||||||
|
|
||||||
|
// Æäåì, ïîêà îñâîáîäèòñÿ áóôôåð DMA
|
||||||
|
while(cfg->spi_master.state & SPI_STATE_TX_BUSY)
|
||||||
|
{
|
||||||
|
vTaskDelay(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = xSemaphoreTake(cfg->mutex, configTICK_RATE_HZ);
|
||||||
|
if(status != pdTRUE)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] Timeout waiting for config mutex.\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
bufp = &(cfg->dma_buff[0]);
|
||||||
|
|
||||||
|
// Ïðîâåðêà íà âìåùàåìîñòü è êîïèðîâàíèå
|
||||||
|
len = min(strip_len, cfg->strip_len);
|
||||||
|
for(i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
WS2812_HSV2RGB(&hsv_values[i], &rgb);
|
||||||
|
bufp = WS2812_RGB2PWM(bufp, rgb.g);
|
||||||
|
bufp = WS2812_RGB2PWM(bufp, rgb.r);
|
||||||
|
bufp = WS2812_RGB2PWM(bufp, rgb.b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Âñå íå èñïîëüçóåìûå ïèêñåëè - âûêëþ÷àåì
|
||||||
|
if(cfg->strip_len > len)
|
||||||
|
{
|
||||||
|
memset(bufp, WS2812_BITS_00, cfg->strip_len - len);
|
||||||
|
bufp += cfg->strip_len - len;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(bufp, 0x0, WS2812_RESET_LEN);
|
||||||
|
xSemaphoreGive(cfg->mutex);
|
||||||
|
|
||||||
|
return WS2812_Tx(cfg, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
ws2812_t *ws2812_Init(uint16_t strip_len)
|
||||||
|
{
|
||||||
|
int32_t result;
|
||||||
|
ws2812_t *cfg;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
cfg = malloc(sizeof(ws2812_t));
|
||||||
|
if(cfg == NULL)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] malloc for cfg failed\n", __func__);
|
||||||
|
result = -1;
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(cfg, 0x0, sizeof(ws2812_t));
|
||||||
|
|
||||||
|
cfg->mutex = xSemaphoreCreateMutex();
|
||||||
|
if(cfg->mutex == NULL)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] Mutex creation failed\n", __func__);
|
||||||
|
result = -1;
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg->events = xEventGroupCreate();
|
||||||
|
if(cfg->events == NULL)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] Creating event group failed\n", __func__);
|
||||||
|
result = -1;
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
spi_init(&(cfg->spi_master), WS2812_SPI_MOSI, WS2812_SPI_MISO, WS2812_SPI_SCLK, WS2812_SPI_CS);
|
||||||
|
spi_format(&(cfg->spi_master), 8, 3, 0);
|
||||||
|
spi_frequency(&(cfg->spi_master), WS2812_SPI_FREQ);
|
||||||
|
spi_irq_hook(&(cfg->spi_master), (spi_irq_handler)master_tr_done_callback, (uint32_t)cfg);
|
||||||
|
|
||||||
|
result = ws2812_SetLen(cfg, strip_len);
|
||||||
|
if(!result)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] ws2812_set_len() failed\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
err_out:
|
||||||
|
if(!result && cfg != NULL)
|
||||||
|
{
|
||||||
|
if(cfg->mutex != NULL)
|
||||||
|
{
|
||||||
|
vQueueDelete(cfg->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cfg->events != NULL)
|
||||||
|
{
|
||||||
|
vEventGroupDelete(cfg->events);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cfg->dma_buff != NULL)
|
||||||
|
{
|
||||||
|
free(cfg->dma_buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(cfg);
|
||||||
|
cfg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ws2812_SetLen(ws2812_t *cfg, uint16_t strip_len)
|
||||||
|
{
|
||||||
|
BaseType_t status;
|
||||||
|
uint32_t reset_off;
|
||||||
|
|
||||||
|
if(cfg == NULL)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] no config given\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// lock the config mutex
|
||||||
|
status = xSemaphoreTake(cfg->mutex, configTICK_RATE_HZ);
|
||||||
|
if(status != pdTRUE)
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] Timeout waiting for config mutex.\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strip_len <= WS2812_LEDS_MAX)
|
||||||
|
{
|
||||||
|
/* TODO: use dynamically allocated buffer */
|
||||||
|
cfg->dma_buff = dma_buffer;
|
||||||
|
|
||||||
|
/* initialise LEDs to off and add reset pulse at end of strip */
|
||||||
|
reset_off = WS2812_DMABUF_LEN(strip_len) - WS2812_RESET_LEN;
|
||||||
|
memset(&(cfg->dma_buff[0]), WS2812_BITS_00, reset_off);
|
||||||
|
memset(&(cfg->dma_buff[reset_off]), 0x0, WS2812_RESET_LEN);
|
||||||
|
cfg->strip_len = strip_len;
|
||||||
|
cfg->buff_len = WS2812_DMABUF_LEN(strip_len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("WS2812: [%s] Strip too long for DMA buffer\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xSemaphoreGive(cfg->mutex);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
64
Firmware/RTLGDB/Project/WS2812/ws2812.h
Normal file
64
Firmware/RTLGDB/Project/WS2812/ws2812.h
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#ifndef _WS2812_H_
|
||||||
|
#define _WS2812_H_
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "event_groups.h"
|
||||||
|
#include <spi_api.h>
|
||||||
|
#include <spi_ex_api.h>
|
||||||
|
#include <autoconf.h>
|
||||||
|
#include <platform_stdlib.h>
|
||||||
|
#include "semphr.h"
|
||||||
|
#include "event_groups.h"
|
||||||
|
#include "macro_common.h"
|
||||||
|
|
||||||
|
#define WS2812_LEDS_MAX 228
|
||||||
|
#define WS2812_RESET_LEN (50 / 2)
|
||||||
|
#define WS2812_DMABUF_LEN(x) ((x) * 3 * 4 + WS2812_RESET_LEN)
|
||||||
|
|
||||||
|
#define WS2812_SPI_FREQ 3400000 // и делённое на 4 (4 бита SPI за 1 бит WS8212) ~~ в итоге 800кГц
|
||||||
|
#define WS2812_SPI_MOSI PC_2 // SPI0
|
||||||
|
#define WS2812_SPI_MISO PC_3
|
||||||
|
#define WS2812_SPI_SCLK PC_1
|
||||||
|
#define WS2812_SPI_CS PC_0
|
||||||
|
|
||||||
|
// Events to signal completion of DMA transfer
|
||||||
|
#define BIT_START (1 << 0)
|
||||||
|
#define BIT_DONE (1 << 1)
|
||||||
|
|
||||||
|
// посылается 2 бита протокола WS2812 за один байт SPI, один бит WS2812 за 4 бита SPI.
|
||||||
|
#define WS2812_BITS_00 0x88
|
||||||
|
#define WS2812_BITS_01 0x8e
|
||||||
|
#define WS2812_BITS_10 0xe8
|
||||||
|
#define WS2812_BITS_11 0xee
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t r;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t b;
|
||||||
|
} ws2812_rgb_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t hue;
|
||||||
|
uint8_t sat;
|
||||||
|
uint8_t value;
|
||||||
|
} ws2812_hsv_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
spi_t spi_master;
|
||||||
|
EventGroupHandle_t *events;
|
||||||
|
SemaphoreHandle_t *mutex;
|
||||||
|
uint8_t *dma_buff;
|
||||||
|
size_t buff_len;
|
||||||
|
uint16_t strip_len;
|
||||||
|
} ws2812_t;
|
||||||
|
|
||||||
|
ws2812_t *ws2812_Init(uint16_t len);
|
||||||
|
int32_t ws2812_SetLen(ws2812_t *cfg, uint16_t len);
|
||||||
|
//int32_t WS2812_DeInit(WS2812_t *cfg);
|
||||||
|
int32_t ws2812_Update(ws2812_t *cfg, ws2812_hsv_t hsv[], uint32_t len, uint16_t delay);
|
||||||
|
|
||||||
|
#endif // _WS2812_H_
|
7
Firmware/RTLGDB/Project/build_info.h
Normal file
7
Firmware/RTLGDB/Project/build_info.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#define UTS_VERSION "2017/12/24-02:16:14"
|
||||||
|
#define RTL8195AFW_COMPILE_TIME "2017/12/24-02:16:14"
|
||||||
|
#define RTL8195AFW_COMPILE_DATE "20171224"
|
||||||
|
#define RTL8195AFW_COMPILE_BY "Andrew"
|
||||||
|
#define RTL8195AFW_COMPILE_HOST ""
|
||||||
|
#define RTL8195AFW_COMPILE_DOMAIN
|
||||||
|
#define RTL195AFW_COMPILER "gcc 6.3.1"
|
30
Firmware/RTLGDB/Project/feep_config.h
Normal file
30
Firmware/RTLGDB/Project/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 0x4347 // id:'0W', type: struct wlan_fast_reconnect
|
||||||
|
//#define FEEP_ID_WIFI_AP_CFG 0x5041 // 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 {
|
||||||
|
uint8_t mode; // =0 dhcp off, =1 - dhcp on, =2 Static ip, =3 - auto
|
||||||
|
uint32_t ip;
|
||||||
|
uint32_t mask;
|
||||||
|
uint32_t 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_ */
|
387
Firmware/RTLGDB/Project/lwipopts.h
Normal file
387
Firmware/RTLGDB/Project/lwipopts.h
Normal file
|
@ -0,0 +1,387 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @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
|
||||||
|
/**
|
||||||
|
* LWIP_AUTOIP==1: Enable AUTOIP module.
|
||||||
|
*/
|
||||||
|
#define LWIP_AUTOIP 0 //Realtek modified (0->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
|
||||||
|
|
||||||
|
extern __attribute__ ((long_call)) unsigned int Rand(void);
|
||||||
|
#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****/
|
10
Firmware/RTLGDB/Project/macro_common.h
Normal file
10
Firmware/RTLGDB/Project/macro_common.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef _MACRO_COMMON_H_
|
||||||
|
#define _MACRO_COMMON_H_
|
||||||
|
|
||||||
|
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
#define scale_up(x) ((x) << 8)
|
||||||
|
#define scale_down(x) ((x) >> 8)
|
||||||
|
|
||||||
|
#endif // _MACRO_COMMON_H_
|
||||||
|
|
95
Firmware/RTLGDB/Project/main.c
Normal file
95
Firmware/RTLGDB/Project/main.c
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
#include "platform_autoconf.h"
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include "hal_crypto.h"
|
||||||
|
#include "hal_log_uart.h"
|
||||||
|
#include "hal_misc.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include "tcm_heap.h"
|
||||||
|
#include "hal_platform.h"
|
||||||
|
#include "rtl8195a_sys_on.h"
|
||||||
|
#include "hal_timer.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_WDG_ON_IDLE
|
||||||
|
#include "rtl8195a_wdt.h"
|
||||||
|
#include "hal_peri_on.h"
|
||||||
|
#include "rtl8195a_peri_on.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Customized Signature (Image Name)
|
||||||
|
#include "section_config.h"
|
||||||
|
#ifndef _MSC_VER // IntelliSense
|
||||||
|
SECTION(".custom.validate.rodata")
|
||||||
|
#endif
|
||||||
|
const unsigned char cus_sig[32] = "WEB Sample";
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_LOG
|
||||||
|
#define DEBUG_MAIN_LEVEL CONFIG_DEBUG_LOG
|
||||||
|
#else
|
||||||
|
#define DEBUG_MAIN_LEVEL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_INIT_NET
|
||||||
|
#define CONFIG_INIT_NET 1
|
||||||
|
#endif
|
||||||
|
#ifndef CONFIG_INTERACTIVE_MODE
|
||||||
|
#define CONFIG_INTERACTIVE_MODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void WDGStart(void);
|
||||||
|
extern void user_init_thrd(void);
|
||||||
|
extern void user_ws_thrd(void);
|
||||||
|
|
||||||
|
void ShowMemInfo(void)
|
||||||
|
{
|
||||||
|
DiagPrintf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n", HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
#if DEBUG_MAIN_LEVEL > 3
|
||||||
|
ConfigDebugErr = -1;
|
||||||
|
ConfigDebugInfo = ~(_DBG_SPI_FLASH_);//|_DBG_TCM_HEAP_);
|
||||||
|
ConfigDebugWarn = -1;
|
||||||
|
CfgSysDebugErr = -1;
|
||||||
|
CfgSysDebugInfo = -1;
|
||||||
|
CfgSysDebugWarn = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_WDG_ON_IDLE
|
||||||
|
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & 0x1FFFFF);
|
||||||
|
#if CONFIG_DEBUG_LOG > 3
|
||||||
|
WDGInitial(CONFIG_WDG_ON_IDLE * 3000); // 30 s
|
||||||
|
#else
|
||||||
|
WDGInitial(CONFIG_WDG_ON_IDLE * 1000); // 4 s
|
||||||
|
#endif
|
||||||
|
WDGStart();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(CONFIG_CRYPTO_MODULE) && (CONFIG_CRYPTO_STARTUP))
|
||||||
|
if(rtl_cryptoEngine_init() != 0 )
|
||||||
|
{
|
||||||
|
DBG_8195A("Crypto engine init failed!\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DEBUG_MAIN_LEVEL > 1
|
||||||
|
vPortFree(pvPortMalloc(4)); // Init RAM heap
|
||||||
|
ShowMemInfo(); // RAM/TCM/Heaps info
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// wlan & user_start intialization
|
||||||
|
xTaskCreate(user_init_thrd, "user_init", 1024, NULL, tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET, NULL);
|
||||||
|
xTaskCreate(user_ws_thrd, "user_ws", 1024, NULL, tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET, NULL);
|
||||||
|
|
||||||
|
// Enable Schedule, Start Kernel
|
||||||
|
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||||
|
#ifdef PLATFORM_FREERTOS
|
||||||
|
vTaskStartScheduler();
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
RtlConsolTaskRom(NULL);
|
||||||
|
#endif
|
||||||
|
}
|
119
Firmware/RTLGDB/Project/main.h
Normal file
119
Firmware/RTLGDB/Project/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
|
255
Firmware/RTLGDB/Project/platform_autoconf.h
Normal file
255
Firmware/RTLGDB/Project/platform_autoconf.h
Normal file
|
@ -0,0 +1,255 @@
|
||||||
|
/*
|
||||||
|
* 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_USE_TCM_HEAP 1
|
||||||
|
#define configUSE_STACK_TCM_HEAP 5 // min priority use tcm ?
|
||||||
|
|
||||||
|
#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 0
|
||||||
|
//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 4 // 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
|
||||||
|
#if defined(RTL8711AM) || defined(USE_SDRAM)
|
||||||
|
#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
|
||||||
|
|
173
Firmware/RTLGDB/Project/platform_opts.h
Normal file
173
Firmware/RTLGDB/Project/platform_opts.h
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*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 0 // 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)
|
||||||
|
#define LED_SETTINGS_SECTOR 0x000FA000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 1
|
||||||
|
#define CONFIG_BSD_TCP 1 //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 0
|
||||||
|
|
||||||
|
//#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__
|
92
Firmware/RTLGDB/Project/rtl8195a/c_types.h
Normal file
92
Firmware/RTLGDB/Project/rtl8195a/c_types.h
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
#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 uint8_t;
|
||||||
|
typedef signed char sint8;
|
||||||
|
typedef signed char int8;
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef unsigned short uint16;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef signed short sint16;
|
||||||
|
typedef signed short int16_t;
|
||||||
|
typedef unsigned int uint32;
|
||||||
|
typedef unsigned int u_int;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef signed int sint32;
|
||||||
|
typedef signed int int32_t;
|
||||||
|
typedef int int32;
|
||||||
|
typedef signed long long sint64;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
typedef float real32;
|
||||||
|
typedef double real64;
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __le16 uint16_t
|
||||||
|
|
||||||
|
typedef unsigned int size_t;
|
||||||
|
typedef int ssize_t;
|
||||||
|
|
||||||
|
#ifndef _SYS_CDEFS_H_
|
||||||
|
#define __packed __attribute__((packed))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define static 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
Firmware/RTLGDB/Project/rtl8195a/os.h
Normal file
593
Firmware/RTLGDB/Project/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 uint8_t *aa = a;
|
||||||
|
const uint8_t *bb = b;
|
||||||
|
size_t i;
|
||||||
|
uint8_t 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
|
||||||
|
uint8_t* os_malloc(uint32_t sz);
|
||||||
|
void os_mfree(uint8_t *pbuf, uint32_t sz);
|
||||||
|
#ifndef os_free
|
||||||
|
#define os_free(p, sz) os_mfree(((uint8_t*)(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(((uint8_t*)(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
Firmware/RTLGDB/Project/rtl8195a/queue.h
Normal file
204
Firmware/RTLGDB/Project/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
Firmware/RTLGDB/Project/rtl8195a/rom_wps_os.h
Normal file
24
Firmware/RTLGDB/Project/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(((uint8_t*)(p)), (sz))
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint8_t *WPS_realloc(uint8_t *old_buf, uint32_t old_sz, uint32_t new_sz);
|
||||||
|
#define os_realloc(p, os, ns) WPS_realloc(((uint8_t*)(p)),(os),(ns))
|
||||||
|
|
||||||
|
#endif /* ROM_WPS_OS_H */
|
10
Firmware/RTLGDB/Project/rtl8195a/rtl_common.h
Normal file
10
Firmware/RTLGDB/Project/rtl8195a/rtl_common.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef __RTL_COMMON_H__
|
||||||
|
#define __RTL_COMMON_H__
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "c_types.h"
|
||||||
|
|
||||||
|
#endif
|
164
Firmware/RTLGDB/Project/rtl8195a/rtl_libc.h
Normal file
164
Firmware/RTLGDB/Project/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_
|
67
Firmware/RTLGDB/Project/sys_cfg.h
Normal file
67
Firmware/RTLGDB/Project/sys_cfg.h
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* 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 powersave_enable : 1; //0 0x0000001 =1 Включение режима экономии энергии (актуально в режиме ST), отключает LogUART
|
||||||
|
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_POWERSAVE 0x0000001 // Включение режима экономии энергии (актуально в режиме ST)
|
||||||
|
#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__
|
1013
Firmware/RTLGDB/Project/tcpsrv/tcp_srv_conn.c
Normal file
1013
Firmware/RTLGDB/Project/tcpsrv/tcp_srv_conn.c
Normal file
File diff suppressed because it is too large
Load diff
188
Firmware/RTLGDB/Project/tcpsrv/tcp_srv_conn.h
Normal file
188
Firmware/RTLGDB/Project/tcpsrv/tcp_srv_conn.h
Normal file
|
@ -0,0 +1,188 @@
|
||||||
|
#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_config.h"
|
||||||
|
#include "tcp.h"
|
||||||
|
|
||||||
|
#include "lwip/err.h"
|
||||||
|
|
||||||
|
#undef mMIN
|
||||||
|
#define mMIN(a, b) ((a < b)? a : b)
|
||||||
|
#define mMAX(a, b) ((a>b)?a:b)
|
||||||
|
|
||||||
|
|
||||||
|
enum srvconn_state {
|
||||||
|
SRVCONN_NONE =0,
|
||||||
|
SRVCONN_CLOSEWAIT, // ожидает закрытия
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
#define SRV_WDGREFESH_IN_POOL // использовать WDGRefresh() в tcpsrv_poll()
|
||||||
|
|
||||||
|
// время (сек), по умолчанию, ожидания запроса (передачи пакета) от клиента, до авто-закрытия соединения,
|
||||||
|
// при = 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 32768 // самый минимум от 6Kb
|
||||||
|
|
||||||
|
// максимальный размер выделяемого буфера в heap для приема порции
|
||||||
|
#ifndef TCP_SRV_SERVER_MAX_RXBUF
|
||||||
|
#define TCP_SRV_SERVER_MAX_RXBUF TCP_WND // (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_SND_BUF //(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 srv_reopen: 1; //0001 открытие нового соединения более max_conn ведет к закрытию наиболее старого соединения.
|
||||||
|
uint16 pcb_time_wait_free: 1; //0002 проверка на макс кол-во и уничтожение 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; //0004 выключение nagle
|
||||||
|
uint16 rx_buf: 1; //0008 прием в буфер, используется ручное управление размером окна TCP
|
||||||
|
uint16 rx_null: 1; //0010 отключение вызова func_received_data() и прием в null (устанавливается автоматически при вызове tcpsrv_disconnect())
|
||||||
|
uint16 tx_null: 1; //0020 отключение вызова func_sent_callback() и передача в null (устанавливается автоматически при вызове tcpsrv_disconnect())
|
||||||
|
uint16 wait_sent: 1; //0040 ожидет завершения/подтверждения передачи от lwip
|
||||||
|
uint16 busy_bufo: 1; //0080 идет обработка bufo
|
||||||
|
uint16 busy_bufi: 1; //0100 идет обработка bufi
|
||||||
|
uint16 tmp0: 1; //0200 резерв
|
||||||
|
uint16 tmp1: 1; //0400 резерв
|
||||||
|
// далее идут биты не относящиеся к работе tcp_srv_conn
|
||||||
|
uint16 user_flg1: 1; //0800 для нужд процедур уровнем выше (пока свободен)
|
||||||
|
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; // номер порта
|
||||||
|
uint16 min_heap; // минимальный размер heap при открытии нового соединения, при = 0 заменяется на 8192.
|
||||||
|
uint8 max_conn; // максимальное кол-во одновременных соединений
|
||||||
|
uint8 conn_count; // кол-во текущих соединений, при инициализации прописывает 0
|
||||||
|
uint8 time_wait_rec; // время (сек) ожидания запроса (передачи пакета) от клиента, до авто-закрытия соединения, по умолчанию TCP_SRV_RECV_WAIT сек.
|
||||||
|
uint8 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); // поиск структуры конфига по номеру порта
|
||||||
|
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_close(TCP_SERV_CFG *p);
|
||||||
|
err_t tcpsrv_close_port(uint16 portn);
|
||||||
|
err_t tcpsrv_close_all(void);
|
||||||
|
|
||||||
|
const char * tspsrv_error_msg(err_t err);
|
||||||
|
const char * tspsrv_tcp_state_msg(enum tcp_state state);
|
||||||
|
const char * tspsrv_srvconn_state_msg(enum srvconn_state state);
|
||||||
|
|
||||||
|
#endif // __TCP_SERV_CONN_H__
|
26
Firmware/RTLGDB/Project/user_config.h
Normal file
26
Firmware/RTLGDB/Project/user_config.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef _user_config_h_
|
||||||
|
#define _user_config_h_
|
||||||
|
|
||||||
|
#define SYS_VERSION "1.0.1"
|
||||||
|
#include "sdk_ver.h"
|
||||||
|
|
||||||
|
#define USE_WEB 80 // включить в трансялцию порт Web, если =0 - по умолчанию выключен
|
||||||
|
#define WEBSOCKET_ENA 1 // включить WEBSOCKET
|
||||||
|
#define USE_SNTP 1 // включить в трансялцию драйвер SNTP, если =0 - по умолчанию выключен, = 1 - по умолчанию включен.
|
||||||
|
#define USE_NETBIOS 1 // включить в трансялцию драйвер NETBIOS, если =0 - по умолчанию выключен.
|
||||||
|
|
||||||
|
#define WEB_DEBUG_FUNCTIONS 1 // =1 - включить в WEB отладочные функции, =0 отключить (остается только конфигурация WiFi)
|
||||||
|
|
||||||
|
// #define WEB_INA219_DRV 1 (set in project.mk !)
|
||||||
|
// #define WEB_ADC_DRV 1 (set in project.mk !)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER // IntelliSense
|
||||||
|
#define __attribute__(packed)
|
||||||
|
//typedef int8_t err_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _user_config_h_
|
||||||
|
|
||||||
|
|
129
Firmware/RTLGDB/Project/user_start.c
Normal file
129
Firmware/RTLGDB/Project/user_start.c
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* user_start.c
|
||||||
|
*
|
||||||
|
* Created on: 26/03/2017
|
||||||
|
* Author: pvvx
|
||||||
|
*/
|
||||||
|
#include "user_config.h"
|
||||||
|
#include "platform_autoconf.h"
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "freertos_pmu.h"
|
||||||
|
#include "tcm_heap.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include "netbios/netbios.h"
|
||||||
|
#include "sntp/sntp.h"
|
||||||
|
#include "sys_cfg.h"
|
||||||
|
#include "wifi_api.h"
|
||||||
|
#include "web/web_srv.h"
|
||||||
|
#include "webfs/webfs.h"
|
||||||
|
|
||||||
|
// mbed
|
||||||
|
#include "gpio_api.h"
|
||||||
|
#include "i2c_api.h"
|
||||||
|
#include "pinmap.h"
|
||||||
|
|
||||||
|
// User
|
||||||
|
#include "ledeffectsserver.h"
|
||||||
|
|
||||||
|
#include "lwip/pbuf.h"
|
||||||
|
#include "lwip/udp.h"
|
||||||
|
#include "lwip/tcp.h"
|
||||||
|
|
||||||
|
struct SystemCfg syscfg = {
|
||||||
|
.cfg.w = SYS_CFG_DEBUG_ENA
|
||||||
|
| SYS_CFG_PIN_CLR_ENA
|
||||||
|
#if defined(USE_NETBIOS) && USE_NETBIOS
|
||||||
|
| SYS_CFG_NETBIOS_ENA
|
||||||
|
#endif
|
||||||
|
#if defined(USE_SNTP) && USE_SNTP
|
||||||
|
| SYS_CFG_SNTP_ENA
|
||||||
|
#endif
|
||||||
|
,
|
||||||
|
#if defined(USE_WEB)
|
||||||
|
.web_port = USE_WEB,
|
||||||
|
#else
|
||||||
|
.web_port = 0,
|
||||||
|
#endif
|
||||||
|
.web_twrec = 5,
|
||||||
|
.web_twcls = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
SemaphoreHandle_t sema_WEBReady = NULL;
|
||||||
|
|
||||||
|
void connect_start(void)
|
||||||
|
{
|
||||||
|
info_printf("\%s: Time at start %d ms.\n", __func__, xTaskGetTickCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
void connect_close(void)
|
||||||
|
{
|
||||||
|
info_printf("\%s: Time at start %d ms.\n", __func__, xTaskGetTickCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
void user_start(void)
|
||||||
|
{
|
||||||
|
info_printf("\%s: Time at start %d ms.\n", __func__, xTaskGetTickCount());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void sys_write_cfg(void)
|
||||||
|
{
|
||||||
|
flash_write_cfg(&syscfg, FEEP_ID_SYS_CFG, sizeof(syscfg));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void console_init(void);
|
||||||
|
|
||||||
|
void user_ws_thrd(void)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (xSemaphoreTake(sema_WEBReady, 10 * configTICK_RATE_HZ))
|
||||||
|
{
|
||||||
|
ledEffectsServer_Init();
|
||||||
|
}
|
||||||
|
WDGRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void user_init_thrd(void)
|
||||||
|
{
|
||||||
|
sema_WEBReady = xSemaphoreCreateMutex();
|
||||||
|
if (xSemaphoreTake(sema_WEBReady, configTICK_RATE_HZ))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if(syscfg.cfg.b.pin_clear_cfg_enable && 0)
|
||||||
|
{
|
||||||
|
// user_test_clear_pin();
|
||||||
|
wifi_cfg.load_flg = 0;
|
||||||
|
}
|
||||||
|
else flash_read_cfg(&syscfg, FEEP_ID_SYS_CFG, sizeof(syscfg));
|
||||||
|
*/
|
||||||
|
wifi_cfg.load_flg = 0;
|
||||||
|
|
||||||
|
if (!syscfg.cfg.b.debug_print_enable) print_off = 1;
|
||||||
|
|
||||||
|
console_init();
|
||||||
|
WEBFSInit();
|
||||||
|
wifi_init(); // Load cfg, init WiFi + LwIP init, WiFi start if wifi_cfg.mode != RTW_MODE_NONE
|
||||||
|
|
||||||
|
#if defined(USE_NETBIOS)
|
||||||
|
if (syscfg.cfg.b.netbios_ena) netbios_init();
|
||||||
|
#endif
|
||||||
|
#if defined(USE_SNTP)
|
||||||
|
if (syscfg.cfg.b.sntp_ena) sntp_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
webserver_init(syscfg.web_port);
|
||||||
|
|
||||||
|
if (syscfg.cfg.b.powersave_enable)
|
||||||
|
{
|
||||||
|
release_wakelock(~WAKELOCK_WLAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
xSemaphoreGive(sema_WEBReady);
|
||||||
|
}
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
52
Firmware/RTLGDB/Project/web/web_auth.c
Normal file
52
Firmware/RTLGDB/Project/web/web_auth.c
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* web_auth.c
|
||||||
|
*
|
||||||
|
* Created on: 23/04/2017.
|
||||||
|
* Author: pvvx
|
||||||
|
*/
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include "web_utils.h"
|
||||||
|
#include "wifi_api.h"
|
||||||
|
#include "web_srv.h"
|
||||||
|
#include "rtl8195a/rtl_libc.h"
|
||||||
|
#include "esp_comp.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------
|
||||||
|
* pbuf[77] = Username and password are combined into a string "username:password"
|
||||||
|
* Return: Authorization Level
|
||||||
|
* 0 - Not Authorized */
|
||||||
|
|
||||||
|
uint8 UserAuthorization(uint8 *pbuf, size_t declen)
|
||||||
|
{
|
||||||
|
uint8 * psw = rtl_strchr(pbuf, ':');
|
||||||
|
if(psw != NULL)
|
||||||
|
{
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
if(rtl_strcmp(pbuf, "rtl871x:webfs_write") == 0)
|
||||||
|
{
|
||||||
|
return WEB_AUTH_LEVEL_WEBFS;
|
||||||
|
}
|
||||||
|
if(rtl_strcmp(pbuf, "rtl871x:ota_write") == 0)
|
||||||
|
{
|
||||||
|
return WEB_AUTH_LEVEL_OTA;
|
||||||
|
}
|
||||||
|
if(rtl_strcmp(pbuf, "rtl871x:supervisor") == 0)
|
||||||
|
{
|
||||||
|
return WEB_AUTH_LEVEL_SUPERVISOR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*psw++ = 0;
|
||||||
|
if(rom_xstrcmp(wifi_ap_cfg.ssid, pbuf) && rom_xstrcmp( wifi_ap_cfg.password, psw))
|
||||||
|
{
|
||||||
|
return WEB_AUTH_LEVEL_USER;
|
||||||
|
}
|
||||||
|
if(rom_xstrcmp(wifi_st_cfg.ssid, pbuf) && rom_xstrcmp( wifi_st_cfg.password, psw))
|
||||||
|
{
|
||||||
|
return WEB_AUTH_LEVEL_USER1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
733
Firmware/RTLGDB/Project/web/web_int_callbacks.c
Normal file
733
Firmware/RTLGDB/Project/web/web_int_callbacks.c
Normal file
|
@ -0,0 +1,733 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* FileName: web_int_callbacks.c
|
||||||
|
* Description: The web server inernal callbacks.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "user_config.h"
|
||||||
|
#ifdef USE_WEB
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include "tcm_heap.h"
|
||||||
|
#include "lwip/tcp.h"
|
||||||
|
#include "flash_eep.h"
|
||||||
|
#include "device_lock.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
|
#include "tcpsrv/tcp_srv_conn.h"
|
||||||
|
#include "web_srv_int.h"
|
||||||
|
#include "web_utils.h"
|
||||||
|
#include "webfs/webfs.h"
|
||||||
|
#include "rtl8195a/rtl_libc.h"
|
||||||
|
#include "sys_cfg.h"
|
||||||
|
#include "wifi_api.h"
|
||||||
|
#include "sys_api.h"
|
||||||
|
#include "esp_comp.h"
|
||||||
|
#include "sdk_ver.h"
|
||||||
|
|
||||||
|
#include "ledeffectsserver.h"
|
||||||
|
|
||||||
|
#ifdef USE_NETBIOS
|
||||||
|
#include "netbios/netbios.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_SNTP
|
||||||
|
#include "sntp/sntp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CAPTDNS
|
||||||
|
#include "captdns.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_MODBUS
|
||||||
|
#include "modbustcp.h"
|
||||||
|
#include "mdbtab.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_RS485DRV
|
||||||
|
#include "driver/rs485drv.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_OVERLAY
|
||||||
|
#include "overlay.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef atoi
|
||||||
|
#define atoi rom_atoi
|
||||||
|
|
||||||
|
//#define mMIN(a, b) ((a<b)?a:b)
|
||||||
|
#define ifcmp(a) if(rom_xstrcmp(cstr, a))
|
||||||
|
|
||||||
|
#define OpenFlash() { device_mutex_lock(RT_DEV_LOCK_FLASH); flash_turnon(); }
|
||||||
|
#define CloseFlash() { SpicDisableRtl8195A(); device_mutex_unlock(RT_DEV_LOCK_FLASH); }
|
||||||
|
|
||||||
|
|
||||||
|
extern struct netif xnetif[NET_IF_NUM]; /* network interface structure */
|
||||||
|
|
||||||
|
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
//#define TEST_SEND_WAVE
|
||||||
|
#endif // #if WEB_DEBUG_FUNCTIONS
|
||||||
|
|
||||||
|
#ifdef TEST_SEND_WAVE
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Test adc
|
||||||
|
// Читает adc в одиночный буфер (~2килобайта) на ~20ksps и сохраняет в виде WAV
|
||||||
|
// Правильное чтение организуется по прерыванию таймера(!).
|
||||||
|
// Тут только демо!
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
typedef struct
|
||||||
|
{ // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
|
||||||
|
unsigned long int RIFF ;/* +00 'RIFF' */
|
||||||
|
unsigned long int size8;/* +04 file size - 8 */
|
||||||
|
unsigned long int WAVE ;/* +08 'WAVE' */
|
||||||
|
unsigned long int fmt ;/* +12 'fmt ' */
|
||||||
|
unsigned long int fsize;/* +16 указатель до 'fact' или 'data' */
|
||||||
|
unsigned short int ccod;/* +20 01 00 Compression code: 1 - PCM/uncompressed */
|
||||||
|
unsigned short int mono;/* +22 00 01 или 00 02 */
|
||||||
|
unsigned long int freq ;/* +24 частота */
|
||||||
|
unsigned long int bps ;/* +28 */
|
||||||
|
unsigned short int blka;/* +32 1/2/4 BlockAlign*/
|
||||||
|
unsigned short int bits;/* +34 разрядность 8/16 */
|
||||||
|
unsigned long int data ;/* +36 'data' */
|
||||||
|
unsigned long int dsize;/* +40 размер данных */
|
||||||
|
} WAV_HEADER;
|
||||||
|
const WAV_HEADER ICACHE_RODATA_ATTR wav_header =
|
||||||
|
{0x46464952L,
|
||||||
|
0x00000008L,
|
||||||
|
0x45564157L,
|
||||||
|
0x20746d66L,
|
||||||
|
0x00000010L,
|
||||||
|
0x0001 ,
|
||||||
|
0x0001 ,
|
||||||
|
0x000055f0L,
|
||||||
|
0x000055f0L,
|
||||||
|
0x0002 ,
|
||||||
|
0x0010 ,
|
||||||
|
0x61746164L,
|
||||||
|
0x00000000L};
|
||||||
|
#define WAV_HEADER_SIZE sizeof(wav_header)
|
||||||
|
//===============================================================================
|
||||||
|
// web_test_adc()
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
void ICACHE_FLASH_ATTR web_test_adc(TCP_SERV_CONN *ts_conn)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *) ts_conn->linkd;
|
||||||
|
unsigned int len = web_conn->msgbufsize - web_conn->msgbuflen;
|
||||||
|
if(len > WAV_HEADER_SIZE + 10) {
|
||||||
|
len -= WAV_HEADER_SIZE;
|
||||||
|
WAV_HEADER * ptr = (WAV_HEADER *) &web_conn->msgbuf[web_conn->msgbuflen];
|
||||||
|
os_memcpy(ptr, &wav_header, WAV_HEADER_SIZE);
|
||||||
|
ptr->dsize = len;
|
||||||
|
web_conn->msgbuflen += WAV_HEADER_SIZE;
|
||||||
|
len >>= 1;
|
||||||
|
read_adcs((uint16 *)(web_conn->msgbuf + web_conn->msgbuflen), len, 0x0808);
|
||||||
|
web_conn->msgbuflen += len << 1;
|
||||||
|
}
|
||||||
|
if(!CheckSCB(SCB_WEBSOC)) SetSCB(SCB_FCLOSE | SCB_DISCONNECT); // connection close
|
||||||
|
}
|
||||||
|
#endif // TEST_SEND_WAVE
|
||||||
|
|
||||||
|
//===============================================================================
|
||||||
|
// WiFi Scan XML
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
extern void wifi_set_timer_scan(int ms);
|
||||||
|
static void ICACHE_FLASH_ATTR web_wscan_xml(TCP_SERV_CONN *ts_conn)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *) ts_conn->linkd;
|
||||||
|
web_scan_handler_t * pwscn_rec = &web_scan_handler_ptr;
|
||||||
|
// Check if this is a first round call
|
||||||
|
if(CheckSCB(SCB_RETRYCB)==0) {
|
||||||
|
int i = 0;
|
||||||
|
web_conn->udata_start = 0;
|
||||||
|
if(pwscn_rec->flg == 2) {
|
||||||
|
i = pwscn_rec->ap_count;
|
||||||
|
wifi_set_timer_scan(7000);
|
||||||
|
} else if(pwscn_rec->flg == 0) api_wifi_scan(NULL);
|
||||||
|
tcp_puts_fd("<total>%d</total>", i);
|
||||||
|
if(i == 0) return;
|
||||||
|
}
|
||||||
|
while(web_conn->msgbuflen + 96 + 10 + 32 <= web_conn->msgbufsize) {
|
||||||
|
if(pwscn_rec->flg && web_conn->udata_start < pwscn_rec->ap_count) {
|
||||||
|
rtw_scan_result_t *si = &pwscn_rec->ap_details[web_conn->udata_start];
|
||||||
|
uint8 ssid[32*6 + 1];
|
||||||
|
int len = si->SSID.len;
|
||||||
|
if(len > 32) len = 32;
|
||||||
|
si->SSID.val[len] = '\0';
|
||||||
|
if(web_conn->msgbuflen + 96 + 10 + htmlcode(ssid, si->SSID.val, 32*6, 32) > web_conn->msgbufsize) break;
|
||||||
|
tcp_puts_fd("<ap id=\"%d\"><ch>%d</ch><au>%d</au><bs>" MACSTR "</bs><ss>%s</ss><rs>%d</rs><hd>%d</hd><wp>%d</wp></ap>",
|
||||||
|
web_conn->udata_start,
|
||||||
|
si->channel,
|
||||||
|
rtw_security_to_idx(si->security),
|
||||||
|
MAC2STR(si->BSSID.octet),
|
||||||
|
ssid,
|
||||||
|
si->signal_strength,
|
||||||
|
// si->band, // rtw_802_11_band_t
|
||||||
|
si->bss_type & 3, // rtw_bss_type_t
|
||||||
|
si->wps_type); // rtw_wps_type_t
|
||||||
|
web_conn->udata_start++;
|
||||||
|
if(web_conn->udata_start >= pwscn_rec->ap_count) {
|
||||||
|
wifi_close_scan();
|
||||||
|
ClrSCB(SCB_RETRYCB);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wifi_close_scan();
|
||||||
|
ClrSCB(SCB_RETRYCB);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// repeat in the next call ...
|
||||||
|
SetSCB(SCB_RETRYCB);
|
||||||
|
SetNextFunSCB(web_wscan_xml);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef USE_MODBUS
|
||||||
|
//===============================================================================
|
||||||
|
// Mdb XML
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
void ICACHE_FLASH_ATTR web_modbus_xml(TCP_SERV_CONN *ts_conn)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *) ts_conn->linkd;
|
||||||
|
while(web_conn->msgbuflen + 24 <= web_conn->msgbufsize) {
|
||||||
|
if(web_conn->udata_start < web_conn->udata_stop) {
|
||||||
|
uint16 val16;
|
||||||
|
if(RdMdbData((uint8 *)&val16, web_conn->udata_start, 1) != 0) tcp_puts_fd("<m%u>?</m%u>", web_conn->udata_start, web_conn->udata_start);
|
||||||
|
else {
|
||||||
|
if(ts_conn->flag.user_option2) {
|
||||||
|
if(ts_conn->flag.user_option1) {
|
||||||
|
tcp_puts_fd("<m%u>0x%04x</m%u>", web_conn->udata_start, val16, web_conn->udata_start);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tcp_puts_fd("<m%u>%04x</m%u>", web_conn->udata_start, val16, web_conn->udata_start);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(ts_conn->flag.user_option1) {
|
||||||
|
tcp_puts_fd("<m%u>%d</m%u>", web_conn->udata_start, (sint32)((sint16)val16), web_conn->udata_start);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tcp_puts_fd("<m%u>%u</m%u>", web_conn->udata_start, val16, web_conn->udata_start);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
web_conn->udata_start++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ClrSCB(SCB_RETRYCB);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// repeat in the next call ...
|
||||||
|
SetSCB(SCB_RETRYCB);
|
||||||
|
SetNextFunSCB(web_modbus_xml);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//===============================================================================
|
||||||
|
// RAM hexdump
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
void ICACHE_FLASH_ATTR web_hexdump(TCP_SERV_CONN *ts_conn)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *) ts_conn->linkd;
|
||||||
|
union {
|
||||||
|
uint32 dw[4];
|
||||||
|
uint8 b[16];
|
||||||
|
}data;
|
||||||
|
web_conn->udata_start &= 0xfffffff0;
|
||||||
|
uint32 *addr = (uint32 *)web_conn->udata_start;
|
||||||
|
int i;
|
||||||
|
web_conn->udata_stop &= 0xfffffff0;
|
||||||
|
while(web_conn->msgbuflen + (9+3*16+17+2) <= web_conn->msgbufsize) {
|
||||||
|
// if((uint32)addr < 0x9A000000) {
|
||||||
|
if((uint32)addr >= 0x98000000 && (uint32)addr < 0x9A000000) {
|
||||||
|
OpenFlash();
|
||||||
|
}
|
||||||
|
tcp_puts("%08x", addr);
|
||||||
|
for(i=0 ; i < 4 ; i++) data.dw[i] = *addr++;
|
||||||
|
web_conn->udata_start = (uint32)addr;
|
||||||
|
if(ts_conn->flag.user_option1) { // dword or byte ?
|
||||||
|
for(i=0 ; i < 4 ; i++) tcp_puts(" %08x", data.dw[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(i=0 ; i < 16 ; i++) tcp_puts(" %02x", data.b[i]);
|
||||||
|
}
|
||||||
|
if((uint32)addr >= 0x98000000 && (uint32)addr < 0x9A000000) {
|
||||||
|
CloseFlash();
|
||||||
|
}
|
||||||
|
tcp_put(' '); tcp_put(' ');
|
||||||
|
for(i=0 ; i < 16 ; i++) tcp_put((data.b[i] >=' ' && data.b[i] != 0x7F)? data.b[i] : '.');
|
||||||
|
tcp_puts("\r\n");
|
||||||
|
if((uint32)addr >= web_conn->udata_stop) {
|
||||||
|
ClrSCB(SCB_RETRYCB);
|
||||||
|
if(!CheckSCB(SCB_WEBSOC)) SetSCB(SCB_FCLOSE | SCB_DISCONNECT); // connection close
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// } else {
|
||||||
|
// tcp_puts("%p = Bad address!\r\n", addr);
|
||||||
|
// ClrSCB(SCB_RETRYCB);
|
||||||
|
// if(!CheckSCB(SCB_WEBSOC)) SetSCB(SCB_FCLOSE | SCB_DISCONNECT); // connection close
|
||||||
|
// return;
|
||||||
|
// };
|
||||||
|
}
|
||||||
|
// repeat in the next call ...
|
||||||
|
SetSCB(SCB_RETRYCB);
|
||||||
|
SetNextFunSCB(web_hexdump);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : web saved flash
|
||||||
|
* Description : Processing the flash data send
|
||||||
|
* Parameters : none (Calback)
|
||||||
|
* Returns : none
|
||||||
|
*******************************************************************************/
|
||||||
|
void ICACHE_FLASH_ATTR web_get_flash(TCP_SERV_CONN *ts_conn)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||||
|
// Check if this is a first round call
|
||||||
|
if(CheckSCB(SCB_RETRYCB)==0) {
|
||||||
|
if(web_conn->udata_start == web_conn->udata_stop) return;
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
os_printf("file_size:%08x ", web_conn->udata_stop - web_conn->udata_start );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// Get/put as many bytes as possible
|
||||||
|
unsigned int len = mMIN(web_conn->msgbufsize - web_conn->msgbuflen, web_conn->udata_stop - web_conn->udata_start);
|
||||||
|
// Read Flash addr = web_conn->webfinc_offsets, len = x, buf = sendbuf
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
os_printf("%08x..%08x ",web_conn->udata_start, web_conn->udata_start + len );
|
||||||
|
#endif
|
||||||
|
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||||
|
if(spi_flash_read(web_conn->udata_start, web_conn->msgbuf, len)) {
|
||||||
|
web_conn->udata_start += len;
|
||||||
|
web_conn->msgbuflen += len;
|
||||||
|
if(web_conn->udata_start < web_conn->udata_stop) {
|
||||||
|
SetNextFunSCB(web_get_flash);
|
||||||
|
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||||
|
SetSCB(SCB_RETRYCB);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||||
|
ClrSCB(SCB_RETRYCB);
|
||||||
|
// SetSCB(SCB_FCLOSE | SCB_DISCONNECT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : web saved flash
|
||||||
|
* Description : Processing the flash data send
|
||||||
|
* Parameters : none (Calback)
|
||||||
|
* Returns : none
|
||||||
|
*******************************************************************************/
|
||||||
|
void ICACHE_FLASH_ATTR web_get_ram(TCP_SERV_CONN *ts_conn)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||||
|
// Check if this is a first round call
|
||||||
|
if(CheckSCB(SCB_RETRYCB)==0) { // On initial call, проверка параметров
|
||||||
|
if(web_conn->udata_start == web_conn->udata_stop) {
|
||||||
|
// SetSCB(SCB_FCLOSE | SCB_DISCONNECT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
os_printf("file_size:%08x ", web_conn->udata_stop - web_conn->udata_start );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// Get/put as many bytes as possible
|
||||||
|
uint32 len = mMIN(web_conn->msgbufsize - web_conn->msgbuflen, web_conn->udata_stop - web_conn->udata_start);
|
||||||
|
if((uint32)web_conn->udata_start >= 0x98000000 && (uint32)web_conn->udata_start < 0x9A000000) {
|
||||||
|
OpenFlash();
|
||||||
|
}
|
||||||
|
copy_align4(web_conn->msgbuf, (void *)(web_conn->udata_start), len);
|
||||||
|
if((uint32)web_conn->udata_start >= 0x98000000 && (uint32)web_conn->udata_start < 0x9A000000) {
|
||||||
|
CloseFlash();
|
||||||
|
}
|
||||||
|
web_conn->msgbuflen += len;
|
||||||
|
web_conn->udata_start += len;
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
os_printf("%08x-%08x ",web_conn->udata_start, web_conn->udata_start + len );
|
||||||
|
#endif
|
||||||
|
if(web_conn->udata_start != web_conn->udata_stop) {
|
||||||
|
SetSCB(SCB_RETRYCB);
|
||||||
|
SetNextFunSCB(web_get_ram);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
ClrSCB(SCB_RETRYCB);
|
||||||
|
// SetSCB(SCB_FCLOSE | SCB_DISCONNECT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : web_callback
|
||||||
|
* Description : callback
|
||||||
|
* Parameters : struct TCP_SERV_CONN
|
||||||
|
* Returns : none
|
||||||
|
******************************************************************************/
|
||||||
|
void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||||
|
// uint8 *cstr = &web_conn->msgbuf[web_conn->msgbuflen];
|
||||||
|
{
|
||||||
|
uint8 *vstr = os_strchr(cstr, '=');
|
||||||
|
if(vstr != NULL) {
|
||||||
|
*vstr++ = '\0';
|
||||||
|
web_int_vars(ts_conn, cstr, vstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("[%s]\n", cstr);
|
||||||
|
#endif
|
||||||
|
ifcmp("start") tcp_puts("0x%08x", web_conn->udata_start);
|
||||||
|
else ifcmp("stop") tcp_puts("0x%08x", web_conn->udata_stop);
|
||||||
|
// **************************************************************************************************** //
|
||||||
|
// **************************************** User settings ********************************************* //
|
||||||
|
else ifcmp("ws_")
|
||||||
|
{
|
||||||
|
cstr += 3;
|
||||||
|
ifcmp("filt_")
|
||||||
|
{
|
||||||
|
cstr += 5;
|
||||||
|
ifcmp("rbw_")
|
||||||
|
{
|
||||||
|
cstr += 4;
|
||||||
|
|
||||||
|
ifcmp("enbl") tcp_puts("%d", filt_rainbow.enabled);
|
||||||
|
else ifcmp("huesteps") tcp_puts("%d", filt_rainbow.hue_steps);
|
||||||
|
else ifcmp("cyclesteps") tcp_puts("%d", filt_rainbow.cycle_steps);
|
||||||
|
}
|
||||||
|
else ifcmp("fd_")
|
||||||
|
{
|
||||||
|
cstr += 3;
|
||||||
|
|
||||||
|
ifcmp("enbl") tcp_puts("%d", filt_fade.enabled);
|
||||||
|
else ifcmp("min") tcp_puts("%d", filt_fade.min);
|
||||||
|
else ifcmp("max") tcp_puts("%d", filt_fade.max);
|
||||||
|
else ifcmp("cyclesteps") tcp_puts("%d", filt_fade.steps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// **************************************************************************************************** //
|
||||||
|
// **************************************************************************************************** //
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
else ifcmp("realm") tcp_puts("%u", web_conn->auth_realm);
|
||||||
|
else ifcmp("auth") tcp_puts("%u", web_conn->auth_level);
|
||||||
|
#endif
|
||||||
|
else ifcmp("xml_")
|
||||||
|
{
|
||||||
|
cstr+=4;
|
||||||
|
ifcmp("scan") web_wscan_xml(ts_conn);
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
if(web_conn->auth_level < WEB_AUTH_LEVEL_USER)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
web_conn->udata_start&=~3;
|
||||||
|
ifcmp("ram") tcp_puts("0x%08x", *((uint32*)web_conn->udata_start));
|
||||||
|
else tcp_put('?');
|
||||||
|
web_conn->udata_start += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else ifcmp("sys_")
|
||||||
|
{
|
||||||
|
cstr+=4;
|
||||||
|
ifcmp("url") tcp_strcpy(get_new_hostname());
|
||||||
|
else ifcmp("cid") tcp_puts("%08x", HalGetChipId());
|
||||||
|
else ifcmp("fid") tcp_puts("%08x", spi_flash_get_id());
|
||||||
|
else ifcmp("fsize") tcp_puts("%u", spi_flash_real_size()); // flashchip->chip_size
|
||||||
|
else ifcmp("sdkver") tcp_strcpy_fd(SDK_VERSION);
|
||||||
|
else ifcmp("sysver") tcp_strcpy_fd(SYS_VERSION);
|
||||||
|
else ifcmp("webver") tcp_strcpy_fd(WEB_SVERSION);
|
||||||
|
else ifcmp("heap") tcp_puts("%u", xPortGetFreeHeapSize());
|
||||||
|
else ifcmp("heapm") tcp_puts("%u", xPortGetMinimumEverFreeHeapSize());
|
||||||
|
else ifcmp("tcmh") tcp_puts("%u", tcm_heap_freeSpace());
|
||||||
|
else ifcmp("time") tcp_puts("%u", xTaskGetTickCount());
|
||||||
|
else ifcmp("mactime") {
|
||||||
|
if(wifi_mode) {
|
||||||
|
union {
|
||||||
|
uint32 dw[2];
|
||||||
|
uint64 dd;
|
||||||
|
}ux;
|
||||||
|
ux.dd = *((uint64_t *)(WIFI_REG_BASE + 0x0560)); // REG_TSFTR -> #include "hal_com_reg.h"
|
||||||
|
tcp_puts("0x%08x%08x", ux.dw[1], ux.dw[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else ifcmp("clkcpu") tcp_puts("%u", HalGetCpuClk());
|
||||||
|
else ifcmp("debug") tcp_put('1' - (print_off & 1)); // rtl_print on/off
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
else ifcmp("restart") {
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) return;
|
||||||
|
#endif
|
||||||
|
webserver_qfn((web_ex_func_cb)sys_reset, NULL, 200);
|
||||||
|
}
|
||||||
|
else ifcmp("ram") tcp_puts("0x%08x", *((uint32 *)(ahextoul(cstr+3)&(~3))));
|
||||||
|
else ifcmp("rdec") tcp_puts("%d", *((uint32 *)(ahextoul(cstr+4)&(~3))));
|
||||||
|
#endif // #if WEB_DEBUG_FUNCTIONS
|
||||||
|
else ifcmp("ip") {
|
||||||
|
uint32 cur_ip;
|
||||||
|
if(netif_default != NULL) cur_ip = netif_default->ip_addr.addr;
|
||||||
|
tcp_puts(IPSTR, IP2STR(&cur_ip));
|
||||||
|
}
|
||||||
|
#ifdef USE_NETBIOS
|
||||||
|
else ifcmp("netbios") {
|
||||||
|
if(syscfg.cfg.b.netbios_ena) tcp_strcpy(netbios_name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
#ifdef WEB_INA219_DRV
|
||||||
|
else ifcmp("ina219") {
|
||||||
|
if(CheckSCB(SCB_WEBSOC)) {
|
||||||
|
extern int ina219_ws(TCP_SERV_CONN *ts_conn, char cmd);
|
||||||
|
int x = ina219_ws(ts_conn, cstr[6]);
|
||||||
|
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
|
||||||
|
else tcp_puts("%d", x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef WEB_MLX90614_DRV
|
||||||
|
else ifcmp("mlx90614") {
|
||||||
|
if(CheckSCB(SCB_WEBSOC)) {
|
||||||
|
extern int mlx90614_ws(TCP_SERV_CONN *ts_conn, char cmd);
|
||||||
|
int x = mlx90614_ws(ts_conn, cstr[6]);
|
||||||
|
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
|
||||||
|
else tcp_puts("%d", x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef WEB_ADC_DRV
|
||||||
|
else ifcmp("adc")
|
||||||
|
{
|
||||||
|
if(CheckSCB(SCB_WEBSOC))
|
||||||
|
{
|
||||||
|
extern int adc_ws(TCP_SERV_CONN *ts_conn, char cmd);
|
||||||
|
int x = adc_ws(ts_conn, cstr[6]);
|
||||||
|
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
|
||||||
|
else tcp_puts("%d", x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef WEB_MPU6050
|
||||||
|
else ifcmp("mpu6050")
|
||||||
|
{
|
||||||
|
if (CheckSCB(SCB_WEBSOC))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else ifcmp("cfg_") {
|
||||||
|
cstr += 4;
|
||||||
|
ifcmp("web_") {
|
||||||
|
cstr += 4;
|
||||||
|
ifcmp("port") tcp_puts("%u", syscfg.web_port);
|
||||||
|
else ifcmp("twrec") tcp_puts("%u", syscfg.web_twrec);
|
||||||
|
else ifcmp("twcls") tcp_puts("%u", syscfg.web_twcls);
|
||||||
|
else ifcmp("twd") tcp_put((syscfg.cfg.b.web_time_wait_delete)? '1' : '0');
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
else ifcmp("sleep") tcp_put((syscfg.cfg.b.powersave_enable)? '1' : '0');
|
||||||
|
else ifcmp("pinclr") tcp_put((syscfg.cfg.b.pin_clear_cfg_enable)? '1' : '0');
|
||||||
|
else ifcmp("debug") tcp_put((syscfg.cfg.b.debug_print_enable)? '1' : '0');
|
||||||
|
#ifdef USE_NETBIOS
|
||||||
|
else ifcmp("netbios") tcp_put((syscfg.cfg.b.netbios_ena)? '1' : '0');
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SNTP
|
||||||
|
else ifcmp("sntp") tcp_put((syscfg.cfg.b.sntp_ena)? '1' : '0');
|
||||||
|
#endif
|
||||||
|
#ifdef USE_CAPTDNS
|
||||||
|
else ifcmp("cdns") tcp_put((syscfg.cfg.b.cdns_ena)? '1' : '0');
|
||||||
|
#endif
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
else ifcmp("wifi_") {
|
||||||
|
cstr+=5;
|
||||||
|
ifcmp("rdcfg") read_wifi_cfg(-1);
|
||||||
|
else ifcmp("newcfg") webserver_qfn((web_ex_func_cb)wifi_run, (void *)((uint32)wifi_cfg.mode), 200);
|
||||||
|
else ifcmp("cmode") tcp_puts("%d", wifi_mode);
|
||||||
|
else ifcmp("mode") tcp_puts("%d", wifi_cfg.mode);
|
||||||
|
else ifcmp("bgn") tcp_puts("%d", wifi_cfg.bgn);
|
||||||
|
else ifcmp("txpow") tcp_puts("%u", wifi_cfg.tx_pwr);
|
||||||
|
else ifcmp("lflg") tcp_puts("%u", wifi_cfg.load_flg);
|
||||||
|
else ifcmp("sflg") tcp_puts("%u", wifi_cfg.save_flg);
|
||||||
|
else ifcmp("adpt") tcp_puts("%u", wifi_cfg.adaptivity);
|
||||||
|
else ifcmp("country") tcp_puts("%u", wifi_cfg.country_code);
|
||||||
|
else ifcmp("ap_") {
|
||||||
|
cstr+=3;
|
||||||
|
ifcmp("ssid") {
|
||||||
|
wifi_ap_cfg.ssid[NDIS_802_11_LENGTH_SSID] = '\0';
|
||||||
|
tcp_strcpy(wifi_ap_cfg.ssid);
|
||||||
|
}
|
||||||
|
else ifcmp("psw") {
|
||||||
|
wifi_ap_cfg.password[IW_PASSPHRASE_MAX_SIZE] = '\0';
|
||||||
|
tcp_strcpy(wifi_ap_cfg.password);
|
||||||
|
}
|
||||||
|
else ifcmp("chl") tcp_puts("%u", wifi_ap_cfg.channel);
|
||||||
|
else ifcmp("mcns") tcp_puts("%u", wifi_ap_cfg.max_sta);
|
||||||
|
else ifcmp("auth") tcp_put((wifi_ap_cfg.security) ? '1' : '0');
|
||||||
|
else ifcmp("hssid") tcp_put((wifi_ap_cfg.ssid_hidden & 1) + '0');
|
||||||
|
else ifcmp("bint") tcp_puts("%u", wifi_ap_cfg.beacon_interval);
|
||||||
|
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[WLAN_AP_NETIF_NUM].hwaddr));
|
||||||
|
else ifcmp("hostname") tcp_strcpy(lwip_host_name[1]);
|
||||||
|
else ifcmp("dhcp") tcp_puts("%u", wifi_ap_dhcp.mode);
|
||||||
|
else ifcmp("ip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.ip));
|
||||||
|
else ifcmp("gw") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.gw));
|
||||||
|
else ifcmp("msk") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.mask));
|
||||||
|
else ifcmp("cip") tcp_puts(IPSTR, IP2STR(&xnetif[WLAN_ST_NETIF_NUM].ip_addr.addr));
|
||||||
|
// else ifcmp("mac") strtomac(pvar, wifi_ap_cfg.macaddr);
|
||||||
|
// else ifcmp("sip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.start_ip));
|
||||||
|
// else ifcmp("eip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.end_ip));
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
else os_printf(" - none! ");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else ifcmp("st_") {
|
||||||
|
cstr+=3;
|
||||||
|
ifcmp("rssi") {
|
||||||
|
int rssi;
|
||||||
|
wifi_get_rssi(&rssi);
|
||||||
|
tcp_puts("%d", rssi);
|
||||||
|
}
|
||||||
|
else ifcmp("status") tcp_puts("%u", wifi_st_status);
|
||||||
|
else ifcmp("arec") tcp_puts("%u", wifi_st_cfg.autoreconnect);
|
||||||
|
else ifcmp("rect") tcp_puts("%u", wifi_st_cfg.reconnect_pause);
|
||||||
|
ifcmp("ssid") {
|
||||||
|
wifi_st_cfg.ssid[NDIS_802_11_LENGTH_SSID] = '\0';
|
||||||
|
tcp_strcpy(wifi_st_cfg.ssid);
|
||||||
|
}
|
||||||
|
else ifcmp("psw") {
|
||||||
|
wifi_st_cfg.password[IW_PASSPHRASE_MAX_SIZE] = '\0';
|
||||||
|
tcp_strcpy(wifi_st_cfg.password);
|
||||||
|
}
|
||||||
|
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[WLAN_ST_NETIF_NUM].hwaddr));
|
||||||
|
else ifcmp("bssid") tcp_puts(MACSTR, MAC2STR(wifi_st_cfg.bssid));
|
||||||
|
else ifcmp("sbss") tcp_puts("%u", wifi_st_cfg.flg);
|
||||||
|
else ifcmp("sleep") tcp_puts("%d", wifi_st_cfg.sleep);
|
||||||
|
else ifcmp("dtim") tcp_puts("%u", wifi_st_cfg.dtim);
|
||||||
|
#if LWIP_NETIF_HOSTNAME
|
||||||
|
else ifcmp("hostname") tcp_strcpy(lwip_host_name[0]);
|
||||||
|
#endif
|
||||||
|
else ifcmp("auth") tcp_puts("%u", wifi_st_cfg.security);
|
||||||
|
else ifcmp("dhcp") tcp_puts("%u", wifi_st_dhcp.mode);
|
||||||
|
else ifcmp("ip") tcp_puts(IPSTR, IP2STR(&wifi_st_dhcp.ip));
|
||||||
|
else ifcmp("gw") tcp_puts(IPSTR, IP2STR(&wifi_st_dhcp.gw));
|
||||||
|
else ifcmp("msk") tcp_puts(IPSTR, IP2STR(&wifi_st_dhcp.mask));
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none!\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none!\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else ifcmp("bin_") {
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) return;
|
||||||
|
#endif
|
||||||
|
cstr+=4;
|
||||||
|
ifcmp("flash") {
|
||||||
|
cstr+=5;
|
||||||
|
if(*cstr == '_') {
|
||||||
|
cstr++;
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
ifcmp("all") {
|
||||||
|
web_conn->udata_start = 0;
|
||||||
|
web_conn->udata_stop = spi_flash_real_size();
|
||||||
|
web_get_flash(ts_conn);
|
||||||
|
}
|
||||||
|
else ifcmp("sec_") {
|
||||||
|
web_conn->udata_start = ahextoul(cstr+4) << 12;
|
||||||
|
web_conn->udata_stop = web_conn->udata_start + FLASH_SECTOR_SIZE;
|
||||||
|
web_get_flash(ts_conn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // #if WEB_DEBUG_FUNCTIONS
|
||||||
|
ifcmp("disk") {
|
||||||
|
web_conn->udata_start = WEBFS_base_addr();
|
||||||
|
web_conn->udata_stop = web_conn->udata_start + WEBFS_curent_size();
|
||||||
|
web_get_flash(ts_conn);
|
||||||
|
}
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
else web_get_flash(ts_conn);
|
||||||
|
}
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
else ifcmp("ram") web_get_ram(ts_conn);
|
||||||
|
#endif // #if WEB_DEBUG_FUNCTIONS
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
else ifcmp("hexdmp") {
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) return;
|
||||||
|
#endif
|
||||||
|
if(cstr[6]=='d') ts_conn->flag.user_option1 = 1;
|
||||||
|
else ts_conn->flag.user_option1 = 0;
|
||||||
|
web_hexdump(ts_conn);
|
||||||
|
}
|
||||||
|
#endif // #if WEB_DEBUG_FUNCTIONS
|
||||||
|
else ifcmp("web_") {
|
||||||
|
cstr+=4;
|
||||||
|
ifcmp("port") tcp_puts("%u", ts_conn->pcfg->port);
|
||||||
|
else ifcmp("host") tcp_puts(IPSTR ":%d", IP2STR(&(ts_conn->pcb->local_ip.addr)), ts_conn->pcb->local_port);
|
||||||
|
else ifcmp("remote") tcp_puts(IPSTR ":%d", IP2STR(&(ts_conn->remote_ip.dw)), ts_conn->remote_port);
|
||||||
|
else ifcmp("twrec") tcp_puts("%u", ts_conn->pcfg->time_wait_rec);
|
||||||
|
else ifcmp("twcls") tcp_puts("%u", ts_conn->pcfg->time_wait_cls);
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
else ifcmp("wfs_") {
|
||||||
|
cstr+=4;
|
||||||
|
ifcmp("files") tcp_puts("%u", numFiles);
|
||||||
|
else ifcmp("addr") tcp_puts("0x%08x", WEBFS_base_addr());
|
||||||
|
else ifcmp("size") tcp_puts("%u", WEBFS_curent_size());
|
||||||
|
else ifcmp("max_size") tcp_puts("%u", WEBFS_max_size());
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
#ifdef USE_OVERLAY
|
||||||
|
else ifcmp("ovl") {
|
||||||
|
cstr += 3;
|
||||||
|
if(*cstr == ':') {
|
||||||
|
int i = ovl_loader(cstr + 1);
|
||||||
|
if (i == 0) {
|
||||||
|
if(CheckSCB(SCB_WEBSOC)) {
|
||||||
|
tcp_puts("%d", ovl_call(1));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
web_conn->web_disc_cb = (web_func_disc_cb)ovl_call; // адрес старта оверлея
|
||||||
|
web_conn->web_disc_par = 1; // параметр функции - инициализация
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tcp_puts("%d", i);
|
||||||
|
}
|
||||||
|
else if(*cstr == '$') {
|
||||||
|
if(ovl_call != NULL) tcp_puts("%d", ovl_call(ahextoul(cstr + 1)));
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
else if(*cstr == '@') {
|
||||||
|
if(ovl_call != NULL) tcp_puts("%d", ovl_call((int) cstr + 1));
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SNTP
|
||||||
|
else ifcmp("sntp_") {
|
||||||
|
cstr += 5;
|
||||||
|
ifcmp("time") tcp_puts("%u", sntp_gen_system_time(0)); // get_sntp_time
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef TEST_SEND_WAVE
|
||||||
|
else ifcmp("test_adc") web_test_adc(ts_conn);
|
||||||
|
#endif
|
||||||
|
else ifcmp("hellomsg") tcp_puts_fd("Web on RTL871x!");
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_WEB
|
427
Firmware/RTLGDB/Project/web/web_int_vars.c
Normal file
427
Firmware/RTLGDB/Project/web/web_int_vars.c
Normal file
|
@ -0,0 +1,427 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* FileName: webserver.c
|
||||||
|
* Description: The web server mode configuration.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "user_config.h"
|
||||||
|
#ifdef USE_WEB
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "freertos_pmu.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include "lwip/ip.h"
|
||||||
|
#include "lwip/ip_addr.h"
|
||||||
|
#include "lwip/tcp.h"
|
||||||
|
#include "tcpsrv/tcp_srv_conn.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
|
#include "web_srv_int.h"
|
||||||
|
#include "web_utils.h"
|
||||||
|
#include "webfs/webfs.h"
|
||||||
|
#include "flash_eep.h"
|
||||||
|
#include "device_lock.h"
|
||||||
|
#include "rtl8195a/rtl_libc.h"
|
||||||
|
#include "sys_cfg.h"
|
||||||
|
#include "wifi_api.h"
|
||||||
|
#include "sys_api.h"
|
||||||
|
#include "esp_comp.h"
|
||||||
|
|
||||||
|
#include "ledeffectsserver.h"
|
||||||
|
|
||||||
|
#ifdef USE_NETBIOS
|
||||||
|
#include "netbios/netbios.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_SNTP
|
||||||
|
#include "sntp/sntp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_LWIP_PING
|
||||||
|
#include "lwip/app/ping.h"
|
||||||
|
struct ping_option pingopt; // for test
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CAPTDNS
|
||||||
|
#include "captdns.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_MODBUS
|
||||||
|
#include "modbustcp.h"
|
||||||
|
#include "mdbtab.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_RS485DRV
|
||||||
|
#include "driver/rs485drv.h"
|
||||||
|
#include "mdbrs485.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_OVERLAY
|
||||||
|
#include "overlay.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void web_get_ram(TCP_SERV_CONN *ts_conn);
|
||||||
|
extern void web_get_flash(TCP_SERV_CONN *ts_conn);
|
||||||
|
extern void web_hexdump(TCP_SERV_CONN *ts_conn);
|
||||||
|
|
||||||
|
#define ifcmp(a) if(rom_xstrcmp(cstr, a))
|
||||||
|
|
||||||
|
extern int rom_atoi(const char *);
|
||||||
|
#undef atoi
|
||||||
|
#define atoi rom_atoi
|
||||||
|
|
||||||
|
typedef uint32 (* call_func)(uint32 a, uint32 b, uint32 c);
|
||||||
|
extern QueueHandle_t xQueueWebSrv;
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : parse_url
|
||||||
|
* Description : parse the received data from the server
|
||||||
|
* Parameters : CurHTTP -- the result of parsing the url
|
||||||
|
* Returns : none
|
||||||
|
*******************************************************************************/
|
||||||
|
void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *pvar)
|
||||||
|
{
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||||
|
uint32 val = ahextoul(pvar);
|
||||||
|
char *cstr = pcmd;
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("[%s=%s]\n", pcmd, pvar);
|
||||||
|
#endif
|
||||||
|
ifcmp("start") web_conn->udata_start = val;
|
||||||
|
else ifcmp("stop") web_conn->udata_stop = val;
|
||||||
|
// **************************************************************************************************** //
|
||||||
|
// **************************************** User settings ********************************************* //
|
||||||
|
else ifcmp("ws_")
|
||||||
|
{
|
||||||
|
cstr += 3;
|
||||||
|
ifcmp("filt_")
|
||||||
|
{
|
||||||
|
cstr += 5;
|
||||||
|
ifcmp("rbw_")
|
||||||
|
{
|
||||||
|
cstr += 4;
|
||||||
|
|
||||||
|
ifcmp("enbl") filt_rainbow.enabled = (uint8_t)val;
|
||||||
|
else ifcmp("huesteps") filt_rainbow.hue_steps = (uint8_t)val;
|
||||||
|
else ifcmp("cyclesteps") filt_rainbow.cycle_steps = (uint8_t)val;
|
||||||
|
}
|
||||||
|
else ifcmp("fd_")
|
||||||
|
{
|
||||||
|
cstr += 3;
|
||||||
|
|
||||||
|
ifcmp("enbl") filt_fade.enabled = (uint8_t)val;
|
||||||
|
else ifcmp("min") filt_fade.min = (uint8_t)val;
|
||||||
|
else ifcmp("max") filt_fade.max = (uint8_t)val;
|
||||||
|
else ifcmp("cyclesteps") filt_fade.steps = (uint8_t)val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// **************************************************************************************************** //
|
||||||
|
// **************************************************************************************************** //
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
else ifcmp("user") web_conn->auth_level = UserAuthorization(pvar, strlen(pvar));
|
||||||
|
else if(web_conn->auth_level < WEB_AUTH_LEVEL_USER) {
|
||||||
|
if(!web_conn->auth_realm) web_conn->auth_realm = WEB_AUTH_LEVEL_USER;
|
||||||
|
SetSCB(SCB_AUTH);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
else ifcmp("sys_") {
|
||||||
|
cstr+=4;
|
||||||
|
ifcmp("restart") {
|
||||||
|
if(val == 12345) webserver_qfn((web_ex_func_cb)sys_reset, NULL, 200);
|
||||||
|
}
|
||||||
|
else ifcmp("ram") { uint32 *ptr = (uint32 *)(ahextoul(cstr+3)&(~3)); str_array(pvar, ptr, 32); }
|
||||||
|
else ifcmp("debug") print_off = (!val) & 1; // rtl_print on/off
|
||||||
|
else ifcmp("dsleep") deepsleep_ex(DSLEEP_WAKEUP_BY_TIMER, val);
|
||||||
|
#ifdef USE_LWIP_PING
|
||||||
|
else ifcmp("ping") {
|
||||||
|
// struct ping_option *pingopt = (struct ping_option *)UartDev.rcv_buff.pRcvMsgBuff;
|
||||||
|
pingopt.ip = ipaddr_addr(pvar);
|
||||||
|
pingopt.count = 3;
|
||||||
|
pingopt.recv_function=NULL;
|
||||||
|
pingopt.sent_function=NULL;
|
||||||
|
ping_start(&pingopt);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif // #if WEB_DEBUG_FUNCTIONS
|
||||||
|
else ifcmp("cfg_") {
|
||||||
|
cstr += 4;
|
||||||
|
ifcmp("web_") {
|
||||||
|
cstr += 4;
|
||||||
|
ifcmp("port") {
|
||||||
|
if(syscfg.web_port != val) {
|
||||||
|
webserver_qfn((web_ex_func_cb)webserver_reinit, (void *)((uint32)syscfg.web_port), 200);
|
||||||
|
syscfg.web_port = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else ifcmp("twd") {
|
||||||
|
if(val) {
|
||||||
|
syscfg.cfg.b.web_time_wait_delete = 1;
|
||||||
|
ts_conn->pcfg->flag.pcb_time_wait_free = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
syscfg.cfg.b.web_time_wait_delete = 0;
|
||||||
|
ts_conn->pcfg->flag.pcb_time_wait_free = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else ifcmp("twrec") {
|
||||||
|
syscfg.web_twrec = val;
|
||||||
|
ts_conn->pcfg->time_wait_rec = val;
|
||||||
|
}
|
||||||
|
else ifcmp("twcls") {
|
||||||
|
syscfg.web_twcls = val;
|
||||||
|
ts_conn->pcfg->time_wait_cls = val;
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none!\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else ifcmp("pinclr") syscfg.cfg.b.pin_clear_cfg_enable = (val)? 1 : 0;
|
||||||
|
else ifcmp("sleep") {
|
||||||
|
syscfg.cfg.b.powersave_enable = (val)? 1 : 0;
|
||||||
|
if(val) release_wakelock(~WAKELOCK_WLAN);
|
||||||
|
else acquire_wakelock(~WAKELOCK_WLAN);
|
||||||
|
}
|
||||||
|
else ifcmp("debug") {
|
||||||
|
syscfg.cfg.b.debug_print_enable = val;
|
||||||
|
print_off = (!val) & 1; // rtl_print on/off
|
||||||
|
}
|
||||||
|
else ifcmp("save") {
|
||||||
|
if(val == 2) SetSCB(SCB_SYSSAVE); // по закрытию соединения вызвать sys_write_cfg()
|
||||||
|
else if(val == 1) sys_write_cfg();
|
||||||
|
}
|
||||||
|
#ifdef USE_NETBIOS
|
||||||
|
else ifcmp("netbios") {
|
||||||
|
syscfg.cfg.b.netbios_ena = (val)? 1 : 0;
|
||||||
|
if(syscfg.cfg.b.netbios_ena) netbios_init();
|
||||||
|
else netbios_off();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SNTP
|
||||||
|
else ifcmp("sntp") {
|
||||||
|
syscfg.cfg.b.sntp_ena = (val)? 1 : 0;
|
||||||
|
if(syscfg.cfg.b.sntp_ena) sntp_init();
|
||||||
|
else sntp_stop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_CAPTDNS
|
||||||
|
else ifcmp("cdns") {
|
||||||
|
syscfg.cfg.b.cdns_ena = (val)? 1 : 0;
|
||||||
|
if(syscfg.cfg.b.cdns_ena && wifi_softap_get_station_num()) captdns_init();
|
||||||
|
else captdns_close();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none!\n");
|
||||||
|
#endif
|
||||||
|
// sys_write_cfg();
|
||||||
|
}
|
||||||
|
else ifcmp("wifi_") {
|
||||||
|
cstr+=5;
|
||||||
|
ifcmp("scan") api_wifi_scan(NULL);
|
||||||
|
else ifcmp("rdcfg") web_conn->udata_stop = read_wifi_cfg(val);
|
||||||
|
else ifcmp("newcfg") webserver_qfn((web_ex_func_cb)wifi_run, (void *)((uint32) wifi_cfg.mode), 200);
|
||||||
|
else ifcmp("mode") wifi_cfg.mode = val;
|
||||||
|
else ifcmp("bgn") wifi_cfg.bgn = val;
|
||||||
|
else ifcmp("lflg") wifi_cfg.load_flg = val;
|
||||||
|
else ifcmp("sflg") wifi_cfg.save_flg = val;
|
||||||
|
else ifcmp("txpow") wifi_cfg.tx_pwr = val;
|
||||||
|
else ifcmp("adpt") wifi_cfg.adaptivity = val;
|
||||||
|
else ifcmp("country") wifi_cfg.country_code = val;
|
||||||
|
// .. mac wifi_set_mac_address()
|
||||||
|
|
||||||
|
// else ifcmp("scan") {
|
||||||
|
// web_conn->web_disc_par = val;
|
||||||
|
// web_conn->web_disc_cb = (web_func_disc_cb)wifi_start_scan;
|
||||||
|
// }
|
||||||
|
else ifcmp("save") { write_wifi_cfg(val); }
|
||||||
|
else ifcmp("ap_") {
|
||||||
|
cstr+=3;
|
||||||
|
ifcmp("ssid") {
|
||||||
|
if(pvar[0]!='\0') {
|
||||||
|
int len = os_strlen(pvar);
|
||||||
|
if(len > NDIS_802_11_LENGTH_SSID) {
|
||||||
|
len = NDIS_802_11_LENGTH_SSID;
|
||||||
|
}
|
||||||
|
os_memset(wifi_ap_cfg.ssid, 0, sizeof(wifi_ap_cfg.ssid));
|
||||||
|
os_memcpy(wifi_ap_cfg.ssid, pvar, len);
|
||||||
|
#ifdef USE_NETBIOS
|
||||||
|
// netbios_set_name(wlan_ap_netifn, wifi_ap_cfg.ssid);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else ifcmp("psw") {
|
||||||
|
int len = os_strlen(pvar);
|
||||||
|
if(len > IW_PASSPHRASE_MAX_SIZE) {
|
||||||
|
len = IW_PASSPHRASE_MAX_SIZE;
|
||||||
|
}
|
||||||
|
os_memset(wifi_ap_cfg.password, 0, sizeof(wifi_ap_cfg.password));
|
||||||
|
os_memcpy(wifi_ap_cfg.password, pvar, len);
|
||||||
|
}
|
||||||
|
else ifcmp("chl") wifi_ap_cfg.channel = val;
|
||||||
|
else ifcmp("mcns") wifi_ap_cfg.max_sta = val;
|
||||||
|
else ifcmp("auth") wifi_ap_cfg.security = val; // =1 IDX_SECURITY_WPA2_AES_PSK, =0 IDX_SECURITY_OPEN
|
||||||
|
else ifcmp("hssid") wifi_ap_cfg.ssid_hidden = val;
|
||||||
|
else ifcmp("bint") wifi_ap_cfg.beacon_interval = val;
|
||||||
|
#if LWIP_NETIF_HOSTNAME
|
||||||
|
else ifcmp("hostname") {
|
||||||
|
int len = os_strlen(pvar);
|
||||||
|
if(len >= LWIP_NETIF_HOSTNAME_SIZE) {
|
||||||
|
len = LWIP_NETIF_HOSTNAME_SIZE-1;
|
||||||
|
}
|
||||||
|
if(len) {
|
||||||
|
os_memset(lwip_host_name[1], 0, LWIP_NETIF_HOSTNAME_SIZE);
|
||||||
|
os_memcpy(lwip_host_name[1], pvar, len);
|
||||||
|
}
|
||||||
|
netbios_set_name(WLAN_AP_NETIF_NUM, lwip_host_name[1]);
|
||||||
|
if(wifi_cfg.save_flg & BID_AP_HOSTNAME) {
|
||||||
|
WEB_SRV_QFNK x;
|
||||||
|
x.fnc = write_wifi_cfg;
|
||||||
|
x.param = (void *)BID_AP_HOSTNAME;
|
||||||
|
xQueueSendToBack(xQueueWebSrv, &x, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else ifcmp("dhcp") wifi_ap_dhcp.mode = val;
|
||||||
|
else ifcmp("ip") wifi_ap_dhcp.ip = ipaddr_addr(pvar);
|
||||||
|
else ifcmp("gw") wifi_ap_dhcp.gw = ipaddr_addr(pvar);
|
||||||
|
else ifcmp("msk") wifi_ap_dhcp.mask = ipaddr_addr(pvar);
|
||||||
|
// else ifcmp("mac") strtomac(pvar, wifi_ap_cfg.macaddr);
|
||||||
|
// else ifcmp("sip") wifi_ap_dhcp.start_ip = ipaddr_addr(pvar);
|
||||||
|
// else ifcmp("eip") wifi_ap_dhcp.end_ip = ipaddr_addr(pvar);
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
else os_printf(" - none! ");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else ifcmp("st_") {
|
||||||
|
cstr+=3;
|
||||||
|
ifcmp("arec") wifi_st_cfg.autoreconnect = val;
|
||||||
|
else ifcmp("rect") wifi_st_cfg.reconnect_pause = val;
|
||||||
|
else ifcmp("ssid") {
|
||||||
|
if(pvar[0]!='\0') {
|
||||||
|
int len = os_strlen(pvar);
|
||||||
|
if(len > NDIS_802_11_LENGTH_SSID) {
|
||||||
|
len = NDIS_802_11_LENGTH_SSID;
|
||||||
|
}
|
||||||
|
os_memset(wifi_st_cfg.ssid, 0, sizeof(wifi_st_cfg.ssid));
|
||||||
|
os_memcpy(wifi_st_cfg.ssid, pvar, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else ifcmp("psw") {
|
||||||
|
int len = os_strlen(pvar);
|
||||||
|
if(len > IW_PASSPHRASE_MAX_SIZE) {
|
||||||
|
len = IW_PASSPHRASE_MAX_SIZE;
|
||||||
|
}
|
||||||
|
os_memset(wifi_st_cfg.password, 0, sizeof(wifi_st_cfg.password));
|
||||||
|
os_memcpy(wifi_st_cfg.password, pvar, len);
|
||||||
|
}
|
||||||
|
else ifcmp("auth") wifi_st_cfg.security = val;
|
||||||
|
else ifcmp("bssid") strtomac(pvar, wifi_st_cfg.bssid);
|
||||||
|
else ifcmp("sbss") wifi_st_cfg.flg = val;
|
||||||
|
else ifcmp("sleep") wifi_st_cfg.sleep = val;
|
||||||
|
else ifcmp("dtim") wifi_st_cfg.dtim = val;
|
||||||
|
#if LWIP_NETIF_HOSTNAME
|
||||||
|
else ifcmp("hostname") {
|
||||||
|
int len = os_strlen(pvar);
|
||||||
|
if(len >= LWIP_NETIF_HOSTNAME_SIZE) {
|
||||||
|
len = LWIP_NETIF_HOSTNAME_SIZE-1;
|
||||||
|
}
|
||||||
|
if(len) {
|
||||||
|
os_memset(lwip_host_name[0], 0, LWIP_NETIF_HOSTNAME_SIZE);
|
||||||
|
os_memcpy(lwip_host_name[0], pvar, len);
|
||||||
|
netbios_set_name(WLAN_ST_NETIF_NUM, lwip_host_name[0]);
|
||||||
|
}
|
||||||
|
if(wifi_cfg.save_flg & BID_ST_HOSTNAME) {
|
||||||
|
WEB_SRV_QFNK x;
|
||||||
|
x.fnc = write_wifi_cfg;
|
||||||
|
x.param = (void *)BID_ST_HOSTNAME;
|
||||||
|
x.pause_ms = 0;
|
||||||
|
xQueueSendToBack(xQueueWebSrv, &x, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else ifcmp("dhcp") wifi_st_dhcp.mode = val;
|
||||||
|
else ifcmp("ip") wifi_st_dhcp.ip = ipaddr_addr(pvar);
|
||||||
|
else ifcmp("gw") wifi_st_dhcp.gw = ipaddr_addr(pvar);
|
||||||
|
else ifcmp("msk") wifi_st_dhcp.mask = ipaddr_addr(pvar);
|
||||||
|
// else ifcmp("mac") strtomac(pvar, wifi_st_cfg.mac);
|
||||||
|
// else ifcmp("sbss") wifi_st_cfg.bssidx = val;
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none!\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none!\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if WEB_DEBUG_FUNCTIONS
|
||||||
|
else if(web_conn->bffiles[0]==WEBFS_WEBCGI_HANDLE && CheckSCB(SCB_GET)) {
|
||||||
|
ifcmp("hexdmp") {
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
os_printf("hexdmp(%p)\n", val);
|
||||||
|
#endif
|
||||||
|
if(val > 0) {
|
||||||
|
if(cstr[6]=='d') ts_conn->flag.user_option1 = 1;
|
||||||
|
else ts_conn->flag.user_option1 = 0;
|
||||||
|
uint32 x = ahextoul(cstr+7);
|
||||||
|
web_conn->udata_start = x;
|
||||||
|
web_conn->udata_stop = val + web_conn->udata_start;
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
os_printf("start=%p, stop=%p\n", web_conn->udata_start, web_conn->udata_stop);
|
||||||
|
#endif
|
||||||
|
web_conn->fileType = HTTP_TXT;
|
||||||
|
SetSCB(SCB_RETRYCB | SCB_FCALBACK);
|
||||||
|
SetNextFunSCB(web_hexdump);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else ifcmp("flash") {
|
||||||
|
cstr+=5;
|
||||||
|
if(*cstr == '_') {
|
||||||
|
cstr++;
|
||||||
|
ifcmp("all") {
|
||||||
|
web_conn->udata_start = 0;
|
||||||
|
web_conn->udata_stop = spi_flash_real_size();
|
||||||
|
web_conn->fileType = HTTP_BIN;
|
||||||
|
SetSCB(SCB_RETRYCB | SCB_FCALBACK);
|
||||||
|
SetNextFunSCB(web_get_flash);
|
||||||
|
}
|
||||||
|
else ifcmp("sec_") {
|
||||||
|
web_conn->udata_start = ahextoul(cstr+4) << 12;
|
||||||
|
web_conn->udata_stop = web_conn->udata_start + FLASH_SECTOR_SIZE*val;
|
||||||
|
web_conn->fileType = HTTP_BIN;
|
||||||
|
SetSCB(SCB_RETRYCB | SCB_FCALBACK);
|
||||||
|
SetNextFunSCB(web_get_flash);
|
||||||
|
}
|
||||||
|
else ifcmp("disk") {
|
||||||
|
web_conn->udata_start = WEBFS_base_addr();
|
||||||
|
web_conn->udata_stop = web_conn->udata_start + WEBFS_curent_size();
|
||||||
|
web_conn->fileType = HTTP_BIN;
|
||||||
|
SetSCB(SCB_RETRYCB | SCB_FCALBACK);
|
||||||
|
SetNextFunSCB(web_get_flash);
|
||||||
|
}
|
||||||
|
else tcp_put('?');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
web_conn->fileType = HTTP_BIN;
|
||||||
|
SetSCB(SCB_RETRYCB | SCB_FCALBACK);
|
||||||
|
SetNextFunSCB(web_get_flash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else ifcmp("bin_ram") {
|
||||||
|
web_conn->fileType = HTTP_BIN;
|
||||||
|
SetSCB(SCB_RETRYCB | SCB_FCALBACK);
|
||||||
|
SetNextFunSCB(web_get_ram);
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none! ");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif // #if WEB_DEBUG_FUNCTIONS
|
||||||
|
#if DEBUGSOO > 5
|
||||||
|
else os_printf(" - none! ");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_WEB
|
2076
Firmware/RTLGDB/Project/web/web_srv.c
Normal file
2076
Firmware/RTLGDB/Project/web/web_srv.c
Normal file
File diff suppressed because it is too large
Load diff
210
Firmware/RTLGDB/Project/web/web_srv.h
Normal file
210
Firmware/RTLGDB/Project/web/web_srv.h
Normal file
|
@ -0,0 +1,210 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
#define USE_WEB_AUTH_LEVEL 0 // 1
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
WEB_AUTH_NONE = 0,
|
||||||
|
WEB_AUTH_LEVEL_USER,
|
||||||
|
WEB_AUTH_LEVEL_USER1,
|
||||||
|
WEB_AUTH_LEVEL_WEBFS,
|
||||||
|
WEB_AUTH_LEVEL_OTA,
|
||||||
|
WEB_AUTH_LEVEL_SUPERVISOR
|
||||||
|
} WEB_AUTH_LEVEL_TYPE;
|
||||||
|
|
||||||
|
// 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_ex_func_cb)(uint32 flg); // внешняя или отложенная функция
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
web_ex_func_cb fnc;
|
||||||
|
void * param;
|
||||||
|
uint16 pause_ms;
|
||||||
|
} 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)
|
||||||
|
#ifdef WEBSOCKET_ENA
|
||||||
|
WS_FRSTAT ws; // параметры websoc
|
||||||
|
#endif
|
||||||
|
#if USE_WEB_AUTH_LEVEL
|
||||||
|
uint8 auth_level; // Уровень авторизации пользователя по паролю WEB_AUTH_LEVEL_TYPE
|
||||||
|
uint8 auth_realm; // Требуемый уровень авторизации (минимальный уровень) WEB_AUTH_LEVEL_TYPE
|
||||||
|
#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);
|
||||||
|
|
||||||
|
BaseType_t webserver_qfn(web_ex_func_cb fnc, void * param, uint16 pause_ms); // вызов функции из task с low priority
|
||||||
|
|
||||||
|
#endif /* _INCLUDE_WEB_SRV_H_ */
|
48
Firmware/RTLGDB/Project/web/web_srv_int.h
Normal file
48
Firmware/RTLGDB/Project/web/web_srv_int.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
// 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 TCP_SRV_SERVER_MAX_RXBUF // максимальный размер 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_SND_BUF) + RESCHK_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);
|
||||||
|
uint8 UserAuthorization(uint8 *pbuf, size_t declen);
|
||||||
|
|
||||||
|
#endif /* _INCLUDE_WEB_SRV_INT_H_ */
|
680
Firmware/RTLGDB/Project/web/web_utils.c
Normal file
680
Firmware/RTLGDB/Project/web/web_utils.c
Normal file
|
@ -0,0 +1,680 @@
|
||||||
|
/*
|
||||||
|
* web_utils.c
|
||||||
|
*
|
||||||
|
* Created on: 25 дек. 2014 г.
|
||||||
|
* Author: PV`
|
||||||
|
*/
|
||||||
|
#include "user_config.h"
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
//#include "bios.h"
|
||||||
|
//#include "sdk/add_func.h"
|
||||||
|
//#include "ets_sys.h"
|
||||||
|
//#include "os_type.h"
|
||||||
|
//#include "osapi.h"
|
||||||
|
//#include "user_interface.h"
|
||||||
|
#include "web_utils.h"
|
||||||
|
#include "esp_comp.h"
|
||||||
|
|
||||||
|
#define mMIN(a, b) ((a<b)?a:b)
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* xstrcpy() из сегментов flash и IRAM с возвратом размера строки:
|
||||||
|
* на выходе размер строки, без учета терминатора '\0'
|
||||||
|
*******************************************************************************/
|
||||||
|
int ICACHE_RAM_ATTR rom_xstrcpy(char * pd, const char * ps)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
union {
|
||||||
|
unsigned char uc[4];
|
||||||
|
unsigned int ud;
|
||||||
|
}tmp;
|
||||||
|
if(ps == 0 || pd == 0) return (0);
|
||||||
|
*pd = 0;
|
||||||
|
unsigned int len = 0;
|
||||||
|
unsigned int *p = (unsigned int *)((unsigned int)ps & (~3));
|
||||||
|
unsigned int xlen = (unsigned int)ps & 3;
|
||||||
|
while(1) {
|
||||||
|
tmp.ud = *p++;
|
||||||
|
do {
|
||||||
|
if((*pd++ = tmp.uc[xlen++]) == 0) return len;
|
||||||
|
len++;
|
||||||
|
xlen &= 3;
|
||||||
|
} while(xlen);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int len = 0;
|
||||||
|
while((*pd++ = *ps++) != 0) len++;
|
||||||
|
return len;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* сравнение строки в ram со строкой в сегменте flash и IRAM
|
||||||
|
* = 1 если шаблон совпадает
|
||||||
|
*******************************************************************************/
|
||||||
|
int ICACHE_RAM_ATTR rom_xstrcmp(char * pd, const char * ps)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
union {
|
||||||
|
unsigned char uc[4];
|
||||||
|
unsigned int ud;
|
||||||
|
}tmp;
|
||||||
|
if(ps == 0 || pd == 0) return 0;
|
||||||
|
unsigned int *p = (unsigned int *)((unsigned int)ps & (~3));
|
||||||
|
unsigned int xlen = (unsigned int)ps & 3;
|
||||||
|
while(1) {
|
||||||
|
tmp.ud = *p++;
|
||||||
|
do {
|
||||||
|
if(tmp.uc[xlen] == 0) return 1;
|
||||||
|
if(tmp.uc[xlen++] != *pd || *pd++ == 0) return 0;
|
||||||
|
xlen &= 3;
|
||||||
|
} while(xlen);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
while(*ps) {
|
||||||
|
if(*pd++ != *ps++) return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* rom_atoi
|
||||||
|
*******************************************************************************/
|
||||||
|
int ICACHE_FLASH_ATTR rom_atoi(const char *s)
|
||||||
|
{
|
||||||
|
int n=0, neg=0;
|
||||||
|
while (*s == ' ') s++;
|
||||||
|
switch (*s) {
|
||||||
|
case '-': neg=1;
|
||||||
|
case '+': s++;
|
||||||
|
}
|
||||||
|
/* Compute n as a negative number to avoid overflow on INT_MIN */
|
||||||
|
while (*s >= '0' && *s <= '9')
|
||||||
|
n = 10*n - (*s++ - '0');
|
||||||
|
return neg ? n : -n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* get_seg_id()
|
||||||
|
*******************************************************************************/
|
||||||
|
const char * const txt_tab_seg[] = {
|
||||||
|
"ROM" // 0
|
||||||
|
"SRAM", // 1
|
||||||
|
"TCM", // 2
|
||||||
|
"FLASH", // 3 // -> flash On
|
||||||
|
"SDRAM", // 4 // -> Test ChipID or HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Off
|
||||||
|
"SOC", // 5 // protected !
|
||||||
|
"CPU", // 6 // protected !
|
||||||
|
"UNK", // 7
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32 tab_seg_def[] = {
|
||||||
|
0x00000000, 0x00050000,
|
||||||
|
0x10000000, 0x10070000,
|
||||||
|
0x1fff0000, 0x20000000,
|
||||||
|
0x98000000, 0xA0000000,
|
||||||
|
0x30000000, 0x30200000,
|
||||||
|
0x40000000, 0x40800000,
|
||||||
|
0xE0000000, 0xE0010000,
|
||||||
|
0x00000000, 0xFFFFFFFF
|
||||||
|
};
|
||||||
|
|
||||||
|
SEG_ID get_seg_id(uint32 addr, int32 size) {
|
||||||
|
SEG_ID ret = SEG_ID_ERR;
|
||||||
|
uint32 * ptr = (uint32 *) &tab_seg_def;
|
||||||
|
if (size > 0) {
|
||||||
|
do {
|
||||||
|
ret++;
|
||||||
|
if (addr >= ptr[0] && addr + size <= ptr[1]) {
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
ptr += 2;
|
||||||
|
} while (ret < SEG_ID_MAX);
|
||||||
|
};
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* copy_align4
|
||||||
|
* копирует данные из области кеширования flash и т.д.
|
||||||
|
*******************************************************************************/
|
||||||
|
void ICACHE_FLASH_ATTR copy_align4(void *ptrd, void *ptrs, uint32 len)
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
uint8 uc[4];
|
||||||
|
uint32 ud;
|
||||||
|
}tmp;
|
||||||
|
uint8 *pd = ptrd;
|
||||||
|
uint32 *p = (uint32 *)((uint32)ptrs & (~3));
|
||||||
|
uint32 xlen = ((uint32)ptrs) & 3;
|
||||||
|
if(xlen) {
|
||||||
|
if(((uint32)p >= 0x10000000)&&((uint32)p < 0x9A002000)) tmp.ud = *p++;
|
||||||
|
else {
|
||||||
|
tmp.ud = 0;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
while (len) {
|
||||||
|
*pd++ = tmp.uc[xlen++];
|
||||||
|
len--;
|
||||||
|
if(xlen >= 4) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xlen = len >> 2;
|
||||||
|
while(xlen) {
|
||||||
|
if(((uint32)p >= 0x10000000)&&((uint32)p < 0x9A002000)) tmp.ud = *p++;
|
||||||
|
else {
|
||||||
|
tmp.ud = 0;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
*pd++ = tmp.uc[0];
|
||||||
|
*pd++ = tmp.uc[1];
|
||||||
|
*pd++ = tmp.uc[2];
|
||||||
|
*pd++ = tmp.uc[3];
|
||||||
|
xlen--;
|
||||||
|
}
|
||||||
|
len &= 3;
|
||||||
|
if(len) {
|
||||||
|
if(((uint32)p >= 0x10000000)&&((uint32)p < 0x9A002000)) tmp.ud = *p;
|
||||||
|
else tmp.ud = 0;
|
||||||
|
uint8 * ptmp = tmp.uc;
|
||||||
|
while (len--) *pd++ = *ptmp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : hextoul
|
||||||
|
*******************************************************************************/
|
||||||
|
// bool conv_str_hex(uint32 * dest, uint8 *s);
|
||||||
|
uint32 ICACHE_FLASH_ATTR hextoul(uint8 *s)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
uint32 val;
|
||||||
|
if(!conv_str_hex(&val, s)) return 0;
|
||||||
|
return val;
|
||||||
|
*/
|
||||||
|
uint32 val = 0;
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
if (*s >= '0' && *s <= '9')
|
||||||
|
{
|
||||||
|
val <<= 4;
|
||||||
|
val |= *s - '0';
|
||||||
|
}
|
||||||
|
else if (*s >= 'A' && *s <= 'F')
|
||||||
|
{
|
||||||
|
val <<= 4;
|
||||||
|
val |= *s - 'A' + 10;
|
||||||
|
}
|
||||||
|
else if (*s >= 'a' && *s <= 'f')
|
||||||
|
{
|
||||||
|
val <<= 4;
|
||||||
|
val |= *s - 'a' + 10;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
s++;
|
||||||
|
};
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : ahextoul
|
||||||
|
*******************************************************************************/
|
||||||
|
// bool convert_para_str(uint32 * dest, uint8 *s);
|
||||||
|
uint32 ICACHE_FLASH_ATTR ahextoul(uint8 *s)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
uint32 ret;
|
||||||
|
if(!convert_para_str(&ret, s)) return 0;
|
||||||
|
return ret;
|
||||||
|
*/
|
||||||
|
if((s[0]=='0') && ((s[1] | 0x20) =='x')) return hextoul(s+2);
|
||||||
|
return rom_atoi(s);
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : cmpcpystr
|
||||||
|
* Description : выбирает слово из строки текста с заданными начальным символом
|
||||||
|
* и конечным терминатором. Терминатор и стартовый символ не копирует, если заданы.
|
||||||
|
* Parameters : При задании начального символа = '\0' берется любой символ (>' ').
|
||||||
|
Копирует до символа <' ' или терминатора.
|
||||||
|
Задается ограничение размера буфера для копируемого слова (с дописыванием в буфер '\0'!).
|
||||||
|
* Returns : Зависит от значения терминатора, указывает на терминатор в строке,
|
||||||
|
если терминатор найден.
|
||||||
|
Если NULL, то начальный или конечный терминатор не найден.
|
||||||
|
*******************************************************************************/
|
||||||
|
uint8 * ICACHE_FLASH_ATTR cmpcpystr(uint8 *pbuf, uint8 *pstr, uint8 a, uint8 b, uint16 len)
|
||||||
|
{
|
||||||
|
if(len == 0) pbuf = NULL;
|
||||||
|
if(pstr == NULL) {
|
||||||
|
if(pbuf != NULL) *pbuf='\0';
|
||||||
|
return NULL;
|
||||||
|
};
|
||||||
|
uint8 c;
|
||||||
|
do {
|
||||||
|
c = *pstr;
|
||||||
|
if(c < ' ') { // строка кончилась
|
||||||
|
if(pbuf != NULL) *pbuf='\0';
|
||||||
|
return NULL; // id не найден
|
||||||
|
};
|
||||||
|
if((a == '\0')&&(c > ' ')) break; // не задан -> любой символ
|
||||||
|
pstr++;
|
||||||
|
if(c == a) break; // нашли стартовый символ (некопируемый в буфер)
|
||||||
|
}while(1);
|
||||||
|
if(pbuf != NULL) {
|
||||||
|
while(len--) {
|
||||||
|
c = *pstr;
|
||||||
|
if(c == b) { // нашли терминирующий символ (некопируемый в буфер)
|
||||||
|
*pbuf='\0';
|
||||||
|
return pstr; // конечный терминатор найден
|
||||||
|
};
|
||||||
|
// if(c <= ' ') { // строка кончилась или пробел
|
||||||
|
if(c < ' ') { // строка кончилась или пробел
|
||||||
|
*pbuf='\0';
|
||||||
|
return NULL; // конечный терминатор не найден
|
||||||
|
};
|
||||||
|
pstr++;
|
||||||
|
*pbuf++ = c;
|
||||||
|
};
|
||||||
|
*--pbuf='\0'; // закрыть буфер
|
||||||
|
};
|
||||||
|
do {
|
||||||
|
c = *pstr;
|
||||||
|
if(c == b) return pstr; // нашли терминирующий символ
|
||||||
|
// if(c <= ' ') return NULL; // строка кончилась
|
||||||
|
if(c < ' ') return NULL; // строка кончилась
|
||||||
|
pstr++;
|
||||||
|
}while(1);
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : str_array
|
||||||
|
* Набирает из строки s массив слов в buf в кол-ве до max_buf
|
||||||
|
* возврат - кол-во переменных в строке
|
||||||
|
* Разделитель переменных в строке ','
|
||||||
|
* Если нет переменной, то пропускает изменение в buf
|
||||||
|
* Примеры:
|
||||||
|
* Строка "1,2,3,4" -> buf = 0x01 0x02 0x03 0x04
|
||||||
|
* Строка "1,,3," -> buf = 0x01 (не изменено) 0x03 (не изменено)
|
||||||
|
*******************************************************************************/
|
||||||
|
uint32 ICACHE_FLASH_ATTR str_array(uint8 *s, uint32 *buf, uint32 max_buf)
|
||||||
|
{
|
||||||
|
uint32 ret = 0;
|
||||||
|
uint8 *sval = NULL;
|
||||||
|
while(max_buf > ret) {
|
||||||
|
if(sval == NULL) {
|
||||||
|
if (*s == '-' && s[1] >= '0' && s[1] <= '9') {
|
||||||
|
sval = s;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
else if (*s >= '0' && *s <= '9') sval = s;
|
||||||
|
}
|
||||||
|
if(*s == ',' || *s <= ')') {
|
||||||
|
if(sval != NULL) {
|
||||||
|
*buf = ahextoul(sval);
|
||||||
|
sval = NULL;
|
||||||
|
}
|
||||||
|
buf++;
|
||||||
|
ret++;
|
||||||
|
if(*s < ')') return ret;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
uint32 ICACHE_FLASH_ATTR str_array_w(uint8 *s, uint16 *buf, uint32 max_buf)
|
||||||
|
{
|
||||||
|
uint32 ret = 0;
|
||||||
|
uint8 *sval = NULL;
|
||||||
|
while(max_buf > ret) {
|
||||||
|
if(sval == NULL) {
|
||||||
|
if (*s == '-' && s[1] >= '0' && s[1] <= '9') {
|
||||||
|
sval = s;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
else if (*s >= '0' && *s <= '9') sval = s;
|
||||||
|
}
|
||||||
|
if(*s == ',' || *s <= ')') {
|
||||||
|
if(sval != NULL) {
|
||||||
|
*buf = ahextoul(sval);
|
||||||
|
sval = NULL;
|
||||||
|
}
|
||||||
|
buf++;
|
||||||
|
ret++;
|
||||||
|
if(*s < ')') return ret;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
uint32 ICACHE_FLASH_ATTR str_array_b(uint8 *s, uint8 *buf, uint32 max_buf)
|
||||||
|
{
|
||||||
|
uint32 ret = 0;
|
||||||
|
uint8 *sval = NULL;
|
||||||
|
while(max_buf > ret) {
|
||||||
|
if(sval == NULL) {
|
||||||
|
if (*s == '-' && s[1] >= '0' && s[1] <= '9') {
|
||||||
|
sval = s;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
else if (*s >= '0' && *s <= '9') sval = s;
|
||||||
|
}
|
||||||
|
if(*s == ',' || *s == '.' || *s <= ')') {
|
||||||
|
if(sval != NULL) {
|
||||||
|
*buf = ahextoul(sval);
|
||||||
|
sval = NULL;
|
||||||
|
}
|
||||||
|
buf++;
|
||||||
|
ret++;
|
||||||
|
if(*s < ')') return ret;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : strtmac
|
||||||
|
*******************************************************************************/
|
||||||
|
void ICACHE_FLASH_ATTR strtomac(uint8 *s, uint8 *macaddr)
|
||||||
|
{
|
||||||
|
uint8 pbuf[4];
|
||||||
|
s = cmpcpystr(pbuf, s, 0, ':', 3);
|
||||||
|
*macaddr++ = hextoul(pbuf);
|
||||||
|
int i = 4;
|
||||||
|
while(i--) {
|
||||||
|
s = cmpcpystr(pbuf, s, ':', ':', 3);
|
||||||
|
*macaddr++ = hextoul(pbuf);
|
||||||
|
}
|
||||||
|
s = cmpcpystr(pbuf, s, ':', ' ', 3);
|
||||||
|
*macaddr++ = hextoul(pbuf);
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : urldecode
|
||||||
|
*******************************************************************************/
|
||||||
|
int ICACHE_FLASH_ATTR urldecode(uint8 *d, uint8 *s, uint16 lend, uint16 lens)
|
||||||
|
{
|
||||||
|
uint16 ret = 0;
|
||||||
|
if(s != NULL) while ((lens--) && (lend--) && (*s > ' ')) {
|
||||||
|
if ((*s == '%')&&(lens > 1)) {
|
||||||
|
s++;
|
||||||
|
int i = 2;
|
||||||
|
uint8 val = 0;
|
||||||
|
while(i--) {
|
||||||
|
if (*s >= '0' && *s <= '9') {
|
||||||
|
val <<= 4;
|
||||||
|
val |= *s - '0';
|
||||||
|
} else if (*s >= 'A' && *s <= 'F') {
|
||||||
|
val <<= 4;
|
||||||
|
val |= *s - 'A' + 10;
|
||||||
|
} else if (*s >= 'a' && *s <= 'f') {
|
||||||
|
val <<= 4;
|
||||||
|
val |= *s - 'a' + 10;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
s++;
|
||||||
|
lens--;
|
||||||
|
};
|
||||||
|
s--;
|
||||||
|
*d++ = val;
|
||||||
|
} else if (*s == '+')
|
||||||
|
*d++ = ' ';
|
||||||
|
else
|
||||||
|
*d++ = *s;
|
||||||
|
ret++;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
*d = '\0';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : urlencode
|
||||||
|
*******************************************************************************/
|
||||||
|
/*int ICACHE_FLASH_ATTR urlencode(uint8 *d, uint8 *s, uint16 lend, uint16 lens)
|
||||||
|
{
|
||||||
|
uint16 ret = 0;
|
||||||
|
if(s != NULL) while ((lens--) && (lend--) && (*s != '\0')) {
|
||||||
|
if ( (48 <= *s && *s <= 57) //0-9
|
||||||
|
|| (65 <= *s && *s <= 90) //abc...xyz
|
||||||
|
|| (97 <= *s && *s <= 122) //ABC...XYZ
|
||||||
|
|| (*s == '~' || *s == '!' || *s == '*' || *s == '(' || *s == ')' || *s == '\'')) {
|
||||||
|
*d++ = *s++;
|
||||||
|
ret++;
|
||||||
|
} else {
|
||||||
|
if(lend >= 3) {
|
||||||
|
ret += 3;
|
||||||
|
lend -= 3;
|
||||||
|
*d++ = '%';
|
||||||
|
uint8 val = *s >> 4;
|
||||||
|
if(val <= 9) val += '0';
|
||||||
|
else val += 0x41 - 10;
|
||||||
|
*d++ = val;
|
||||||
|
val = *s++ & 0x0F;
|
||||||
|
if(val <= 9) val += '0';
|
||||||
|
else val += 0x41 - 10;
|
||||||
|
*d++ = val;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*d = '\0';
|
||||||
|
return ret;
|
||||||
|
}*/
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : htmlcode
|
||||||
|
*******************************************************************************/
|
||||||
|
int ICACHE_FLASH_ATTR htmlcode(uint8 *d, uint8 *s, uint16 lend, uint16 lens)
|
||||||
|
{
|
||||||
|
uint16 ret = 0;
|
||||||
|
if(s != NULL) while ((lens--) && (lend--) && (*s != '\0')) {
|
||||||
|
if ( *s == 0x27 ) { // "'" '
|
||||||
|
if(lend >= 6) {
|
||||||
|
ret += 6;
|
||||||
|
lend -= 6;
|
||||||
|
s++;
|
||||||
|
*d++ = '&';
|
||||||
|
*d++ = 'a';
|
||||||
|
*d++ = 'p';
|
||||||
|
*d++ = 'o';
|
||||||
|
*d++ = 's';
|
||||||
|
*d++ = ';';
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
} else if ( *s == '"' ) { // "
|
||||||
|
if(lend >= 6) {
|
||||||
|
ret += 6;
|
||||||
|
lend -= 6;
|
||||||
|
s++;
|
||||||
|
*d++ = '&';
|
||||||
|
*d++ = 'q';
|
||||||
|
*d++ = 'u';
|
||||||
|
*d++ = 'o';
|
||||||
|
*d++ = 't';
|
||||||
|
*d++ = ';';
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
} else if ( *s == '&' ) { // &
|
||||||
|
if(lend >= 5) {
|
||||||
|
ret += 5;
|
||||||
|
lend -= 5;
|
||||||
|
s++;
|
||||||
|
*d++ = '&';
|
||||||
|
*d++ = 'a';
|
||||||
|
*d++ = 'm';
|
||||||
|
*d++ = 'p';
|
||||||
|
*d++ = ';';
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
} else if ( *s == '<' ) { // <
|
||||||
|
if(lend >= 4) {
|
||||||
|
ret += 4;
|
||||||
|
lend -= 4;
|
||||||
|
s++;
|
||||||
|
*d++ = '&';
|
||||||
|
*d++ = 'l';
|
||||||
|
*d++ = 't';
|
||||||
|
*d++ = ';';
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
} else if ( *s == '>' ) { // >
|
||||||
|
if(lend >= 4) {
|
||||||
|
ret += 4;
|
||||||
|
lend -= 4;
|
||||||
|
s++;
|
||||||
|
*d++ = '&';
|
||||||
|
*d++ = 'g';
|
||||||
|
*d++ = 't';
|
||||||
|
*d++ = ';';
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
} else {
|
||||||
|
*d++ = *s++;
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*d = '\0';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
extern size_t rtl_strlen(const char *str);
|
||||||
|
extern int rtl_strncmp(const char *s1, const char *s2, size_t n);
|
||||||
|
|
||||||
|
uint8* ICACHE_FLASH_ATTR
|
||||||
|
web_strnstr(const uint8* buffer, const uint8* token, int len)
|
||||||
|
{
|
||||||
|
const uint8* p;
|
||||||
|
int tokenlen = rtl_strlen(token);
|
||||||
|
if (tokenlen == 0) {
|
||||||
|
return (uint8 *)buffer;
|
||||||
|
};
|
||||||
|
for (p = buffer; *p && (p + tokenlen <= buffer + len); p++) {
|
||||||
|
if ((*p == *token) && (rtl_strncmp(p, token, tokenlen) == 0)) {
|
||||||
|
return (uint8 *)p;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
static const uint8_t base64map[128] ICACHE_RODATA_ATTR =
|
||||||
|
{
|
||||||
|
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||||
|
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||||
|
255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63,
|
||||||
|
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255,
|
||||||
|
255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||||
|
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255,
|
||||||
|
255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||||
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255
|
||||||
|
};
|
||||||
|
//=============================================================================
|
||||||
|
bool ICACHE_FLASH_ATTR base64decode(const uint8 *in, int len, uint8_t *out, int *outlen)
|
||||||
|
{
|
||||||
|
// uint8 *map = (uint8 *)UartDev.rcv_buff.pRcvMsgBuff;
|
||||||
|
// ets_memcpy(map, base64map, 128);
|
||||||
|
uint8 *map = (uint8 *) base64map;
|
||||||
|
int g, t, x, y, z;
|
||||||
|
uint8_t c;
|
||||||
|
g = 3;
|
||||||
|
for (x = y = z = t = 0; x < len; x++) {
|
||||||
|
if ((c = map[in[x]&0x7F]) == 0xff) continue;
|
||||||
|
if (c == 254) { /* this is the end... */
|
||||||
|
c = 0;
|
||||||
|
if (--g < 0) return false;
|
||||||
|
}
|
||||||
|
else if (g != 3) return false; /* only allow = at end */
|
||||||
|
t = (t<<6) | c;
|
||||||
|
if (++y == 4) {
|
||||||
|
out[z++] = (uint8_t)((t>>16)&255);
|
||||||
|
if (g > 1) out[z++] = (uint8_t)((t>>8)&255);
|
||||||
|
if (g > 2) out[z++] = (uint8_t)(t&255);
|
||||||
|
y = t = 0;
|
||||||
|
}
|
||||||
|
/* check that we don't go past the output buffer */
|
||||||
|
if (z > *outlen) return false;
|
||||||
|
}
|
||||||
|
if (y != 0) return false;
|
||||||
|
*outlen = z;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
/* Table 6-bit-index-to-ASCII used for base64-encoding */
|
||||||
|
const uint8_t base64_table[] = {
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||||
|
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
|
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||||
|
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
||||||
|
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||||
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||||
|
'+', '/'
|
||||||
|
};
|
||||||
|
// ld: PROVIDE ( base64_table = 0x3FFFD600 );
|
||||||
|
//extern const uint8_t base64_table[];
|
||||||
|
//=============================================================================
|
||||||
|
/** Base64 encoding */
|
||||||
|
size_t ICACHE_FLASH_ATTR base64encode(char* target, size_t target_len, const char* source, size_t source_len)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
sint8 j;
|
||||||
|
size_t target_idx = 0;
|
||||||
|
size_t longer = 3 - (source_len % 3);
|
||||||
|
size_t source_len_b64 = source_len + longer;
|
||||||
|
size_t len = (((source_len_b64) * 4) / 3);
|
||||||
|
uint8 x = 5;
|
||||||
|
uint8 current = 0;
|
||||||
|
|
||||||
|
if(target == NULL || target_len < len) return 0;
|
||||||
|
|
||||||
|
for (i = 0; i < source_len_b64; i++) {
|
||||||
|
uint8 b = (i < source_len ? source[i] : 0);
|
||||||
|
for (j = 7; j >= 0; j--, x--) {
|
||||||
|
uint8 shift = ((b & (1 << j)) != 0) ? 1 : 0;
|
||||||
|
current |= shift << x;
|
||||||
|
if (x == 0) {
|
||||||
|
target[target_idx++] = base64_table[current];
|
||||||
|
x = 6;
|
||||||
|
current = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = len - longer; i < len; i++) {
|
||||||
|
target[i] = '=';
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//=============================================================================
|
||||||
|
void ICACHE_FLASH_ATTR print_hex_dump(uint8 *buf, uint32 len, uint8 k)
|
||||||
|
{
|
||||||
|
if(!system_get_os_print()) return; // if(*((uint8 *)(0x3FFE8000)) == 0) return;
|
||||||
|
uint32 ss[2];
|
||||||
|
ss[0] = 0x78323025; // "%02x"
|
||||||
|
ss[1] = k; // ","...'\0'
|
||||||
|
uint8* ptr = buf;
|
||||||
|
while(len--) {
|
||||||
|
if(len == 0) ss[1] = 0;
|
||||||
|
ets_printf((uint8 *)&ss[0], *ptr++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
#define LowerCase(a) ((('A' <= a) && (a <= 'Z')) ? a + 32 : a)
|
||||||
|
|
||||||
|
char* ICACHE_FLASH_ATTR word_to_lower_case(char* text) {
|
||||||
|
for(; *text ==' '; text++);
|
||||||
|
char* p = text;
|
||||||
|
for (; *p >= ' '; p++) {
|
||||||
|
*p = LowerCase(*p);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
//=============================================================================
|
||||||
|
/* char UpperCase(char ch) {
|
||||||
|
return (('a' <= ch) && (ch <= 'z')) ? ch - 32 : ch; }*/
|
||||||
|
#define UpperCase(a) ((('a' <= a) && (a <= 'z')) ? a - 32 : a)
|
||||||
|
|
||||||
|
char* ICACHE_FLASH_ATTR str_to_upper_case(char* text) {
|
||||||
|
char* p = text;
|
||||||
|
for (; *p; ++p) {
|
||||||
|
*p = UpperCase(*p);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
48
Firmware/RTLGDB/Project/web/web_utils.h
Normal file
48
Firmware/RTLGDB/Project/web/web_utils.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* FileName: web_utils.h
|
||||||
|
* Alternate SDK
|
||||||
|
* Author: PV`
|
||||||
|
* (c) PV` 2015
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE_WEB_UTILS_H_
|
||||||
|
#define _INCLUDE_WEB_UTILS_H_
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SEG_ID_ROM = 0,
|
||||||
|
SEG_ID_SRAM,
|
||||||
|
SEG_ID_TCM,
|
||||||
|
SEG_ID_FLASH,
|
||||||
|
SEG_ID_SDRAM,
|
||||||
|
SEG_ID_SOC,
|
||||||
|
SEG_ID_CPU,
|
||||||
|
SEG_ID_ERR,
|
||||||
|
SEG_ID_MAX
|
||||||
|
} SEG_ID;
|
||||||
|
|
||||||
|
extern const uint32 tab_seg_def[];
|
||||||
|
SEG_ID get_seg_id(uint32 addr, int32 size);
|
||||||
|
|
||||||
|
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_ */
|
352
Firmware/RTLGDB/Project/web/web_websocket.c
Normal file
352
Firmware/RTLGDB/Project/web/web_websocket.c
Normal file
|
@ -0,0 +1,352 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* FileName: web_websocket.c
|
||||||
|
* Description: websocket for web
|
||||||
|
* Author: pvvx
|
||||||
|
* 2016
|
||||||
|
*******************************************************************************/
|
||||||
|
#include "user_config.h"
|
||||||
|
#ifdef WEBSOCKET_ENA
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
//#include "bios.h"
|
||||||
|
//#include "osapi.h"
|
||||||
|
//#include "sdk/rom2ram.h"
|
||||||
|
#include "lwip/tcp.h"
|
||||||
|
#include "tcpsrv/tcp_srv_conn.h"
|
||||||
|
#include "web_srv_int.h"
|
||||||
|
#include "web_srv.h"
|
||||||
|
#include "web_utils.h"
|
||||||
|
#include "web_websocket.h"
|
||||||
|
#include "websock.h"
|
||||||
|
#include "rtl8195a/rtl_libc.h"
|
||||||
|
#include "esp_comp.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#undef DEBUGSOO
|
||||||
|
#define DEBUGSOO 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define copy_s4d1 rtl_memcpy
|
||||||
|
|
||||||
|
//#define mMIN(a, b) ((a<b)?a:b)
|
||||||
|
|
||||||
|
#define MAX_RX_BUF_SIZE 8192
|
||||||
|
|
||||||
|
const char txt_wsping[] ICACHE_RODATA_ATTR = "ws:ping";
|
||||||
|
const char txt_wspong[] ICACHE_RODATA_ATTR = "ws:pong";
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
// websock_tx_frame() - передача фрейма
|
||||||
|
//=============================================================================
|
||||||
|
err_t ICACHE_FLASH_ATTR
|
||||||
|
websock_tx_frame(TCP_SERV_CONN *ts_conn, uint32 opcode, uint8 *raw_data, uint32 raw_len)
|
||||||
|
{
|
||||||
|
err_t err = WebsocketTxFrame(ts_conn, opcode, raw_data, raw_len);
|
||||||
|
if(err != ERR_OK) {
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("ws%utx[%u] error %d!\n", opcode, raw_len, err);
|
||||||
|
#endif
|
||||||
|
((WEB_SRV_CONN *)ts_conn->linkd)->webflag |= SCB_DISCONNECT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if((opcode & WS_OPCODE_BITS) == WS_OPCODE_CLOSE) {
|
||||||
|
((WEB_SRV_CONN *)ts_conn->linkd)->ws.flg |= WS_FLG_CLOSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
// websock_tx_close_err() - вывод сообщения закрытия или ошибки
|
||||||
|
//=============================================================================
|
||||||
|
err_t ICACHE_FLASH_ATTR
|
||||||
|
websock_tx_close_err(TCP_SERV_CONN *ts_conn, uint32 err)
|
||||||
|
{
|
||||||
|
uint8 uc[2];
|
||||||
|
uc[1] = err;
|
||||||
|
uc[0] = err>>8;
|
||||||
|
return websock_tx_frame(ts_conn, WS_OPCODE_CLOSE | WS_FRAGMENT_FIN, uc, 2);
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
// websock_rx_data() прием данных
|
||||||
|
//=============================================================================
|
||||||
|
#define MAX_WS_DATA_BLK_SIZE (tcp_sndbuf(ts_conn->pcb)-8) // (TCP_MSS - 8)
|
||||||
|
//=============================================================================
|
||||||
|
bool ICACHE_FLASH_ATTR
|
||||||
|
websock_rx_data(TCP_SERV_CONN *ts_conn)
|
||||||
|
{
|
||||||
|
// HTTP_CONN *CurHTTP;
|
||||||
|
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||||
|
if(web_conn == NULL) return false;
|
||||||
|
WS_FRSTAT *ws = &web_conn->ws;
|
||||||
|
uint16 len;
|
||||||
|
uint8 *pstr;
|
||||||
|
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("ws_rx[%u]%u ", ts_conn->sizei, ts_conn->cntri);
|
||||||
|
#endif
|
||||||
|
if(ts_conn->sizei == 0) return true; // докачивать
|
||||||
|
tcpsrv_unrecved_win(ts_conn);
|
||||||
|
if((ws->flg & WS_FLG_CLOSE) != 0) {
|
||||||
|
// убить буфер ts_conn->pbufi, конец давно :)
|
||||||
|
web_feee_bufi(ts_conn);
|
||||||
|
SetSCB(SCB_DISCONNECT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(ts_conn->sizei > MAX_RX_BUF_SIZE) {
|
||||||
|
#if DEBUGSOO > 0
|
||||||
|
os_printf("ws:rxbuf_full! ");
|
||||||
|
#endif
|
||||||
|
// убить буфер ts_conn->pbufi и ответить ошибкой WS_CLOSE_UNEXPECTED_ERROR
|
||||||
|
web_feee_bufi(ts_conn);
|
||||||
|
websock_tx_close_err(ts_conn, WS_CLOSE_MESSAGE_TOO_BIG); // WS_CLOSE_UNEXPECTED_ERROR);
|
||||||
|
SetSCB(SCB_DISCONNECT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pstr = ts_conn->pbufi;// + ts_conn->cntri;
|
||||||
|
len = ts_conn->sizei;// - ts_conn->cntri;
|
||||||
|
while(ts_conn->cntri < ts_conn->sizei || (ws->flg & WS_FLG_FIN) != 0) {
|
||||||
|
pstr = ts_conn->pbufi;// + ts_conn->cntri;
|
||||||
|
len = ts_conn->sizei;// - ts_conn->cntri;
|
||||||
|
if((ws->flg & WS_FLG_FIN) != 0 // обработка
|
||||||
|
|| ws->frame_len > ws->cur_len) {
|
||||||
|
ws->flg &= ~WS_FLG_FIN;
|
||||||
|
len = mMIN(ws->frame_len - ws->cur_len, mMIN(MAX_WS_DATA_BLK_SIZE, len));
|
||||||
|
// размаскировать
|
||||||
|
if((ws->flg & WS_FLG_MASK) != 0) WebsocketMask(ws, pstr, len);
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("wsfr[%u]blk[%u]at:%u ", ws->frame_len, len, ws->cur_len);
|
||||||
|
#endif
|
||||||
|
switch(ws->status) {
|
||||||
|
case sw_frs_binary:
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("ws:bin ");
|
||||||
|
#endif
|
||||||
|
if(ws->frame_len != 0) {
|
||||||
|
// пока просто эхо
|
||||||
|
uint32 opcode = WS_OPCODE_BINARY;
|
||||||
|
if(ws->cur_len != 0) opcode = WS_OPCODE_CONTINUE;
|
||||||
|
if(ws->frame_len == ws->cur_len + len) opcode |= WS_FRAGMENT_FIN;
|
||||||
|
if(websock_tx_frame(ts_conn, opcode, pstr, len) != ERR_OK) {
|
||||||
|
return false; // не докачивать, ошибка или закрытие
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ws->cur_len += len;
|
||||||
|
ts_conn->cntri += len;
|
||||||
|
break;
|
||||||
|
case sw_frs_text:
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("ws:txt ");
|
||||||
|
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
if(ws->frame_len != 0) {
|
||||||
|
uint8 tt = pstr[len];
|
||||||
|
pstr[len] = 0;
|
||||||
|
os_printf("'%s' ", pstr);
|
||||||
|
pstr[len] = tt;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
if(ws->frame_len == ws->cur_len + len && ws->frame_len != 0) { // полное соо
|
||||||
|
web_conn->msgbufsize = tcp_sndbuf(ts_conn->pcb); // сколько можем выввести сейчас?
|
||||||
|
if (web_conn->msgbufsize < MIN_SEND_SIZE) {
|
||||||
|
#if DEBUGSOO > 0
|
||||||
|
os_printf("ws:sndbuf=%u! ", web_conn->msgbufsize);
|
||||||
|
#endif
|
||||||
|
websock_tx_close_err(ts_conn, WS_CLOSE_UNEXPECTED_ERROR);
|
||||||
|
SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
web_conn->msgbufsize -= 16;
|
||||||
|
if(ws->frame_len == (sizeof(txt_wsping)-1) && rom_xstrcmp(pstr, txt_wsping) != 0){
|
||||||
|
copy_s4d1(pstr, (void *)txt_wspong, sizeof(txt_wspong) - 1);
|
||||||
|
if(websock_tx_frame(ts_conn, WS_OPCODE_TEXT | WS_FRAGMENT_FIN, pstr, sizeof(txt_wspong) - 1) != ERR_OK) {
|
||||||
|
return false; // не докачивать, ошибка или закрытие
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(web_conn->msgbuf) os_free(web_conn->msgbuf);
|
||||||
|
web_conn->msgbuf = (uint8 *) os_malloc(web_conn->msgbufsize);
|
||||||
|
if (web_conn->msgbuf == NULL) {
|
||||||
|
#if DEBUGSOO > 0
|
||||||
|
os_printf("ws:mem!\n");
|
||||||
|
#endif
|
||||||
|
websock_tx_close_err(ts_conn, WS_CLOSE_UNEXPECTED_ERROR);
|
||||||
|
SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
web_conn->msgbuflen = 0;
|
||||||
|
uint32 opcode;
|
||||||
|
if(CheckSCB(SCB_RETRYCB)) { // повторный callback? да
|
||||||
|
if(web_conn->func_web_cb != NULL) web_conn->func_web_cb(ts_conn);
|
||||||
|
if(!CheckSCB(SCB_RETRYCB)) {
|
||||||
|
// ClrSCB(SCB_FCLOSE | SCB_DISCONNECT);
|
||||||
|
opcode = WS_OPCODE_CONTINUE | WS_FRAGMENT_FIN;
|
||||||
|
}
|
||||||
|
else opcode = WS_OPCODE_CONTINUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pstr[len] = '\0';
|
||||||
|
uint8 *vstr = os_strchr(pstr, '=');
|
||||||
|
if(vstr != NULL) {
|
||||||
|
*vstr++ = '\0';
|
||||||
|
web_int_vars(ts_conn, pstr, vstr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
web_conn->msgbuf[0] = 0;
|
||||||
|
web_int_callback(ts_conn, pstr);
|
||||||
|
}
|
||||||
|
if(CheckSCB(SCB_RETRYCB)) opcode = WS_OPCODE_TEXT;
|
||||||
|
else {
|
||||||
|
// ClrSCB(SCB_FCLOSE | SCB_DISCONNECT);
|
||||||
|
opcode = WS_OPCODE_TEXT | WS_FRAGMENT_FIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(web_conn->msgbuflen != 0) {
|
||||||
|
if(websock_tx_frame(ts_conn, opcode, web_conn->msgbuf, web_conn->msgbuflen) != ERR_OK) {
|
||||||
|
if(web_conn->msgbuf) os_free(web_conn->msgbuf);
|
||||||
|
web_conn->msgbuf = NULL;
|
||||||
|
return false; // не докачивать, ошибка или закрытие
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(web_conn->msgbuf) os_free(web_conn->msgbuf);
|
||||||
|
web_conn->msgbuf = NULL;
|
||||||
|
if(CheckSCB(SCB_RETRYCB)) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if(0) {
|
||||||
|
uint32 opcode = WS_OPCODE_TEXT;
|
||||||
|
if(ws->cur_len != 0) opcode = WS_OPCODE_CONTINUE;
|
||||||
|
if(ws->frame_len == ws->cur_len + len) opcode |= WS_FRAGMENT_FIN;
|
||||||
|
if(websock_tx_frame(ts_conn, opcode, pstr, len) != ERR_OK) {
|
||||||
|
return false; // не докачивать, ошибка или закрытие
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
ws->cur_len += len;
|
||||||
|
ts_conn->cntri += len;
|
||||||
|
return true; // докачивать
|
||||||
|
// break;
|
||||||
|
// break;
|
||||||
|
case sw_frs_ping:
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("ws:ping ");
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
uint32 opcode = WS_OPCODE_PONG;
|
||||||
|
if(ws->cur_len != 0) opcode = WS_OPCODE_CONTINUE;
|
||||||
|
if(ws->frame_len == ws->cur_len + len) opcode |= WS_FRAGMENT_FIN;
|
||||||
|
if(websock_tx_frame(ts_conn, opcode, pstr, len) != ERR_OK) {
|
||||||
|
return false; // не докачивать, ошибка или закрытие
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ws->cur_len += len;
|
||||||
|
ts_conn->cntri += len;
|
||||||
|
return true; // докачивать
|
||||||
|
// break;
|
||||||
|
case sw_frs_pong:
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("ws:pong ");
|
||||||
|
#endif
|
||||||
|
ws->cur_len += len;
|
||||||
|
ts_conn->cntri += len;
|
||||||
|
break;
|
||||||
|
// return true;
|
||||||
|
case sw_frs_close:
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("ws:close ");
|
||||||
|
#endif
|
||||||
|
// if((ws->flg & WS_FLG_CLOSE) == 0) {
|
||||||
|
{
|
||||||
|
if(len >= 2) {
|
||||||
|
uint32 close_code = (pstr[0]<<8) | pstr[1];
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("code:%d ", close_code);
|
||||||
|
#endif
|
||||||
|
if(close_code == WS_CLOSE_NORMAL) websock_tx_close_err(ts_conn, WS_CLOSE_NORMAL);
|
||||||
|
// else websock_tx_frame(ts_conn, WS_OPCODE_CLOSE | WS_FRAGMENT_FIN, NULL, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
websock_tx_close_err(ts_conn, WS_CLOSE_NORMAL);
|
||||||
|
// websock_tx_frame(ts_conn, WS_OPCODE_CLOSE | WS_FRAGMENT_FIN, NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ts_conn->flag.pcb_time_wait_free = 1;
|
||||||
|
SetSCB(SCB_DISCONNECT);
|
||||||
|
// ts_conn->cntri = ts_conn->sizei;
|
||||||
|
/* ws->cur_len += len;
|
||||||
|
ts_conn->cntri += len; */
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
#if DEBUGSOO > 0
|
||||||
|
os_printf("ws:f?! ");
|
||||||
|
#endif
|
||||||
|
websock_tx_close_err(ts_conn, WS_CLOSE_UNEXPECTED_ERROR);
|
||||||
|
SetSCB(SCB_DISCONNECT);
|
||||||
|
// ts_conn->cntri = ts_conn->sizei;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(ws->cur_len >= ws->frame_len) { // прием и разбор нового фрейма
|
||||||
|
if((ws->flg & WS_FLG_FIN) != 0) { // обработка
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("ws_rx:fin=%u ", ws->cur_len);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uint32 ret = WebsocketHead(ws, pstr, len);
|
||||||
|
if(ret >= WS_CLOSE_NORMAL) { // error или close
|
||||||
|
|
||||||
|
#if DEBUGSOO > 0
|
||||||
|
os_printf("ws:txerr=%u ", ret);
|
||||||
|
#endif
|
||||||
|
websock_tx_close_err(ts_conn, ret);
|
||||||
|
// ts_conn->cntri = ts_conn->sizei; // убить буфер ts_conn->pbufi
|
||||||
|
return false; // error
|
||||||
|
}
|
||||||
|
else if(ret == 0) {
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("ws_rx... ");
|
||||||
|
#endif
|
||||||
|
return true; // докачивать
|
||||||
|
}
|
||||||
|
ts_conn->cntri += ws->head_len; // вычесть заголовок
|
||||||
|
/*
|
||||||
|
switch(ws->status) {
|
||||||
|
case sw_frs_binary:
|
||||||
|
break;
|
||||||
|
case sw_frs_text:
|
||||||
|
if(ws->frame_len > MAX_RX_BUF_SIZE) {
|
||||||
|
websock_tx_close_err(ts_conn, WS_CLOSE_MESSAGE_TOO_BIG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("trim%u-%u ", ts_conn->sizei, ts_conn->sizei - ts_conn->cntri );
|
||||||
|
#endif
|
||||||
|
if(!web_trim_bufi(ts_conn, &ts_conn->pbufi[ts_conn->cntri], ts_conn->sizei - ts_conn->cntri)) {
|
||||||
|
#if DEBUGSOO > 0
|
||||||
|
os_printf("ws:trim_err! ");
|
||||||
|
#endif
|
||||||
|
// убить буфер ts_conn->pbufi и ответить ошибкой WS_CLOSE_UNEXPECTED_ERROR
|
||||||
|
websock_tx_close_err(ts_conn, WS_CLOSE_UNEXPECTED_ERROR);
|
||||||
|
SetSCB(SCB_DISCONNECT);
|
||||||
|
// ts_conn->cntri = ts_conn->sizei;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return false; // не докачивать, ошибка или закрытие
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
//=============================================================================
|
||||||
|
#endif // WEBSOCKET_ENA
|
||||||
|
|
||||||
|
|
18
Firmware/RTLGDB/Project/web/web_websocket.h
Normal file
18
Firmware/RTLGDB/Project/web/web_websocket.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#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);
|
||||||
|
err_t websock_tx_frame(TCP_SERV_CONN *ts_conn, uint32 opcode, uint8 *raw_data, uint32 raw_len);
|
||||||
|
|
||||||
|
#endif // WEBSOCKET_ENA
|
||||||
|
#endif /* _WEB_WEBSOCKET_H_ */
|
245
Firmware/RTLGDB/Project/web/websock.c
Normal file
245
Firmware/RTLGDB/Project/web/websock.c
Normal file
|
@ -0,0 +1,245 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* FileName: websock.c
|
||||||
|
* Description: websocket for web ESP8266
|
||||||
|
* Author: PV`
|
||||||
|
* (c) PV` 2016
|
||||||
|
*******************************************************************************/
|
||||||
|
#include "user_config.h"
|
||||||
|
#ifdef WEBSOCKET_ENA
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include "tcpsrv/tcp_srv_conn.h"
|
||||||
|
#include "web_utils.h" // base64encode()
|
||||||
|
#include "web_srv.h"
|
||||||
|
//#include "phy/phy.h"
|
||||||
|
#include "device_lock.h"
|
||||||
|
#include "lwip/tcp.h"
|
||||||
|
#include "websock.h"
|
||||||
|
#include "rtl8195a/rtl_libc.h"
|
||||||
|
#include "esp_comp.h"
|
||||||
|
#include "hal_crypto.h"
|
||||||
|
|
||||||
|
// HTTP/1.1 101 Web Socket Protocol Handshake\r\n
|
||||||
|
const uint8 WebSocketHTTPOkKey[] ICACHE_RODATA_ATTR = "HTTP/1.1 101 Switching Protocols\r\nAccess-Control-Allow-Origin: *\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: %s\r\n\r\n";
|
||||||
|
const uint8 WebSocketAddKey[] ICACHE_RODATA_ATTR = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
|
const uint8 *HTTPUpgrade = "Upgrade:";
|
||||||
|
const uint8 *HTTPwebsocket = "websocket";
|
||||||
|
const uint8 *HTTPSecWebSocketKey = "Sec-WebSocket-Key:";
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
// WebSocketAcceptKey()
|
||||||
|
// 1) взять строковое значение из заголовка Sec-WebSocket-Key и объединить со
|
||||||
|
// строкой 258EAFA5-E914-47DA-95CA-C5AB0DC85B11
|
||||||
|
// 2) вычислить бинарный хеш SHA-1 (бинарная строка из 20 символов) от полученной
|
||||||
|
// в первом пункте строки
|
||||||
|
// 3) закодировать хеш в Base64
|
||||||
|
// skey[24+36]:'dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
|
||||||
|
// cha:'b37a4f2cc0624f1690f64606cf385945b2bec4ea'
|
||||||
|
// key[28]:'s3pPLMBiTxaQ9kYGzzhZRbK+xOo='
|
||||||
|
//=============================================================================
|
||||||
|
uint8 buff[maxsizeWebSocketKey + sizeWebSocketAddKey]; // [68]
|
||||||
|
bool ICACHE_FLASH_ATTR WebSocketAcceptKey(uint8* dkey, uint8* skey)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
bool ret = false;
|
||||||
|
uint8 keybuf[CRYPTO_SHA1_DIGEST_LENGTH];
|
||||||
|
uint8 * buff = os_malloc(maxsizeWebSocketKey + sizeWebSocketAddKey);
|
||||||
|
if(buff) {
|
||||||
|
while(skey[len] >= '+' && len < maxsizeWebSocketKey) {
|
||||||
|
buff[len] = skey[len];
|
||||||
|
len++;
|
||||||
|
};
|
||||||
|
if(len > minsizeWebSocketKey) {
|
||||||
|
rtl_memcpy(&buff[len], WebSocketAddKey, sizeWebSocketAddKey+1);
|
||||||
|
device_mutex_lock(RT_DEV_LOCK_CRYPTO);
|
||||||
|
rtl_crypto_sha1(buff, len + sizeWebSocketAddKey, keybuf);
|
||||||
|
device_mutex_unlock(RT_DEV_LOCK_CRYPTO);
|
||||||
|
// rtl_cryptoEngine_info();
|
||||||
|
len = base64encode(dkey, FileNameSize, keybuf, CRYPTO_SHA1_DIGEST_LENGTH);
|
||||||
|
#if DEBUGSOO > 2
|
||||||
|
os_printf("\ncha:'");
|
||||||
|
print_hex_dump(keybuf, CRYPTO_SHA1_DIGEST_LENGTH, '\0');
|
||||||
|
os_printf("'\n");
|
||||||
|
os_printf("key[%u]:'%s'\n", len, dkey);
|
||||||
|
#endif
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
os_free(buff);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
// websock_mask() размаскирование блока
|
||||||
|
//=============================================================================
|
||||||
|
void ICACHE_FLASH_ATTR
|
||||||
|
WebsocketMask(WS_FRSTAT *ws, uint8 *raw_data, uint32 raw_len)
|
||||||
|
{
|
||||||
|
uint32 i, x = ws->cur_len;
|
||||||
|
#if DEBUGSOO > 3
|
||||||
|
os_printf("mask[%u]%u ", raw_len, x);
|
||||||
|
#endif
|
||||||
|
for (i = 0; i < raw_len; i++) {
|
||||||
|
raw_data[i] ^= ws->mask.uc[x++ & 3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
// websock_head() разбор заголовка
|
||||||
|
//=============================================================================
|
||||||
|
uint32 ICACHE_FLASH_ATTR
|
||||||
|
WebsocketHead(WS_FRSTAT *ws, uint8 *raw_data, uint32 raw_len)
|
||||||
|
{
|
||||||
|
// определить размер заголовка фрейма
|
||||||
|
uint32 head_len = 2;
|
||||||
|
if(raw_len < head_len) return 0; // докачивать
|
||||||
|
uint32 data_len = raw_data[1] & WS_SIZE1_BITS;
|
||||||
|
if(data_len == 127) head_len = 10;
|
||||||
|
else if(data_len == 126) head_len = 4;
|
||||||
|
if(raw_data[1] & WS_MASK_FLG) head_len += 4;
|
||||||
|
if(raw_len < head_len) return 0; // докачивать
|
||||||
|
ws->head_len = head_len;
|
||||||
|
ws->cur_len = 0;
|
||||||
|
ws->flg = 0;
|
||||||
|
data_len = raw_data[1] & WS_SIZE1_BITS;
|
||||||
|
if(data_len >= 126) {
|
||||||
|
if(data_len == 127) {
|
||||||
|
uint32 i;
|
||||||
|
for(i = 3; i < 6; i++) {
|
||||||
|
if(raw_data[i] != 0) {
|
||||||
|
ws->status = sw_frs_close;
|
||||||
|
ws->frame_len = 0;
|
||||||
|
return WS_CLOSE_MESSAGE_TOO_BIG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data_len = (raw_data[6] << 24) | (raw_data[7] << 16) | (raw_data[8] << 8) | raw_data[9];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data_len = (raw_data[2] << 8) | raw_data[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(raw_data[1] & WS_MASK_FLG) {
|
||||||
|
ws->flg |= WS_FLG_MASK;
|
||||||
|
ws->mask.uc[0] = raw_data[head_len-4];
|
||||||
|
ws->mask.uc[1] = raw_data[head_len-3];
|
||||||
|
ws->mask.uc[2] = raw_data[head_len-2];
|
||||||
|
ws->mask.uc[3] = raw_data[head_len-1];
|
||||||
|
}
|
||||||
|
// else ws->mask = 0;
|
||||||
|
uint8 opcode = raw_data[0] & WS_OPCODE_BITS;
|
||||||
|
switch(opcode) {
|
||||||
|
case WS_OPCODE_PING: // эхо - дублировать прием
|
||||||
|
raw_data[0] &= ~WS_FRAGMENT_FIN;
|
||||||
|
raw_data[0] |= WS_OPCODE_PONG;
|
||||||
|
ws->status = sw_frs_pong;
|
||||||
|
ws->frame_len = data_len;
|
||||||
|
break;
|
||||||
|
case WS_OPCODE_PONG: // эхо - дублировать прием
|
||||||
|
ws->status = sw_frs_ping;
|
||||||
|
ws->frame_len = data_len;
|
||||||
|
break;
|
||||||
|
case WS_OPCODE_CONTINUE: // продолжить
|
||||||
|
if(ws->status == sw_frs_pong) {
|
||||||
|
ws->frame_len = data_len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else ws->frame_len += data_len;
|
||||||
|
break;
|
||||||
|
case WS_OPCODE_CLOSE: //
|
||||||
|
ws->status = sw_frs_close;
|
||||||
|
ws->frame_len = data_len;
|
||||||
|
break;
|
||||||
|
case WS_OPCODE_TEXT:
|
||||||
|
ws->status = sw_frs_text;
|
||||||
|
ws->frame_len = data_len;
|
||||||
|
break;
|
||||||
|
case WS_OPCODE_BINARY:
|
||||||
|
ws->status = sw_frs_binary;
|
||||||
|
ws->frame_len = data_len;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ws->status = sw_frs_close;
|
||||||
|
ws->frame_len = 0;
|
||||||
|
return WS_CLOSE_WRONG_TYPE;
|
||||||
|
}
|
||||||
|
// uint32 len = mMIN(raw_len - head_len, data_len);
|
||||||
|
// if((ws->flg & WS_FLG_MASK) != 0) websock_mask(ws, &raw_data[head_len], mMIN(raw_len - head_len, len));
|
||||||
|
// ws->cur_len += len;
|
||||||
|
if((raw_data[0] & WS_FRAGMENT_FIN) != 0) { // конец - данные на обработку
|
||||||
|
ws->flg |= WS_FLG_FIN;
|
||||||
|
}
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("ws#%02xrx[%u] ", raw_data[0], data_len);
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
/*
|
||||||
|
if(data_len + head_len <= raw_len) { // весь пакет уже в буфере?
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0; // докачивать */
|
||||||
|
}
|
||||||
|
//=============================================================================
|
||||||
|
// websock_tx_frame() - передача фрейма
|
||||||
|
//=============================================================================
|
||||||
|
err_t ICACHE_FLASH_ATTR
|
||||||
|
WebsocketTxFrame(TCP_SERV_CONN *ts_conn, uint32 opcode, uint8 *raw_data, uint32 raw_len)
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
uint8 uc[8];
|
||||||
|
uint16 uw[4];
|
||||||
|
uint32 ud[2];
|
||||||
|
}head;
|
||||||
|
union {
|
||||||
|
uint8 uc[4];
|
||||||
|
uint16 uw[2];
|
||||||
|
uint32 ud;
|
||||||
|
}mask;
|
||||||
|
if(raw_data == NULL) raw_len = 0;
|
||||||
|
head.ud[0] = opcode;
|
||||||
|
uint32 head_len;
|
||||||
|
if(raw_len > 126) {
|
||||||
|
head.uc[1] = 126;
|
||||||
|
head.uc[2] = raw_len>>8;
|
||||||
|
head.uc[3] = raw_len;
|
||||||
|
head_len = 4;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
head.uc[1] = raw_len;
|
||||||
|
head_len = 2;
|
||||||
|
};
|
||||||
|
if(opcode & (WS_MASK_FLG << 8)) {
|
||||||
|
mask.ud ^= rand();
|
||||||
|
head.uc[1] |= WS_MASK_FLG;
|
||||||
|
head.uc[head_len] = mask.uc[0];
|
||||||
|
head.uc[head_len+1] = mask.uc[1];
|
||||||
|
head.uc[head_len+2] = mask.uc[2];
|
||||||
|
head.uc[head_len+3] = mask.uc[3];
|
||||||
|
head_len += 4;
|
||||||
|
}
|
||||||
|
uint32 len = tcp_sndbuf(ts_conn->pcb);
|
||||||
|
err_t err = 1; // ERR_BUF;
|
||||||
|
if(len >= raw_len + head_len) {
|
||||||
|
#if DEBUGSOO > 1
|
||||||
|
os_printf("ws#%02xtx[%u] ", head.uc[0], raw_len);
|
||||||
|
#endif
|
||||||
|
ts_conn->flag.nagle_disabled = 0;
|
||||||
|
tcp_nagle_disable(ts_conn->pcb);
|
||||||
|
err = tcpsrv_int_sent_data(ts_conn, head.uc, head_len);
|
||||||
|
ts_conn->flag.nagle_disabled = 1;
|
||||||
|
if(err == ERR_OK && raw_len != 0) {
|
||||||
|
if(opcode & (WS_MASK_FLG << 8)) {
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0; i < raw_len; i++) {
|
||||||
|
raw_data[i] ^= mask.uc[i & 3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = tcpsrv_int_sent_data(ts_conn, raw_data, raw_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // WEBSOCKET_ENA
|
||||||
|
|
110
Firmware/RTLGDB/Project/web/websock.h
Normal file
110
Firmware/RTLGDB/Project/web/websock.h
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* File: websock.h
|
||||||
|
* Small WEB server ESP8266EX
|
||||||
|
* Author: PV`
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _WEBSOCK_H_
|
||||||
|
#define _WEBSOCK_H_
|
||||||
|
#include "lwip/err.h"
|
||||||
|
#include "tcpsrv/tcp_srv_conn.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_ */
|
483
Firmware/RTLGDB/Project/webfs/webfs.c
Normal file
483
Firmware/RTLGDB/Project/webfs/webfs.c
Normal file
|
@ -0,0 +1,483 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* WEBFS.c
|
||||||
|
* RTL871x Flash WEB File System v1.0
|
||||||
|
********************************************************************/
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "diag.h"
|
||||||
|
#include <osdep_api.h>
|
||||||
|
#include <osdep_service.h>
|
||||||
|
#include "device_lock.h"
|
||||||
|
#include "flash_api.h"
|
||||||
|
//#include "flash_eep.h"
|
||||||
|
|
||||||
|
#include "webfs/webfs.h"
|
||||||
|
#include "rtl8195a/rtl_libc.h"
|
||||||
|
#include "esp_comp.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define WEBFS_CODE_ATTR
|
||||||
|
#define WEBFS_DATA_ATTR
|
||||||
|
|
||||||
|
#define web_mutex_lock() device_mutex_lock(RT_DEV_LOCK_FLASH)
|
||||||
|
#define web_mutex_unlock() device_mutex_unlock(RT_DEV_LOCK_FLASH)
|
||||||
|
|
||||||
|
// Supports long file names to 64 characters
|
||||||
|
#define MAX_FILE_NAME_LEN 64 // VarNameSize
|
||||||
|
uint32 disk_base_addr WEBFS_DATA_ATTR;
|
||||||
|
#define WEBFS_HEAD_ADDR disk_base_addr
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Structure:
|
||||||
|
*
|
||||||
|
* [F][W][E][B][uint8 Ver Hi][uint8 Ver Lo] // заголовок диска
|
||||||
|
* [uint16 Number of Files] // кол-во файлов на диске
|
||||||
|
* [Name Hash 0]...[Name Hash N] // uint16 типа хеш на каждое имя файла
|
||||||
|
* [File Record 0]...[File Record N] // uint32 указатели на адреса структур файлов, относительно начала диска
|
||||||
|
*
|
||||||
|
* File Record Structure:
|
||||||
|
* [uint32 Len] размер файла с заголовком
|
||||||
|
* [uint16 HeadLen] длина заголовка, включая размер, флаг, имя (адрес данных - адрес позиции len)
|
||||||
|
* [uint16 Flags] бит 0 =1 - файл сжат GZIP, бит 1 = 1 - парсится - имеет динамические переменные
|
||||||
|
* [File Name, 0] Имя файла с "СИ" терминатором
|
||||||
|
* [File Data] данные файла
|
||||||
|
*
|
||||||
|
* Name hash (2 uint8s) is calculated as follows:
|
||||||
|
* hash = 0
|
||||||
|
* for each(uint8 in name)
|
||||||
|
* hash += uint8
|
||||||
|
* hash <<= 1
|
||||||
|
*
|
||||||
|
* Technically this means the hash only includes the
|
||||||
|
* final 15 characters of a name.
|
||||||
|
*
|
||||||
|
* String FileNmae Structure (1 to 64 uint8s):
|
||||||
|
* ["path/to/file.ext"][0x00]
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Current version is 1.0
|
||||||
|
*/
|
||||||
|
// Lock WEBFS access during the upgrade
|
||||||
|
volatile bool isWEBFSLocked WEBFS_DATA_ATTR;
|
||||||
|
// Track the WEBFS File Handles
|
||||||
|
// WEBFSStubs[0] is reserved for internal use (FAT access)
|
||||||
|
WEBFS_STUB WEBFSStubs[MAX_WEBFS_OPENFILES+1] WEBFS_DATA_ATTR; // + HANDLE = 0
|
||||||
|
// FAT record cache
|
||||||
|
WEBFS_FAT_RECORD fatCache WEBFS_DATA_ATTR;
|
||||||
|
// ID of currently loaded fatCache
|
||||||
|
static uint32 fatCacheID WEBFS_DATA_ATTR;
|
||||||
|
// Number of files in this WEBFS image
|
||||||
|
uint16 numFiles WEBFS_DATA_ATTR;
|
||||||
|
|
||||||
|
static void GetFATRecord(uint16 fatID);
|
||||||
|
static void WEBFS_Update(void);
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
Function:
|
||||||
|
void WEBFSInit(void)
|
||||||
|
Description:
|
||||||
|
Web Disk Init
|
||||||
|
*****************************************************************************/
|
||||||
|
void WEBFS_CODE_ATTR WEBFSInit(void)
|
||||||
|
{
|
||||||
|
disk_base_addr = WEBFS_base_addr();
|
||||||
|
os_memset((char *) &WEBFSStubs, 0xff, sizeof(WEBFSStubs));
|
||||||
|
// Validate the image and load numFiles
|
||||||
|
WEBFS_Update();
|
||||||
|
#if DEBUGSOO > 0
|
||||||
|
os_printf("\nDisk init: %d files, addr = %p\n", numFiles, disk_base_addr);
|
||||||
|
#endif
|
||||||
|
// тут надо расчет контрольки тела диска или другой контроль...
|
||||||
|
if(numFiles == 0) isWEBFSLocked = true;
|
||||||
|
else isWEBFSLocked = false;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function:
|
||||||
|
WEBFS_HANDLE WEBFSOpen(uint8* cFile)
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Opens a file in the WEBFS2 file system.
|
||||||
|
|
||||||
|
Precondition:
|
||||||
|
None
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
cFile - a null terminated file name to open
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
An WEBFS_HANDLE to the opened file if found, or WEBFS_INVALID_HANDLE
|
||||||
|
if the file could not be found or no free handles exist.
|
||||||
|
***************************************************************************/
|
||||||
|
WEBFS_HANDLE WEBFS_CODE_ATTR WEBFSOpen(uint8* cFile)
|
||||||
|
{
|
||||||
|
WEBFS_HANDLE hWEBFS;
|
||||||
|
uint16 nameHash;
|
||||||
|
int i, len = 0;
|
||||||
|
uint16 hashCache[16];
|
||||||
|
uint8 bufname[MAX_FILE_NAME_LEN];
|
||||||
|
uint8 *ptr;
|
||||||
|
|
||||||
|
// Make sure WEBFS is unlocked and we got a filename
|
||||||
|
if(*cFile == '\0' || isWEBFSLocked == true)
|
||||||
|
return WEBFS_INVALID_HANDLE;
|
||||||
|
|
||||||
|
// Calculate the name hash to speed up searching
|
||||||
|
for(nameHash = 0, ptr = cFile; *ptr != '\0'; ptr++)
|
||||||
|
{
|
||||||
|
nameHash += *ptr;
|
||||||
|
nameHash <<= 1;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
// Find a free file handle to use
|
||||||
|
for(hWEBFS = 1; hWEBFS <= MAX_WEBFS_OPENFILES; hWEBFS++)
|
||||||
|
if(WEBFSStubs[hWEBFS].addr == WEBFS_INVALID) break;
|
||||||
|
if(hWEBFS == MAX_WEBFS_OPENFILES)
|
||||||
|
return WEBFS_INVALID_HANDLE;
|
||||||
|
// Read in hashes, and check remainder on a match. Store 8 in cache for performance
|
||||||
|
for(i = 0; i < numFiles; i++) {
|
||||||
|
// For new block of 8, read in data
|
||||||
|
if((i & 0x0F) == 0) {
|
||||||
|
WEBFSStubs[0].addr = 12 + i*2;
|
||||||
|
WEBFSStubs[0].bytesRem = 32;
|
||||||
|
WEBFSGetArray(0, (uint8*)hashCache, 32);
|
||||||
|
}
|
||||||
|
// If the hash matches, compare the full filename
|
||||||
|
if(hashCache[i&0x0F] == nameHash)
|
||||||
|
{
|
||||||
|
GetFATRecord(i);
|
||||||
|
// filename comparison
|
||||||
|
WEBFSStubs[0].addr = fatCache.string;
|
||||||
|
WEBFSStubs[0].bytesRem = MAX_FILE_NAME_LEN;
|
||||||
|
WEBFSGetArray(0, bufname, MAX_FILE_NAME_LEN);
|
||||||
|
if(os_strncmp(cFile, bufname, len) == 0) { // Filename matches, so return true
|
||||||
|
WEBFSStubs[hWEBFS].addr = fatCache.data;
|
||||||
|
WEBFSStubs[hWEBFS].bytesRem = fatCache.len;
|
||||||
|
WEBFSStubs[hWEBFS].fatID = i;
|
||||||
|
return hWEBFS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No file name matched, so return nothing
|
||||||
|
return WEBFS_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: void WEBFSClose(WEBFS_HANDLE hWEBFS)
|
||||||
|
Summary: Closes a file.
|
||||||
|
Returns: None
|
||||||
|
***************************************************************************/
|
||||||
|
void WEBFS_CODE_ATTR WEBFSClose(WEBFS_HANDLE hWEBFS)
|
||||||
|
{
|
||||||
|
if(hWEBFS != 0 && hWEBFS <= MAX_WEBFS_OPENFILES)
|
||||||
|
WEBFSStubs[hWEBFS].addr = WEBFS_INVALID;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: uint16 WEBFSGetArray(WEBFS_HANDLE hWEBFS, uint8* cData, uint16 wLen)
|
||||||
|
Description: Reads a series of uint8s from a file.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters:
|
||||||
|
hWEBFS - the file handle from which to read
|
||||||
|
cData - where to store the uint8s that were read
|
||||||
|
wLen - how many uint8s to read
|
||||||
|
Returns:
|
||||||
|
The number of uint8s successfully read. If this is less than wLen,
|
||||||
|
an EOF occurred while attempting to read.
|
||||||
|
***************************************************************************/
|
||||||
|
uint16 WEBFS_CODE_ATTR WEBFSGetArray(WEBFS_HANDLE hWEBFS, uint8* cData, uint16 wLen)
|
||||||
|
{
|
||||||
|
// Make sure we're reading a valid address
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES) return 0;
|
||||||
|
|
||||||
|
// Determine how many we can actually read
|
||||||
|
if(wLen > WEBFSStubs[hWEBFS].bytesRem) wLen = WEBFSStubs[hWEBFS].bytesRem;
|
||||||
|
// Make sure we're reading a valid address
|
||||||
|
if(WEBFSStubs[hWEBFS].addr == WEBFS_INVALID || wLen == 0) return 0;
|
||||||
|
|
||||||
|
if(cData != NULL) {
|
||||||
|
|
||||||
|
// Read the data
|
||||||
|
web_mutex_lock();
|
||||||
|
// if(wLen < 16)
|
||||||
|
flash_stream_read(&flashobj, WEBFSStubs[hWEBFS].addr + WEBFS_HEAD_ADDR, wLen, cData);
|
||||||
|
// else flash_burst_read(&flashobj, WEBFSStubs[hWEBFS].addr + WEBFS_HEAD_ADDR, wLen, cData);
|
||||||
|
web_mutex_unlock();
|
||||||
|
|
||||||
|
// if(spi_flash_read(WEBFSStubs[hWEBFS].addr+WEBFS_HEAD_ADDR, cData, wLen) != SPI_FLASH_RESULT_OK)
|
||||||
|
// return 0;
|
||||||
|
};
|
||||||
|
WEBFSStubs[hWEBFS].addr += wLen;
|
||||||
|
WEBFSStubs[hWEBFS].bytesRem -= wLen;
|
||||||
|
return wLen;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function:
|
||||||
|
bool WEBFSSeek(WEBFS_HANDLE hWEBFS, uint32 dwOffset, WEBFS_SEEK_MODE tMode)
|
||||||
|
Description: Moves the current read pointer to a new location.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters:
|
||||||
|
hWEBFS - the file handle to seek with
|
||||||
|
dwOffset - offset from the specified position in the specified direction
|
||||||
|
tMode - one of the WEBFS_SEEK_MODE constants
|
||||||
|
Returns:
|
||||||
|
true - the seek was successful
|
||||||
|
false - either the new location or the handle itself was invalid
|
||||||
|
***************************************************************************/
|
||||||
|
bool WEBFS_CODE_ATTR WEBFSSeek(WEBFS_HANDLE hWEBFS, uint32 dwOffset, WEBFS_SEEK_MODE tMode)
|
||||||
|
{
|
||||||
|
uint32 temp;
|
||||||
|
|
||||||
|
// Make sure a valid file is open
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES || WEBFSStubs[hWEBFS].addr == WEBFS_INVALID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch(tMode)
|
||||||
|
{
|
||||||
|
// Seek offset uint8s from start
|
||||||
|
case WEBFS_SEEK_START:
|
||||||
|
temp = WEBFSGetSize(hWEBFS);
|
||||||
|
if(dwOffset > temp)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WEBFSStubs[hWEBFS].addr = WEBFSGetStartAddr(hWEBFS) + dwOffset;
|
||||||
|
WEBFSStubs[hWEBFS].bytesRem = temp - dwOffset;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Seek forwards offset uint8s
|
||||||
|
case WEBFS_SEEK_FORWARD:
|
||||||
|
if(dwOffset > WEBFSStubs[hWEBFS].bytesRem)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WEBFSStubs[hWEBFS].addr += dwOffset;
|
||||||
|
WEBFSStubs[hWEBFS].bytesRem -= dwOffset;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Seek backwards offset uint8s
|
||||||
|
case WEBFS_SEEK_REWIND:
|
||||||
|
temp = WEBFSGetStartAddr(hWEBFS);
|
||||||
|
if(WEBFSStubs[hWEBFS].addr < temp + dwOffset)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WEBFSStubs[hWEBFS].addr -= dwOffset;
|
||||||
|
WEBFSStubs[hWEBFS].bytesRem += dwOffset;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Seek so that offset uint8s remain in file
|
||||||
|
case WEBFS_SEEK_END:
|
||||||
|
temp = WEBFSGetSize(hWEBFS);
|
||||||
|
if(dwOffset > temp)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WEBFSStubs[hWEBFS].addr = WEBFSGetEndAddr(hWEBFS) - dwOffset;
|
||||||
|
WEBFSStubs[hWEBFS].bytesRem = dwOffset;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: static void GetFATRecord(uint16 fatID)
|
||||||
|
Description: Loads the FAT record for a specified handle.
|
||||||
|
Precondition: None
|
||||||
|
Parameters: fatID - the ID of the file whose FAT is to be loaded
|
||||||
|
Returns: None
|
||||||
|
Remarks: The FAT record will be stored in fatCache.
|
||||||
|
***************************************************************************/
|
||||||
|
static void WEBFS_CODE_ATTR GetFATRecord(uint16 fatID)
|
||||||
|
{
|
||||||
|
WEBFS_FHEADER fhead;
|
||||||
|
if(fatID == fatCacheID || fatID >= numFiles) return;
|
||||||
|
// Read the FAT record to the cache
|
||||||
|
WEBFSStubs[0].bytesRem = sizeof(fhead) + 4;
|
||||||
|
WEBFSStubs[0].addr = 12 + numFiles*2 + fatID *4;
|
||||||
|
WEBFSGetArray(0, (uint8 *)&fatCache.data, 4);
|
||||||
|
WEBFSStubs[0].addr = fatCache.data;
|
||||||
|
WEBFSGetArray(0, (uint8 *)&fhead, sizeof(fhead));
|
||||||
|
fatCache.len = fhead.blksize - fhead.headlen;
|
||||||
|
fatCache.string = fatCache.data + 8;
|
||||||
|
fatCache.flags = fhead.flags;
|
||||||
|
fatCache.data = fatCache.data + fhead.headlen;
|
||||||
|
fatCacheID = fatID;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: uint16 WEBFSGetFlags(WEBFS_HANDLE hWEBFS)
|
||||||
|
Description: Reads a file's flags.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters: hWEBFS - the file handle from which to read the metadata
|
||||||
|
Returns: The flags that were associated with the file
|
||||||
|
***************************************************************************/
|
||||||
|
uint16 WEBFS_CODE_ATTR WEBFSGetFlags(WEBFS_HANDLE hWEBFS)
|
||||||
|
{
|
||||||
|
// Make sure a valid file is open
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES || WEBFSStubs[hWEBFS].addr == WEBFS_INVALID)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
//move to the point for reading
|
||||||
|
GetFATRecord(WEBFSStubs[hWEBFS].fatID);
|
||||||
|
return fatCache.flags;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: uint32 WEBFSGetSize(WEBFS_HANDLE hWEBFS)
|
||||||
|
Description: Reads the size of a file.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters: hWEBFS - the file handle from which to read the metadata
|
||||||
|
Returns: The size that was read as a uint32
|
||||||
|
***************************************************************************/
|
||||||
|
uint32 WEBFS_CODE_ATTR WEBFSGetSize(WEBFS_HANDLE hWEBFS)
|
||||||
|
{
|
||||||
|
// Make sure a valid file is open
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES || WEBFSStubs[hWEBFS].addr == WEBFS_INVALID)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Move to the point for reading
|
||||||
|
GetFATRecord(WEBFSStubs[hWEBFS].fatID);
|
||||||
|
return fatCache.len;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: uint32 WEBFSGetBytesRem(WEBFS_HANDLE hWEBFS)
|
||||||
|
Description: Determines how many uint8s remain to be read.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters: hWEBFS - the file handle from which to read the metadata
|
||||||
|
Returns: The number of uint8s remaining in the file as a uint32
|
||||||
|
***************************************************************************/
|
||||||
|
uint32 WEBFS_CODE_ATTR WEBFSGetBytesRem(WEBFS_HANDLE hWEBFS)
|
||||||
|
{
|
||||||
|
// Make sure a valid file is open
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES || WEBFSStubs[hWEBFS].addr == WEBFS_INVALID)
|
||||||
|
return 0;
|
||||||
|
return WEBFSStubs[hWEBFS].bytesRem;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: WEBFS_PTR WEBFSGetStartAddr(WEBFS_HANDLE hWEBFS)
|
||||||
|
Description: Reads the starting address of a file.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters: hWEBFS - the file handle from which to read the metadata
|
||||||
|
Returns: The starting address of the file in the WEBFS image
|
||||||
|
***************************************************************************/
|
||||||
|
WEBFS_PTR WEBFS_CODE_ATTR WEBFSGetStartAddr(WEBFS_HANDLE hWEBFS)
|
||||||
|
{
|
||||||
|
// Make sure a valid file is open
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES || WEBFSStubs[hWEBFS].addr == WEBFS_INVALID)
|
||||||
|
return 0;
|
||||||
|
// Move to the point for reading
|
||||||
|
GetFATRecord(WEBFSStubs[hWEBFS].fatID);
|
||||||
|
return fatCache.data;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: WEBFS_PTR WEBFSGetEndAddr(WEBFS_HANDLE hWEBFS)
|
||||||
|
Description: Determines the ending address of a file.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters: hWEBFS - the file handle from which to read the metadata
|
||||||
|
Returns: The address just after the file ends (start address of next file)
|
||||||
|
***************************************************************************/
|
||||||
|
WEBFS_PTR WEBFS_CODE_ATTR WEBFSGetEndAddr(WEBFS_HANDLE hWEBFS)
|
||||||
|
{
|
||||||
|
// Make sure a valid file is open
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES || WEBFSStubs[hWEBFS].addr == WEBFS_INVALID)
|
||||||
|
return WEBFS_INVALID;
|
||||||
|
// Move to the point for reading
|
||||||
|
GetFATRecord(WEBFSStubs[hWEBFS].fatID);
|
||||||
|
return fatCache.data + fatCache.len;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: bool WEBFSGetFilename(WEBFS_HANDLE hWEBFS, uint8* cName, uint16 wLen)
|
||||||
|
Description: Reads the file name of a file that is already open.
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters:
|
||||||
|
hWEBFS - the file handle from which to determine the file name
|
||||||
|
cName - where to store the name of the file
|
||||||
|
wLen - the maximum length of data to store in cName
|
||||||
|
Returns:
|
||||||
|
true - the file name was successfully located
|
||||||
|
false - the file handle provided is not currently open
|
||||||
|
***************************************************************************/
|
||||||
|
bool WEBFS_CODE_ATTR WEBFSGetFilename(WEBFS_HANDLE hWEBFS, uint8* cName, uint16 wLen)
|
||||||
|
{
|
||||||
|
uint32 addr;
|
||||||
|
|
||||||
|
// Make sure a valid file is open
|
||||||
|
if(hWEBFS > MAX_WEBFS_OPENFILES || WEBFSStubs[hWEBFS].addr == WEBFS_INVALID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Move to the point for reading
|
||||||
|
GetFATRecord(WEBFSStubs[hWEBFS].fatID);
|
||||||
|
addr = fatCache.string;
|
||||||
|
WEBFSStubs[0].addr = addr;
|
||||||
|
WEBFSStubs[0].bytesRem = 255;
|
||||||
|
|
||||||
|
// Read the value and return
|
||||||
|
WEBFSGetArray(0, cName, wLen);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: uint32 WEBFSGetPosition(WEBFS_HANDLE hWEBFS)
|
||||||
|
Description: Determines the current position in the file
|
||||||
|
Precondition: The file handle referenced by hWEBFS is already open.
|
||||||
|
Parameters: hWEBFS - the file handle for which to determine position
|
||||||
|
Returns: The position in the file as a uint32 (or WEBFS_PTR)
|
||||||
|
***************************************************************************/
|
||||||
|
uint32 WEBFS_CODE_ATTR WEBFSGetPosition(WEBFS_HANDLE hWEBFS)
|
||||||
|
{
|
||||||
|
return WEBFSStubs[hWEBFS].addr - WEBFSGetStartAddr(hWEBFS);
|
||||||
|
}
|
||||||
|
/*****************************************************************************
|
||||||
|
Function: void WEBFS_Update(void)
|
||||||
|
Summary: Validates the WEBFS Image
|
||||||
|
Description: Verifies that the WEBFS image is valid, and reads the number of
|
||||||
|
available files from the image header. This function is called on
|
||||||
|
boot, and again after any image is written.
|
||||||
|
Parameters: None
|
||||||
|
Returns: None
|
||||||
|
***************************************************************************/
|
||||||
|
static void WEBFS_CODE_ATTR WEBFS_Update(void)
|
||||||
|
{
|
||||||
|
// Update numFiles
|
||||||
|
WEBFS_DISK_HEADER dhead;
|
||||||
|
WEBFSStubs[0].addr = 0;
|
||||||
|
WEBFSStubs[0].bytesRem = sizeof(dhead);
|
||||||
|
WEBFSGetArray(0, (uint8*)&dhead, sizeof(dhead));
|
||||||
|
if(dhead.id == WEBFS_DISK_ID && dhead.ver == WEBFS_DISK_VER) { //"FWEB"1,0 ?
|
||||||
|
numFiles = dhead.numFiles;
|
||||||
|
}
|
||||||
|
else numFiles = 0;
|
||||||
|
fatCacheID = WEBFS_INVALID_FAT;
|
||||||
|
}
|
||||||
|
/****************************************************************************
|
||||||
|
* WEBFS_max_size()
|
||||||
|
***************************************************************************/
|
||||||
|
uint32 WEBFS_CODE_ATTR WEBFS_max_size(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
uint32 size = spi_flash_real_size();
|
||||||
|
if(size > WEBFS_DISK_ADDR_BIGFLASH) size -= WEBFS_DISK_ADDR_BIGFLASH;
|
||||||
|
else {
|
||||||
|
size = WEBFS_DISK_ADDR_MINFLASH_END - WEBFS_DISK_ADDR_MINFLASH_START;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
*/
|
||||||
|
return spi_flash_real_size() - WEBFS_DISK_FADDR;
|
||||||
|
}
|
||||||
|
/****************************************************************************
|
||||||
|
* WEBFS_size()
|
||||||
|
***************************************************************************/
|
||||||
|
uint32 WEBFS_CODE_ATTR WEBFS_curent_size(void)
|
||||||
|
{
|
||||||
|
uint32 size = 0;
|
||||||
|
web_mutex_lock();
|
||||||
|
if(numFiles) flash_read_word(&flashobj, disk_base_addr + 8, (uint32_t *) &size);
|
||||||
|
web_mutex_unlock();
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
/****************************************************************************
|
||||||
|
* WEBFS_size()
|
||||||
|
***************************************************************************/
|
||||||
|
uint32 WEBFS_CODE_ATTR WEBFS_base_addr(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
uint32 webfs_faddr;
|
||||||
|
if(flash_get_size(&flashobj) <= WEBFS_DISK_ADDR_BIGFLASH) webfs_faddr = WEBFS_DISK_ADDR_MINFLASH_START;
|
||||||
|
else webfs_faddr = WEBFS_DISK_ADDR_BIGFLASH;
|
||||||
|
return webfs_faddr;
|
||||||
|
*/
|
||||||
|
return WEBFS_DISK_FADDR;
|
||||||
|
}
|
116
Firmware/RTLGDB/Project/webfs/webfs.h
Normal file
116
Firmware/RTLGDB/Project/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
|
78
Firmware/RTLGDB/Project/wifi_user_set.h
Normal file
78
Firmware/RTLGDB/Project/wifi_user_set.h
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* 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 // Стартовый режим WiFi: RTW_MODE_STA_AP, RTW_MODE_AP, RTW_MODE_STA, RTW_MODE_NONE
|
||||||
|
#define DEF_WIFI_AP_STATIONS 3 // Max number of STAs, should be 1..3, default is 3
|
||||||
|
#define DEF_WIFI_COUNTRY RTW_COUNTRY_RU // Регион использования WiFi...
|
||||||
|
#define DEF_WIFI_TX_PWR RTW_TX_PWR_PERCENTAGE_12_5 // RTW_TX_PWR_PERCENTAGE_75 // RTW_TX_PWR_PERCENTAGE_100
|
||||||
|
#define DEF_WIFI_BGN RTW_NETWORK_BGN // rtw_network_mode_t
|
||||||
|
#define DEF_WIFI_ADAPTIVITY RTW_ADAPTIVITY_DISABLE // RTW_ADAPTIVITY_NORMAL // RTW_ADAPTIVITY_DISABLE/RTW_ADAPTIVITY_NORMAL/RTW_ADAPTIVITY_CARRIER_SENSE
|
||||||
|
|
||||||
|
/* Опции загрузки конфигов по старту */
|
||||||
|
//#define DEF_LOAD_CFG 0 // старт в назначенном режиме по умолчанию
|
||||||
|
#define DEF_LOAD_CFG BID_ALL_WIFI_CFG // старт в назначенном общем режиме по умолчанию, с загрузками последних конфигураций ST и AP
|
||||||
|
//#define DEF_LOAD_CFG (BID_ALL_WIFI_CFG | BID_WIFI_CFG) // старт в записанном режиме
|
||||||
|
|
||||||
|
/* Опции разрешения записи конфигов по упсешному соединению или выполнению операции установок режимов WiFi без ошибок */
|
||||||
|
#define DEF_SAVE_CFG (BID_ALL_WIFI_CFG | BID_WIFI_CFG) // сохранение по успешному соединению/выполненю для всех конфигов:
|
||||||
|
// (для ST или AP пишутся раздельно) с проверкой на изменения
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================ Interface 0 - wlan0 = AP =============================================================
|
||||||
|
#define DEF_AP_SSID "Silly-Lamp"
|
||||||
|
#define DEF_AP_PASSWORD "0123456789"
|
||||||
|
/* Варианты типов Security для AP:
|
||||||
|
RTW_SECURITY_OPEN - Open Security
|
||||||
|
RTW_SECURITY_WPA_TKIP_PSK - WPA Security
|
||||||
|
RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
|
||||||
|
RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers */
|
||||||
|
#define DEF_AP_SECURITY RTW_ENCRYPTION_WPA2_MIXED // WEP security is NOT IMPLEMENTED. It is NOT SECURE!
|
||||||
|
#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)
|
||||||
|
// if not defined DHCP_START && DHCP_STOP -> 2..255
|
||||||
|
//#define DEF_AP_DHCP_START 2 // DHCP ip start xx.xx.xx.2
|
||||||
|
//#define DEF_AP_DHCP_STOP 15 // DHCP ip stop xx.xx.xx.15
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================ Interface 1 - wlan1 = STA =============================================================
|
||||||
|
#define DEF_ST_SSID "Appppp" // Имя SSID AP (роутера) для присоединения по умолчанию (первый старт)
|
||||||
|
#define DEF_ST_PASSWORD "123456789" // Пароль AP (роутера) для присоединения по умолчанию (первый старт)
|
||||||
|
#define DEF_ST_SECURITY RTW_ENCRYPTION_WPA2_MIXED // Тип Security
|
||||||
|
#define DEF_ST_BSSID { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } // If bssid set is not ff.ff.ff.ff.ff.ff,
|
||||||
|
#define DEF_ST_USE_BSSID 0 // 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_SLEEP 3 // 0 - Off, 1 - IPS, 2 - LPS, 3 - IPS/LPS mode
|
||||||
|
#define DEF_ST_LPS_DTIM 1 // LPS DTIM
|
||||||
|
#define DEF_ST_DHCP_MODE 1 // =0 dhcp off,
|
||||||
|
// =1 - dhcp on, - динамический ip
|
||||||
|
// =2 Static ip, - fixed ip
|
||||||
|
// =3 - auto fix - старт в режиме "dhcp on", после получения ip - фиксация и переключение в режим рестартов со "Static ip"
|
||||||
|
#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_ */
|
627
Firmware/RTLGDB/RTLGDB.vcxproj
Normal file
627
Firmware/RTLGDB/RTLGDB.vcxproj
Normal file
|
@ -0,0 +1,627 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ApplicationType>LinuxDebugger</ApplicationType>
|
||||||
|
<SecureShellExecutable>ssh</SecureShellExecutable>
|
||||||
|
<RemoteDebuggerExecutable>gdb</RemoteDebuggerExecutable>
|
||||||
|
<LocalDebuggerExecutable>gdb</LocalDebuggerExecutable>
|
||||||
|
<OCDDebuggerServerAddress>localhost:3333</OCDDebuggerServerAddress>
|
||||||
|
<Keyword>IoT</Keyword>
|
||||||
|
<ProjectGuid>{3D8B16B6-9763-48AD-A514-F45680E8613B}</ProjectGuid>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Makefile</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Makefile</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Makefile</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Makefile</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Assets\LinuxDebugger.xaml" />
|
||||||
|
<None Include="Assets\LocalDebugger.xaml" />
|
||||||
|
<None Include="Assets\OCDDebugger.xaml" />
|
||||||
|
<None Include="Assets\linux_nmake.xaml" />
|
||||||
|
<None Include="makefile" />
|
||||||
|
<None Include="project.mk" />
|
||||||
|
<None Include="USDK\flasher.mk" />
|
||||||
|
<None Include="USDK\Makefile" />
|
||||||
|
<None Include="USDK\paths.mk" />
|
||||||
|
<None Include="USDK\sdkbuild.mk" />
|
||||||
|
<None Include="USDK\sdkset.mk" />
|
||||||
|
<None Include="userset.mk" />
|
||||||
|
<None Include="WEBFiles\elements.css" />
|
||||||
|
<None Include="WEBFiles\elements.js" />
|
||||||
|
<None Include="WEBFiles\html5kellycolorpicker.min.js" />
|
||||||
|
<None Include="WEBFiles\index.html" />
|
||||||
|
<None Include="webfs.mk" />
|
||||||
|
</ItemGroup>
|
||||||
|
<!--Import Project="$(MSBuildThisFileDirectory)\Microsoft.cpp.Linux.targets" /-->
|
||||||
|
<!-- To Enable linux debugger -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<UseDefaultDebuggersPropertyPageSchemas>false</UseDefaultDebuggersPropertyPageSchemas>
|
||||||
|
<UseDefaultPropertyPageSchemas>false</UseDefaultPropertyPageSchemas>
|
||||||
|
<_ApplicableDebuggers>Desktop</_ApplicableDebuggers>
|
||||||
|
<DebuggerFlavor>LinuxDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\ProjectItemsSchema.xml" />
|
||||||
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\directories.xml" />
|
||||||
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\debugger_general.xml" />
|
||||||
|
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)\Assets\LinuxDebugger.xaml" />
|
||||||
|
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)\Assets\LocalDebugger.xaml" />
|
||||||
|
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)\Assets\OCDDebugger.xaml" />
|
||||||
|
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)\Assets\linux_nmake.xaml" />
|
||||||
|
<!-- project only rules -->
|
||||||
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\general_makefile.xml">
|
||||||
|
<Context>Project</Context>
|
||||||
|
</PropertyPageSchema>
|
||||||
|
<!-- Property sheet only rules -->
|
||||||
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\general_makefile_ps.xml;$(VCTargetsPath)$(LangID)\usermacros.xml">
|
||||||
|
<Context>PropertySheet</Context>
|
||||||
|
</PropertyPageSchema>
|
||||||
|
<!-- File only rules -->
|
||||||
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\general_file.xml">
|
||||||
|
<Context>File</Context>
|
||||||
|
</PropertyPageSchema>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<DesktopDebuggerPages Include="$(MSBuildThisFileDirectory)\Assets\LinuxDebugger.xaml" />
|
||||||
|
<DesktopDebuggerPages Include="$(MSBuildThisFileDirectory)\Assets\LocalDebugger.xaml" />
|
||||||
|
<DesktopDebuggerPages Include="$(MSBuildThisFileDirectory)\Assets\OCDDebugger.xaml" />
|
||||||
|
<DesktopDebuggerPages Include="$(MSBuildThisFileDirectory)\Assets\linux_nmake.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectCapability Include="Linux" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Project\build_info.h" />
|
||||||
|
<ClInclude Include="Project\feep_config.h" />
|
||||||
|
<ClInclude Include="Project\FreeRTOSConfig.h" />
|
||||||
|
<ClInclude Include="Project\lwipopts.h" />
|
||||||
|
<ClInclude Include="Project\main.h" />
|
||||||
|
<ClInclude Include="Project\platform_autoconf.h" />
|
||||||
|
<ClInclude Include="Project\platform_opts.h" />
|
||||||
|
<ClInclude Include="Project\rtl8195a\c_types.h" />
|
||||||
|
<ClInclude Include="Project\rtl8195a\os.h" />
|
||||||
|
<ClInclude Include="Project\rtl8195a\queue.h" />
|
||||||
|
<ClInclude Include="Project\rtl8195a\rom_wps_os.h" />
|
||||||
|
<ClInclude Include="Project\rtl8195a\rtl_common.h" />
|
||||||
|
<ClInclude Include="Project\rtl8195a\rtl_libc.h" />
|
||||||
|
<ClInclude Include="Project\sys_cfg.h" />
|
||||||
|
<ClInclude Include="Project\tcpsrv\tcp_srv_conn.h" />
|
||||||
|
<ClInclude Include="Project\user_config.h" />
|
||||||
|
<ClInclude Include="Project\webfs\webfs.h" />
|
||||||
|
<ClInclude Include="Project\web\websock.h" />
|
||||||
|
<ClInclude Include="Project\web\web_srv.h" />
|
||||||
|
<ClInclude Include="Project\web\web_srv_int.h" />
|
||||||
|
<ClInclude Include="Project\web\web_utils.h" />
|
||||||
|
<ClInclude Include="Project\web\web_websocket.h" />
|
||||||
|
<ClInclude Include="Project\wifi_user_set.h" />
|
||||||
|
<ClInclude Include="Project\WS2812\ledeffectsserver.h" />
|
||||||
|
<ClInclude Include="Project\WS2812\ledfilters.h" />
|
||||||
|
<ClInclude Include="Project\WS2812\ws2812.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\lwip_netconf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\sdk_ver.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\rtw_wowlan\wifi_wowlan.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\rtw_wpa_supplicant\src\utils\os.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\rtw_wpa_supplicant\src\utils\rom\rom_wps_os.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\rtw_wpa_supplicant\src\wps\wps_defs.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\wifi_conf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\wifi_ind.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\wifi_simple_config.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\wifi_simple_config_parser.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi\wifi_util.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\api\wifi_interactive_ext.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\autoconf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\byteorder\generic.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\byteorder\little_endian.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\byteorder\swab.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\drv_conf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\drv_types.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\ethernet.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\HalPwrSeqCmd.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\HalVerDef.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\hal_com.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\hal_com_phycfg.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\hal_com_reg.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\hal_intf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\hal_pg.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\hal_phy.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\hal_phy_reg.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\ieee80211.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\if_ether.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\ip.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\lxbus_hal.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\lxbus_ops.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\lxbus_osintf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\pack_begin.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\pack_end.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_aes.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_arc4.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_ieee80211.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_md5.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_rc4.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_rtw_message.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_rtw_message_e.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_rtw_psk.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_rtw_security.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rom_sha1.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtl8195a_hal.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtl8711b_hal.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_ap.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_byteorder.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_cmd.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_debug.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_eeprom.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_efuse.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_event.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_ht.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_intfs.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_io.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_ioctl_set.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_led.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_mlme.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_mlme_ext.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_mp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_p2p.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_promisc.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_psk.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_pwrctrl.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_qos.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_recv.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_rf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_security.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\rtw_xmit.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\sta_info.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\wifi.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\wifi_constants.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\wifi_lib.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\wifi_structures.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\wlan_basic_types.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\wlan_bssdef.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\include\wlan_lib.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\hci\gspi\gspi_spec.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\hci\hci_intfs.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\hci\hci_spec.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\hci\lxbus\lxbus_spec.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\hci\sdio\sdio_spec.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\freertos\freertos_intfs.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\freertos\freertos_recv.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\freertos\freertos_skbuff.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\freertos\freertos_xmit.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\freertos\wrapper.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\lwip_intf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\netdev.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\osdep_intf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\skbuff.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\wireless.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\drivers\wlan\realtek\src\osdep\wlan_intf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\analogin_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\analogout_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\can_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\ethernet_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\gpio_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\gpio_irq_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\i2c_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\pinmap.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\port_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\pwmout_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\rtc_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\serial_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\sleep_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\spi_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal\us_ticker_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\dma_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\efuse_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\ethernet_ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\flash_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\flash_eep.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\gpio_ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\gpio_irq_ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\i2c_ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\i2s_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\log_uart_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\nfc_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\serial_ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\sleep_ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\spdio_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\spi_ex_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\sys_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\hal_ext\wdt_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\targets\hal\rtl8195a\device.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\targets\hal\rtl8195a\gpio_object.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\targets\hal\rtl8195a\objects.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\targets\hal\rtl8195a\PeripheralNames.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\targets\hal\rtl8195a\PinNames.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\targets\hal\rtl8195a\PortNames.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\mbed\targets\hal\rtl8195a\timer_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\port\realtek\freertos\ethernetif.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\port\realtek\freertos\sys_arch.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\autoip.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\icmp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\igmp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\inet.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\inet_chksum.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\ip.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\ip_addr.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\ipv4\lwip\ip_frag.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\api.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\api_msg.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\arch.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\debug.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\def.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\dhcp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\dns.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\err.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\init.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\lwip_timers.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\mem.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\memp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\memp_std.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\netbuf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\netdb.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\netif.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\netifapi.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\opt.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\pbuf.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\raw.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\sio.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\snmp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\snmp_asn1.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\snmp_msg.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\snmp_structs.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\sockets.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\stats.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\sys.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\tcp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\tcpip.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\tcp_impl.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\lwip\udp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\netif\etharp.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\netif\loopif.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\netif\ppp_oe.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\netif\slipif.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\posix\netdb.h" />
|
||||||
|
<ClInclude Include="USDK\component\common\network\lwip\src\include\posix\sys\socket.h" />
|
||||||
|
<ClInclude Include="USDK\component\os\freertos\freertos_service.h" />
|
||||||
|
<ClInclude Include="USDK\component\os\os_dep\include\device_lock.h" />
|
||||||
|
<ClInclude Include="USDK\component\os\os_dep\include\osdep_service.h" />
|
||||||
|
<ClInclude Include="USDK\component\os\os_dep\include\os_support.h" />
|
||||||
|
<ClInclude Include="USDK\component\os\os_dep\include\tcm_heap.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\cmsis.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\cmsis_nvic.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\diag.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\rand.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\rtl_stdlib.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\rtl_utility.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\strproc.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\system_8195a.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\cmsis\device\va_list.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\bitband_io.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_adc.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_common.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_crypto.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_dac.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_diag.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_efuse.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_gdma.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_gpio.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_i2c.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_i2s.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_irqn.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_log_uart.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_mii.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_misc.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_nfc.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_pcm.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_peri_on.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_pinmux.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_platform.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_pwm.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_sdio.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_sdio_host.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_sdr_controller.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_soc_ps_monitor.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_spi_flash.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_ssi.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_timer.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_uart.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_usb.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_util.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\hal_vector_table.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_adc.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_dac.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_gdma.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_gpio.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_gspi.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_i2c.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_i2s.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_mii.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_nfc.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_pcm.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_peri_on.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_pwm.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_sdio.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_sdio_host.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_sdr.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_spi_flash.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_ssi.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_sys_on.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_timer.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_uart.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_usb.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_wdt.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\driver\rtl_consol.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\driver\rtl_sec.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\os\freertos_pmu_8195a.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\os\mailbox.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\os\osdep_api.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\os\os_support.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\os\os_timer.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\include\rtl_bios_data.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\include\rtl_lib.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\include\rtl_rr_libc.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\include\rt_lib_rom.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\common\bsp\basic_types.h" />
|
||||||
|
<ClInclude Include="USDK\component\soc\realtek\common\bsp\section_config.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Project\main.c" />
|
||||||
|
<ClCompile Include="Project\tcpsrv\tcp_srv_conn.c" />
|
||||||
|
<ClCompile Include="Project\user_start.c" />
|
||||||
|
<ClCompile Include="Project\webfs\webfs.c" />
|
||||||
|
<ClCompile Include="Project\web\websock.c" />
|
||||||
|
<ClCompile Include="Project\web\web_auth.c" />
|
||||||
|
<ClCompile Include="Project\web\web_int_callbacks.c" />
|
||||||
|
<ClCompile Include="Project\web\web_int_vars.c" />
|
||||||
|
<ClCompile Include="Project\web\web_srv.c" />
|
||||||
|
<ClCompile Include="Project\web\web_utils.c" />
|
||||||
|
<ClCompile Include="Project\web\web_websocket.c" />
|
||||||
|
<ClCompile Include="Project\WS2812\ledeffectsserver.c" />
|
||||||
|
<ClCompile Include="Project\WS2812\ledfilters.c" />
|
||||||
|
<ClCompile Include="Project\WS2812\ws2812.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\lwip_netconf.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\lwip_netconf1.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\rtw_wowlan\dev_wowlan.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\rtw_wpa_supplicant\src\utils\os_freertos.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\rtw_wpa_supplicant\wpa_supplicant\wifi_eap_config.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\rtw_wpa_supplicant\wpa_supplicant\wifi_p2p_config.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\rtw_wpa_supplicant\wpa_supplicant\wifi_wps_config.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\wifi_conf.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\wifi_ind.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\wifi_promisc.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\wifi_simple_config.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi\wifi_util.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi_api_scan.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\api\wifi_interactive_mode.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\drivers\wlan\realtek\src\hci\gspi\gspi_intf.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\drivers\wlan\realtek\src\hci\gspi\gspi_io.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\drivers\wlan\realtek\src\hci\gspi\gspi_isr.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\drivers\wlan\realtek\src\hci\sdio\sdio_drvio.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\drivers\wlan\realtek\src\hci\sdio\sdio_intf.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\drivers\wlan\realtek\src\hci\sdio\sdio_isr.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\drivers\wlan\realtek\src\osdep\lwip_intf.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\analogin_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\dma_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\efuse_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\ethernet_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\flash_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\flash_eep.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\gpio_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\gpio_irq_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\i2c_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\i2s_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\log_uart_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\nfc_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\pinmap.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\pinmap_common.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\port_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\pwmout_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\rtc_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\serial_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\sleep.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\spdio_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\spi_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\sys_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\timer_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\us_ticker.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\mbed\targets\hal\rtl8195a\wdt_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\port\realtek\freertos\ethernetif.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\port\realtek\freertos\sys_arch.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\api_lib.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\api_msg.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\err.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\netbuf.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\netdb.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\netifapi.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\sockets.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\api\tcpip.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\def.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\dhcp.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\dns.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\init.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\autoip.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\icmp.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\igmp.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\inet.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\inet_chksum.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\ip.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\ip_addr.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\ipv4\ip_frag.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\lwip_timers.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\mem.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\memp.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\netif.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\pbuf.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\raw.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\snmp\asn1_dec.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\snmp\asn1_enc.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\snmp\mib2.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\snmp\mib_structs.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\snmp\msg_in.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\snmp\msg_out.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\stats.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\sys.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\tcp.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\tcp_in.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\tcp_out.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\core\udp.c" />
|
||||||
|
<ClCompile Include="USDK\component\common\network\lwip\src\netif\etharp.c" />
|
||||||
|
<ClCompile Include="USDK\component\os\freertos\freertos_service.c" />
|
||||||
|
<ClCompile Include="USDK\component\os\os_dep\device_lock.c" />
|
||||||
|
<ClCompile Include="USDK\component\os\os_dep\osdep_service.c" />
|
||||||
|
<ClCompile Include="USDK\component\os\os_dep\tcm_heap.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\cmsis\device\app_start.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\cmsis\device\cmsis_nvic.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\cmsis\device\system_8195a.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\bitband_io.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_32k.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_adc.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_common.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_dac.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_efuse.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_gdma.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_gpio.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_i2c.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_i2s.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_log_uart.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_mii.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_misc.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_nfc.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_pcm.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_pinmux.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_pwm.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_sdio_host.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_sdr_controller.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_soc_ps_monitor.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_spi_flash_ram.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_ssi.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_timer.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\hal_uart.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\fw_loader_main.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\hal_misc_v0.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\low_level_io.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\rtl_bios_data.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\rtl_boot.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\rtl_boot_min.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\rtl_boot_ram.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\rtl_boot_tst.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\startup.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\ram_lib\startup_old.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_adc.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_dac.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_gdma.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_gpio.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_i2c.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_i2s.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_mii.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_nfc.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_pcm.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_pwm.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_sdio_device.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_sdio_host.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_sdio_host_open.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_ssi.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_timer.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\fwlib\rtl8195a\rtl8195a_uart.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\driver\console_hs_uart.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\driver\console_i2c.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\driver\low_level_io.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\driver\rtl_consol.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\driver\rtl_console_new.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\os\freertos_pmu_8195a.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\os\mailbox.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\os\osdep_api.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\lib_rtlstd\c_stdio.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\lib_rtlstd\ram_libc.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\lib_rtlstd\ram_libgloss_retarget.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\lib_rtlstd\ram_pvvx_libc.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\lib_rtlstd\rtl_eabi_cast_ram.c" />
|
||||||
|
<ClCompile Include="USDK\component\soc\realtek\8195a\misc\rtl_std_lib\lib_rtlstd\rtl_math_ram.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<!-- To Enable linux debugger End -->
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<NMakeBuildCommandLine>mingw32-make -s -j 6 all</NMakeBuildCommandLine>
|
||||||
|
<IncludePath>C:\RTL\6-2017-q2\arm-none-eabi\include;$(ProjectDir)USDK\component\common\mbed\targets\hal\rtl8195a;$(ProjectDir)USDK\component\common\mbed\common;$(ProjectDir)USDK\component\common\mbed\hal;$(ProjectDir)USDK\component\common\mbed\hal_ext;$(ProjectDir)USDK\component\common\mbed\api;$(ProjectDir)USDK\component\common\api;$(ProjectDir)USDK\component\common\api\at_cmd;$(ProjectDir)USDK\component\common\api\network;$(ProjectDir)USDK\component\common\api\platform;$(ProjectDir)USDK\component\common\api\wifi\rtw_wowlan;$(ProjectDir)USDK\component\common\api\wifi;$(ProjectDir)USDK\component\common\network;$(ProjectDir)USDK\component\common\network\lwip\port\realtek;$(ProjectDir)USDK\component\common\network\lwip\port\realtek\arch;$(ProjectDir)USDK\component\common\network\lwip\port\realtek\freertos;$(ProjectDir)USDK\component\common\network\lwip\src\api;$(ProjectDir)USDK\component\common\network\lwip\src\core\ipv4;$(ProjectDir)USDK\component\common\network\lwip\src\core\snmp;$(ProjectDir)USDK\component\common\network\lwip\src\core;$(ProjectDir)USDK\component\common\network\lwip\src\include;$(ProjectDir)USDK\component\common\network\lwip\src\include\ipv4;$(ProjectDir)USDK\component\common\network\lwip\src\include\ipv4\lwip;$(ProjectDir)USDK\component\common\network\lwip\src\include\lwip;$(ProjectDir)USDK\component\common\network\lwip\src\include\netif;$(ProjectDir)USDK\component\common\network\lwip\src\include\posix\sys;$(ProjectDir)USDK\component\common\network\lwip\src\include\posix;$(ProjectDir)USDK\component\common\network\lwip\src\netif;$(ProjectDir)USDK\component\common\drivers\wlan\realtek\include;$(ProjectDir)USDK\component\common\drivers\wlan\realtek\include\byteorder;$(ProjectDir)USDK\component\common\drivers\wlan\realtek\src\osdep;$(ProjectDir)USDK\component\common\drivers\wlan\realtek\src\osdep\freertos;$(ProjectDir)USDK\component\os\freertos\freertos\Source;$(ProjectDir)USDK\component\os\freertos\freertos\Source\portable\GCC\ARM_CM3;$(ProjectDir)USDK\component\os\freertos\freertos\Source\include;$(ProjectDir)USDK\component\os\freertos;$(ProjectDir)USDK\component\os\os_dep\include;$(ProjectDir)USDK\component\os\os_dep;$(ProjectDir)USDK\component\os\rtx;$(ProjectDir)USDK\component\soc\realtek\common\bsp;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib\src;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib\rtl8195a;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib\rtl8195a\src;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib\ram_lib;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib\ram_lib\wlan\realtek\wlan_ram_map\rom;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib\ram_lib\usb_otg\include;$(ProjectDir)USDK\component\soc\realtek\8195a\fwlib\ram_lib\usb_otg\include\usb_otg_inc;$(ProjectDir)USDK\component\soc\realtek\8195a\cmsis;$(ProjectDir)USDK\component\soc\realtek\8195a\cmsis\device;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\driver;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\platform;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\os;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\rtl_std_lib;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\rtl_std_lib\include;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\rtl_std_lib\lib_rtlstd;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\rtl_std_lib\libc\rom\string;$(ProjectDir)USDK\component\soc\realtek\8195a\misc\rtl_std_lib\libgloss\rtl8195a\rom;$(ProjectDir)Project;$(ProjectDir)Project\web;$(ProjectDir)Project\webfs;$(ProjectDir)Project\tcpsrv;$(ProjectDir)Project\driver;$(ProjectDir)Project\rtl8195a;$(ProjectDir)Project\ina219;$(ProjectDir)Project\adc_ws;$(ProjectDir)Project\MPU6050;$(ProjectDir)Project\SSD1306;$(ProjectDir)Project\MLX90614;$(ProjectDir)Project\WS2812;$(ProjectDir)Project\WEBFiles;$(IncludePath)</IncludePath>
|
||||||
|
<NMakeReBuildCommandLine>mingw32-make -s -j 6 rebuild</NMakeReBuildCommandLine>
|
||||||
|
<NMakeCleanCommandLine>mingw32-make -s clean</NMakeCleanCommandLine>
|
||||||
|
<NMakeOutput>ram_all.bin</NMakeOutput>
|
||||||
|
<OutDir>$(ProjectDir)Debug\bin\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)Debug</IntDir>
|
||||||
|
<NMakePreprocessorDefinitions>CONFIG_PLATFORM_8195A=1;GCC_ARMCM3;M3;F_CPU=166666666L;__STDC__;__extension__=</NMakePreprocessorDefinitions>
|
||||||
|
<ExecutablePath>$(PATH)</ExecutablePath>
|
||||||
|
<ReferencePath />
|
||||||
|
<LibraryPath />
|
||||||
|
<LibraryWPath />
|
||||||
|
<ExcludePath>
|
||||||
|
</ExcludePath>
|
||||||
|
<SourcePath>$(SourcePath)</SourcePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<NMakeBuildCommandLine>
|
||||||
|
</NMakeBuildCommandLine>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<BuildLog>
|
||||||
|
<Path>$(ProjectDir)Debug\$(MSBuildProjectName).log</Path>
|
||||||
|
</BuildLog>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
1683
Firmware/RTLGDB/RTLGDB.vcxproj.filters
Normal file
1683
Firmware/RTLGDB/RTLGDB.vcxproj.filters
Normal file
File diff suppressed because it is too large
Load diff
12
Firmware/RTLGDB/RTLGDB.vcxproj.user
Normal file
12
Firmware/RTLGDB/RTLGDB.vcxproj.user
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OCDDebuggerExecutable>C:\RTL\6-2017-q2\bin\arm-none-eabi-gdb.exe</OCDDebuggerExecutable>
|
||||||
|
<OCDDebugBinary>$(ProjectDir)Debug\obj\Debug.axf</OCDDebugBinary>
|
||||||
|
<DebuggerFlavor>OCDDebugger</DebuggerFlavor>
|
||||||
|
<OCDDebuggerServerAddress>localhost:2331</OCDDebuggerServerAddress>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<DebuggerFlavor>OCDDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
60
Firmware/RTLGDB/USDK/Makefile
Normal file
60
Firmware/RTLGDB/USDK/Makefile
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
include userset.mk
|
||||||
|
|
||||||
|
all: ram_all
|
||||||
|
mp: ram_all_mp
|
||||||
|
|
||||||
|
.PHONY: ram_all
|
||||||
|
ram_all:
|
||||||
|
@$(MAKE) -f $(SDK_PATH)sdkbuild.mk
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk genbin1 genbin23
|
||||||
|
|
||||||
|
.PHONY: ram_all_mp
|
||||||
|
ram_all_mp:
|
||||||
|
@$(MAKE) -f $(SDK_PATH)sdkbuild.mk mp
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk mp
|
||||||
|
|
||||||
|
.PHONY: clean clean_all
|
||||||
|
clean:
|
||||||
|
@$(MAKE) -f $(SDK_PATH)sdkbuild.mk clean
|
||||||
|
|
||||||
|
clean_all:
|
||||||
|
@$(MAKE) -f $(SDK_PATH)sdkbuild.mk clean_all
|
||||||
|
|
||||||
|
.PHONY: flashburn runram reset test readfullflash flashwebfs flashboot
|
||||||
|
flashboot:
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk flashboot
|
||||||
|
|
||||||
|
flashburn:
|
||||||
|
#JLinkGDB-WrFlash.bat
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk flashburn
|
||||||
|
|
||||||
|
flash_OTA:
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk flash_OTA
|
||||||
|
|
||||||
|
webfs:
|
||||||
|
@$(MAKE) -f webfs.mk
|
||||||
|
|
||||||
|
flashwebfs:
|
||||||
|
@$(MAKE) -f webfs.mk
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk flashwebfs
|
||||||
|
#JLinkGDB-WrWebFs.bat
|
||||||
|
|
||||||
|
runram:
|
||||||
|
#JLink-RunRAM.bat
|
||||||
|
@$(MAKE) --f $(SDK_PATH)flasher.mk runram
|
||||||
|
|
||||||
|
runsdram:
|
||||||
|
#JLink-RunRAM.bat
|
||||||
|
@$(MAKE) --f $(SDK_PATH)flasher.mk runsdram
|
||||||
|
|
||||||
|
reset:
|
||||||
|
#JLink-Reset.bat
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk reset
|
||||||
|
|
||||||
|
test:
|
||||||
|
JLink-RTL00ConsoleROM.bat
|
||||||
|
#@make -f flasher.mk test
|
||||||
|
|
||||||
|
readfullflash:
|
||||||
|
#JLink-RdFullFlash.bat
|
||||||
|
@$(MAKE) -f $(SDK_PATH)flasher.mk readfullflash
|
175
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_cloud.c
Normal file
175
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_cloud.c
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "log_service.h"
|
||||||
|
#include "cmsis_os.h"
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
|
||||||
|
#if CONFIG_JOYLINK
|
||||||
|
#if 1
|
||||||
|
void fATCJ(void *arg)
|
||||||
|
{
|
||||||
|
extern void joylink_erase(void);
|
||||||
|
printf("\r\n[ATCJ] Erase wifi and joylink info.");
|
||||||
|
if(arg){
|
||||||
|
printf("\r\n[ATCJ]Usage : ATCJ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
joylink_erase();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void fATCJ(void *arg)
|
||||||
|
{
|
||||||
|
extern void cmd_jd_smart(int argc, char **argv);
|
||||||
|
int argc;
|
||||||
|
char *argv[MAX_ARGC] = {0};
|
||||||
|
printf("[ATCJ]:simple config command for jdsmart\n\r");
|
||||||
|
if(!arg){
|
||||||
|
printf("[ATCJ]Usage: ATCJ=simple_config\n\r");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
argv[0] = "simple_config";
|
||||||
|
if((argc = parse_param(arg, argv)) > 1){
|
||||||
|
cmd_jd_smart(argc, argv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("[ATCJ]Usage: ATCJ=simple_config\n\r");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_GAGENT
|
||||||
|
void fATCG(void *arg)
|
||||||
|
{
|
||||||
|
example_gagent();
|
||||||
|
}
|
||||||
|
void fATCE(void *arg)
|
||||||
|
{//Erase gagent config flash
|
||||||
|
extern int GAgent_DevEraseConfigData();
|
||||||
|
GAgent_DevEraseConfigData();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_QQ_LINK
|
||||||
|
void fATCQ(void *arg)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
unsigned char *argv[MAX_ARGC] = {0};
|
||||||
|
extern void device_write_sn_license(int argc, unsigned char **argv);
|
||||||
|
extern void device_erase_all(int argc, unsigned char **argv);
|
||||||
|
|
||||||
|
if(!arg)
|
||||||
|
{
|
||||||
|
printf("\r\n[ATCQ] Write sn/license into flash or Erase all info\r\n");
|
||||||
|
printf("\r\n[ATCQ] Usage: ATCQ=erase");
|
||||||
|
printf("\r\n[ATCQ] Usage: ATCQ=sn,xxxxxxxx\r\n ATCQ=licensepart1,xxxxxxxx\r\n ATCQ=licensepart2,xxxxxxxx");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
argv[0] = "sn&&license&&erase";
|
||||||
|
argc = parse_param(arg, argv);
|
||||||
|
if(argc == 3) // Write sn&&license
|
||||||
|
{
|
||||||
|
device_write_sn_license(argc, argv);
|
||||||
|
}
|
||||||
|
else if(argc == 2) // Erase all info : ATCQ=erase
|
||||||
|
{
|
||||||
|
device_erase_all(argc, argv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("\r\n[ATCQ] Usage: ATCQ=erase");
|
||||||
|
printf("\r\n[ATCQ]Usage: ATCQ=sn,xxxxxxxx\r\n ATCQ=licensepart1,xxxxxxxx\r\n ATCQ=licensepart2,xxxxxxxx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_AIRKISS_CLOUD
|
||||||
|
void fATCW(void *arg)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
unsigned char *argv[MAX_ARGC] = {0};
|
||||||
|
extern void airkiss_cloud_write_device_info(int argc, unsigned char **argv);
|
||||||
|
extern void airkiss_cloud_erase_ap_profile(int argc, unsigned char **argv);
|
||||||
|
|
||||||
|
if(!arg) goto USAGE;
|
||||||
|
|
||||||
|
argv[0] = "type/id/licese/erase";
|
||||||
|
argc = parse_param(arg, argv);
|
||||||
|
if(argc == 3) // Write typw/id/license
|
||||||
|
{
|
||||||
|
airkiss_cloud_write_device_info(argc, argv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(argc == 2) // Erase wifi profile : ATCW=erase
|
||||||
|
{
|
||||||
|
airkiss_cloud_erase_ap_profile(argc, argv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto USAGE;
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
printf("\r\n[ATCW] Write ORDERLY device's type/id/license into flash or Erase wifi profile");
|
||||||
|
printf("\r\n[ATCW] Usage: ATCW=type,xxxxxxxx");
|
||||||
|
printf("\r\n[ATCW] Usage: ATCW=id,xxxxxxxx");
|
||||||
|
printf("\r\n[ATCW] Usage: ATCW=licensepart1,xxxxxxxx\t(80-Byte long)");
|
||||||
|
printf("\r\n[ATCW] Usage: ATCW=licensepart2,xxxxxxxx\t(80-Byte long)");
|
||||||
|
printf("\r\n[ATCW] Usage: ATCW=erase");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ALINK
|
||||||
|
extern void example_alink(void);
|
||||||
|
extern int alink_erase_wifi_config();
|
||||||
|
extern void alink_reset_to_factory(void *arg);
|
||||||
|
|
||||||
|
void fATCA(void *arg)
|
||||||
|
{
|
||||||
|
example_alink();
|
||||||
|
}
|
||||||
|
|
||||||
|
void fATCZ(void *arg)
|
||||||
|
{
|
||||||
|
//Erase alink config flash
|
||||||
|
alink_erase_wifi_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
void fATCT(void *arg)
|
||||||
|
{
|
||||||
|
alink_reset_to_factory(NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void fATCx(void *arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
log_item_t at_cloud_items[ ] = {
|
||||||
|
#if CONFIG_JOYLINK
|
||||||
|
{"ATCJ", fATCJ,},
|
||||||
|
#endif
|
||||||
|
#if CONFIG_GAGENT
|
||||||
|
{"ATCG", fATCG,},
|
||||||
|
{"ATCE", fATCE,},
|
||||||
|
#endif
|
||||||
|
#if CONFIG_QQ_LINK
|
||||||
|
{"ATCQ", fATCQ,},
|
||||||
|
#endif
|
||||||
|
#if CONFIG_AIRKISS_CLOUD
|
||||||
|
{"ATCW", fATCW},
|
||||||
|
#endif
|
||||||
|
#if CONFIG_ALINK
|
||||||
|
{"ATCA", fATCA,},
|
||||||
|
{"ATCZ", fATCZ,},
|
||||||
|
{"ATCT", fATCT,},
|
||||||
|
#endif
|
||||||
|
{"ATC?", fATCx,},
|
||||||
|
};
|
||||||
|
void at_cloud_init(void)
|
||||||
|
{
|
||||||
|
log_service_add_table(at_cloud_items, sizeof(at_cloud_items)/sizeof(at_cloud_items[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SUPPORT_LOG_SERVICE
|
||||||
|
log_module_init(at_cloud_init);
|
||||||
|
#endif
|
|
@ -0,0 +1,91 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "log_service.h"
|
||||||
|
#include "platform_opts.h"
|
||||||
|
#include <lwip_netconf.h>
|
||||||
|
#include "cmsis_os.h"
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
#include <lwip/sockets.h>
|
||||||
|
#include <lwip/tcpip.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define _AT_DHCP_ETHERNET_MII_ "ATE0"
|
||||||
|
#define _AT_SET_DEFAULT_INTERFACE "ATE1"
|
||||||
|
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
extern int dhcp_ethernet_mii;
|
||||||
|
extern int ethernet_if_default;
|
||||||
|
extern struct netif xnetif[NET_IF_NUM];
|
||||||
|
|
||||||
|
void fATE0(void *arg)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
char *argv[MAX_ARGC] = {0};
|
||||||
|
printf("[ATE0]:DHCP configure for ethernet\n\r");
|
||||||
|
if(!arg){
|
||||||
|
printf("[ATE0]Usage to disable DHCP: ATE0=0\n");
|
||||||
|
printf("[ATE0]Usage to enable DHCP: ATE0=1\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if('0' == *(char *)arg)
|
||||||
|
{
|
||||||
|
dhcp_ethernet_mii = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if('1' == *(char *)arg)
|
||||||
|
{
|
||||||
|
dhcp_ethernet_mii = 1;
|
||||||
|
LwIP_DHCP(NET_IF_NUM - 1, DHCP_START);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("[ATE0]Usage to disable DHCP: ATE0=0\n");
|
||||||
|
printf("[ATE0]Usage to enable DHCP: ATE0=1\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fATE1(void *arg)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
char *argv[MAX_ARGC] = {0};
|
||||||
|
printf("[ATE1]:Set/check the default interface\n\r");
|
||||||
|
if(!arg){
|
||||||
|
if(ethernet_if_default)
|
||||||
|
printf("Ethernet is the default interface\n");
|
||||||
|
else
|
||||||
|
printf("wlan is the default interface\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if('0' == *(char *)arg)
|
||||||
|
{
|
||||||
|
ethernet_if_default = 0;
|
||||||
|
printf("wlan is set to the default interface\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if('1' == *(char *)arg)
|
||||||
|
{
|
||||||
|
ethernet_if_default = 1;
|
||||||
|
printf("ethernet is set to the default interface\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("[ATE0]Usage to check the default interface: ATE1\n");
|
||||||
|
printf("[ATE0]Usage to set ethernet as default interface: ATE1=1\n");
|
||||||
|
printf("[ATE0]Usage to set wlan as default interface: ATE1=0\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log_item_t at_ethernet_items[ ] = {
|
||||||
|
{"ATE0", fATE0,},
|
||||||
|
{"ATE1", fATE1,}
|
||||||
|
};
|
||||||
|
|
||||||
|
void at_ethernet_init(void)
|
||||||
|
{
|
||||||
|
log_service_add_table(at_ethernet_items, sizeof(at_ethernet_items)/sizeof(at_ethernet_items[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
log_module_init(at_ethernet_init);
|
||||||
|
|
||||||
|
#endif
|
2263
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_lwip.c
Normal file
2263
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_lwip.c
Normal file
File diff suppressed because it is too large
Load diff
100
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_lwip.h
Normal file
100
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_lwip.h
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
#ifndef __ATCMD_LWIP_H__
|
||||||
|
#define __ATCMD_LWIP_H__
|
||||||
|
|
||||||
|
#include <platform_opts.h>
|
||||||
|
#ifdef CONFIG_AT_LWIP
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include <lwip/opt.h>
|
||||||
|
#include "lwip/sockets.h"
|
||||||
|
#include "lwip/api.h"
|
||||||
|
#include "lwip/sys.h"
|
||||||
|
#include "lwip/igmp.h"
|
||||||
|
#include "lwip/inet.h"
|
||||||
|
#include "lwip/tcp.h"
|
||||||
|
#include "lwip/raw.h"
|
||||||
|
#include "lwip/udp.h"
|
||||||
|
#include "lwip/tcpip.h"
|
||||||
|
#include "lwip/pbuf.h"
|
||||||
|
#include "lwip/netdb.h"
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define _AT_TRANSPORT_MODE_ "ATP1"
|
||||||
|
#define _AT_TRANSPORT_LOCAL_PORT_ "ATP2"
|
||||||
|
#define _AT_TRANSPORT_REMOTE_IP_ "ATP3"
|
||||||
|
#define _AT_TRANSPORT_REMOTE_PORT_ "ATP4"
|
||||||
|
#define _AT_TRANSPORT_START_SERVER_ "ATP5"
|
||||||
|
#define _AT_TRANSPORT_START_CLIENT_ "ATP6"
|
||||||
|
#define _AT_TRANSPORT_SHOW_SETTING_ "ATP?"
|
||||||
|
#define _AT_TRANSPORT_RECEIVE_DATA_ "ATR0"
|
||||||
|
#define _AT_TRANSPORT_RECEIVE_PACKET_SIZE_ "ATR1"
|
||||||
|
#define _AT_TRANSPORT_WRITE_DATA_ "ATRA"
|
||||||
|
#define _AT_TRANSPORT_WRITE_PACKET_SIZE_ "ATRB"
|
||||||
|
|
||||||
|
#define NODE_MODE_TCP 0
|
||||||
|
#define NODE_MODE_UDP 1
|
||||||
|
|
||||||
|
#define NODE_ROLE_SERVER 0
|
||||||
|
#define NODE_ROLE_CLIENT 1
|
||||||
|
#define NODE_ROLE_SEED 2
|
||||||
|
|
||||||
|
#define INVALID_SOCKET_ID (-1)
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
#ifndef NET_IF_NUM
|
||||||
|
#define NET_IF_NUM 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ATCMD_LWIP_TASK_PRIORITY (tskIDLE_PRIORITY + 1)
|
||||||
|
|
||||||
|
#if ATCMD_VER == ATVER_2
|
||||||
|
|
||||||
|
#define SERVER "127.0.0.1"
|
||||||
|
|
||||||
|
#define NUM_NS (MEMP_NUM_NETCONN) //maximum number of node and seed, same as NUM_SOCKETS
|
||||||
|
|
||||||
|
#define ETH_MAX_MTU 1500
|
||||||
|
|
||||||
|
#define INVALID_CON_ID (-1)
|
||||||
|
|
||||||
|
#define RECV_SELECT_TIMEOUT_SEC (0)
|
||||||
|
#define RECV_SELECT_TIMEOUT_USEC (20000) //20ms
|
||||||
|
|
||||||
|
typedef struct ns
|
||||||
|
{
|
||||||
|
int con_id;
|
||||||
|
int sockfd;
|
||||||
|
s8_t role;
|
||||||
|
int protocol;
|
||||||
|
u32_t addr;
|
||||||
|
u16_t port;
|
||||||
|
u32_t local_addr;
|
||||||
|
u16_t local_port;
|
||||||
|
xTaskHandle handletask;
|
||||||
|
struct ns* next;
|
||||||
|
struct ns* nextseed;
|
||||||
|
} node;
|
||||||
|
|
||||||
|
extern xTaskHandle atcmd_lwip_tt_task;
|
||||||
|
extern xSemaphoreHandle atcmd_lwip_tt_sema;
|
||||||
|
extern volatile int atcmd_lwip_tt_datasize;
|
||||||
|
extern volatile int atcmd_lwip_tt_lasttickcnt;
|
||||||
|
#define ATCMD_LWIP_TT_MAX_DELAY_TIME_MS (20) //transparent transmission interval
|
||||||
|
|
||||||
|
extern int atcmd_lwip_is_tt_mode(void);
|
||||||
|
extern void atcmd_lwip_set_tt_mode(int enable);
|
||||||
|
int atcmd_lwip_send_data(node *curnode, u8 *data, u16 data_sz, struct sockaddr_in cli_addr);
|
||||||
|
int atcmd_lwip_receive_data(node *curnode, u8 *buffer, u16 buffer_size, int *recv_size,
|
||||||
|
u8_t *udp_clientaddr, u16_t *udp_clientport);
|
||||||
|
node* create_node(int mode, s8_t role);
|
||||||
|
void init_node_pool(void);
|
||||||
|
void delete_node(node *n);
|
||||||
|
int hang_node(node* insert_node);
|
||||||
|
int hang_seednode(node* main_node ,node* insert_node);
|
||||||
|
node *seek_node(int con_id);
|
||||||
|
node *tryget_node(int n);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //#ifdef CONFIG_AT_LWIP
|
||||||
|
#endif //#ifndef __ATCMD_LWIP_H__
|
195
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_mp.c
Normal file
195
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_mp.c
Normal file
|
@ -0,0 +1,195 @@
|
||||||
|
#include <platform_stdlib.h>
|
||||||
|
#include <platform_opts.h>
|
||||||
|
#include <gpio_api.h>
|
||||||
|
#include "log_service.h"
|
||||||
|
#include "atcmd_mp.h"
|
||||||
|
|
||||||
|
#if CONFIG_ATCMD_MP_EXT0
|
||||||
|
extern void fATM0(void *arg); // MP ext0 AT command
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ATCMD_MP
|
||||||
|
//-------- AT MP commands ---------------------------------------------------------------
|
||||||
|
void fATMG(void *arg)
|
||||||
|
{
|
||||||
|
gpio_t gpio_test;
|
||||||
|
int argc = 0, val, cnts, i, write=0, data=0;
|
||||||
|
char *argv[MAX_ARGC] = {0}, port, num;
|
||||||
|
PinName pin = NC;
|
||||||
|
u32 tConfigDebugInfo = ConfigDebugInfo;
|
||||||
|
|
||||||
|
AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "[ATMG]: _AT_MP_GPIO_TEST_");
|
||||||
|
if(!arg){
|
||||||
|
AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "[ATMG] Usage: ATSG=w,PINNAMES(ex:A0B1C2...),VALUE(0/1)");
|
||||||
|
AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "[ATMG] Usage: ATSG=r,PINNAMES(ex:A0B1C2...)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
argc = parse_param(arg, argv);
|
||||||
|
cnts = strlen(argv[2]);
|
||||||
|
if(cnts % 2) return;
|
||||||
|
cnts /= 2;
|
||||||
|
if(cnts == 0) return;
|
||||||
|
|
||||||
|
if(strcmp(argv[1], "w") == 0){
|
||||||
|
write = 1;
|
||||||
|
if(strcmp(argv[3], "1") == 0)
|
||||||
|
data = 1;
|
||||||
|
}
|
||||||
|
// Remove debug info massage
|
||||||
|
_AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "[ATMG] %s: ", argv[1]);
|
||||||
|
ConfigDebugInfo = 0;
|
||||||
|
for(i=0; i<(cnts*2); i+=2){
|
||||||
|
pin = NC;
|
||||||
|
port = argv[2][i];
|
||||||
|
num = argv[2][i+1];
|
||||||
|
if(port >= 'a' && port <= 'z')
|
||||||
|
port -= ('a' - 'A');
|
||||||
|
if(num >= 'a' && num <= 'z')
|
||||||
|
num -= ('a' - 'A');
|
||||||
|
switch(port){
|
||||||
|
case 'A':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PA_0; break; case '1': pin = PA_1; break; case '2': pin = PA_2; break; case '3': pin = PA_3; break;
|
||||||
|
case '4': pin = PA_4; break; case '5': pin = PA_5; break; case '6': pin = PA_6; break; case '7': pin = PA_7; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PB_0; break; case '1': pin = PB_1; break; case '2': pin = PB_2; break; case '3': pin = PB_3; break;
|
||||||
|
case '4': pin = PB_4; break; case '5': pin = PB_5; break; case '6': pin = PB_6; break; case '7': pin = PB_7; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PC_0; break; case '1': pin = PC_1; break; case '2': pin = PC_2; break; case '3': pin = PC_3; break;
|
||||||
|
case '4': pin = PC_4; break; case '5': pin = PC_5; break; case '6': pin = PC_6; break; case '7': pin = PC_7; break;
|
||||||
|
case '8': pin = PC_8; break; case '9': pin = PC_9; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PD_0; break; case '1': pin = PD_1; break; case '2': pin = PD_2; break; case '3': pin = PD_3; break;
|
||||||
|
case '4': pin = PD_4; break; case '5': pin = PD_5; break; case '6': pin = PD_6; break; case '7': pin = PD_7; break;
|
||||||
|
case '8': pin = PD_8; break; case '9': pin = PD_9; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PE_0; break; case '1': pin = PE_1; break; case '2': pin = PE_2; break; case '3': pin = PE_3; break;
|
||||||
|
case '4': pin = PE_4; break; case '5': pin = PE_5; break; case '6': pin = PE_6; break; case '7': pin = PE_7; break;
|
||||||
|
case '8': pin = PE_8; break; case '9': pin = PE_9; break; case 'A': pin = PE_A; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PF_0; break; case '1': pin = PF_1; break; case '2': pin = PF_2; break; case '3': pin = PF_3; break;
|
||||||
|
case '4': pin = PF_4; break; case '5': pin = PF_5; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'G':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PG_0; break; case '1': pin = PG_1; break; case '2': pin = PG_2; break; case '3': pin = PG_3; break;
|
||||||
|
case '4': pin = PG_4; break; case '5': pin = PG_5; break; case '6': pin = PG_6; break; case '7': pin = PG_7; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PH_0; break; case '1': pin = PH_1; break; case '2': pin = PH_2; break; case '3': pin = PH_3; break;
|
||||||
|
case '4': pin = PH_4; break; case '5': pin = PH_5; break; case '6': pin = PH_6; break; case '7': pin = PH_7; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PI_0; break; case '1': pin = PI_1; break; case '2': pin = PI_2; break; case '3': pin = PI_3; break;
|
||||||
|
case '4': pin = PI_4; break; case '5': pin = PI_5; break; case '6': pin = PI_6; break; case '7': pin = PI_7; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'J':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PJ_0; break; case '1': pin = PJ_1; break; case '2': pin = PJ_2; break; case '3': pin = PJ_3; break;
|
||||||
|
case '4': pin = PJ_4; break; case '5': pin = PJ_5; break; case '6': pin = PJ_6; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'K':
|
||||||
|
switch(num){
|
||||||
|
case '0': pin = PK_0; break; case '1': pin = PK_1; break; case '2': pin = PK_2; break; case '3': pin = PK_3; break;
|
||||||
|
case '4': pin = PK_4; break; case '5': pin = PK_5; break; case '6': pin = PK_6; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(pin == NC){
|
||||||
|
_AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "X,");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Initial input control pin
|
||||||
|
gpio_init(&gpio_test, pin);
|
||||||
|
if(write){
|
||||||
|
gpio_dir(&gpio_test, PIN_OUTPUT); // Direction: Output
|
||||||
|
gpio_mode(&gpio_test, PullNone); // No pull
|
||||||
|
gpio_write(&gpio_test, data);
|
||||||
|
_AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "%d,", data);
|
||||||
|
}else{
|
||||||
|
gpio_dir(&gpio_test, PIN_INPUT); // Direction: Input
|
||||||
|
gpio_mode(&gpio_test, PullUp); // Pull-High
|
||||||
|
val = gpio_read(&gpio_test);
|
||||||
|
_AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "%d,", val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_AT_DBG_MSG(AT_FLAG_GPIO, AT_DBG_ALWAYS, "\n");
|
||||||
|
// Recover debug info massage
|
||||||
|
ConfigDebugInfo = tConfigDebugInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fATMR(void *arg)
|
||||||
|
{
|
||||||
|
u32 idx;
|
||||||
|
|
||||||
|
AT_PRINTK("[ATMR]: _AT_MP_SDR_TEST_");
|
||||||
|
#ifdef CONFIG_SDR_EN
|
||||||
|
for (idx = 0; idx < 0x200000; idx = idx+4){
|
||||||
|
HAL_WRITE32(0x30000000, idx, 0x12345678);
|
||||||
|
if (HAL_READ32(0x30000000, idx) != 0x12345678) {
|
||||||
|
AT_PRINTK("[ATMR]: SDR test fail addr 0x08x, value 0x08%x",(0x30000000+idx),HAL_READ32(0x30000000, idx));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AT_PRINTK("[ATMR]: SDR test success");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void fATMt(void *arg)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
char *argv[MAX_ARGC] = {0};
|
||||||
|
|
||||||
|
AT_PRINTK("[ATM#]: _AT_MP_TEST_");
|
||||||
|
argc = parse_param(arg, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fATMx(void *arg)
|
||||||
|
{
|
||||||
|
AT_PRINTK("[ATM?]: _AT_MP_HELP_");
|
||||||
|
}
|
||||||
|
|
||||||
|
log_item_t at_mp_items[] = {
|
||||||
|
{"ATMG", fATMG,}, // MP GPIO test
|
||||||
|
{"ATMR", fATMR,}, // MP SDR test
|
||||||
|
{"ATM#", fATMt,}, // test command
|
||||||
|
{"ATM?", fATMx,}, // Help
|
||||||
|
#if CONFIG_ATCMD_MP_EXT0
|
||||||
|
{"ATM0", fATM0,}, // MP ext0 AT command
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
void at_mp_init(void)
|
||||||
|
{
|
||||||
|
log_service_add_table(at_mp_items, sizeof(at_mp_items)/sizeof(at_mp_items[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SUPPORT_LOG_SERVICE
|
||||||
|
log_module_init(at_mp_init);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // #if CONFIG_ATCMD_MP
|
||||||
|
|
12
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_mp.h
Normal file
12
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_mp.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef __ATCMD_MP_H__
|
||||||
|
#define __ATCMD_MP_H__
|
||||||
|
|
||||||
|
#define CONFIG_ATCMD_MP_EXT0 0 //support MP ext0 AT command
|
||||||
|
|
||||||
|
typedef struct _at_command_mp_ext_item_{
|
||||||
|
char *mp_ext_cmd;
|
||||||
|
int (*mp_ext_fun)(void **argv, int argc);
|
||||||
|
char *mp_ext_usage;
|
||||||
|
}at_mp_ext_item_t;
|
||||||
|
|
||||||
|
#endif
|
1434
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_sys.c
Normal file
1434
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_sys.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef __ATCMD_SYS_H__
|
||||||
|
#define __ATCMD_SYS_H__
|
||||||
|
#ifdef CONFIG_AT_SYS
|
||||||
|
#endif //
|
||||||
|
|
||||||
|
#endif
|
2836
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi.c
Normal file
2836
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi.c
Normal file
File diff suppressed because it is too large
Load diff
166
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi.h
Normal file
166
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi.h
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
#ifndef __ATCMD_WIFI_H__
|
||||||
|
#define __ATCMD_WIFI_H__
|
||||||
|
#include <platform_opts.h>
|
||||||
|
#include "main.h"
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#ifdef USE_FLASH_EEP
|
||||||
|
#include "flash_eep.h"
|
||||||
|
#include "feep_config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WLAN0_NAME
|
||||||
|
#define WLAN0_NAME "wlan0"
|
||||||
|
#endif
|
||||||
|
#ifndef WLAN1_NAME
|
||||||
|
#define WLAN1_NAME "wlan1"
|
||||||
|
#endif
|
||||||
|
/* Give default value if not defined */
|
||||||
|
#ifndef NET_IF_NUM
|
||||||
|
#ifdef CONFIG_CONCURRENT_MODE
|
||||||
|
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN) + 1)
|
||||||
|
#else
|
||||||
|
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN))
|
||||||
|
#endif // end of CONFIG_CONCURRENT_MODE
|
||||||
|
#endif // end of NET_IF_NUM
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef IP_ADDR0
|
||||||
|
#define IP_ADDR0 192
|
||||||
|
#define IP_ADDR1 168
|
||||||
|
#define IP_ADDR2 3
|
||||||
|
#define IP_ADDR3 80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef NETMASK_ADDR0
|
||||||
|
#define NETMASK_ADDR0 255
|
||||||
|
#define NETMASK_ADDR1 255
|
||||||
|
#define NETMASK_ADDR2 255
|
||||||
|
#define NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef GW_ADDR0
|
||||||
|
#define GW_ADDR0 192
|
||||||
|
#define GW_ADDR1 168
|
||||||
|
#define GW_ADDR2 3
|
||||||
|
#define GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef AP_IP_ADDR0
|
||||||
|
#define AP_IP_ADDR0 192
|
||||||
|
#define AP_IP_ADDR1 168
|
||||||
|
#define AP_IP_ADDR2 43
|
||||||
|
#define AP_IP_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef AP_NETMASK_ADDR0
|
||||||
|
#define AP_NETMASK_ADDR0 255
|
||||||
|
#define AP_NETMASK_ADDR1 255
|
||||||
|
#define AP_NETMASK_ADDR2 255
|
||||||
|
#define AP_NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef AP_GW_ADDR0
|
||||||
|
#define AP_GW_ADDR0 192
|
||||||
|
#define AP_GW_ADDR1 168
|
||||||
|
#define AP_GW_ADDR2 43
|
||||||
|
#define AP_GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||||
|
#include "wifi_structures.h"
|
||||||
|
#include <wlan_fast_connect/example_wlan_fast_connect.h>
|
||||||
|
typedef struct _UART_LOG_CONF_{
|
||||||
|
u32 BaudRate;
|
||||||
|
u8 DataBits;
|
||||||
|
u8 StopBits;
|
||||||
|
u8 Parity;
|
||||||
|
u8 FlowControl;
|
||||||
|
}UART_LOG_CONF, *PUART_LOG_CONF;
|
||||||
|
|
||||||
|
#define ATCMD_WIFI_CONN_STORE_MAX_NUM (1)
|
||||||
|
struct atcmd_wifi_conf{
|
||||||
|
int32_t auto_enable;
|
||||||
|
rtw_wifi_setting_t setting;
|
||||||
|
int32_t reconn_num;
|
||||||
|
int32_t reconn_last_index;
|
||||||
|
struct wlan_fast_reconnect reconn[ATCMD_WIFI_CONN_STORE_MAX_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ATCMD_LWIP_CONN_STORE_MAX_NUM (1)
|
||||||
|
struct atcmd_lwip_conn_info{
|
||||||
|
int32_t role; //client, server or seed
|
||||||
|
uint32_t protocol; //tcp or udp
|
||||||
|
uint32_t remote_addr; //remote ip
|
||||||
|
uint32_t remote_port; //remote port
|
||||||
|
uint32_t local_addr; //locale ip, not used yet
|
||||||
|
uint32_t local_port; //locale port, not used yet
|
||||||
|
uint32_t reserved; //reserve for further use
|
||||||
|
};
|
||||||
|
struct atcmd_lwip_conf {
|
||||||
|
int32_t enable; //enable or not
|
||||||
|
int32_t conn_num;
|
||||||
|
int32_t last_index;
|
||||||
|
int32_t reserved; //reserve for further use
|
||||||
|
struct atcmd_lwip_conn_info conn[ATCMD_LWIP_CONN_STORE_MAX_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AT_PARTITION_ALL = 0,
|
||||||
|
AT_PARTITION_UART = 1,
|
||||||
|
AT_PARTITION_WIFI = 2,
|
||||||
|
AT_PARTITION_LWIP = 3
|
||||||
|
} AT_PARTITION;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AT_PARTITION_READ = 0,
|
||||||
|
AT_PARTITION_WRITE = 1,
|
||||||
|
AT_PARTITION_ERASE = 2
|
||||||
|
} AT_PARTITION_OP;
|
||||||
|
|
||||||
|
//first segment for uart
|
||||||
|
#define UART_SETTING_BACKUP_SECTOR (0x8000)
|
||||||
|
#define UART_CONF_DATA_OFFSET (0)
|
||||||
|
#define UART_CONF_DATA_SIZE ((((sizeof(UART_LOG_CONF)-1)>>2) + 1)<<2)
|
||||||
|
|
||||||
|
//second segment for wifi config
|
||||||
|
#define WIFI_CONF_DATA_OFFSET (UART_CONF_DATA_OFFSET+UART_CONF_DATA_SIZE)
|
||||||
|
#define WIFI_CONF_DATA_SIZE ((((sizeof(struct atcmd_wifi_conf)-1)>>2) + 1)<<2)
|
||||||
|
|
||||||
|
//fouth segment for lwip config
|
||||||
|
#define LWIP_CONF_DATA_OFFSET (WIFI_CONF_DATA_OFFSET+WIFI_CONF_DATA_SIZE)
|
||||||
|
#define LWIP_CONF_DATA_SIZE ((((sizeof(struct atcmd_lwip_conf)-1)>>2) + 1)<<2)
|
||||||
|
|
||||||
|
extern void atcmd_update_partition_info(AT_PARTITION id, AT_PARTITION_OP ops, u8 *data, u16 len);
|
||||||
|
|
||||||
|
#define ATSTRING_LEN (LOG_SERVICE_BUFLEN)
|
||||||
|
extern char at_string[ATSTRING_LEN];
|
||||||
|
|
||||||
|
extern unsigned char gAT_Echo; // default echo on
|
||||||
|
//extern void uart_at_lock(void);
|
||||||
|
//extern void uart_at_unlock(void);
|
||||||
|
extern void uart_at_send_string(char *str);
|
||||||
|
extern void uart_at_send_buf(u8 *buf, u32 len);
|
||||||
|
|
||||||
|
#define at_printf(fmt, args...) do{\
|
||||||
|
/*uart_at_lock();*/\
|
||||||
|
snprintf(at_string, ATSTRING_LEN, fmt, ##args); \
|
||||||
|
uart_at_send_string(at_string);\
|
||||||
|
/*uart_at_unlock();*/\
|
||||||
|
}while(0)
|
||||||
|
#define at_print_data(data, size) do{\
|
||||||
|
/*uart_at_lock();*/\
|
||||||
|
uart_at_send_buf(data, size);\
|
||||||
|
/*uart_at_unlock();*/\
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define at_printf(fmt, args...) do{printf(fmt, ##args);}while(0)
|
||||||
|
#define at_print_data(data, size) do{__rtl_memDump(data, size, NULL);}while(0)
|
||||||
|
#endif//#if CONFIG_EXAMPLE_UART_ATCMD
|
||||||
|
|
||||||
|
#endif
|
2873
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi1.c
Normal file
2873
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi1.c
Normal file
File diff suppressed because it is too large
Load diff
171
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi1.h
Normal file
171
Firmware/RTLGDB/USDK/component/common/api/at_cmd/atcmd_wifi1.h
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
#ifndef __ATCMD_WIFI_H__
|
||||||
|
#define __ATCMD_WIFI_H__
|
||||||
|
#include <platform_opts.h>
|
||||||
|
#ifdef CONFIG_AT_WIFI
|
||||||
|
#include "main.h"
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#ifdef USE_FLASH_EEP
|
||||||
|
#include "flash_eep.h"
|
||||||
|
#include "feep_config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WLAN0_NAME
|
||||||
|
#define WLAN0_NAME "wlan0"
|
||||||
|
#endif
|
||||||
|
#ifndef WLAN1_NAME
|
||||||
|
#define WLAN1_NAME "wlan1"
|
||||||
|
#endif
|
||||||
|
/* Give default value if not defined */
|
||||||
|
#ifndef NET_IF_NUM
|
||||||
|
#ifdef CONFIG_CONCURRENT_MODE
|
||||||
|
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN) + 1)
|
||||||
|
#else
|
||||||
|
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN))
|
||||||
|
#endif // end of CONFIG_CONCURRENT_MODE
|
||||||
|
#endif // end of NET_IF_NUM
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef IP_ADDR0
|
||||||
|
#define IP_ADDR0 192
|
||||||
|
#define IP_ADDR1 168
|
||||||
|
#define IP_ADDR2 3
|
||||||
|
#define IP_ADDR3 80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef NETMASK_ADDR0
|
||||||
|
#define NETMASK_ADDR0 255
|
||||||
|
#define NETMASK_ADDR1 255
|
||||||
|
#define NETMASK_ADDR2 255
|
||||||
|
#define NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef GW_ADDR0
|
||||||
|
#define GW_ADDR0 192
|
||||||
|
#define GW_ADDR1 168
|
||||||
|
#define GW_ADDR2 3
|
||||||
|
#define GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef AP_IP_ADDR0
|
||||||
|
#define AP_IP_ADDR0 192
|
||||||
|
#define AP_IP_ADDR1 168
|
||||||
|
#define AP_IP_ADDR2 43
|
||||||
|
#define AP_IP_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef AP_NETMASK_ADDR0
|
||||||
|
#define AP_NETMASK_ADDR0 255
|
||||||
|
#define AP_NETMASK_ADDR1 255
|
||||||
|
#define AP_NETMASK_ADDR2 255
|
||||||
|
#define AP_NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef AP_GW_ADDR0
|
||||||
|
#define AP_GW_ADDR0 192
|
||||||
|
#define AP_GW_ADDR1 168
|
||||||
|
#define AP_GW_ADDR2 43
|
||||||
|
#define AP_GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CONFIG_AT_WIFI
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||||
|
|
||||||
|
#include "wifi_structures.h"
|
||||||
|
#include <wlan_fast_connect/example_wlan_fast_connect.h>
|
||||||
|
typedef struct _UART_LOG_CONF_{
|
||||||
|
u32 BaudRate;
|
||||||
|
u8 DataBits;
|
||||||
|
u8 StopBits;
|
||||||
|
u8 Parity;
|
||||||
|
u8 FlowControl;
|
||||||
|
}UART_LOG_CONF, *PUART_LOG_CONF;
|
||||||
|
|
||||||
|
#define ATCMD_WIFI_CONN_STORE_MAX_NUM (1)
|
||||||
|
struct atcmd_wifi_conf{
|
||||||
|
struct wlan_fast_reconnect reconn[ATCMD_WIFI_CONN_STORE_MAX_NUM];
|
||||||
|
int32_t auto_enable;
|
||||||
|
rtw_wifi_setting_t setting;
|
||||||
|
int32_t reconn_num;
|
||||||
|
int32_t reconn_last_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ATCMD_LWIP_CONN_STORE_MAX_NUM (1)
|
||||||
|
struct atcmd_lwip_conn_info{
|
||||||
|
int32_t role; //client, server or seed
|
||||||
|
uint32_t protocol; //tcp or udp
|
||||||
|
uint32_t remote_addr; //remote ip
|
||||||
|
uint32_t remote_port; //remote port
|
||||||
|
uint32_t local_addr; //locale ip, not used yet
|
||||||
|
uint32_t local_port; //locale port, not used yet
|
||||||
|
uint32_t reserved; //reserve for further use
|
||||||
|
};
|
||||||
|
struct atcmd_lwip_conf {
|
||||||
|
int32_t enable; //enable or not
|
||||||
|
int32_t conn_num;
|
||||||
|
int32_t last_index;
|
||||||
|
int32_t reserved; //reserve for further use
|
||||||
|
struct atcmd_lwip_conn_info conn[ATCMD_LWIP_CONN_STORE_MAX_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AT_PARTITION_ALL = 0,
|
||||||
|
AT_PARTITION_UART = FEEP_ID_UART_CFG,
|
||||||
|
AT_PARTITION_WIFI = FEEP_ID_WIFI_CFG,
|
||||||
|
AT_PARTITION_LWIP = FEEP_ID_LWIP_CFG
|
||||||
|
} AT_PARTITION;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AT_PARTITION_READ = 0,
|
||||||
|
AT_PARTITION_WRITE = 1,
|
||||||
|
AT_PARTITION_ERASE = 2
|
||||||
|
} AT_PARTITION_OP;
|
||||||
|
|
||||||
|
//first segment for uart
|
||||||
|
#define UART_SETTING_BACKUP_SECTOR (0x8000)
|
||||||
|
#define UART_CONF_DATA_OFFSET (0)
|
||||||
|
#define UART_CONF_DATA_SIZE ((((sizeof(UART_LOG_CONF)-1)>>2) + 1)<<2)
|
||||||
|
|
||||||
|
//second segment for wifi config
|
||||||
|
#define WIFI_CONF_DATA_OFFSET (UART_CONF_DATA_OFFSET+UART_CONF_DATA_SIZE)
|
||||||
|
#define WIFI_CONF_DATA_SIZE ((((sizeof(struct atcmd_wifi_conf)-1)>>2) + 1)<<2)
|
||||||
|
|
||||||
|
//fouth segment for lwip config
|
||||||
|
#define LWIP_CONF_DATA_OFFSET (WIFI_CONF_DATA_OFFSET+WIFI_CONF_DATA_SIZE)
|
||||||
|
#define LWIP_CONF_DATA_SIZE ((((sizeof(struct atcmd_lwip_conf)-1)>>2) + 1)<<2)
|
||||||
|
|
||||||
|
extern void atcmd_update_partition_info(AT_PARTITION id, AT_PARTITION_OP ops, u8 *data, u16 len);
|
||||||
|
|
||||||
|
#define ATSTRING_LEN (LOG_SERVICE_BUFLEN)
|
||||||
|
extern char at_string[ATSTRING_LEN];
|
||||||
|
|
||||||
|
extern unsigned char gAT_Echo; // default echo on
|
||||||
|
//extern void uart_at_lock(void);
|
||||||
|
//extern void uart_at_unlock(void);
|
||||||
|
extern void uart_at_send_string(char *str);
|
||||||
|
extern void uart_at_send_buf(u8 *buf, u32 len);
|
||||||
|
|
||||||
|
#define at_printf(fmt, args...) do{\
|
||||||
|
/*uart_at_lock();*/\
|
||||||
|
snprintf(at_string, ATSTRING_LEN, fmt, ##args); \
|
||||||
|
uart_at_send_string(at_string);\
|
||||||
|
/*uart_at_unlock();*/\
|
||||||
|
}while(0)
|
||||||
|
#define at_print_data(data, size) do{\
|
||||||
|
/*uart_at_lock();*/\
|
||||||
|
uart_at_send_buf(data, size);\
|
||||||
|
/*uart_at_unlock();*/\
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define at_printf(fmt, args...) do{printf(fmt, ##args);}while(0)
|
||||||
|
#define at_print_data(data, size) do{__rtl_memDump(data, size, NULL);}while(0)
|
||||||
|
#endif//#if CONFIG_EXAMPLE_UART_ATCMD
|
||||||
|
|
||||||
|
#endif
|
497
Firmware/RTLGDB/USDK/component/common/api/at_cmd/log_service.c
Normal file
497
Firmware/RTLGDB/USDK/component/common/api/at_cmd/log_service.c
Normal file
|
@ -0,0 +1,497 @@
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||||
|
#include "freertos_pmu.h"
|
||||||
|
#endif
|
||||||
|
#include "log_service.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "wifi_util.h"
|
||||||
|
#include "atcmd_wifi.h"
|
||||||
|
#include "osdep_api.h"
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||||
|
#include "atcmd_lwip.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SUPPORT_LOG_SERVICE
|
||||||
|
//======================================================
|
||||||
|
struct list_head log_hash[ATC_INDEX_NUM];
|
||||||
|
#ifdef CONFIG_AT_USR
|
||||||
|
extern void at_user_init(void);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_AT_WIFI
|
||||||
|
extern void at_wifi_init(void);
|
||||||
|
#endif
|
||||||
|
//extern void at_fs_init(void);
|
||||||
|
|
||||||
|
#ifdef CONFIG_AT_SYS
|
||||||
|
extern void at_sys_init(void);
|
||||||
|
#endif
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
extern void at_ethernet_init(void);
|
||||||
|
#endif
|
||||||
|
#if CONFIG_GOOGLE_NEST
|
||||||
|
extern void at_google_init(void);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_AT_LWIP
|
||||||
|
extern void at_transport_init(void);
|
||||||
|
#endif
|
||||||
|
//extern void at_app_init(void);
|
||||||
|
#if CONFIG_ALINK
|
||||||
|
extern void at_cloud_init(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
char log_buf[LOG_SERVICE_BUFLEN];
|
||||||
|
#if CONFIG_LOG_HISTORY
|
||||||
|
char log_history[LOG_HISTORY_LEN][LOG_SERVICE_BUFLEN];
|
||||||
|
static unsigned int log_history_count = 0;
|
||||||
|
#endif
|
||||||
|
xSemaphoreHandle log_rx_interrupt_sema = NULL;
|
||||||
|
#if CONFIG_LOG_SERVICE_LOCK
|
||||||
|
xSemaphoreHandle log_service_sema = NULL;
|
||||||
|
#endif
|
||||||
|
extern xSemaphoreHandle uart_rx_interrupt_sema;
|
||||||
|
|
||||||
|
#if CONFIG_INIC_EN
|
||||||
|
extern unsigned char inic_cmd_ioctl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__ICCARM__)
|
||||||
|
#pragma section=".data.log_init"
|
||||||
|
|
||||||
|
unsigned int __log_init_begin__;
|
||||||
|
unsigned int __log_init_end__;
|
||||||
|
#elif defined ( __CC_ARM ) || defined(__GNUC__)
|
||||||
|
//#pragma section=".data.log_init"
|
||||||
|
log_init_t* __log_init_begin__;
|
||||||
|
log_init_t* __log_init_end__;
|
||||||
|
log_init_t log_init_table[] = {
|
||||||
|
|
||||||
|
#ifdef CONFIG_AT_WIFI
|
||||||
|
at_wifi_init,
|
||||||
|
#endif
|
||||||
|
// at_fs_init,
|
||||||
|
#ifdef CONFIG_AT_SYS
|
||||||
|
at_sys_init,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
at_ethernet_init
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_GOOGLE_NEST
|
||||||
|
at_google_init
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_TRANSPORT
|
||||||
|
at_transport_init
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ALINK
|
||||||
|
at_cloud_init
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_AT_USR
|
||||||
|
at_user_init
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// at_app_init
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
#error "not implement, add to linker script"
|
||||||
|
extern unsigned int __log_init_begin__;
|
||||||
|
extern unsigned int __log_init_end__;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define USE_STRSEP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//======================================================
|
||||||
|
int hash_index(char *str)
|
||||||
|
{
|
||||||
|
unsigned int seed = 131; // 31 131 1313 13131 131313 etc..
|
||||||
|
unsigned int hash = 0;
|
||||||
|
|
||||||
|
while (*str)
|
||||||
|
{
|
||||||
|
hash = hash * seed + (*str++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (hash & 0x7FFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_add_new_command(log_item_t *new)
|
||||||
|
{
|
||||||
|
int index = hash_index(new->log_cmd)%ATC_INDEX_NUM;
|
||||||
|
|
||||||
|
list_add(&new->node, &log_hash[index]);
|
||||||
|
}
|
||||||
|
void start_log_service(void);
|
||||||
|
void log_service_init(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
#if defined (__ICCARM__)
|
||||||
|
log_init_t *log_init_table;
|
||||||
|
__log_init_begin__ = (unsigned int)__section_begin(".data.log_init");
|
||||||
|
__log_init_end__ = (unsigned int)__section_end(".data.log_init");
|
||||||
|
log_init_table = (log_init_t *)__log_init_begin__;
|
||||||
|
#elif defined(__CC_ARM) || defined(__GNUC__)
|
||||||
|
__log_init_begin__ = log_init_table;
|
||||||
|
__log_init_end__ = log_init_table + sizeof(log_init_table);
|
||||||
|
#else
|
||||||
|
#error "not implement"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
for(i=0;i<ATC_INDEX_NUM;i++)
|
||||||
|
INIT_LIST_HEAD(&log_hash[i]);
|
||||||
|
|
||||||
|
for(i=0;i<(__log_init_end__-__log_init_begin__)/sizeof(log_init_t); i++)
|
||||||
|
log_init_table[i]();
|
||||||
|
|
||||||
|
/* Initial uart rx swmaphore*/
|
||||||
|
vSemaphoreCreateBinary(log_rx_interrupt_sema);
|
||||||
|
xSemaphoreTake(log_rx_interrupt_sema, 1/portTICK_RATE_MS);
|
||||||
|
#if CONFIG_LOG_SERVICE_LOCK
|
||||||
|
log_service_lock_init();
|
||||||
|
#endif
|
||||||
|
start_log_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
//sizeof(log_items)/sizeof(log_items[0])
|
||||||
|
void log_service_add_table(log_item_t *tbl, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0;i<len;i++)
|
||||||
|
log_add_new_command(&tbl[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* log_action(char *cmd)
|
||||||
|
{
|
||||||
|
int search_cnt=0;
|
||||||
|
int index = hash_index(cmd)%ATC_INDEX_NUM;
|
||||||
|
struct list_head *head = &log_hash[index];
|
||||||
|
struct list_head *iterator;
|
||||||
|
log_item_t *item;
|
||||||
|
void *act = NULL;
|
||||||
|
|
||||||
|
list_for_each(iterator, head) {
|
||||||
|
item = list_entry(iterator, log_item_t, node);
|
||||||
|
search_cnt++;
|
||||||
|
if( strcmp(item->log_cmd, cmd) == 0){
|
||||||
|
//printf("%s match %s, search cnt %d\n\r", cmd, item->log_cmd, search_cnt);
|
||||||
|
act = (void*)item->at_act;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return act;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* log_handler(char *cmd)
|
||||||
|
{
|
||||||
|
log_act_t action=NULL;
|
||||||
|
char buf[LOG_SERVICE_BUFLEN] = {0};
|
||||||
|
char *copy=buf;
|
||||||
|
char *token = NULL;
|
||||||
|
char *param = NULL;
|
||||||
|
char tok[5] = {0};//'\0'
|
||||||
|
#if CONFIG_LOG_HISTORY
|
||||||
|
strcpy(log_history[((log_history_count++)%LOG_HISTORY_LEN)], log_buf);
|
||||||
|
#endif
|
||||||
|
strncpy(copy, cmd,LOG_SERVICE_BUFLEN-1);
|
||||||
|
|
||||||
|
#if defined(USE_STRSEP)
|
||||||
|
token = _strsep(©, "=");
|
||||||
|
param = copy;
|
||||||
|
#else
|
||||||
|
token = strtok(copy, "=");
|
||||||
|
param = strtok(NULL, NULL);
|
||||||
|
#endif
|
||||||
|
if(token && (strlen(token) <= 4))
|
||||||
|
strcpy(tok, token);
|
||||||
|
else{
|
||||||
|
//printf("\n\rAT Cmd format error!\n");
|
||||||
|
return NULL;
|
||||||
|
};
|
||||||
|
//printf(" Command %s \n\r ", tok);
|
||||||
|
//printf(" Param %s \n\r", param);
|
||||||
|
action = (log_act_t)log_action(tok);
|
||||||
|
|
||||||
|
if(action){
|
||||||
|
action(param);
|
||||||
|
}
|
||||||
|
return (void*)action;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int parse_param(char *buf, char **argv)
|
||||||
|
{
|
||||||
|
int argc = 1;
|
||||||
|
char str_buf[LOG_SERVICE_BUFLEN] = "\0";
|
||||||
|
int str_count = 0;
|
||||||
|
int buf_cnt = 0;
|
||||||
|
|
||||||
|
if(buf == NULL)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
while((argc < MAX_ARGC) && (*buf != '\0')) {
|
||||||
|
while((*buf == ',') || (*buf == '[') || (*buf == ']')){
|
||||||
|
if((*buf == ',') && (*(buf+1) == ',')){
|
||||||
|
argv[argc] = NULL;
|
||||||
|
argc++;
|
||||||
|
}
|
||||||
|
*buf = '\0';
|
||||||
|
buf++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*buf == '\0')
|
||||||
|
break;
|
||||||
|
else if(*buf == '"'){
|
||||||
|
memset(str_buf,'\0',LOG_SERVICE_BUFLEN);
|
||||||
|
str_count = 0;
|
||||||
|
buf_cnt = 0;
|
||||||
|
*buf = '\0';
|
||||||
|
buf ++;
|
||||||
|
if(*buf == '\0')
|
||||||
|
break;
|
||||||
|
argv[argc] = buf;
|
||||||
|
while((*buf != '"')&&(*buf != '\0')){
|
||||||
|
if(*buf == '\\'){
|
||||||
|
buf ++;
|
||||||
|
buf_cnt++;
|
||||||
|
}
|
||||||
|
str_buf[str_count] = *buf;
|
||||||
|
str_count++;
|
||||||
|
buf_cnt++;
|
||||||
|
buf ++;
|
||||||
|
}
|
||||||
|
*buf = '\0';
|
||||||
|
memcpy(buf-buf_cnt,str_buf,buf_cnt);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
argv[argc] = buf;
|
||||||
|
}
|
||||||
|
argc++;
|
||||||
|
buf++;
|
||||||
|
|
||||||
|
while( (*buf != ',')&&(*buf != '\0')&&(*buf != '[')&&(*buf != ']') )
|
||||||
|
buf++;
|
||||||
|
}
|
||||||
|
exit:
|
||||||
|
return argc;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char gDbgLevel = AT_DBG_ERROR;
|
||||||
|
unsigned int gDbgFlag = 0xFFFFFFFF;
|
||||||
|
void at_set_debug_level(unsigned char newDbgLevel)
|
||||||
|
{
|
||||||
|
gDbgLevel = newDbgLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void at_set_debug_mask(unsigned int newDbgFlag)
|
||||||
|
{
|
||||||
|
gDbgFlag = newDbgFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SUPPORT_INTERACTIVE_MODE
|
||||||
|
extern char uart_buf[64];
|
||||||
|
void legency_interactive_handler(unsigned char argc, unsigned char **argv)
|
||||||
|
{
|
||||||
|
#if 0 //defined(CONFIG_PLATFORM_8195A)
|
||||||
|
if(argc<1)
|
||||||
|
{
|
||||||
|
DiagPrintf("Wrong argument number!\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DiagPrintf("Wlan Normal Mode\n");
|
||||||
|
|
||||||
|
WlanNormal( argc, argv);
|
||||||
|
#else
|
||||||
|
strncpy(uart_buf, log_buf, 63);//uart_buf[64]
|
||||||
|
xSemaphoreGive(uart_rx_interrupt_sema);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
#ifndef WLAN0_NAME
|
||||||
|
#define WLAN0_NAME "wlan0"
|
||||||
|
#endif
|
||||||
|
#ifndef WLAN1_NAME
|
||||||
|
#define WLAN1_NAME "wlan1"
|
||||||
|
#endif
|
||||||
|
int mp_commnad_handler(char *cmd)
|
||||||
|
{
|
||||||
|
char buf[64] = {0};
|
||||||
|
char *token = NULL;
|
||||||
|
|
||||||
|
//strcpy(buf, cmd);
|
||||||
|
strncpy(buf, cmd, (64-1));
|
||||||
|
token = strtok(buf, " ");
|
||||||
|
if(token && (strcmp(buf, "iwpriv") == 0)){
|
||||||
|
token = strtok(NULL, "");
|
||||||
|
wext_private_command(WLAN0_NAME, token, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
void print_help_msg(void){
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
extern void print_wlan_help(void);
|
||||||
|
print_wlan_help();
|
||||||
|
#endif
|
||||||
|
//add other help message print here
|
||||||
|
}
|
||||||
|
|
||||||
|
int print_help_handler(char *cmd){
|
||||||
|
if(strcmp(cmd, "help") == 0){
|
||||||
|
print_help_msg();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_LOG_SERVICE_LOCK
|
||||||
|
void log_service_lock(void)
|
||||||
|
{
|
||||||
|
rtw_down_sema(&log_service_sema);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 log_service_lock_timeout(u32 ms)
|
||||||
|
{
|
||||||
|
return rtw_down_timeout_sema(&log_service_sema, ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_service_unlock(void)
|
||||||
|
{
|
||||||
|
rtw_up_sema(&log_service_sema);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_service_lock_init(void){
|
||||||
|
rtw_init_sema(&log_service_sema, 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void log_service(void *param)
|
||||||
|
{
|
||||||
|
_AT_DBG_MSG(AT_FLAG_COMMON, AT_DBG_ALWAYS, "\n\rStart LOG SERVICE MODE\n\r");
|
||||||
|
_AT_DBG_MSG(AT_FLAG_COMMON, AT_DBG_ALWAYS, "\n\r# ");
|
||||||
|
while(1){
|
||||||
|
while(xSemaphoreTake(log_rx_interrupt_sema, portMAX_DELAY) != pdTRUE);
|
||||||
|
#if CONFIG_LOG_SERVICE_LOCK
|
||||||
|
log_service_lock();
|
||||||
|
#endif
|
||||||
|
if(log_handler((char *)log_buf) == NULL){
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
if(mp_commnad_handler((char *)log_buf) < 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if SUPPORT_INTERACTIVE_MODE
|
||||||
|
print_help_handler((char *)log_buf);
|
||||||
|
legency_interactive_handler(NULL, NULL);
|
||||||
|
#if CONFIG_LOG_SERVICE_LOCK
|
||||||
|
log_service_unlock();
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
#else
|
||||||
|
if(print_help_handler((char *)log_buf) < 0){
|
||||||
|
at_printf("\r\nunknown command '%s'", log_buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log_buf[0] = '\0';
|
||||||
|
#if CONFIG_INIC_EN
|
||||||
|
inic_cmd_ioctl = 0;
|
||||||
|
#endif
|
||||||
|
_AT_DBG_MSG(AT_FLAG_COMMON, AT_DBG_ALWAYS, "\n\r[MEM] After do cmd, available heap %d+%d\n\r", xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||||
|
_AT_DBG_MSG(AT_FLAG_COMMON, AT_DBG_ALWAYS, "\r\n\n# "); //"#" is needed for mp tool
|
||||||
|
#if CONFIG_EXAMPLE_UART_ATCMD
|
||||||
|
if(atcmd_lwip_is_tt_mode())
|
||||||
|
at_printf(STR_END_OF_ATDATA_RET);
|
||||||
|
else
|
||||||
|
at_printf(STR_END_OF_ATCMD_RET);
|
||||||
|
#endif
|
||||||
|
#if CONFIG_LOG_SERVICE_LOCK
|
||||||
|
log_service_unlock();
|
||||||
|
#endif
|
||||||
|
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||||
|
release_wakelock(WAKELOCK_LOGUART);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define STACKSIZE 1280
|
||||||
|
void start_log_service(void)
|
||||||
|
{
|
||||||
|
xTaskHandle CreatedTask;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
#if 0 // CONFIG_USE_TCM_HEAP
|
||||||
|
extern void *tcm_heap_malloc(int size);
|
||||||
|
void *stack_addr = tcm_heap_malloc(STACKSIZE * sizeof(int));
|
||||||
|
|
||||||
|
if(stack_addr == NULL){
|
||||||
|
}
|
||||||
|
|
||||||
|
result = xTaskGenericCreate(
|
||||||
|
log_service,
|
||||||
|
( signed portCHAR * ) "log_srv",
|
||||||
|
STACKSIZE,
|
||||||
|
NULL,
|
||||||
|
tskIDLE_PRIORITY + 5,
|
||||||
|
&CreatedTask,
|
||||||
|
stack_addr,
|
||||||
|
NULL);
|
||||||
|
#else
|
||||||
|
result = xTaskCreate( log_service, ( signed portCHAR * ) "log_srv", STACKSIZE, NULL, tskIDLE_PRIORITY + 5, &CreatedTask );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(result != pdPASS) {
|
||||||
|
printf("\n\r%s xTaskCreate failed", __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void fAT_exit(void *arg){
|
||||||
|
printf("\n\rLeave LOG SERVICE");
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
#if CONFIG_LOG_HISTORY
|
||||||
|
void fAT_log(void *arg){
|
||||||
|
int i = 0;
|
||||||
|
printf("[AT]log history:\n\n\r");
|
||||||
|
if(log_history_count > LOG_HISTORY_LEN){
|
||||||
|
for(i=0; i<4; i++)
|
||||||
|
printf(" %s\n\r", log_history[((log_history_count+i)%LOG_HISTORY_LEN)]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for(i=0; i<(log_history_count-1); i++)
|
||||||
|
printf(" %s\n\r", log_history[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
log_item_t at_log_items[ ] = {
|
||||||
|
{"AT--", fAT_exit,},
|
||||||
|
#if CONFIG_LOG_HISTORY
|
||||||
|
{"AT??", fAT_log,},
|
||||||
|
#endif
|
||||||
|
{"ATxx", fAT_exit,}
|
||||||
|
};
|
||||||
|
void at_log_init(void)
|
||||||
|
{
|
||||||
|
log_service_add_table(at_log_items, sizeof(at_log_items)/sizeof(at_log_items[0]));
|
||||||
|
}
|
||||||
|
log_module_init(at_log_init);
|
||||||
|
#endif
|
123
Firmware/RTLGDB/USDK/component/common/api/at_cmd/log_service.h
Normal file
123
Firmware/RTLGDB/USDK/component/common/api/at_cmd/log_service.h
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
#ifndef LOG_SERVICE_H
|
||||||
|
#define LOG_SERVICE_H
|
||||||
|
|
||||||
|
#include "dlist.h"
|
||||||
|
/*
|
||||||
|
* Include user defined options first. Anything not defined in these files
|
||||||
|
* will be set to standard values. Override anything you dont like!
|
||||||
|
*/
|
||||||
|
#if defined(CONFIG_PLATFORM_8195A) || defined(CONFIG_PLATFORM_8711B)
|
||||||
|
#include "platform_opts.h"
|
||||||
|
#include "platform_stdlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ICCARM__
|
||||||
|
#define STRINGIFY(s) #s
|
||||||
|
#define SECTION(_name) _Pragma( STRINGIFY(location=_name))
|
||||||
|
#define log_module_init(fn) \
|
||||||
|
SECTION(".data.log_init") __root static void* log_##fn = (void*)fn
|
||||||
|
#elif defined(__CC_ARM)
|
||||||
|
#define log_module_init(fn) \
|
||||||
|
static void* log_##fn __attribute__((section(".data.log_init"))) = (void*)fn;
|
||||||
|
#define DiagPrintf printf
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define log_module_init(fn) \
|
||||||
|
static void* log_##fn __attribute__((section(".data.log_init"))) = (void*)fn;
|
||||||
|
#else
|
||||||
|
#error "not implement"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ATC_INDEX_NUM 32
|
||||||
|
|
||||||
|
#ifndef SUPPORT_LOG_SERVICE
|
||||||
|
#define SUPPORT_LOG_SERVICE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//LOG_SERVICE_BUFLEN: default, only 63 bytes could be used for keeping input
|
||||||
|
// cmd, the last byte is for string end ('\0').
|
||||||
|
#ifndef LOG_SERVICE_BUFLEN
|
||||||
|
#define LOG_SERVICE_BUFLEN 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_LOG_HISTORY
|
||||||
|
#define CONFIG_LOG_HISTORY 0
|
||||||
|
#if CONFIG_LOG_HISTORY
|
||||||
|
#define LOG_HISTORY_LEN 5
|
||||||
|
#endif
|
||||||
|
#endif //#ifndef CONFIG_LOG_HISTORY
|
||||||
|
|
||||||
|
#ifndef MAX_ARGC
|
||||||
|
#define MAX_ARGC 12
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_LOG_SERVICE_LOCK
|
||||||
|
#define CONFIG_LOG_SERVICE_LOCK 0 // //to protect log_buf[], only one command processed per time
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define AT_BIT(n) (1<<n)
|
||||||
|
#define AT_FLAG_DUMP AT_BIT(0)
|
||||||
|
#define AT_FLAG_EDIT AT_BIT(1)
|
||||||
|
#define AT_FLAG_ADC AT_BIT(2)
|
||||||
|
#define AT_FLAG_GPIO AT_BIT(3)
|
||||||
|
#define AT_FLAG_OTA AT_BIT(4)
|
||||||
|
#define AT_FLAG_NFC AT_BIT(5)
|
||||||
|
#define AT_FLAG_OS AT_BIT(6)
|
||||||
|
#define AT_FLAG_LWIP AT_BIT(7)
|
||||||
|
#define AT_FLAG_COMMON AT_BIT(8)
|
||||||
|
#define AT_FLAG_WIFI AT_BIT(9)
|
||||||
|
|
||||||
|
enum{
|
||||||
|
AT_DBG_OFF = 0,
|
||||||
|
AT_DBG_ALWAYS,
|
||||||
|
AT_DBG_ERROR,
|
||||||
|
AT_DBG_WARNING,
|
||||||
|
AT_DBG_INFO
|
||||||
|
};
|
||||||
|
|
||||||
|
extern unsigned char gDbgLevel;
|
||||||
|
extern unsigned int gDbgFlag;
|
||||||
|
|
||||||
|
#define AT_PRINTK(fmt, args...) printf(fmt"\r\n",## args)
|
||||||
|
#define _AT_PRINTK(fmt, args...) printf(fmt,## args)
|
||||||
|
#define AT_DBG_MSG(flag, level, fmt, args...) \
|
||||||
|
do{ \
|
||||||
|
if(((flag) & gDbgFlag) && (level <= gDbgLevel)){ \
|
||||||
|
AT_PRINTK(fmt,## args); \
|
||||||
|
} \
|
||||||
|
}while(0)
|
||||||
|
#define _AT_DBG_MSG(flag, level, fmt, args...) \
|
||||||
|
do{ \
|
||||||
|
if(((flag) & gDbgFlag) && (level <= gDbgLevel)){ \
|
||||||
|
_AT_PRINTK(fmt,## args); \
|
||||||
|
} \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#ifndef SUPPORT_INTERACTIVE_MODE
|
||||||
|
#define SUPPORT_INTERACTIVE_MODE 0
|
||||||
|
#endif //#ifndef SUPPORT_INTERACTIVE_MODE
|
||||||
|
|
||||||
|
typedef void (*log_init_t)(void);
|
||||||
|
typedef void (*log_act_t)(void*);
|
||||||
|
typedef struct _at_command_item_{
|
||||||
|
char *log_cmd;
|
||||||
|
log_act_t at_act;
|
||||||
|
struct list_head node;
|
||||||
|
}log_item_t;
|
||||||
|
|
||||||
|
void log_service_add_table(log_item_t *tbl, int len);
|
||||||
|
int parse_param(char *buf, char **argv);
|
||||||
|
void at_set_debug_mask(unsigned int newDbgFlag);
|
||||||
|
void at_set_debug_level(unsigned char newDbgLevel);
|
||||||
|
void log_service_init(void);
|
||||||
|
#if CONFIG_LOG_SERVICE_LOCK
|
||||||
|
void log_service_lock_init(void);
|
||||||
|
void log_service_lock(void);
|
||||||
|
u32 log_service_lock_timeout(u32 ms);
|
||||||
|
void log_service_unlock(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define C_NUM_AT_CMD 4 //"ATxx", 4 characters
|
||||||
|
#define C_NUM_AT_CMD_DLT 1 //"=", 1 charater
|
||||||
|
#define STR_END_OF_ATCMD_RET "\r\n# " //each AT command response will end with this string
|
||||||
|
#define STR_END_OF_ATDATA_RET "\r\n> " //data transparent transmission indicator
|
||||||
|
#endif
|
455
Firmware/RTLGDB/USDK/component/common/api/lwip_netconf.c
Normal file
455
Firmware/RTLGDB/USDK/component/common/api/lwip_netconf.c
Normal file
|
@ -0,0 +1,455 @@
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "lwip/mem.h"
|
||||||
|
#include "lwip/memp.h"
|
||||||
|
#include "lwip/dhcp.h"
|
||||||
|
#include "lwip/dns.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
#include "wifi_ind.h"
|
||||||
|
#endif
|
||||||
|
#if defined(STM32F2XX)
|
||||||
|
#include "stm322xg_eval_lcd.h"
|
||||||
|
#elif defined(STM32F4XX)
|
||||||
|
#include "stm324xg_eval_lcd.h"
|
||||||
|
#endif
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef IP_ADDR0
|
||||||
|
#define IP_ADDR0 192
|
||||||
|
#define IP_ADDR1 168
|
||||||
|
#define IP_ADDR2 1
|
||||||
|
#define IP_ADDR3 80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef NETMASK_ADDR0
|
||||||
|
#define NETMASK_ADDR0 255
|
||||||
|
#define NETMASK_ADDR1 255
|
||||||
|
#define NETMASK_ADDR2 255
|
||||||
|
#define NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef GW_ADDR0
|
||||||
|
#define GW_ADDR0 192
|
||||||
|
#define GW_ADDR1 168
|
||||||
|
#define GW_ADDR2 1
|
||||||
|
#define GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef AP_IP_ADDR0
|
||||||
|
#define AP_IP_ADDR0 192
|
||||||
|
#define AP_IP_ADDR1 168
|
||||||
|
#define AP_IP_ADDR2 43
|
||||||
|
#define AP_IP_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef AP_NETMASK_ADDR0
|
||||||
|
#define AP_NETMASK_ADDR0 255
|
||||||
|
#define AP_NETMASK_ADDR1 255
|
||||||
|
#define AP_NETMASK_ADDR2 255
|
||||||
|
#define AP_NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef AP_GW_ADDR0
|
||||||
|
#define AP_GW_ADDR0 192
|
||||||
|
#define AP_GW_ADDR1 168
|
||||||
|
#define AP_GW_ADDR2 43
|
||||||
|
#define AP_GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Static IP ADDRESS FOR ETHERNET*/
|
||||||
|
#ifndef ETH_IP_ADDR0
|
||||||
|
#define ETH_IP_ADDR0 192
|
||||||
|
#define ETH_IP_ADDR1 168
|
||||||
|
#define ETH_IP_ADDR2 0
|
||||||
|
#define ETH_IP_ADDR3 80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK FOR ETHERNET*/
|
||||||
|
#ifndef ETH_NETMASK_ADDR0
|
||||||
|
#define ETH_NETMASK_ADDR0 255
|
||||||
|
#define ETH_NETMASK_ADDR1 255
|
||||||
|
#define ETH_NETMASK_ADDR2 255
|
||||||
|
#define ETH_NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway address for ethernet*/
|
||||||
|
#ifndef ETH_GW_ADDR0
|
||||||
|
#define ETH_GW_ADDR0 192
|
||||||
|
#define ETH_GW_ADDR1 168
|
||||||
|
#define ETH_GW_ADDR2 0
|
||||||
|
#define ETH_GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
#define MAX_DHCP_TRIES 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
struct netif xnetif[NET_IF_NUM]; /* network interface structure */
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief Initializes the lwIP stack
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
extern int error_flag;
|
||||||
|
extern rtw_mode_t wifi_mode;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int lwip_init_done = 0;
|
||||||
|
|
||||||
|
void LwIP_Init(void)
|
||||||
|
{
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
int8_t idx = 0;
|
||||||
|
|
||||||
|
/* Create tcp_ip stack thread */
|
||||||
|
tcpip_init( NULL, NULL );
|
||||||
|
|
||||||
|
/* - netif_add(struct netif *netif, struct ip_addr *ipaddr,
|
||||||
|
struct ip_addr *netmask, struct ip_addr *gw,
|
||||||
|
void *state, err_t (* init)(struct netif *netif),
|
||||||
|
err_t (* input)(struct pbuf *p, struct netif *netif))
|
||||||
|
|
||||||
|
Adds your network interface to the netif_list. Allocate a struct
|
||||||
|
netif and pass a pointer to this structure as the first argument.
|
||||||
|
Give pointers to cleared ip_addr structures when using DHCP,
|
||||||
|
or fill them with sane numbers otherwise. The state pointer may be NULL.
|
||||||
|
|
||||||
|
The init function pointer must point to a initialization function for
|
||||||
|
your ethernet netif interface. The following code illustrates it's use.*/
|
||||||
|
//printf("NET_IF_NUM:%d\n\r",NET_IF_NUM);
|
||||||
|
for(idx=0;idx<NET_IF_NUM;idx++){
|
||||||
|
if(idx==0){
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
IP4_ADDR(&ipaddr, AP_IP_ADDR0, AP_IP_ADDR1, AP_IP_ADDR2, AP_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, AP_NETMASK_ADDR0, AP_NETMASK_ADDR1 , AP_NETMASK_ADDR2, AP_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, AP_GW_ADDR0, AP_GW_ADDR1, AP_GW_ADDR2, AP_GW_ADDR3);
|
||||||
|
}
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
if(idx == NET_IF_NUM - 1)
|
||||||
|
{
|
||||||
|
IP4_ADDR(&ipaddr, ETH_IP_ADDR0, ETH_IP_ADDR1, ETH_IP_ADDR2, ETH_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, ETH_NETMASK_ADDR0, ETH_NETMASK_ADDR1 , ETH_NETMASK_ADDR2, ETH_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, ETH_GW_ADDR0, ETH_GW_ADDR1, ETH_GW_ADDR2, ETH_GW_ADDR3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
xnetif[idx].name[0] = 'r';
|
||||||
|
xnetif[idx].name[1] = '0'+idx;
|
||||||
|
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
if(idx == NET_IF_NUM - 1)
|
||||||
|
netif_add(&xnetif[idx], &ipaddr, &netmask, &gw, NULL, ðernetif_mii_init, &tcpip_input);
|
||||||
|
else
|
||||||
|
netif_add(&xnetif[idx], &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
|
||||||
|
#else
|
||||||
|
netif_add(&xnetif[idx], &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
|
||||||
|
#endif
|
||||||
|
printf("interface %d is initialized\n", idx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Registers the default network interface. */
|
||||||
|
netif_set_default(&xnetif[0]);
|
||||||
|
|
||||||
|
/*move these operations to wifi_on/wifi_off*/
|
||||||
|
#if 0
|
||||||
|
/* When the netif is fully configured this function must be called.*/
|
||||||
|
for(idx = 0;idx < NET_IF_NUM;idx++)
|
||||||
|
netif_set_up(&xnetif[idx]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lwip_init_done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LwIP_DHCP_Process_Handle
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
uint8_t LwIP_DHCP(uint8_t idx, uint8_t dhcp_state)
|
||||||
|
{
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
uint32_t IPaddress;
|
||||||
|
uint8_t iptab[4];
|
||||||
|
uint8_t DHCP_state;
|
||||||
|
int mscnt = 0;
|
||||||
|
struct netif *pnetif = NULL;
|
||||||
|
|
||||||
|
DHCP_state = dhcp_state;
|
||||||
|
|
||||||
|
#if !CONFIG_ETHERNET
|
||||||
|
if(idx > 1)
|
||||||
|
idx = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pnetif = &xnetif[idx];
|
||||||
|
if(DHCP_state == 0){
|
||||||
|
pnetif->ip_addr.addr = 0;
|
||||||
|
pnetif->netmask.addr = 0;
|
||||||
|
pnetif->gw.addr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
//printf(" ========DHCP_state:%d============\n",DHCP_state);
|
||||||
|
switch (DHCP_state)
|
||||||
|
{
|
||||||
|
case DHCP_START:
|
||||||
|
{
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_unreg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl);
|
||||||
|
#endif
|
||||||
|
dhcp_start(pnetif);
|
||||||
|
IPaddress = 0;
|
||||||
|
DHCP_state = DHCP_WAIT_ADDRESS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DHCP_WAIT_ADDRESS:
|
||||||
|
{
|
||||||
|
/* If DHCP stopped by wifi_disconn_hdl*/
|
||||||
|
if(pnetif->dhcp->state == 0)
|
||||||
|
{
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
|
||||||
|
printf("LwIP_DHCP: dhcp stop.\n");
|
||||||
|
return DHCP_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the new IP address */
|
||||||
|
IPaddress = pnetif->ip_addr.addr;
|
||||||
|
|
||||||
|
if (IPaddress!=0)
|
||||||
|
{
|
||||||
|
DHCP_state = DHCP_ADDRESS_ASSIGNED;
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_reg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Stop DHCP */
|
||||||
|
// dhcp_stop(pnetif); /* can not stop, need to renew, Robbie*/
|
||||||
|
|
||||||
|
iptab[0] = (uint8_t)(IPaddress >> 24);
|
||||||
|
iptab[1] = (uint8_t)(IPaddress >> 16);
|
||||||
|
iptab[2] = (uint8_t)(IPaddress >> 8);
|
||||||
|
iptab[3] = (uint8_t)(IPaddress);
|
||||||
|
printf("Interface %d IP address : %d.%d.%d.%d\n", idx, iptab[3], iptab[2], iptab[1], iptab[0]);
|
||||||
|
// printf("Time at start %d ms.\n", xTaskGetTickCount());
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
error_flag = RTW_NO_ERROR;
|
||||||
|
#endif
|
||||||
|
return DHCP_ADDRESS_ASSIGNED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* DHCP timeout */
|
||||||
|
if (pnetif->dhcp->tries > MAX_DHCP_TRIES)
|
||||||
|
{
|
||||||
|
DHCP_state = DHCP_TIMEOUT;
|
||||||
|
|
||||||
|
/* Stop DHCP */
|
||||||
|
dhcp_stop(pnetif);
|
||||||
|
|
||||||
|
/* Static address used */
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
|
||||||
|
|
||||||
|
iptab[0] = IP_ADDR3;
|
||||||
|
iptab[1] = IP_ADDR2;
|
||||||
|
iptab[2] = IP_ADDR1;
|
||||||
|
iptab[3] = IP_ADDR0;
|
||||||
|
printf("Interface %d DHCP timeout\n",idx);
|
||||||
|
printf("Static IP address : %d.%d.%d.%d\n", iptab[3], iptab[2], iptab[1], iptab[0]);
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
error_flag = RTW_DHCP_FAIL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
if(idx == NET_IF_NUM -1) // This is the ethernet interface, set it up for static ip address
|
||||||
|
netif_set_up(pnetif);
|
||||||
|
#endif
|
||||||
|
return DHCP_TIMEOUT;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
//sys_msleep(DHCP_FINE_TIMER_MSECS);
|
||||||
|
vTaskDelay(DHCP_FINE_TIMER_MSECS);
|
||||||
|
dhcp_fine_tmr();
|
||||||
|
mscnt += DHCP_FINE_TIMER_MSECS;
|
||||||
|
if (mscnt >= DHCP_COARSE_TIMER_SECS*1000)
|
||||||
|
{
|
||||||
|
dhcp_coarse_tmr();
|
||||||
|
mscnt = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DHCP_RELEASE_IP:
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_unreg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl);
|
||||||
|
#endif
|
||||||
|
printf("LwIP_DHCP: Release ip\n");
|
||||||
|
dhcp_release_unicast(pnetif);
|
||||||
|
return DHCP_RELEASE_IP;
|
||||||
|
case DHCP_STOP:
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_unreg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl);
|
||||||
|
#endif
|
||||||
|
printf("LwIP_DHCP: dhcp stop.\n");
|
||||||
|
dhcp_stop(pnetif);
|
||||||
|
return DHCP_STOP;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LwIP_ReleaseIP(uint8_t idx)
|
||||||
|
{
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
struct netif *pnetif = &xnetif[idx];
|
||||||
|
|
||||||
|
IP4_ADDR(&ipaddr, 0, 0, 0, 0);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
IP4_ADDR(&gw, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetMAC(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) (pnetif->hwaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetIP(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->ip_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetGW(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->gw);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetMASK(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->netmask);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetBC(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->dhcp->offered_bc_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LWIP_DNS
|
||||||
|
void LwIP_GetDNS(struct ip_addr* dns)
|
||||||
|
{
|
||||||
|
*dns = dns_getserver(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LwIP_SetDNS(struct ip_addr* dns)
|
||||||
|
{
|
||||||
|
dns_setserver(0, dns);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
void LwIP_UseStaticIP(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
|
||||||
|
/* Static address used */
|
||||||
|
if(pnetif->name[1] == '0'){
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
if(wifi_mode == RTW_MODE_STA){
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
}
|
||||||
|
else if(wifi_mode == RTW_MODE_AP){
|
||||||
|
IP4_ADDR(&ipaddr, AP_IP_ADDR0, AP_IP_ADDR1, AP_IP_ADDR2, AP_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, AP_NETMASK_ADDR0, AP_NETMASK_ADDR1 , AP_NETMASK_ADDR2, AP_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, AP_GW_ADDR0, AP_GW_ADDR1, AP_GW_ADDR2, AP_GW_ADDR3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}else{
|
||||||
|
IP4_ADDR(&ipaddr, AP_IP_ADDR0, AP_IP_ADDR1, AP_IP_ADDR2, AP_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, AP_NETMASK_ADDR0, AP_NETMASK_ADDR1 , AP_NETMASK_ADDR2, AP_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, AP_GW_ADDR0, AP_GW_ADDR1, AP_GW_ADDR2, AP_GW_ADDR3);
|
||||||
|
}
|
||||||
|
|
||||||
|
netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
|
||||||
|
}
|
||||||
|
#if LWIP_AUTOIP
|
||||||
|
#include <lwip/autoip.h>
|
||||||
|
|
||||||
|
void LwIP_AUTOIP(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
uint8_t *ip = LwIP_GetIP(pnetif);
|
||||||
|
|
||||||
|
autoip_start(pnetif);
|
||||||
|
|
||||||
|
while((pnetif->autoip->state == AUTOIP_STATE_PROBING) || (pnetif->autoip->state == AUTOIP_STATE_ANNOUNCING)) {
|
||||||
|
vTaskDelay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*((uint32_t *) ip) == 0) {
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
|
||||||
|
printf("AUTOIP timeout\n");
|
||||||
|
|
||||||
|
/* Static address used */
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
|
||||||
|
printf("Static IP address : %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Link-local address: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
/* Get IPv6 address with lwip 1.5.0 */
|
||||||
|
void LwIP_AUTOIP_IPv6(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
uint8_t *ipv6 = (uint8_t *) &(pnetif->ip6_addr[0].addr[0]);
|
||||||
|
|
||||||
|
netif_create_ip6_linklocal_address(pnetif, 1);
|
||||||
|
printf("IPv6 link-local address: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
|
||||||
|
ipv6[0], ipv6[1], ipv6[2], ipv6[3], ipv6[4], ipv6[5], ipv6[6], ipv6[7],
|
||||||
|
ipv6[8], ipv6[9], ipv6[10], ipv6[11], ipv6[12], ipv6[13], ipv6[14], ipv6[15]);
|
||||||
|
}
|
||||||
|
#endif
|
91
Firmware/RTLGDB/USDK/component/common/api/lwip_netconf.h
Normal file
91
Firmware/RTLGDB/USDK/component/common/api/lwip_netconf.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file netconf.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V1.1.0
|
||||||
|
* @date 07-October-2011
|
||||||
|
* @brief This file contains all the functions prototypes for the netconf.c
|
||||||
|
* file.
|
||||||
|
******************************************************************************
|
||||||
|
* @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>
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __NETCONF_H
|
||||||
|
#define __NETCONF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "tcpip.h"
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
#include "platform_opts.h"
|
||||||
|
#include "autoconf.h"
|
||||||
|
|
||||||
|
// macros
|
||||||
|
/* Give default value if not defined */
|
||||||
|
#ifndef NET_IF_NUM
|
||||||
|
#ifdef CONFIG_CONCURRENT_MODE
|
||||||
|
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN) + 1)
|
||||||
|
#else
|
||||||
|
#define NET_IF_NUM ((CONFIG_ETHERNET) + (CONFIG_WLAN))
|
||||||
|
#endif // end of CONFIG_CONCURRENT_MODE
|
||||||
|
#endif // end of NET_IF_NUM
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
DHCP_START=0,
|
||||||
|
DHCP_WAIT_ADDRESS,
|
||||||
|
DHCP_ADDRESS_ASSIGNED,
|
||||||
|
DHCP_RELEASE_IP,
|
||||||
|
DHCP_STOP,
|
||||||
|
DHCP_TIMEOUT
|
||||||
|
} DHCP_State_TypeDef;
|
||||||
|
|
||||||
|
/* Extern functions ------------------------------------------------------------*/
|
||||||
|
void wifi_rx_beacon_hdl( char* buf, int buf_len, int flags, void* userdata);
|
||||||
|
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void LwIP_Init(void);
|
||||||
|
uint8_t LwIP_DHCP(uint8_t idx, uint8_t dhcp_state);
|
||||||
|
unsigned char* LwIP_GetMAC(struct netif *pnetif);
|
||||||
|
unsigned char* LwIP_GetIP(struct netif *pnetif);
|
||||||
|
unsigned char* LwIP_GetGW(struct netif *pnetif);
|
||||||
|
uint8_t* LwIP_GetMASK(struct netif *pnetif);
|
||||||
|
uint8_t* LwIP_GetBC(struct netif *pnetif);
|
||||||
|
#if LWIP_DNS
|
||||||
|
void LwIP_GetDNS(struct ip_addr* dns);
|
||||||
|
void LwIP_SetDNS(struct ip_addr* dns);
|
||||||
|
#endif
|
||||||
|
void LwIP_UseStaticIP(struct netif *pnetif);
|
||||||
|
#if LWIP_AUTOIP
|
||||||
|
void LwIP_AUTOIP(struct netif *pnetif);
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
void LwIP_AUTOIP_IPv6(struct netif *pnetif);
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __NETCONF_H */
|
||||||
|
|
||||||
|
|
||||||
|
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
405
Firmware/RTLGDB/USDK/component/common/api/lwip_netconf1.c
Normal file
405
Firmware/RTLGDB/USDK/component/common/api/lwip_netconf1.c
Normal file
|
@ -0,0 +1,405 @@
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "lwip/mem.h"
|
||||||
|
#include "lwip/memp.h"
|
||||||
|
#include "lwip/dhcp.h"
|
||||||
|
#include "lwip/dns.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
#include "wifi_ind.h"
|
||||||
|
#endif
|
||||||
|
#if defined(STM32F2XX)
|
||||||
|
#include "stm322xg_eval_lcd.h"
|
||||||
|
#elif defined(STM32F4XX)
|
||||||
|
#include "stm324xg_eval_lcd.h"
|
||||||
|
#endif
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef IP_ADDR0
|
||||||
|
#define IP_ADDR0 192
|
||||||
|
#define IP_ADDR1 168
|
||||||
|
#define IP_ADDR2 1
|
||||||
|
#define IP_ADDR3 80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef NETMASK_ADDR0
|
||||||
|
#define NETMASK_ADDR0 255
|
||||||
|
#define NETMASK_ADDR1 255
|
||||||
|
#define NETMASK_ADDR2 255
|
||||||
|
#define NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef GW_ADDR0
|
||||||
|
#define GW_ADDR0 192
|
||||||
|
#define GW_ADDR1 168
|
||||||
|
#define GW_ADDR2 1
|
||||||
|
#define GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Static IP ADDRESS*/
|
||||||
|
#ifndef AP_IP_ADDR0
|
||||||
|
#define AP_IP_ADDR0 192
|
||||||
|
#define AP_IP_ADDR1 168
|
||||||
|
#define AP_IP_ADDR2 43
|
||||||
|
#define AP_IP_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK*/
|
||||||
|
#ifndef AP_NETMASK_ADDR0
|
||||||
|
#define AP_NETMASK_ADDR0 255
|
||||||
|
#define AP_NETMASK_ADDR1 255
|
||||||
|
#define AP_NETMASK_ADDR2 255
|
||||||
|
#define AP_NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway Address*/
|
||||||
|
#ifndef AP_GW_ADDR0
|
||||||
|
#define AP_GW_ADDR0 192
|
||||||
|
#define AP_GW_ADDR1 168
|
||||||
|
#define AP_GW_ADDR2 43
|
||||||
|
#define AP_GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Static IP ADDRESS FOR ETHERNET*/
|
||||||
|
#ifndef ETH_IP_ADDR0
|
||||||
|
#define ETH_IP_ADDR0 192
|
||||||
|
#define ETH_IP_ADDR1 168
|
||||||
|
#define ETH_IP_ADDR2 0
|
||||||
|
#define ETH_IP_ADDR3 80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*NETMASK FOR ETHERNET*/
|
||||||
|
#ifndef ETH_NETMASK_ADDR0
|
||||||
|
#define ETH_NETMASK_ADDR0 255
|
||||||
|
#define ETH_NETMASK_ADDR1 255
|
||||||
|
#define ETH_NETMASK_ADDR2 255
|
||||||
|
#define ETH_NETMASK_ADDR3 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Gateway address for ethernet*/
|
||||||
|
#ifndef ETH_GW_ADDR0
|
||||||
|
#define ETH_GW_ADDR0 192
|
||||||
|
#define ETH_GW_ADDR1 168
|
||||||
|
#define ETH_GW_ADDR2 0
|
||||||
|
#define ETH_GW_ADDR3 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
#define MAX_DHCP_TRIES 5
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
struct netif xnetif[NET_IF_NUM]; /* network interface structure */
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief Initializes the lwIP stack
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
extern char error_flag;
|
||||||
|
extern unsigned char wifi_mode; // rtw_mode_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int lwip_init_done = 0;
|
||||||
|
|
||||||
|
void LwIP_Init(void)
|
||||||
|
{
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
int8_t idx = 0;
|
||||||
|
/* Create tcp_ip stack thread */
|
||||||
|
tcpip_init( NULL, NULL );
|
||||||
|
|
||||||
|
/* - netif_add(struct netif *netif, struct ip_addr *ipaddr,
|
||||||
|
struct ip_addr *netmask, struct ip_addr *gw,
|
||||||
|
void *state, err_t (* init)(struct netif *netif),
|
||||||
|
err_t (* input)(struct pbuf *p, struct netif *netif))
|
||||||
|
|
||||||
|
Adds your network interface to the netif_list. Allocate a struct
|
||||||
|
netif and pass a pointer to this structure as the first argument.
|
||||||
|
Give pointers to cleared ip_addr structures when using DHCP,
|
||||||
|
or fill them with sane numbers otherwise. The state pointer may be NULL.
|
||||||
|
|
||||||
|
The init function pointer must point to a initialization function for
|
||||||
|
your ethernet netif interface. The following code illustrates it's use.*/
|
||||||
|
//printf("NET_IF_NUM:%d\n\r",NET_IF_NUM);
|
||||||
|
for(idx = NET_IF_NUM - 1; idx >= 0 ; idx--) {
|
||||||
|
if(idx == 0){
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
}
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
else if(idx == NET_IF_NUM - 1)
|
||||||
|
{
|
||||||
|
IP4_ADDR(&ipaddr, ETH_IP_ADDR0, ETH_IP_ADDR1, ETH_IP_ADDR2, ETH_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, ETH_NETMASK_ADDR0, ETH_NETMASK_ADDR1 , ETH_NETMASK_ADDR2, ETH_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, ETH_GW_ADDR0, ETH_GW_ADDR1, ETH_GW_ADDR2, ETH_GW_ADDR3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
IP4_ADDR(&ipaddr, AP_IP_ADDR0, AP_IP_ADDR1, AP_IP_ADDR2, AP_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, AP_NETMASK_ADDR0, AP_NETMASK_ADDR1 , AP_NETMASK_ADDR2, AP_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, AP_GW_ADDR0, AP_GW_ADDR1, AP_GW_ADDR2, AP_GW_ADDR3);
|
||||||
|
}
|
||||||
|
xnetif[idx].name[0] = 'r';
|
||||||
|
xnetif[idx].name[1] = '0'+idx;
|
||||||
|
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
if(idx == NET_IF_NUM - 1)
|
||||||
|
netif_add(&xnetif[idx], &ipaddr, &netmask, &gw, NULL, ðernetif_mii_init, &tcpip_input);
|
||||||
|
else
|
||||||
|
netif_add(&xnetif[idx], &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
|
||||||
|
#else
|
||||||
|
netif_add(&xnetif[idx], &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
|
||||||
|
#endif
|
||||||
|
info_printf("interface %d is initialized\n", idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Registers the default network interface. */
|
||||||
|
netif_set_default(&xnetif[0]);
|
||||||
|
|
||||||
|
/* When the netif is fully configured this function must be called.*/
|
||||||
|
for(idx = 0; idx < NET_IF_NUM; idx++)
|
||||||
|
netif_set_up(&xnetif[idx]);
|
||||||
|
|
||||||
|
lwip_init_done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LwIP_DHCP_Process_Handle
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
uint8_t LwIP_DHCP(uint8_t idx, uint8_t dhcp_state) {
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
uint32_t IPaddress;
|
||||||
|
uint8_t iptab[4];
|
||||||
|
uint8_t DHCP_state;
|
||||||
|
int mscnt = 0;
|
||||||
|
struct netif *pnetif = NULL;
|
||||||
|
|
||||||
|
DHCP_state = dhcp_state;
|
||||||
|
|
||||||
|
#if !CONFIG_ETHERNET
|
||||||
|
if (idx > 1)
|
||||||
|
idx = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pnetif = &xnetif[idx];
|
||||||
|
if (DHCP_state == 0) {
|
||||||
|
pnetif->ip_addr.addr = 0;
|
||||||
|
pnetif->netmask.addr = 0;
|
||||||
|
pnetif->gw.addr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
//info_printf("\n\r ========DHCP_state:%d============\n\r",DHCP_state);
|
||||||
|
switch (DHCP_state) {
|
||||||
|
case DHCP_START: {
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_unreg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl);
|
||||||
|
#endif
|
||||||
|
dhcp_start(pnetif);
|
||||||
|
IPaddress = 0;
|
||||||
|
DHCP_state = DHCP_WAIT_ADDRESS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DHCP_WAIT_ADDRESS: {
|
||||||
|
/* Read the new IP address */
|
||||||
|
IPaddress = pnetif->ip_addr.addr;
|
||||||
|
|
||||||
|
if (IPaddress != 0) {
|
||||||
|
DHCP_state = DHCP_ADDRESS_ASSIGNED;
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_reg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Stop DHCP */
|
||||||
|
// dhcp_stop(pnetif); /* can not stop, need to renew, Robbie*/
|
||||||
|
iptab[0] = (uint8_t) (IPaddress >> 24);
|
||||||
|
iptab[1] = (uint8_t) (IPaddress >> 16);
|
||||||
|
iptab[2] = (uint8_t) (IPaddress >> 8);
|
||||||
|
iptab[3] = (uint8_t) (IPaddress);
|
||||||
|
info_printf("Interface %d IP address: %d.%d.%d.%d\n", idx, iptab[3],
|
||||||
|
iptab[2], iptab[1], iptab[0]);
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
error_flag = RTW_NO_ERROR;
|
||||||
|
#endif
|
||||||
|
return DHCP_ADDRESS_ASSIGNED;
|
||||||
|
} else {
|
||||||
|
/* DHCP timeout */
|
||||||
|
if (pnetif->dhcp->tries > MAX_DHCP_TRIES) {
|
||||||
|
DHCP_state = DHCP_TIMEOUT;
|
||||||
|
|
||||||
|
/* Stop DHCP */
|
||||||
|
dhcp_stop(pnetif);
|
||||||
|
|
||||||
|
/* Static address used */
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
netif_set_addr(pnetif, &ipaddr, &netmask, &gw);
|
||||||
|
|
||||||
|
iptab[0] = IP_ADDR3;
|
||||||
|
iptab[1] = IP_ADDR2;
|
||||||
|
iptab[2] = IP_ADDR1;
|
||||||
|
iptab[3] = IP_ADDR0;
|
||||||
|
info_printf("Interface %d DHCP timeout\n", idx);
|
||||||
|
info_printf("Static IP address: %d.%d.%d.%d\n", iptab[3], iptab[2], iptab[1], iptab[0]);
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
error_flag = RTW_DHCP_FAIL;
|
||||||
|
#endif
|
||||||
|
return DHCP_TIMEOUT;
|
||||||
|
} else {
|
||||||
|
//sys_msleep(DHCP_FINE_TIMER_MSECS);
|
||||||
|
vTaskDelay(DHCP_FINE_TIMER_MSECS);
|
||||||
|
dhcp_fine_tmr();
|
||||||
|
mscnt += DHCP_FINE_TIMER_MSECS;
|
||||||
|
if (mscnt >= DHCP_COARSE_TIMER_SECS * 1000) {
|
||||||
|
dhcp_coarse_tmr();
|
||||||
|
mscnt = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DHCP_RELEASE_IP:
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_unreg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl);
|
||||||
|
#endif
|
||||||
|
info_printf("LwIP_DHCP(%d): Release ip\n", idx);
|
||||||
|
dhcp_release_unicast(pnetif);
|
||||||
|
return DHCP_RELEASE_IP;
|
||||||
|
case DHCP_STOP:
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
wifi_unreg_event_handler(WIFI_EVENT_BEACON_AFTER_DHCP, wifi_rx_beacon_hdl);
|
||||||
|
#endif
|
||||||
|
info_printf("LwIP_DHCP(%d): dhcp stop.\n", idx);
|
||||||
|
dhcp_stop(pnetif);
|
||||||
|
return DHCP_STOP;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetMAC(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) (pnetif->hwaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetIP(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->ip_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetGW(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->gw);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetMASK(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->netmask);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* LwIP_GetBC(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
return (uint8_t *) &(pnetif->dhcp->offered_bc_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LWIP_DNS
|
||||||
|
void LwIP_GetDNS(struct ip_addr* dns)
|
||||||
|
{
|
||||||
|
*dns = dns_getserver(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LwIP_SetDNS(struct ip_addr* dns)
|
||||||
|
{
|
||||||
|
dns_setserver(0, dns);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
void LwIP_UseStaticIP(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
|
||||||
|
/* Static address used */
|
||||||
|
if(pnetif->name[1] == '0'){
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
if(wifi_mode == RTW_MODE_STA){
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
}
|
||||||
|
else if(wifi_mode == RTW_MODE_AP){
|
||||||
|
IP4_ADDR(&ipaddr, AP_IP_ADDR0, AP_IP_ADDR1, AP_IP_ADDR2, AP_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, AP_NETMASK_ADDR0, AP_NETMASK_ADDR1 , AP_NETMASK_ADDR2, AP_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, AP_GW_ADDR0, AP_GW_ADDR1, AP_GW_ADDR2, AP_GW_ADDR3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}else{
|
||||||
|
IP4_ADDR(&ipaddr, AP_IP_ADDR0, AP_IP_ADDR1, AP_IP_ADDR2, AP_IP_ADDR3);
|
||||||
|
IP4_ADDR(&netmask, AP_NETMASK_ADDR0, AP_NETMASK_ADDR1 , AP_NETMASK_ADDR2, AP_NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, AP_GW_ADDR0, AP_GW_ADDR1, AP_GW_ADDR2, AP_GW_ADDR3);
|
||||||
|
}
|
||||||
|
|
||||||
|
netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
|
||||||
|
}
|
||||||
|
#if LWIP_AUTOIP
|
||||||
|
#include <lwip/autoip.h>
|
||||||
|
|
||||||
|
void LwIP_AUTOIP(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
uint8_t *ip = LwIP_GetIP(pnetif);
|
||||||
|
|
||||||
|
autoip_start(pnetif);
|
||||||
|
|
||||||
|
while((pnetif->autoip->state == AUTOIP_STATE_PROBING) || (pnetif->autoip->state == AUTOIP_STATE_ANNOUNCING)) {
|
||||||
|
vTaskDelay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*((uint32_t *) ip) == 0) {
|
||||||
|
struct ip_addr ipaddr;
|
||||||
|
struct ip_addr netmask;
|
||||||
|
struct ip_addr gw;
|
||||||
|
|
||||||
|
printf("AUTOIP timeout\n");
|
||||||
|
|
||||||
|
/* Static address used */
|
||||||
|
IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
|
||||||
|
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
|
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
|
||||||
|
netif_set_addr(pnetif, &ipaddr , &netmask, &gw);
|
||||||
|
printf("Static IP address : %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Link-local address: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
/* Get IPv6 address with lwip 1.5.0 */
|
||||||
|
void LwIP_AUTOIP_IPv6(struct netif *pnetif)
|
||||||
|
{
|
||||||
|
uint8_t *ipv6 = (uint8_t *) &(pnetif->ip6_addr[0].addr[0]);
|
||||||
|
|
||||||
|
netif_create_ip6_linklocal_address(pnetif, 1);
|
||||||
|
printf("IPv6 link-local address: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
|
||||||
|
ipv6[0], ipv6[1], ipv6[2], ipv6[3], ipv6[4], ipv6[5], ipv6[6], ipv6[7],
|
||||||
|
ipv6[8], ipv6[9], ipv6[10], ipv6[11], ipv6[12], ipv6[13], ipv6[14], ipv6[15]);
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,21 @@
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
#ifndef __MAIN_TEST_H
|
||||||
|
#define __MAIN_TEST_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Exported test functions ------------------------------------------------------- */
|
||||||
|
void do_ping_test(char *ip, int size, int count, int interval);
|
||||||
|
void do_ping_call(char *ip, int loop, int count);
|
||||||
|
void interactive_question(char *question, char *choice, char *buf, int buf_size);
|
||||||
|
void start_interactive_mode(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __MAIN_TEST_H
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------//
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file netconf.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V1.1.0
|
||||||
|
* @date 07-October-2011
|
||||||
|
* @brief This file contains all the functions prototypes for the netconf.c
|
||||||
|
* file.
|
||||||
|
******************************************************************************
|
||||||
|
* @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>
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __NETCONF_H
|
||||||
|
#define __NETCONF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// TODO: remove this file
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#if 0
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void LwIP_Init(void);
|
||||||
|
void LwIP_DHCP(void);
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __NETCONF_H */
|
||||||
|
|
||||||
|
|
||||||
|
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
#ifndef __RTL8195A_IT_H_
|
||||||
|
#define __RTL8195A_IT_H_
|
||||||
|
|
||||||
|
|
||||||
|
int irq_alloc_wlan(void *contex);
|
||||||
|
|
||||||
|
#endif //__RTL8195A_IT_H_
|
|
@ -0,0 +1,47 @@
|
||||||
|
#ifndef _UTIL_H
|
||||||
|
#define _UTIL_H
|
||||||
|
|
||||||
|
#include <wireless.h>
|
||||||
|
#include <wlan_intf.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wifi_util.h"
|
||||||
|
#if 0
|
||||||
|
typedef enum _WIFI_EVENT_INDICATE{
|
||||||
|
WIFI_EVENT_CONNECT = 0,
|
||||||
|
WIFI_EVENT_DISCONNECT = 1,
|
||||||
|
WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2,
|
||||||
|
}WIFI_EVENT_INDICATE;
|
||||||
|
rtw_event_indicate_t
|
||||||
|
|
||||||
|
int wext_get_ssid(const char *ifname, __u8 *ssid);
|
||||||
|
int wext_set_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||||
|
int wext_set_auth_param(const char *ifname, __u16 idx, __u32 value);
|
||||||
|
int wext_set_key_ext(const char *ifname, __u16 alg, const __u8 *addr, int key_idx, int set_tx, const __u8 *seq, __u16 seq_len, __u8 *key, __u16 key_len);
|
||||||
|
int wext_get_enc_ext(const char *ifname, __u16 *alg);
|
||||||
|
int wext_set_passphrase(const char *ifname, const __u8 *passphrase, __u16 passphrase_len);
|
||||||
|
int wext_get_passphrase(const char *ifname, __u8 *passphrase);
|
||||||
|
int wext_set_mode(const char *ifname, int mode);
|
||||||
|
int wext_get_mode(const char *ifname, int *mode);
|
||||||
|
int wext_set_ap_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||||
|
int wext_set_country(const char *ifname, char *country_code);
|
||||||
|
int wext_get_rssi(const char *ifname, int *rssi);
|
||||||
|
int wext_set_channel(const char *ifname, __u8 ch);
|
||||||
|
int wext_get_channel(const char *ifname, __u8 *ch);
|
||||||
|
int wext_set_scan(const char *ifname, char *buf, __u16 buf_len);
|
||||||
|
int wext_get_scan(const char *ifname, char *buf, __u16 buf_len);
|
||||||
|
int wext_mp_command(const char *ifname, char *cmd, int show_msg);
|
||||||
|
int wext_wifi_priv(const char *ifname, int argc, char **argv);
|
||||||
|
void wext_wlan_indicate(unsigned int cmd, union iwreq_data *wrqu, char *extra);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define wext_handshake_done rltk_wlan_handshake_done
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _UTIL_H */
|
|
@ -0,0 +1,222 @@
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include <lwip/sockets.h>
|
||||||
|
#if LWIP_SOCKET
|
||||||
|
#include <lwip/raw.h>
|
||||||
|
#include <lwip/icmp.h>
|
||||||
|
#include <lwip/inet_chksum.h>
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
|
||||||
|
//#define PING_IP "192.168.0.1"
|
||||||
|
#define PING_IP "192.168.159.1"
|
||||||
|
#define PING_TO 1000
|
||||||
|
#define PING_ID 0xABCD
|
||||||
|
#define BUF_SIZE 10000
|
||||||
|
#define STACKSIZE 1024
|
||||||
|
|
||||||
|
static unsigned short ping_seq = 0;
|
||||||
|
static int infinite_loop, ping_count, data_size, ping_interval, ping_call;
|
||||||
|
static char ping_ip[16];
|
||||||
|
|
||||||
|
static void generate_ping_echo(unsigned char *buf, int size)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct icmp_echo_hdr *pecho;
|
||||||
|
|
||||||
|
for(i = 0; i < size; i ++) {
|
||||||
|
buf[sizeof(struct icmp_echo_hdr) + i] = (unsigned char) i;
|
||||||
|
}
|
||||||
|
|
||||||
|
pecho = (struct icmp_echo_hdr *) buf;
|
||||||
|
ICMPH_TYPE_SET(pecho, ICMP_ECHO);
|
||||||
|
ICMPH_CODE_SET(pecho, 0);
|
||||||
|
pecho->chksum = 0;
|
||||||
|
pecho->id = PING_ID;
|
||||||
|
pecho->seqno = htons(++ ping_seq);
|
||||||
|
|
||||||
|
//Checksum includes icmp header and data. Need to calculate after fill up icmp header
|
||||||
|
pecho->chksum = inet_chksum(pecho, sizeof(struct icmp_echo_hdr) + size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ping_test(void *param)
|
||||||
|
//void ping_test()
|
||||||
|
{
|
||||||
|
int i, ping_socket;
|
||||||
|
int pint_timeout = PING_TO;
|
||||||
|
struct sockaddr_in to_addr, from_addr;
|
||||||
|
int from_addr_len = sizeof(struct sockaddr);
|
||||||
|
int ping_size, reply_size;
|
||||||
|
unsigned char *ping_buf, *reply_buf;
|
||||||
|
unsigned int ping_time, reply_time;
|
||||||
|
struct ip_hdr *iphdr;
|
||||||
|
struct icmp_echo_hdr *pecho;
|
||||||
|
|
||||||
|
if(data_size > BUF_SIZE){
|
||||||
|
printf("[ERROR] %s: data size error, can't exceed %d\n",__func__,BUF_SIZE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ping size = icmp header(8 bytes) + data size
|
||||||
|
ping_size = sizeof(struct icmp_echo_hdr) + data_size;
|
||||||
|
|
||||||
|
ping_buf = pvPortMalloc(ping_size);
|
||||||
|
if(NULL == ping_buf){
|
||||||
|
printf("[ERROR] %s: Allocate ping_buf failed\n",__func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
reply_buf = pvPortMalloc(ping_size);
|
||||||
|
if(NULL == reply_buf){
|
||||||
|
vPortFree(ping_buf);
|
||||||
|
printf("[ERROR] %s: Allocate reply_buf failed\n",__func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("[%s] PING %s %d(%d) bytes of data\n", __FUNCTION__, ping_ip, data_size, sizeof(struct ip_hdr) + sizeof(struct icmp_echo_hdr) + data_size);
|
||||||
|
|
||||||
|
for(i = 0; (i < ping_count) || (infinite_loop == 1); i ++) {
|
||||||
|
ping_socket = socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP);
|
||||||
|
#ifdef CONFIG_LWIP_1_5_0
|
||||||
|
struct timeval timeout;
|
||||||
|
timeout.tv_sec = pint_timeout / 1000;
|
||||||
|
timeout.tv_usec = pint_timeout % 1000 * 1000;
|
||||||
|
setsockopt(ping_socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
|
||||||
|
#else
|
||||||
|
setsockopt(ping_socket, SOL_SOCKET, SO_RCVTIMEO, &pint_timeout, sizeof(pint_timeout));
|
||||||
|
#endif
|
||||||
|
to_addr.sin_len = sizeof(to_addr);
|
||||||
|
to_addr.sin_family = AF_INET;
|
||||||
|
to_addr.sin_addr.s_addr = inet_addr(ping_ip);
|
||||||
|
|
||||||
|
generate_ping_echo(ping_buf, data_size);
|
||||||
|
sendto(ping_socket, ping_buf, ping_size, 0, (struct sockaddr *) &to_addr, sizeof(to_addr));
|
||||||
|
|
||||||
|
ping_time = xTaskGetTickCount();
|
||||||
|
if((reply_size = recvfrom(ping_socket, reply_buf, ping_size, 0, (struct sockaddr *) &from_addr, (socklen_t *) &from_addr_len))
|
||||||
|
>= (int)(sizeof(struct ip_hdr) + sizeof(struct icmp_echo_hdr))) {
|
||||||
|
|
||||||
|
reply_time = xTaskGetTickCount();
|
||||||
|
iphdr = (struct ip_hdr *)reply_buf;
|
||||||
|
pecho = (struct icmp_echo_hdr *)(reply_buf + (IPH_HL(iphdr) * 4));
|
||||||
|
|
||||||
|
if((pecho->id == PING_ID) && (pecho->seqno == htons(ping_seq))) {
|
||||||
|
printf("[%s] %d bytes from %s: icmp_seq=%d time=%d ms\n", __FUNCTION__, reply_size - sizeof(struct ip_hdr), inet_ntoa(from_addr.sin_addr), htons(pecho->seqno), (reply_time - ping_time) * portTICK_RATE_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("[%s] Request timeout for icmp_seq %d\n", __FUNCTION__, ping_seq);
|
||||||
|
|
||||||
|
close(ping_socket);
|
||||||
|
vTaskDelay(ping_interval * configTICK_RATE_HZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
vPortFree(ping_buf);
|
||||||
|
vPortFree(reply_buf);
|
||||||
|
|
||||||
|
if(!ping_call)
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_ping_call(char *ip, int loop, int count)
|
||||||
|
{
|
||||||
|
ping_call = 1;
|
||||||
|
ping_seq = 0;
|
||||||
|
data_size = 120;
|
||||||
|
ping_interval = 1;
|
||||||
|
infinite_loop = loop;
|
||||||
|
ping_count = count;
|
||||||
|
strcpy(ping_ip, ip);
|
||||||
|
ping_test(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_ping(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int argv_count = 2;
|
||||||
|
|
||||||
|
if(argc < 2)
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
|
//ping cmd default value
|
||||||
|
infinite_loop = 0;
|
||||||
|
ping_count = 4;
|
||||||
|
data_size = 32;
|
||||||
|
ping_interval = 1;
|
||||||
|
ping_call = 1;
|
||||||
|
ping_seq = 0;
|
||||||
|
|
||||||
|
while(argv_count<=argc){
|
||||||
|
//first operation
|
||||||
|
if(argv_count == 2){
|
||||||
|
memset(ping_ip, 0, sizeof(ping_ip));
|
||||||
|
strncpy(ping_ip, argv[argv_count-1], (strlen(argv[argv_count-1])>16)?16:strlen(argv[argv_count-1]));
|
||||||
|
argv_count++;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(strcmp(argv[argv_count-1], "-t") == 0){
|
||||||
|
infinite_loop = 1;
|
||||||
|
argv_count++;
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[argv_count-1], "-n") == 0){
|
||||||
|
if(argc < (argv_count+1))
|
||||||
|
goto Exit;
|
||||||
|
ping_count = (int) atoi(argv[argv_count]);
|
||||||
|
argv_count+=2;
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[argv_count-1], "-l") == 0){
|
||||||
|
if(argc < (argv_count+1))
|
||||||
|
goto Exit;
|
||||||
|
data_size = (int) atoi(argv[argv_count]);
|
||||||
|
argv_count+=2;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ping_test(NULL);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
printf("[ATWI] Usage: ATWI=[host],[options]\n");
|
||||||
|
printf("\t-t\tPing the specified host until stopped\n");
|
||||||
|
printf("\t-n\t# Number of echo requests to send (default 4 times)\n");
|
||||||
|
printf("\t-l\t# Send buffer size (default 32 bytes)\n");
|
||||||
|
printf("\tExample:\n");
|
||||||
|
printf("\t\tATWI=192.168.1.2,-n,100,-l,5000\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_ping_test(char *ip, int size, int count, int interval)
|
||||||
|
{
|
||||||
|
if((sizeof(struct icmp_echo_hdr) + size) > BUF_SIZE) {
|
||||||
|
printf("%s BUF_SIZE(%d) is too small\n", __FUNCTION__, BUF_SIZE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ip == NULL)
|
||||||
|
strcpy(ping_ip, PING_IP);
|
||||||
|
else
|
||||||
|
strcpy(ping_ip, ip);
|
||||||
|
|
||||||
|
ping_call = 0;
|
||||||
|
ping_seq = 0;
|
||||||
|
data_size = size;
|
||||||
|
ping_interval = interval;
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
infinite_loop = 1;
|
||||||
|
ping_count = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
infinite_loop = 0;
|
||||||
|
ping_count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xTaskCreate(ping_test, ((const signed char*)"ping_test"), STACKSIZE, NULL, tskIDLE_PRIORITY + 1, NULL) != pdPASS)
|
||||||
|
printf("%s xTaskCreate failed\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
#endif // LWIP_SOCKET
|
|
@ -0,0 +1,110 @@
|
||||||
|
#include "rtl8195a.h"
|
||||||
|
#include <main.h>
|
||||||
|
#include "rtl8195a_it.h"
|
||||||
|
|
||||||
|
/* os dependent*/
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "queue.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <diag.h>
|
||||||
|
#define printf DiagPrintf
|
||||||
|
|
||||||
|
/*-----------------------------Global Variable ---------------------*/
|
||||||
|
//#ifdef CONFIG_WLAN
|
||||||
|
//#ifdef CONFIG_ISR_THREAD_MODE_INTERRUPT
|
||||||
|
extern xSemaphoreHandle *pExportWlanIrqSemaphore;
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_WLAN
|
||||||
|
#ifdef CONFIG_ISR_THREAD_MODE_INTERRUPT
|
||||||
|
|
||||||
|
//TODO: chris
|
||||||
|
#define IRQ_HANDLED 1
|
||||||
|
#define IRQ_NONE 0
|
||||||
|
|
||||||
|
int wlan_Interrupt (
|
||||||
|
IN VOID* Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
|
printf("wlan interrupt\n");
|
||||||
|
/* This semaphore is initialized once wlan interrupt handler thread is created and initialized*/
|
||||||
|
if(!pExportWlanIrqSemaphore)
|
||||||
|
{
|
||||||
|
printf("%s(%d)\n", __FUNCTION__, __LINE__);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s(%d)\n", __FUNCTION__, __LINE__);
|
||||||
|
xSemaphoreGiveFromISR( *pExportWlanIrqSemaphore, &xHigherPriorityTaskWoken );
|
||||||
|
|
||||||
|
printf("%s(%d)\n", __FUNCTION__, __LINE__);
|
||||||
|
/* Switch tasks if necessary. */
|
||||||
|
if( xHigherPriorityTaskWoken != pdFALSE )
|
||||||
|
{
|
||||||
|
printf("%s(%d)\n", __FUNCTION__, __LINE__);
|
||||||
|
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
#else
|
||||||
|
struct dvobj_priv *dvobj = (struct dvobj_priv *)Data;
|
||||||
|
_adapter *adapter = dvobj->if1;
|
||||||
|
DBG_8192C("Dma isr\n");
|
||||||
|
|
||||||
|
if (dvobj->irq_enabled == 0) {
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
}
|
||||||
|
DBG_871X("%s(%d)\n", __FUNCTION__, __LINE__);
|
||||||
|
if(rtw_hal_interrupt_handler(adapter) == _FAIL)
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
//return IRQ_NONE;
|
||||||
|
DBG_871X("%s(%d)\n", __FUNCTION__, __LINE__);
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
lextra_bus_dma_Interrupt (
|
||||||
|
IN VOID* Data
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function register interrupt handler and is called by wlan driver
|
||||||
|
* Return 0 if success, Others if fail
|
||||||
|
*/
|
||||||
|
|
||||||
|
int irq_alloc_wlan(void *contex)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
IRQ_HANDLE IrqHandle = {0};
|
||||||
|
|
||||||
|
printf("Register Interrupt\n");
|
||||||
|
IrqHandle.Data = (u32) (contex);
|
||||||
|
IrqHandle.IrqNum = WL_DMA_IRQ;
|
||||||
|
IrqHandle.IrqFun = (IRQ_FUN)wlan_Interrupt;
|
||||||
|
//IrqHandle.IrqFun = (IRQ_FUN)lextra_bus_dma_Interrupt;
|
||||||
|
IrqHandle.Priority = 0;
|
||||||
|
|
||||||
|
InterruptRegister(&IrqHandle);
|
||||||
|
InterruptEn(&IrqHandle);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "main_test.h"
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
#include "wifi_conf.h"
|
||||||
|
#include "wlan_intf.h"
|
||||||
|
#include "wifi_constants.h"
|
||||||
|
#endif
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
//#include "wifi_interactive_ext.h"
|
||||||
|
|
||||||
|
#ifndef CONFIG_INIT_NET
|
||||||
|
#define CONFIG_INIT_NET 1
|
||||||
|
#endif
|
||||||
|
#ifndef CONFIG_INTERACTIVE_MODE
|
||||||
|
#define CONFIG_INTERACTIVE_MODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define STACKSIZE (512 + 768)
|
||||||
|
|
||||||
|
xSemaphoreHandle uart_rx_interrupt_sema = NULL;
|
||||||
|
|
||||||
|
void init_thread(void *param)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if CONFIG_INIT_NET
|
||||||
|
#if CONFIG_LWIP_LAYER
|
||||||
|
/* Initilaize the LwIP stack */
|
||||||
|
// DBG_8195A("\nLwIP Init\n");
|
||||||
|
LwIP_Init();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if CONFIG_WIFI_IND_USE_THREAD
|
||||||
|
wifi_manager_init();
|
||||||
|
#endif
|
||||||
|
#if CONFIG_WLAN
|
||||||
|
// DBG_8195A("\nWiFi_on(RTW_MODE_STA)\n");
|
||||||
|
wifi_on(RTW_MODE_STA);
|
||||||
|
#if CONFIG_AUTO_RECONNECT
|
||||||
|
//setup reconnection flag
|
||||||
|
// u8 mode;
|
||||||
|
// if(wifi_get_autoreconnect(&mode) > 0 && mode != 1)
|
||||||
|
wifi_set_autoreconnect(1);
|
||||||
|
#endif
|
||||||
|
// printf("\n\r%s(%d), Available heap %d\n\r", __FUNCTION__, __LINE__, xPortGetFreeHeapSize());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_INTERACTIVE_MODE
|
||||||
|
/* Initial uart rx swmaphore*/
|
||||||
|
vSemaphoreCreateBinary(uart_rx_interrupt_sema);
|
||||||
|
xSemaphoreTake(uart_rx_interrupt_sema, 1/portTICK_RATE_MS);
|
||||||
|
start_interactive_mode();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Kill init thread after all init tasks done */
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlan_network()
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
void *stack_addr = tcm_heap_malloc(STACKSIZE*sizeof(int));
|
||||||
|
if(stack_addr == NULL){
|
||||||
|
printf("%s: Out of TCM heap!\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
if (xTaskGenericCreate(
|
||||||
|
init_thread,
|
||||||
|
(const char *)"init",
|
||||||
|
STACKSIZE,
|
||||||
|
NULL,
|
||||||
|
tskIDLE_PRIORITY + 3 + PRIORITIE_OFFSET,
|
||||||
|
NULL,
|
||||||
|
stack_addr,
|
||||||
|
NULL) != pdTRUE)
|
||||||
|
printf("%s: xTaskCreate(init_thread) failed\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if(xTaskCreate(init_thread, ((const char*)"init"), STACKSIZE, NULL, tskIDLE_PRIORITY + 3 + PRIORITIE_OFFSET, NULL) != pdPASS) // +3
|
||||||
|
printf("%s: xTaskCreate(init_thread) failed\n", __FUNCTION__);
|
||||||
|
#endif
|
||||||
|
}
|
262
Firmware/RTLGDB/USDK/component/common/api/platform/dlist.h
Normal file
262
Firmware/RTLGDB/USDK/component/common/api/platform/dlist.h
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
#ifndef __LIST_H
|
||||||
|
#define __LIST_H
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#ifndef inline
|
||||||
|
#define inline __inline
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This file is from Linux Kernel (include/linux/list.h)
|
||||||
|
* and modified by simply removing hardware prefetching of list items.
|
||||||
|
* Here by copyright, credits attributed to wherever they belong.
|
||||||
|
* Kulesh Shanmugasundaram (kulesh [squiggly] isis.poly.edu)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Simple doubly linked list implementation.
|
||||||
|
*
|
||||||
|
* Some of the internal functions ("__xxx") are useful when
|
||||||
|
* manipulating whole lists rather than single entries, as
|
||||||
|
* sometimes we already know the next/prev entries and we can
|
||||||
|
* generate better code by using them directly rather than
|
||||||
|
* using the generic single-entry routines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct list_head {
|
||||||
|
struct list_head *next, *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||||
|
|
||||||
|
#define LIST_HEAD(name) \
|
||||||
|
struct list_head name = LIST_HEAD_INIT(name)
|
||||||
|
|
||||||
|
#define INIT_LIST_HEAD(ptr) do { \
|
||||||
|
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert a new entry between two known consecutive entries.
|
||||||
|
*
|
||||||
|
* This is only for internal list manipulation where we know
|
||||||
|
* the prev/next entries already!
|
||||||
|
*/
|
||||||
|
static inline void __list_add(struct list_head *new,
|
||||||
|
struct list_head *prev,
|
||||||
|
struct list_head *next)
|
||||||
|
{
|
||||||
|
next->prev = new;
|
||||||
|
new->next = next;
|
||||||
|
new->prev = prev;
|
||||||
|
prev->next = new;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_add - add a new entry
|
||||||
|
* @new: new entry to be added
|
||||||
|
* @head: list head to add it after
|
||||||
|
*
|
||||||
|
* Insert a new entry after the specified head.
|
||||||
|
* This is good for implementing stacks.
|
||||||
|
*/
|
||||||
|
static inline void list_add(struct list_head *new, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_add(new, head, head->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_add_tail - add a new entry
|
||||||
|
* @new: new entry to be added
|
||||||
|
* @head: list head to add it before
|
||||||
|
*
|
||||||
|
* Insert a new entry before the specified head.
|
||||||
|
* This is useful for implementing queues.
|
||||||
|
*/
|
||||||
|
static inline void list_add_tail(struct list_head *new, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_add(new, head->prev, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete a list entry by making the prev/next entries
|
||||||
|
* point to each other.
|
||||||
|
*
|
||||||
|
* This is only for internal list manipulation where we know
|
||||||
|
* the prev/next entries already!
|
||||||
|
*/
|
||||||
|
static inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||||
|
{
|
||||||
|
next->prev = prev;
|
||||||
|
prev->next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_del - deletes entry from list.
|
||||||
|
* @entry: the element to delete from the list.
|
||||||
|
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
|
||||||
|
*/
|
||||||
|
static inline void list_del(struct list_head *entry)
|
||||||
|
{
|
||||||
|
__list_del(entry->prev, entry->next);
|
||||||
|
entry->next = (void *) 0;
|
||||||
|
entry->prev = (void *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_del_init - deletes entry from list and reinitialize it.
|
||||||
|
* @entry: the element to delete from the list.
|
||||||
|
*/
|
||||||
|
static inline void list_del_init(struct list_head *entry)
|
||||||
|
{
|
||||||
|
__list_del(entry->prev, entry->next);
|
||||||
|
INIT_LIST_HEAD(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_move - delete from one list and add as another's head
|
||||||
|
* @list: the entry to move
|
||||||
|
* @head: the head that will precede our entry
|
||||||
|
*/
|
||||||
|
static inline void list_move(struct list_head *list, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_del(list->prev, list->next);
|
||||||
|
list_add(list, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_move_tail - delete from one list and add as another's tail
|
||||||
|
* @list: the entry to move
|
||||||
|
* @head: the head that will follow our entry
|
||||||
|
*/
|
||||||
|
static inline void list_move_tail(struct list_head *list,
|
||||||
|
struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_del(list->prev, list->next);
|
||||||
|
list_add_tail(list, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_empty - tests whether a list is empty
|
||||||
|
* @head: the list to test.
|
||||||
|
*/
|
||||||
|
static inline int list_empty(struct list_head *head)
|
||||||
|
{
|
||||||
|
return head->next == head;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void __list_splice(struct list_head *list,
|
||||||
|
struct list_head *head)
|
||||||
|
{
|
||||||
|
struct list_head *first = list->next;
|
||||||
|
struct list_head *last = list->prev;
|
||||||
|
struct list_head *at = head->next;
|
||||||
|
|
||||||
|
first->prev = head;
|
||||||
|
head->next = first;
|
||||||
|
|
||||||
|
last->next = at;
|
||||||
|
at->prev = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_splice - join two lists
|
||||||
|
* @list: the new list to add.
|
||||||
|
* @head: the place to add it in the first list.
|
||||||
|
*/
|
||||||
|
static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||||
|
{
|
||||||
|
if (!list_empty(list))
|
||||||
|
__list_splice(list, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||||
|
* @list: the new list to add.
|
||||||
|
* @head: the place to add it in the first list.
|
||||||
|
*
|
||||||
|
* The list at @list is reinitialised
|
||||||
|
*/
|
||||||
|
static inline void list_splice_init(struct list_head *list,
|
||||||
|
struct list_head *head)
|
||||||
|
{
|
||||||
|
if (!list_empty(list)) {
|
||||||
|
__list_splice(list, head);
|
||||||
|
INIT_LIST_HEAD(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_entry - get the struct for this entry
|
||||||
|
* @ptr: the &struct list_head pointer.
|
||||||
|
* @type: the type of the struct this is embedded in.
|
||||||
|
* @member: the name of the list_struct within the struct.
|
||||||
|
*/
|
||||||
|
#define list_entry(ptr, type, member) \
|
||||||
|
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_first_entry - get the first element from a list
|
||||||
|
* @ptr: the list head to take the element from.
|
||||||
|
* @type: the type of the struct this is embedded in.
|
||||||
|
* @member: the name of the list_head within the struct.
|
||||||
|
*
|
||||||
|
* Note, that list is expected to be not empty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define list_first_entry(ptr, type, member) \
|
||||||
|
list_entry((ptr)->next, type, member)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each - iterate over a list
|
||||||
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
|
* @head: the head for your list.
|
||||||
|
*/
|
||||||
|
#define list_for_each(pos, head) \
|
||||||
|
for (pos = (head)->next; pos != (head); \
|
||||||
|
pos = pos->next)
|
||||||
|
/**
|
||||||
|
* list_for_each_prev - iterate over a list backwards
|
||||||
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
|
* @head: the head for your list.
|
||||||
|
*/
|
||||||
|
#define list_for_each_prev(pos, head) \
|
||||||
|
for (pos = (head)->prev; pos != (head); \
|
||||||
|
pos = pos->prev)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||||
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
|
* @n: another &struct list_head to use as temporary storage
|
||||||
|
* @head: the head for your list.
|
||||||
|
*/
|
||||||
|
#define list_for_each_safe(pos, n, head) \
|
||||||
|
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||||
|
pos = n, n = pos->next)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each_entry - iterate over list of given type
|
||||||
|
* @pos: the type * to use as a loop counter.
|
||||||
|
* @head: the head for your list.
|
||||||
|
* @member: the name of the list_struct within the struct.
|
||||||
|
*/
|
||||||
|
#define list_for_each_entry(pos, head, member, type) \
|
||||||
|
for (pos = list_entry((head)->next, type, member); \
|
||||||
|
&pos->member != (head); \
|
||||||
|
pos = list_entry(pos->member.next, type, member))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||||
|
* @pos: the type * to use as a loop counter.
|
||||||
|
* @n: another type * to use as temporary storage
|
||||||
|
* @head: the head for your list.
|
||||||
|
* @member: the name of the list_struct within the struct.
|
||||||
|
*/
|
||||||
|
#define list_for_each_entry_safe(pos, n, head, member, type) \
|
||||||
|
for (pos = list_entry((head)->next, type, member), \
|
||||||
|
n = list_entry(pos->member.next, type, member); \
|
||||||
|
&pos->member != (head); \
|
||||||
|
pos = n, n = list_entry(n->member.next, type, member))
|
||||||
|
|
||||||
|
#endif
|
168
Firmware/RTLGDB/USDK/component/common/api/platform/esp_comp.h
Normal file
168
Firmware/RTLGDB/USDK/component/common/api/platform/esp_comp.h
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
#ifndef _INCLUDE_ESP_COMP_H_
|
||||||
|
#define _INCLUDE_ESP_COMP_H_
|
||||||
|
|
||||||
|
#include "platform_autoconf.h"
|
||||||
|
#include "flash_api.h"
|
||||||
|
|
||||||
|
#define ICACHE_FLASH_ATTR
|
||||||
|
#define ICACHE_RODATA_ATTR
|
||||||
|
#define DATA_IRAM_ATTR
|
||||||
|
#define ICACHE_RAM_ATTR
|
||||||
|
|
||||||
|
|
||||||
|
#define os_printf rtl_printf
|
||||||
|
#define os_printf_plus rtl_printf
|
||||||
|
#define os_sprintf_fd rtl_sprintf
|
||||||
|
#define ets_sprintf rtl_sprintf
|
||||||
|
|
||||||
|
//#ifndef os_malloc
|
||||||
|
#undef os_malloc
|
||||||
|
extern void *pvPortMalloc(size_t xWantedSize);
|
||||||
|
#define os_malloc pvPortMalloc
|
||||||
|
#undef os_zalloc
|
||||||
|
extern void *pvPortZalloc(size_t xWantedSize);
|
||||||
|
#define os_zalloc pvPortZalloc
|
||||||
|
//#undef os_calloc
|
||||||
|
//#define os_calloc pvPortCalloc
|
||||||
|
#undef os_realloc
|
||||||
|
extern void *pvPortReAlloc(void *pv, size_t xWantedSize);
|
||||||
|
#define os_realloc pvPortReAlloc
|
||||||
|
#undef os_free
|
||||||
|
extern void vPortFree(void *pv);
|
||||||
|
#define os_free vPortFree
|
||||||
|
//#endif
|
||||||
|
extern size_t xPortGetFreeHeapSize(void);
|
||||||
|
#define system_get_free_heap_size xPortGetFreeHeapSize
|
||||||
|
|
||||||
|
#define os_bzero rtl_bzero
|
||||||
|
#define os_delay_us wait_us // HalDelayUs
|
||||||
|
//#define os_install_putc1 rtl_install_putc1
|
||||||
|
//#define os_install_putc2 rtl_install_putc2
|
||||||
|
//#define os_intr_lock rtl_intr_lock
|
||||||
|
//#define os_intr_unlock rtl_intr_unlock
|
||||||
|
//#define os_isr_attach rtl_isr_attach
|
||||||
|
//#define os_isr_mask rtl_isr_mask
|
||||||
|
//#define os_isr_unmask rtl_isr_unmask
|
||||||
|
#define os_memcmp rtl_memcmp
|
||||||
|
#define os_memcpy rtl_memcpy
|
||||||
|
#define ets_memcpy rtl_memcpy
|
||||||
|
#define os_memmove rtl_memmove
|
||||||
|
#define os_memset rtl_memset
|
||||||
|
#define os_putc rtl_putc
|
||||||
|
//#define os_str2macaddr rtl_str2macaddr
|
||||||
|
//#define os_strcat strcat
|
||||||
|
#define os_strchr rtl_strchr
|
||||||
|
#define os_strrchr rtl_strrchr
|
||||||
|
#define os_strcmp rtl_strcmp
|
||||||
|
#define os_strcpy rtl_strcpy
|
||||||
|
#define os_strlen rtl_strlen
|
||||||
|
#define os_strncmp rtl_strncmp
|
||||||
|
#define os_strncpy rtl_strncpy
|
||||||
|
#define os_strstr rtl_strstr
|
||||||
|
#define os_random Rand
|
||||||
|
|
||||||
|
//extern uint32 phy_get_rand(void);
|
||||||
|
#define system_get_os_print() 1
|
||||||
|
|
||||||
|
#ifdef USE_US_TIMER
|
||||||
|
#define os_timer_arm_us(a, b, c) rtl_timer_arm_new(a, b, c, 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//#define os_timer_arm(a, b, c) rtl_timer_arm_new(a, b, c, 1)
|
||||||
|
//#define os_timer_disarm rtl_timer_disarm
|
||||||
|
//#define os_timer_init rtl_timer_init
|
||||||
|
//#define os_timer_setfn rtl_timer_setfn
|
||||||
|
|
||||||
|
//#define os_timer_done rtl_timer_done
|
||||||
|
//#define os_timer_handler_isr rtl_timer_handler_isr
|
||||||
|
|
||||||
|
//#define os_update_cpu_frequency rtl_update_cpu_frequency
|
||||||
|
|
||||||
|
//#define os_sprintf ets_sprintf
|
||||||
|
/*
|
||||||
|
typedef struct{
|
||||||
|
uint32_t deviceId; //+00
|
||||||
|
uint32_t chip_size; //+04 chip size in byte
|
||||||
|
uint32_t block_size; //+08
|
||||||
|
uint32_t sector_size; //+0c
|
||||||
|
uint32_t page_size; //+10
|
||||||
|
uint32_t status_mask; //+14
|
||||||
|
} SpiFlashChip;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SPI_FLASH_RESULT_OK,
|
||||||
|
SPI_FLASH_RESULT_ERR,
|
||||||
|
SPI_FLASH_RESULT_TIMEOUT
|
||||||
|
} SpiFlashOpResult;
|
||||||
|
|
||||||
|
extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714
|
||||||
|
*/
|
||||||
|
|
||||||
|
// include "flash_api.h"
|
||||||
|
#define spi_flash_real_size() flash_get_size(&flashobj)
|
||||||
|
#define Cache_Read_Disable() SpicDisableRtl8195A()
|
||||||
|
#define Cache_Read_Enable(a, b, c) flash_turnon()
|
||||||
|
|
||||||
|
#define spi_flash_get_id() ((flashobj.SpicInitPara.id[0] << 16) | (flashobj.SpicInitPara.id[1]<<8) | flashobj.SpicInitPara.id[2])
|
||||||
|
//SpiFlashOpResult spi_flash_read_status(uint32_t * sta);
|
||||||
|
//SpiFlashOpResult spi_flash_write_status(uint32_t sta);
|
||||||
|
#define spi_flash_erase_sector(sec) flash_erase_sector(&flashobj, (sec)<<12)
|
||||||
|
#define spi_flash_write(faddr, pbuf, size) flash_stream_write(&flashobj, faddr, size, (uint8_t *)pbuf)
|
||||||
|
#define spi_flash_read(faddr, pbuf, size) flash_stream_read(&flashobj, faddr, size, (uint8_t *)pbuf)
|
||||||
|
#define spi_flash_erase_block(blk) flash_erase_block(&flashobj, (blk)<<16);
|
||||||
|
|
||||||
|
#ifndef ip4_addr1
|
||||||
|
#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
|
||||||
|
#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
|
||||||
|
#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
|
||||||
|
#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
|
||||||
|
#endif
|
||||||
|
/* These are cast to u16_t, with the intent that they are often arguments
|
||||||
|
* to printf using the U16_F format from cc.h. */
|
||||||
|
#ifndef ip4_addr1_16
|
||||||
|
#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
|
||||||
|
#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
|
||||||
|
#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
|
||||||
|
#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef IP2STR
|
||||||
|
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
|
||||||
|
ip4_addr2_16(ipaddr), \
|
||||||
|
ip4_addr3_16(ipaddr), \
|
||||||
|
ip4_addr4_16(ipaddr)
|
||||||
|
|
||||||
|
#undef IPSTR
|
||||||
|
#define IPSTR "%d.%d.%d.%d"
|
||||||
|
|
||||||
|
#ifndef MAC2STR
|
||||||
|
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||||
|
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DEBUGSOO
|
||||||
|
/* 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 */
|
||||||
|
#if CONFIG_DEBUG_LOG > 3
|
||||||
|
#define DEBUGSOO (CONFIG_DEBUG_LOG - 1)
|
||||||
|
#elif CONFIG_DEBUG_LOG > 1
|
||||||
|
#define DEBUGSOO 2
|
||||||
|
#else
|
||||||
|
#define DEBUGSOO CONFIG_DEBUG_LOG
|
||||||
|
#endif
|
||||||
|
#endif //#ifndef DEBUGSOO
|
||||||
|
|
||||||
|
//#define system_get_sdk_version() "3.5.3"
|
||||||
|
|
||||||
|
//#define system_get_time xTaskGetTickCount
|
||||||
|
//#define ets_get_cpu_frequency HalGetCpuClk
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _INCLUDE_ESP_COMP_H_
|
|
@ -0,0 +1,289 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
******************************************************************************/
|
||||||
|
#ifndef __PLATFORM_STDLIB_H__
|
||||||
|
#define __PLATFORM_STDLIB_H__
|
||||||
|
|
||||||
|
#define USE_CLIB_PATCH 0
|
||||||
|
#if defined (__GNUC__)
|
||||||
|
/* build rom should set USE_RTL_ROM_CLIB=0 */
|
||||||
|
#ifndef CONFIG_MBED_ENABLED
|
||||||
|
#include <rt_lib_rom.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BUILD_ROM
|
||||||
|
#define USE_RTL_ROM_CLIB 0
|
||||||
|
#else
|
||||||
|
#define BUFFERED_PRINTF 0
|
||||||
|
#ifndef CONFIG_MBED_ENABLED
|
||||||
|
#define USE_RTL_ROM_CLIB 1
|
||||||
|
#else
|
||||||
|
#define USE_RTL_ROM_CLIB 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_PLATFORM_8195A)
|
||||||
|
#if defined (__IARSTDLIB__)
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "diag.h"
|
||||||
|
|
||||||
|
#define strsep(str, delim) _strsep(str, delim)
|
||||||
|
#else
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "diag.h"
|
||||||
|
#include "strproc.h"
|
||||||
|
#include "basic_types.h"
|
||||||
|
#include "hal_misc.h"
|
||||||
|
#if USE_RTL_ROM_CLIB
|
||||||
|
#include "rtl_lib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef printf
|
||||||
|
#undef sprintf
|
||||||
|
#undef snprintf
|
||||||
|
#undef atoi
|
||||||
|
#undef memcmp
|
||||||
|
#undef memcpy
|
||||||
|
#undef memset
|
||||||
|
#undef strcmp
|
||||||
|
#undef strcpy
|
||||||
|
#undef strlen
|
||||||
|
#undef strncmp
|
||||||
|
#undef strncpy
|
||||||
|
#undef strsep
|
||||||
|
#undef strtok
|
||||||
|
#if USE_RTL_ROM_CLIB
|
||||||
|
#undef memchr
|
||||||
|
#undef memmove
|
||||||
|
#undef strcat
|
||||||
|
#undef strchr
|
||||||
|
#undef strncat
|
||||||
|
#undef strstr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_RTL_ROM_CLIB
|
||||||
|
#if BUFFERED_PRINTF
|
||||||
|
extern int buffered_printf(const char* fmt, ...);
|
||||||
|
#define printf buffered_printf
|
||||||
|
#else
|
||||||
|
#define printf rtl_printf
|
||||||
|
#endif
|
||||||
|
#define sprintf rtl_sprintf
|
||||||
|
#define snprintf rtl_snprintf
|
||||||
|
#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
|
||||||
|
#else
|
||||||
|
#if USE_CLIB_PATCH
|
||||||
|
extern int DiagSscanfPatch(const char *buf, const char *fmt, ...);
|
||||||
|
extern char* DiagStrtokPatch(char *str, const char* delim);
|
||||||
|
extern char* DiagStrstrPatch(char *string, char *substring);
|
||||||
|
extern int DiagSnPrintfPatch(char *buf, size_t size, const char *fmt, ...);
|
||||||
|
extern u32 DiagPrintfPatch(const char *fmt, ...);
|
||||||
|
extern u32 DiagSPrintfPatch(u8 *buf, const char *fmt, ...);
|
||||||
|
#define printf DiagPrintfPatch
|
||||||
|
#define sprintf DiagSPrintfPatch
|
||||||
|
#define snprintf DiagSnPrintfPatch
|
||||||
|
#define strstr(a, b) DiagStrstrPatch((char *)(a), (char *)(b))
|
||||||
|
#define strtok DiagStrtokPatch
|
||||||
|
#else
|
||||||
|
#define printf DiagPrintf
|
||||||
|
#define sprintf(fmt, arg...) DiagSPrintf((u8*)fmt, ##arg)
|
||||||
|
#if defined (__GNUC__)
|
||||||
|
#define snprintf DiagSnPrintf // NULL function
|
||||||
|
#define strstr(str1, str2) prvStrStr(str1, str2) // NULL function
|
||||||
|
#endif
|
||||||
|
#define strtok(str, delim) _strsep(str, delim)
|
||||||
|
#endif
|
||||||
|
#define memcmp(dst, src, sz) _memcmp(dst, src, sz)
|
||||||
|
#define memcpy(dst, src, sz) _memcpy(dst, src, sz)
|
||||||
|
#define memset(dst, val, sz) _memset(dst, val, sz)
|
||||||
|
#define strchr(s, c) _strchr(s, c) // for B-cut ROM
|
||||||
|
#define strcmp(str1, str2) prvStrCmp((const unsigned char *) str1, (const unsigned char *) str2)
|
||||||
|
#define strcpy(dest, src) _strcpy(dest, src)
|
||||||
|
#define strlen(str) prvStrLen((const unsigned char *) str)
|
||||||
|
#define strncmp(str1, str2, cnt) _strncmp(str1, str2, cnt)
|
||||||
|
#define strncpy(dest, src, count) _strncpy(dest, src, count)
|
||||||
|
#define strsep(str, delim) _strsep(str, delim)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define atoi(str) prvAtoi(str)
|
||||||
|
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
|
||||||
|
|
||||||
|
#if USE_CLIB_PATCH
|
||||||
|
#undef sscanf
|
||||||
|
#define sscanf DiagSscanfPatch
|
||||||
|
#else
|
||||||
|
#if defined (__GNUC__)
|
||||||
|
#undef sscanf //_sscanf
|
||||||
|
//extern int DiagSscanfPatch(const char *buf, const char *fmt, ...);
|
||||||
|
//#define sscanf DiagSscanfPatch
|
||||||
|
#define sscanf sscanf // use libc sscanf
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif // defined (__IARSTDLIB__)
|
||||||
|
|
||||||
|
//
|
||||||
|
// memory management
|
||||||
|
//
|
||||||
|
#undef malloc
|
||||||
|
extern void *pvPortMalloc(size_t xWantedSize);
|
||||||
|
#define malloc pvPortMalloc
|
||||||
|
|
||||||
|
#undef zalloc
|
||||||
|
extern void *pvPortZalloc(size_t xWantedSize);
|
||||||
|
#define zalloc pvPortZalloc
|
||||||
|
|
||||||
|
#undef realloc
|
||||||
|
extern void *pvPortReAlloc(void *pv, size_t xWantedSize);
|
||||||
|
#define realloc pvPortReAlloc
|
||||||
|
|
||||||
|
#undef free
|
||||||
|
extern void vPortFree(void *pv);
|
||||||
|
#define free vPortFree
|
||||||
|
|
||||||
|
#elif defined (CONFIG_PLATFORM_8711B)
|
||||||
|
|
||||||
|
#if defined (__IARSTDLIB__)
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h> /* va_list */
|
||||||
|
#include "diag.h"
|
||||||
|
|
||||||
|
#define strsep(str, delim) _strsep(str, delim)
|
||||||
|
#else
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h> /* va_list */
|
||||||
|
#include "diag.h"
|
||||||
|
#include "strproc.h"
|
||||||
|
#include "memproc.h"
|
||||||
|
#include "basic_types.h"
|
||||||
|
#if USE_RTL_ROM_CLIB
|
||||||
|
#include "rtl_lib.h"
|
||||||
|
#include "rom_libc_string.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef printf
|
||||||
|
#undef sprintf
|
||||||
|
#undef snprintf
|
||||||
|
#undef memchr
|
||||||
|
#undef memcmp
|
||||||
|
#undef memcpy
|
||||||
|
#undef memset
|
||||||
|
#undef memmove
|
||||||
|
#undef strcmp
|
||||||
|
#undef strcpy
|
||||||
|
#undef strlen
|
||||||
|
#undef strncmp
|
||||||
|
#undef strncpy
|
||||||
|
#undef strsep
|
||||||
|
#undef strtok
|
||||||
|
#undef strcat
|
||||||
|
#undef strchr
|
||||||
|
#undef strncat
|
||||||
|
#undef strstr
|
||||||
|
#undef atol
|
||||||
|
#undef atoi
|
||||||
|
#undef strpbrk
|
||||||
|
|
||||||
|
#if USE_RTL_ROM_CLIB
|
||||||
|
#if BUFFERED_PRINTF
|
||||||
|
extern int buffered_printf(const char* fmt, ...);
|
||||||
|
#define printf buffered_printf
|
||||||
|
#else
|
||||||
|
#define printf rtl_printf
|
||||||
|
#endif
|
||||||
|
#define sprintf rtl_sprintf
|
||||||
|
#define snprintf rtl_snprintf
|
||||||
|
#define vsnprintf rtl_vsnprintf
|
||||||
|
#else
|
||||||
|
#define printf DiagPrintf
|
||||||
|
#define sprintf(fmt, arg...) DiagSPrintf((u8*)fmt, ##arg)
|
||||||
|
#define snprintf DiagSnPrintf // NULL function
|
||||||
|
#define vsnprintf(buf, size, fmt, ap) VSprintf(buf, fmt, ap)
|
||||||
|
#endif
|
||||||
|
#define memchr __rtl_memchr_v1_00
|
||||||
|
#define memcmp(dst, src, sz) _memcmp(dst, src, sz)
|
||||||
|
#define memcpy(dst, src, sz) _memcpy(dst, src, sz)
|
||||||
|
#define memmove __rtl_memmove_v1_00
|
||||||
|
#define memset(dst, val, sz) _memset(dst, val, sz)
|
||||||
|
|
||||||
|
#define strchr(s, c) _strchr(s, c) // for B-cut ROM
|
||||||
|
#define strcmp(str1, str2) prvStrCmp((const unsigned char *) str1, (const unsigned char *) str2)
|
||||||
|
#define strcpy(dest, src) _strcpy(dest, src)
|
||||||
|
#define strlen(str) prvStrLen((const unsigned char *) str)
|
||||||
|
#define strsep(str, delim) _strsep(str, delim)
|
||||||
|
#define strstr(str1, str2) prvStrStr(str1, str2) // NULL function
|
||||||
|
#define strtok(str, delim) prvStrtok(str, delim)//_strsep(str, delim)
|
||||||
|
#define strcat __rtl_strcat_v1_00
|
||||||
|
|
||||||
|
#define strncmp(str1, str2, cnt) _strncmp(str1, str2, cnt)
|
||||||
|
#define strncpy(dest, src, count) _strncpy(dest, src, count)
|
||||||
|
#define strncat __rtl_strncat_v1_00
|
||||||
|
|
||||||
|
#define atol(str) strtol(str,NULL,10)
|
||||||
|
#define atoi(str) prvAtoi(str)
|
||||||
|
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
|
||||||
|
#if defined (__GNUC__)
|
||||||
|
#undef sscanf
|
||||||
|
#define sscanf _sscanf_patch
|
||||||
|
#define rand Rand
|
||||||
|
#endif
|
||||||
|
//extern int _sscanf_patch(const char *buf, const char *fmt, ...);
|
||||||
|
//#define sscanf _sscanf_patch
|
||||||
|
|
||||||
|
|
||||||
|
#endif // defined (__IARSTDLIB__)
|
||||||
|
|
||||||
|
//
|
||||||
|
// memory management
|
||||||
|
//
|
||||||
|
extern void *pvPortMalloc( size_t xWantedSize );
|
||||||
|
extern void vPortFree( void *pv );
|
||||||
|
#define malloc pvPortMalloc
|
||||||
|
#define free vPortFree
|
||||||
|
#elif defined(USE_STM322xG_EVAL) || defined(USE_STM324xG_EVAL) || defined(STM32F10X_XL)
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__PLATFORM_STDLIB_H__
|
||||||
|
|
|
@ -0,0 +1,915 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
this is the c lib patch, It can help when the clib provided by IAR
|
||||||
|
does not work well.
|
||||||
|
|
||||||
|
How to use this:
|
||||||
|
1.You must include platform_stdlib.h in you source file。
|
||||||
|
2.There is a macro USE_CLIB_PATCH in platform_stdlib.h should be opened.
|
||||||
|
|
||||||
|
If there is some problems using this patch,
|
||||||
|
You'd better check if you code runs into these functions:
|
||||||
|
|
||||||
|
DiagSscanfPatch
|
||||||
|
DiagStrtokPatch
|
||||||
|
DiagStrstrPatch
|
||||||
|
DiagSnPrintfPatch
|
||||||
|
DiagPrintfPatch
|
||||||
|
DiagSPrintfPatch
|
||||||
|
DiagPrintfPatch
|
||||||
|
DiagSPrintfPatch
|
||||||
|
DiagSnPrintfPatch
|
||||||
|
DiagStrstrPatch
|
||||||
|
DiagStrtokPatch
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef CONFIG_PLATFORM_8711B
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#define DiagPutChar HalSerialPutcRtl8195a
|
||||||
|
|
||||||
|
#define IN
|
||||||
|
#define NULL 0
|
||||||
|
|
||||||
|
typedef unsigned int size_t;
|
||||||
|
typedef unsigned int SIZE_T;
|
||||||
|
typedef unsigned long long u64;
|
||||||
|
typedef unsigned int u32;
|
||||||
|
typedef unsigned short int u16;
|
||||||
|
typedef unsigned char u8;
|
||||||
|
typedef signed long long s64;
|
||||||
|
typedef signed int s32;
|
||||||
|
typedef signed short int s16;
|
||||||
|
typedef unsigned char bool;
|
||||||
|
|
||||||
|
|
||||||
|
extern u8 txt0123456789ABCDEF[16];
|
||||||
|
#define tab0123456789ABCDEF txt0123456789ABCDEF // = "0123456789ABCDEF"
|
||||||
|
|
||||||
|
|
||||||
|
#define in_range(c, lo, up) ((u8)c >= lo && (u8)c <= up)
|
||||||
|
#define isprint(c) in_range(c, 0x20, 0x7f)
|
||||||
|
#define isdigit(c) in_range(c, '0', '9')
|
||||||
|
#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
|
||||||
|
#define islower(c) in_range(c, 'a', 'z')
|
||||||
|
#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == ',')
|
||||||
|
#define ULLONG_MAX (~0ULL)
|
||||||
|
#define USHRT_MAX ((u16)(~0U))
|
||||||
|
#define KSTRTOX_OVERFLOW (1U << 31)
|
||||||
|
#define SHRT_MAX ((s16)(USHRT_MAX>>1))
|
||||||
|
|
||||||
|
static inline char _tolower(const char c)
|
||||||
|
{
|
||||||
|
return c | 0x20;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
|
||||||
|
extern s64 div_s64(s64 dividend, s32 divisor);
|
||||||
|
extern inline char _tolower(const char c);
|
||||||
|
extern u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder);
|
||||||
|
extern u64 div_u64(u64 dividend, u32 divisor);
|
||||||
|
extern unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p);
|
||||||
|
extern const char *_parse_integer_fixup_radix(const char *s, unsigned int *base);
|
||||||
|
extern char *skip_spaces(const char *str);
|
||||||
|
extern int skip_atoi(const char **s);
|
||||||
|
extern void HalSerialPutcRtl8195a(u8 c);
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned long long simple_strtoull_patch(const char *cp, char **endp, unsigned int base)
|
||||||
|
{
|
||||||
|
unsigned long long result;
|
||||||
|
unsigned int rv;
|
||||||
|
|
||||||
|
cp = _parse_integer_fixup_radix(cp, &base);
|
||||||
|
rv = _parse_integer(cp, base, &result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static long long simple_strtoll_patch(const char *cp, char **endp, unsigned int base)
|
||||||
|
{
|
||||||
|
if(*cp == '-')
|
||||||
|
return -simple_strtoull_patch(cp + 1, endp, base);
|
||||||
|
|
||||||
|
return simple_strtoull_patch(cp, endp, base);
|
||||||
|
}
|
||||||
|
static unsigned long simple_strtoul_patch(const char *cp, char **endp, unsigned int base)
|
||||||
|
{
|
||||||
|
return simple_strtoull_patch(cp, endp, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
static long simple_strtol_patch(const char *cp, char **endp, unsigned int base)
|
||||||
|
{
|
||||||
|
if(*cp == '-')
|
||||||
|
return -simple_strtoul_patch(cp + 1, endp, base);
|
||||||
|
|
||||||
|
return simple_strtoul_patch(cp, endp, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int judge_digit_width(const char *str)
|
||||||
|
{
|
||||||
|
|
||||||
|
int width = 0;
|
||||||
|
|
||||||
|
while(isdigit(*str)) {
|
||||||
|
width++;
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int _vsscanf_patch(const char *buf, const char *fmt, va_list args)
|
||||||
|
{
|
||||||
|
const char *str = buf;
|
||||||
|
char *next;
|
||||||
|
char digit;
|
||||||
|
int num = 0;
|
||||||
|
int i =0;
|
||||||
|
u8 qualifier;
|
||||||
|
unsigned int base;
|
||||||
|
union {
|
||||||
|
long long s;
|
||||||
|
unsigned long long u;
|
||||||
|
} val;
|
||||||
|
s16 field_width;
|
||||||
|
bool is_sign;
|
||||||
|
|
||||||
|
char str_store[20] = {0};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while(*fmt) {
|
||||||
|
/* skip any white space in format */
|
||||||
|
/* white space in format matchs any amount of
|
||||||
|
* white space, including none, in the input.
|
||||||
|
*/
|
||||||
|
if(isspace(*fmt)) {
|
||||||
|
fmt = skip_spaces(++fmt);
|
||||||
|
str = skip_spaces(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* anything that is not a conversion must match exactly */
|
||||||
|
if(*fmt != '%' && *fmt) {
|
||||||
|
if(*fmt++ != *str++) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!*fmt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++fmt;
|
||||||
|
|
||||||
|
/* skip this conversion.
|
||||||
|
* advance both strings to next white space
|
||||||
|
*/
|
||||||
|
if(*fmt == '*') {
|
||||||
|
if(!*str) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(!isspace(*fmt) && *fmt != '%' && *fmt)
|
||||||
|
fmt++;
|
||||||
|
|
||||||
|
while(!isspace(*str) && *str)
|
||||||
|
str++;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get field width */
|
||||||
|
field_width = -1;
|
||||||
|
|
||||||
|
if(isdigit(*fmt)) {
|
||||||
|
|
||||||
|
field_width = skip_atoi(&fmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(field_width <= 0) {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get conversion qualifier */
|
||||||
|
qualifier = -1;
|
||||||
|
|
||||||
|
if(*fmt == 'h' || _tolower(*fmt) == 'l' ||
|
||||||
|
_tolower(*fmt) == 'z') {
|
||||||
|
qualifier = *fmt++;
|
||||||
|
|
||||||
|
if(qualifier == *fmt) {
|
||||||
|
if(qualifier == 'h') {
|
||||||
|
qualifier = 'H';
|
||||||
|
fmt++;
|
||||||
|
} else if(qualifier == 'l') {
|
||||||
|
qualifier = 'L';
|
||||||
|
fmt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!*fmt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*fmt == 'n') {
|
||||||
|
/* return number of characters read so far */
|
||||||
|
*va_arg(args, int *) = str - buf;
|
||||||
|
++fmt;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!*str) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
base = 10;
|
||||||
|
is_sign = 0;
|
||||||
|
|
||||||
|
switch(*fmt++) {
|
||||||
|
case 'c': {
|
||||||
|
char *s = (char *)va_arg(args, char*);
|
||||||
|
|
||||||
|
if(field_width == -1)
|
||||||
|
field_width = 1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
*s++ = *str++;
|
||||||
|
} while(--field_width > 0 && *str);
|
||||||
|
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case 's': {
|
||||||
|
char *s = (char *)va_arg(args, char *);
|
||||||
|
|
||||||
|
if(field_width == -1)
|
||||||
|
field_width = SHRT_MAX;
|
||||||
|
|
||||||
|
/* first, skip leading white space in buffer */
|
||||||
|
str = skip_spaces(str);
|
||||||
|
|
||||||
|
/* now copy until next white space */
|
||||||
|
while(*str && !isspace(*str) && field_width--) {
|
||||||
|
*s++ = *str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
*s = '\0';
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case 'o':
|
||||||
|
base = 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
case 'X':
|
||||||
|
base = 16;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'i':
|
||||||
|
base = 0;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
is_sign = 1;
|
||||||
|
|
||||||
|
case 'u':
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '%':
|
||||||
|
|
||||||
|
/* looking for '%' in str */
|
||||||
|
if(*str++ != '%') {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* invalid format; stop here */
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* have some sort of integer conversion.
|
||||||
|
* first, skip white space in buffer.
|
||||||
|
*/
|
||||||
|
str = skip_spaces(str);
|
||||||
|
|
||||||
|
digit = *str;
|
||||||
|
|
||||||
|
if(is_sign && digit == '-')
|
||||||
|
digit = *(str + 1);
|
||||||
|
|
||||||
|
if(!digit
|
||||||
|
|| (base == 16 && !isxdigit(digit))
|
||||||
|
|| (base == 10 && !isdigit(digit))
|
||||||
|
|| (base == 8 && (!isdigit(digit) || digit > '7'))
|
||||||
|
|| (base == 0 && !isdigit(digit))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//here problem *******************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//troy add ,fix support %2d, but not support %d
|
||||||
|
if(field_width <= 0) {
|
||||||
|
|
||||||
|
field_width = judge_digit_width(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////troy add, fix str passed inwidth wrong
|
||||||
|
for(i = 0; i<field_width ; i++)
|
||||||
|
str_store[i] = str[i];
|
||||||
|
|
||||||
|
next = (char*)str + field_width;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(is_sign) {
|
||||||
|
val.s = qualifier != 'L' ?
|
||||||
|
simple_strtol_patch(str_store, &next, base) :
|
||||||
|
simple_strtoll_patch(str_store, &next, base);
|
||||||
|
} else {
|
||||||
|
val.u = qualifier != 'L' ?
|
||||||
|
simple_strtoul_patch(str_store, &next, base) :
|
||||||
|
simple_strtoull_patch(str_store, &next, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////troy add
|
||||||
|
for(i = 0; i<20 ; i++)
|
||||||
|
str_store[i] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
//判断转换的字符串的宽度是否大于 %2d
|
||||||
|
if(field_width > 0 && next - str > field_width) {
|
||||||
|
if(base == 0)
|
||||||
|
_parse_integer_fixup_radix(str, &base);
|
||||||
|
|
||||||
|
while(next - str > field_width) {
|
||||||
|
if(is_sign) {
|
||||||
|
val.s = div_s64(val.s, base);
|
||||||
|
} else {
|
||||||
|
val.u = div_u64(val.u, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
--next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(qualifier) {
|
||||||
|
case 'H': /* that's 'hh' in format */
|
||||||
|
if(is_sign)
|
||||||
|
*va_arg(args, signed char *) = val.s;
|
||||||
|
else
|
||||||
|
*va_arg(args, unsigned char *) = val.u;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
if(is_sign)
|
||||||
|
*va_arg(args, short *) = val.s;
|
||||||
|
else
|
||||||
|
*va_arg(args, unsigned short *) = val.u;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
if(is_sign)
|
||||||
|
*va_arg(args, long *) = val.s;
|
||||||
|
else
|
||||||
|
*va_arg(args, unsigned long *) = val.u;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
if(is_sign)
|
||||||
|
*va_arg(args, long long *) = val.s;
|
||||||
|
else
|
||||||
|
*va_arg(args, unsigned long long *) = val.u;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Z':
|
||||||
|
case 'z':
|
||||||
|
*va_arg(args, size_t *) = val.u;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if(is_sign)
|
||||||
|
*va_arg(args, int *) = val.s;
|
||||||
|
else
|
||||||
|
*va_arg(args, unsigned int *) = val.u;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
num++;
|
||||||
|
|
||||||
|
if(!next) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int DiagSscanfPatch(const char *buf, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
i = _vsscanf_patch(buf, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char* DiagStrtokPatch(char *str, const char* delim) {
|
||||||
|
static char* _buffer;
|
||||||
|
|
||||||
|
if(str != NULL) _buffer = str;
|
||||||
|
|
||||||
|
if(_buffer[0] == '\0') return NULL;
|
||||||
|
|
||||||
|
char *ret = _buffer, *b;
|
||||||
|
const char *d;
|
||||||
|
|
||||||
|
for(b = _buffer; *b !='\0'; b++) {
|
||||||
|
for(d = delim; *d != '\0'; d++) {
|
||||||
|
if(*b == *d) {
|
||||||
|
*b = '\0';
|
||||||
|
_buffer = b+1;
|
||||||
|
|
||||||
|
// skip the beginning delimiters
|
||||||
|
if(b == ret) {
|
||||||
|
ret++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char *DiagStrstrPatch(char *string, char *substring)
|
||||||
|
{
|
||||||
|
register char *a, *b;
|
||||||
|
|
||||||
|
/* First scan quickly through the two strings looking for a
|
||||||
|
* single-character match. When it's found, then compare the
|
||||||
|
* rest of the substring.
|
||||||
|
*/
|
||||||
|
|
||||||
|
b = substring;
|
||||||
|
|
||||||
|
if(*b == 0) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(; *string != 0; string += 1) {
|
||||||
|
if(*string != *b) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
a = string;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
if(*b == 0) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*a++ != *b++) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b = substring;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (char *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int DiagSnPrintfPatch(char *buf, size_t size, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
char *p, *s, *buf_end = NULL;
|
||||||
|
const int *dp = ((const int *)&fmt)+1;
|
||||||
|
|
||||||
|
if(buf == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
s = buf;
|
||||||
|
buf_end = size? (buf + size):(char*)~0;
|
||||||
|
|
||||||
|
for(; *fmt != '\0'; ++fmt) {
|
||||||
|
|
||||||
|
if(*fmt != '%') {
|
||||||
|
*s++ = *fmt;
|
||||||
|
|
||||||
|
if(s >= buf_end) {
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*++fmt == 's') {
|
||||||
|
for(p = (char *)*dp++; *p != '\0'; p++) {
|
||||||
|
*s++ = *p;
|
||||||
|
|
||||||
|
if(s >= buf_end) {
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { /* Length of item is bounded */
|
||||||
|
char tmp[20], *q = tmp;
|
||||||
|
int alt = 0;
|
||||||
|
int shift = 0;// = 12;
|
||||||
|
const long *lpforchk = (const long *)dp;
|
||||||
|
|
||||||
|
if((*lpforchk) < 0x10) {
|
||||||
|
shift = 0;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x10) && ((*lpforchk) < 0x100)) {
|
||||||
|
shift = 4;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x100) && ((*lpforchk) < 0x1000)) {
|
||||||
|
shift = 8;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x1000) && ((*lpforchk) < 0x10000)) {
|
||||||
|
shift = 12;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x10000) && ((*lpforchk) < 0x100000)) {
|
||||||
|
shift = 16;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x100000) && ((*lpforchk) < 0x1000000)) {
|
||||||
|
shift = 20;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x1000000) && ((*lpforchk) < 0x10000000)) {
|
||||||
|
shift = 24;
|
||||||
|
}
|
||||||
|
else if((*lpforchk) >= 0x10000000) {
|
||||||
|
shift = 28;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
shift = 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((*fmt >= '0') && (*fmt <= '9'))
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
unsigned char fch = *fmt;
|
||||||
|
|
||||||
|
for(width=0; (fch>='0') && (fch<='9'); fch=*++fmt)
|
||||||
|
{ width = width * 10 + fch - '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
shift=(width-1)*4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Before each format q points to tmp buffer
|
||||||
|
* After each format q points past end of item
|
||||||
|
*/
|
||||||
|
if((*fmt == 'x')||(*fmt == 'X') || (*fmt == 'p') || (*fmt == 'P')) {
|
||||||
|
/* With x86 gcc, sizeof(long) == sizeof(int) */
|
||||||
|
const long *lp = (const long *)dp;
|
||||||
|
long h = *lp++;
|
||||||
|
int hex_count = 0;
|
||||||
|
unsigned long h_back = h;
|
||||||
|
int ncase = (*fmt & 0x20);
|
||||||
|
dp = (const int *)lp;
|
||||||
|
|
||||||
|
if((*fmt == 'p') || (*fmt == 'P'))
|
||||||
|
alt=1;
|
||||||
|
|
||||||
|
if(alt) {
|
||||||
|
*q++ = '0';
|
||||||
|
*q++ = 'X' | ncase;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(h_back) {
|
||||||
|
hex_count += (h_back & 0xF) ? 1 : 0;
|
||||||
|
h_back = h_back >> 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(shift < (hex_count - 1)*4)
|
||||||
|
shift = (hex_count - 1)*4;
|
||||||
|
|
||||||
|
for(; shift >= 0; shift -= 4)
|
||||||
|
*q++ = tab0123456789ABCDEF[(h >> shift) & 0xF] | ncase;
|
||||||
|
}
|
||||||
|
else if(*fmt == 'd') {
|
||||||
|
int i = *dp++;
|
||||||
|
char *r;
|
||||||
|
int digit_space = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if(i < 0) {
|
||||||
|
*q++ = '-';
|
||||||
|
i = -i;
|
||||||
|
digit_space++;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = q; /* save beginning of digits */
|
||||||
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
*q++ = '0' + (i % 10);
|
||||||
|
i /= 10;
|
||||||
|
digit_space++;
|
||||||
|
} while(i);
|
||||||
|
|
||||||
|
|
||||||
|
for(; shift >= 0; shift -= 4) {
|
||||||
|
|
||||||
|
if(digit_space-- > 0) {
|
||||||
|
; //do nothing
|
||||||
|
} else {
|
||||||
|
*q++ = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reverse digits, stop in middle */
|
||||||
|
r = q; /* don't alter q */
|
||||||
|
|
||||||
|
while(--r > p) {
|
||||||
|
i = *r;
|
||||||
|
*r = *p;
|
||||||
|
*p++ = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(*fmt == 'c')
|
||||||
|
*q++ = *dp++;
|
||||||
|
else
|
||||||
|
*q++ = *fmt;
|
||||||
|
|
||||||
|
/* now output the saved string */
|
||||||
|
for(p = tmp; p < q; ++p) {
|
||||||
|
*s++ = *p;
|
||||||
|
|
||||||
|
if(s >= buf_end) {
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
|
||||||
|
if(buf)
|
||||||
|
*s = '\0';
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
return(s-buf);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************/
|
||||||
|
|
||||||
|
static int VSprintfPatch(char *buf, const char *fmt, const int *dp)
|
||||||
|
{
|
||||||
|
char *p, *s;
|
||||||
|
s = buf;
|
||||||
|
|
||||||
|
for(; *fmt != '\0'; ++fmt) {
|
||||||
|
if(*fmt != '%') {
|
||||||
|
if(buf) {
|
||||||
|
*s++ = *fmt;
|
||||||
|
} else {
|
||||||
|
DiagPutChar(*fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*++fmt == 's') {
|
||||||
|
for(p = (char *)*dp++; *p != '\0'; p++) {
|
||||||
|
if(buf) {
|
||||||
|
*s++ = *p;
|
||||||
|
} else {
|
||||||
|
DiagPutChar(*p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { /* Length of item is bounded */
|
||||||
|
char tmp[20], *q = tmp;
|
||||||
|
int alt = 0;
|
||||||
|
int shift = 0;// = 12;
|
||||||
|
const long *lpforchk = (const long *)dp;
|
||||||
|
|
||||||
|
if((*lpforchk) < 0x10) {
|
||||||
|
shift = 0;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x10) && ((*lpforchk) < 0x100)) {
|
||||||
|
shift = 4;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x100) && ((*lpforchk) < 0x1000)) {
|
||||||
|
shift = 8;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x1000) && ((*lpforchk) < 0x10000)) {
|
||||||
|
shift = 12;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x10000) && ((*lpforchk) < 0x100000)) {
|
||||||
|
shift = 16;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x100000) && ((*lpforchk) < 0x1000000)) {
|
||||||
|
shift = 20;
|
||||||
|
}
|
||||||
|
else if(((*lpforchk) >= 0x1000000) && ((*lpforchk) < 0x10000000)) {
|
||||||
|
shift = 24;
|
||||||
|
}
|
||||||
|
else if((*lpforchk) >= 0x10000000) {
|
||||||
|
shift = 28;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
shift = 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1 //wei patch for %02x
|
||||||
|
|
||||||
|
if((*fmt >= '0') && (*fmt <= '9'))
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
unsigned char fch = *fmt;
|
||||||
|
|
||||||
|
for(width=0; (fch>='0') && (fch<='9'); fch=*++fmt)
|
||||||
|
{ width = width * 10 + fch - '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
shift=(width-1)*4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Before each format q points to tmp buffer
|
||||||
|
* After each format q points past end of item
|
||||||
|
*/
|
||||||
|
|
||||||
|
if((*fmt == 'x')||(*fmt == 'X') || (*fmt == 'p') || (*fmt == 'P')) {
|
||||||
|
/* With x86 gcc, sizeof(long) == sizeof(int) */
|
||||||
|
const long *lp = (const long *)dp;
|
||||||
|
long h = *lp++;
|
||||||
|
int hex_count = 0;
|
||||||
|
unsigned long h_back = h;
|
||||||
|
int ncase = (*fmt & 0x20);
|
||||||
|
dp = (const int *)lp;
|
||||||
|
|
||||||
|
if((*fmt == 'p') || (*fmt == 'P'))
|
||||||
|
alt=1;
|
||||||
|
|
||||||
|
if(alt) {
|
||||||
|
*q++ = '0';
|
||||||
|
*q++ = 'X' | ncase;
|
||||||
|
}
|
||||||
|
|
||||||
|
//hback 是实际得到的数据,hex_count是统计数据的HEX字符个数
|
||||||
|
while(h_back) {
|
||||||
|
hex_count += (h_back & 0xF) ? 1 : 0;
|
||||||
|
h_back = h_back >> 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
//这里修复 example: 字符有4个,但是用了%02x导致字符被截断的情况
|
||||||
|
if(shift < (hex_count - 1)*4)
|
||||||
|
shift = (hex_count - 1)*4;
|
||||||
|
|
||||||
|
//printf("(%d,%d)", hex_count, shift);
|
||||||
|
|
||||||
|
for(; shift >= 0; shift -= 4) {
|
||||||
|
|
||||||
|
*q++ = tab0123456789ABCDEF[(h >> shift) & 0xF] | ncase;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(*fmt == 'd') {
|
||||||
|
int i = *dp++;
|
||||||
|
char *r;
|
||||||
|
int digit_space = 0;
|
||||||
|
|
||||||
|
if(i < 0) {
|
||||||
|
*q++ = '-';
|
||||||
|
i = -i;
|
||||||
|
digit_space++;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = q; /* save beginning of digits */
|
||||||
|
|
||||||
|
do {
|
||||||
|
*q++ = '0' + (i % 10);
|
||||||
|
i /= 10;
|
||||||
|
digit_space++;
|
||||||
|
} while(i);
|
||||||
|
|
||||||
|
//这里修复 example:用了%08d后,在数字前面没有0的情况
|
||||||
|
for(; shift >= 0; shift -= 4) {
|
||||||
|
|
||||||
|
if(digit_space-- > 0) {
|
||||||
|
; //do nothing
|
||||||
|
} else {
|
||||||
|
*q++ = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reverse digits, stop in middle */
|
||||||
|
r = q; /* don't alter q */
|
||||||
|
|
||||||
|
while(--r > p) {
|
||||||
|
i = *r;
|
||||||
|
*r = *p;
|
||||||
|
*p++ = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(*fmt == 'c')
|
||||||
|
*q++ = *dp++;
|
||||||
|
else
|
||||||
|
*q++ = *fmt;
|
||||||
|
|
||||||
|
/* now output the saved string */
|
||||||
|
for(p = tmp; p < q; ++p) {
|
||||||
|
if(buf) {
|
||||||
|
*s++ = *p;
|
||||||
|
} else {
|
||||||
|
DiagPutChar(*p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((*p) == '\n') {
|
||||||
|
DiagPutChar('\r');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buf)
|
||||||
|
*s = '\0';
|
||||||
|
|
||||||
|
return (s - buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int DiagPrintfPatch(
|
||||||
|
IN const char *fmt, ...
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return VSprintfPatch(0, fmt, ((const int *)&fmt)+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DiagSPrintfPatch(
|
||||||
|
IN u8 *buf,
|
||||||
|
IN const char *fmt, ...
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return VSprintfPatch((char*)buf, fmt, ((const int *)&fmt)+1);
|
||||||
|
}
|
||||||
|
#endif
|
13
Firmware/RTLGDB/USDK/component/common/api/sdk_ver.h
Normal file
13
Firmware/RTLGDB/USDK/component/common/api/sdk_ver.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
* sdk_ver.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _PLATFORM_SDK_VER_H_
|
||||||
|
#define _PLATFORM_SDK_VER_H_
|
||||||
|
|
||||||
|
#define SDK_VER_NUM 0x40b2
|
||||||
|
|
||||||
|
#define SDK_VERSION "4.0.2" // 4.0b + 4.0b_patch_i2c_nonDNA_for_gcc(v01).zip
|
||||||
|
|
||||||
|
#endif /* _PLATFORM_SDK_VER_H_ */
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue