Use CI-CD-Github-Actions for spelling and formatting, add in the bot formatting action, update the CI-CD workflow files. Fix incorrect spelling and formatting on files. (#1083)
* Use new version of CI-CD Actions, checkout@v3 instead of checkout@v2 on all jobs * Use cSpell spell check, and use ubuntu-20.04 for formatting check * Add in bot formatting action * Update freertos_demo.yml and freertos_plus_demo.yml files to increase github log readability * Add in a Qemu demo onto the workflows.pull/1087/head
parent
537007d96c
commit
3a2f6646f0
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,14 @@
|
|||||||
certifi==2023.7.22
|
Deprecated
|
||||||
chardet==4.0.0
|
GitPython
|
||||||
|
PyGithub
|
||||||
|
PyJWT
|
||||||
|
PyYAML
|
||||||
|
certifi
|
||||||
|
chardet
|
||||||
colorama
|
colorama
|
||||||
Deprecated==1.2.10
|
gitdb
|
||||||
gitdb==4.0.5
|
idna
|
||||||
GitPython==3.1.32
|
|
||||||
idna==2.10
|
|
||||||
PyGithub==1.55
|
|
||||||
PyJWT==2.4.0
|
|
||||||
PyYAML==5.4
|
|
||||||
requests
|
requests
|
||||||
smmap==3.0.4
|
smmap
|
||||||
urllib3==1.26.5
|
urllib3
|
||||||
wrapt==1.12.1
|
wrapt
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main( int argc, char * argv[] )
|
||||||
|
{
|
||||||
|
setvbuf( stdout, NULL, _IONBF, 0 );
|
||||||
|
FILE * fp;
|
||||||
|
char path[ 256 ];
|
||||||
|
char cmd[ 256 ];
|
||||||
|
|
||||||
|
/* Open the command for reading. */
|
||||||
|
fp = popen("find . -name RTOSDemo.out", "r");
|
||||||
|
/* Read the output a line at a time - output it. */
|
||||||
|
while( fgets( path, sizeof( path ), fp ) != NULL )
|
||||||
|
{
|
||||||
|
printf( "Path: %s\n", path );
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(cmd, "qemu-system-arm -machine mps2-an385 -monitor null -semihosting --semihosting-config enable=on,target=native -serial stdio -nographic -kernel %s", path);
|
||||||
|
printf("cmd= %s\n", cmd);
|
||||||
|
fp = popen( cmd, "r" );
|
||||||
|
if( fp == NULL )
|
||||||
|
{
|
||||||
|
printf( "Failed to run command\n" );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the output a line at a time - output it. */
|
||||||
|
while( fgets( path, sizeof( path ), fp ) != NULL )
|
||||||
|
{
|
||||||
|
printf( "%s", path );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close */
|
||||||
|
pclose( fp );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,13 +1,14 @@
|
|||||||
certifi>=2020.12.5
|
Deprecated
|
||||||
chardet>=3.0.4
|
GitPython
|
||||||
Deprecated>=1.2.10
|
PyGithub
|
||||||
gitdb>=4.0.5
|
PyJWT
|
||||||
GitPython>=3.1.11
|
PyYAML
|
||||||
idna>=2.10
|
certifi
|
||||||
PyGithub>=1.54
|
chardet
|
||||||
PyJWT>=1.7.1
|
colorama
|
||||||
PyYAML>=5.3.1
|
gitdb
|
||||||
requests>=2.24.0
|
idna
|
||||||
smmap>=3.0.4
|
requests
|
||||||
urllib3>=1.25.11
|
smmap
|
||||||
wrapt>=1.12.1
|
urllib3
|
||||||
|
wrapt
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
name: Format Pull Request Files
|
||||||
|
|
||||||
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
env:
|
||||||
|
bashPass: \033[32;1mPASSED -
|
||||||
|
bashInfo: \033[33;1mINFO -
|
||||||
|
bashFail: \033[31;1mFAILED -
|
||||||
|
bashEnd: \033[0m
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Formatting:
|
||||||
|
name: Run Formatting Check
|
||||||
|
if: ${{ github.event.issue.pull_request }} &&
|
||||||
|
( ( github.event.comment.body == '/bot run uncrustify' ) ||
|
||||||
|
( github.event.comment.body == '/bot run formatting' ) )
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- name: Apply Formatting Fix
|
||||||
|
uses: FreeRTOS/CI-CD-Github-Actions/formatting-bot@main
|
||||||
|
id: check-formatting
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
[{000214A0-0000-0000-C000-000000000046}]
|
[{000214A0-0000-0000-C000-000000000046}]
|
||||||
Prop3=19,2
|
Prop3=19,2
|
||||||
[InternetShortcut]
|
[InternetShortcut]
|
||||||
URL=http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html
|
URL=http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html
|
||||||
IDList=
|
IDList=
|
||||||
|
@ -1,249 +1,249 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|x64">
|
<ProjectConfiguration Include="Release|x64">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<ProjectGuid>{4be4e103-5bf4-4a85-9656-ec20852a2b8e}</ProjectGuid>
|
<ProjectGuid>{4be4e103-5bf4-4a85-9656-ec20852a2b8e}</ProjectGuid>
|
||||||
<RootNamespace>OtaOverHttpDemo</RootNamespace>
|
<RootNamespace>OtaOverHttpDemo</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="Shared">
|
<ImportGroup Label="Shared">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetName>RTOSDemo</TargetName>
|
<TargetName>RTOSDemo</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetName>RTOSDemo</TargetName>
|
<TargetName>RTOSDemo</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetName>RTOSDemo</TargetName>
|
<TargetName>RTOSDemo</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetName>RTOSDemo</TargetName>
|
<TargetName>RTOSDemo</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;_DEBUG;_CONSOLE;WIN32;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;_DEBUG;_CONSOLE;WIN32;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;WIN32;NDEBUG;_CONSOLE;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;WIN32;NDEBUG;_CONSOLE;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;_DEBUG;_CONSOLE;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;_DEBUG;_CONSOLE;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;NDEBUG;_CONSOLE;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG;WIN32;__little_endian__=1;NDEBUG;_CONSOLE;MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Common\HTTP_Utils;..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\Common\coreMQTT_Agent_Interface\include;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\coreJSON\source\include;..\..\..\..\Source\AWS\ota\source\include;..\..\..\..\Source\AWS\ota\source\portable\os;..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\Common\Ota_PAL\Win32\Code_Signature_Verification;..\Common\Ota_PAL\Win32;..\Common\subscription-manager;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\coreHTTP\coreHTTP.vcxproj">
|
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\coreHTTP\coreHTTP.vcxproj">
|
||||||
<Project>{ee39fa0f-cefb-4c29-a571-05a28fdd47fd}</Project>
|
<Project>{ee39fa0f-cefb-4c29-a571-05a28fdd47fd}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj">
|
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj">
|
||||||
<Project>{c90e6cc5-818b-4c97-8876-0986d989387c}</Project>
|
<Project>{c90e6cc5-818b-4c97-8876-0986d989387c}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj">
|
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj">
|
||||||
<Project>{72c209c4-49a4-4942-a201-44706c9d77ec}</Project>
|
<Project>{72c209c4-49a4-4942-a201-44706c9d77ec}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj">
|
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj">
|
||||||
<Project>{be362ac0-b10b-4276-b84e-6304652ba228}</Project>
|
<Project>{be362ac0-b10b-4276-b84e-6304652ba228}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\MbedTLS\MbedTLS.vcxproj">
|
<ProjectReference Include="..\..\..\..\VisualStudio_StaticProjects\MbedTLS\MbedTLS.vcxproj">
|
||||||
<Project>{e1016f3e-94e9-4864-9fd8-1d7c1fefbfd7}</Project>
|
<Project>{e1016f3e-94e9-4864-9fd8-1d7c1fefbfd7}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent_command_functions.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent_command_functions.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\ports\freertos_plus_tcp\tcp_sockets_wrapper.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\ports\freertos_plus_tcp\tcp_sockets_wrapper.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls.c" />
|
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota.c" />
|
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_base64.c" />
|
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_base64.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_cbor.c" />
|
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_cbor.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_http.c" />
|
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_http.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_interface.c" />
|
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_interface.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_mqtt.c" />
|
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\ota_mqtt.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\portable\os\ota_os_freertos.c" />
|
<ClCompile Include="..\..\..\..\Source\AWS\ota\source\portable\os\ota_os_freertos.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\coreJSON\source\core_json.c" />
|
<ClCompile Include="..\..\..\..\Source\coreJSON\source\core_json.c" />
|
||||||
<ClCompile Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c" />
|
<ClCompile Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder_close_container_checked.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder_close_container_checked.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborerrorstrings.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborerrorstrings.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser_dup_string.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser_dup_string.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborpretty.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborpretty.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborpretty_stdio.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborpretty_stdio.c" />
|
||||||
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborvalidation.c" />
|
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborvalidation.c" />
|
||||||
<ClCompile Include="..\..\..\Common\coreMQTT_Agent_Interface\freertos_agent_message.c" />
|
<ClCompile Include="..\..\..\Common\coreMQTT_Agent_Interface\freertos_agent_message.c" />
|
||||||
<ClCompile Include="..\..\..\Common\coreMQTT_Agent_Interface\freertos_command_pool.c" />
|
<ClCompile Include="..\..\..\Common\coreMQTT_Agent_Interface\freertos_command_pool.c" />
|
||||||
<ClCompile Include="..\Common\HTTP_Utils\http_demo_utils.c" />
|
<ClCompile Include="..\Common\HTTP_Utils\http_demo_utils.c" />
|
||||||
<ClCompile Include="..\Common\Ota_PAL\Win32\Code_Signature_Verification\code_signature_verification_mbedtls.c" />
|
<ClCompile Include="..\Common\Ota_PAL\Win32\Code_Signature_Verification\code_signature_verification_mbedtls.c" />
|
||||||
<ClCompile Include="..\Common\Ota_PAL\Win32\ota_pal.c" />
|
<ClCompile Include="..\Common\Ota_PAL\Win32\ota_pal.c" />
|
||||||
<ClCompile Include="..\Common\subscription-manager\subscription_manager.c" />
|
<ClCompile Include="..\Common\subscription-manager\subscription_manager.c" />
|
||||||
<ClCompile Include="DemoTasks\OtaOverHttpDemoExample.c" />
|
<ClCompile Include="DemoTasks\OtaOverHttpDemoExample.c" />
|
||||||
<ClCompile Include="main.c" />
|
<ClCompile Include="main.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent_command_functions.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent_command_functions.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent_message_interface.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent_message_interface.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_config_defaults.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_config_defaults.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_serializer.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_serializer.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_state.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_state.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface\transport_interface.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface\transport_interface.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_tcp_sockets_wrapper.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include\tcp_sockets_wrapper.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\tcp_sockets_wrapper\include\tcp_sockets_wrapper.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls.h" />
|
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_appversion32.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_appversion32.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_base64_private.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_base64_private.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_cbor_private.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_cbor_private.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_config_defaults.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_config_defaults.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_http_interface.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_http_interface.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_http_private.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_http_private.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_interface_private.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_interface_private.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_mqtt_interface.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_mqtt_interface.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_mqtt_private.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_mqtt_private.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_os_interface.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_os_interface.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_platform_interface.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_platform_interface.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_private.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\include\ota_private.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\portable\os\ota_os_freertos.h" />
|
<ClInclude Include="..\..\..\..\Source\AWS\ota\source\portable\os\ota_os_freertos.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\coreJSON\source\include\core_json.h" />
|
<ClInclude Include="..\..\..\..\Source\coreJSON\source\include\core_json.h" />
|
||||||
<ClInclude Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\include\backoff_algorithm.h" />
|
<ClInclude Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\include\backoff_algorithm.h" />
|
||||||
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cbor.h" />
|
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cbor.h" />
|
||||||
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborinternal_p.h" />
|
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborinternal_p.h" />
|
||||||
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborjson.h" />
|
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborjson.h" />
|
||||||
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\compilersupport_p.h" />
|
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\compilersupport_p.h" />
|
||||||
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\tinycbor-version.h" />
|
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\tinycbor-version.h" />
|
||||||
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\utf8_p.h" />
|
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\utf8_p.h" />
|
||||||
<ClInclude Include="..\..\..\Common\coreMQTT_Agent_Interface\include\freertos_agent_message.h" />
|
<ClInclude Include="..\..\..\Common\coreMQTT_Agent_Interface\include\freertos_agent_message.h" />
|
||||||
<ClInclude Include="..\..\..\Common\coreMQTT_Agent_Interface\include\freertos_command_pool.h" />
|
<ClInclude Include="..\..\..\Common\coreMQTT_Agent_Interface\include\freertos_command_pool.h" />
|
||||||
<ClInclude Include="..\Common\HTTP_Utils\http_demo_utils.h" />
|
<ClInclude Include="..\Common\HTTP_Utils\http_demo_utils.h" />
|
||||||
<ClInclude Include="..\Common\Ota_PAL\Win32\Code_Signature_Verification\aws_ota_codesigner_certificate.h" />
|
<ClInclude Include="..\Common\Ota_PAL\Win32\Code_Signature_Verification\aws_ota_codesigner_certificate.h" />
|
||||||
<ClInclude Include="..\Common\Ota_PAL\Win32\Code_Signature_Verification\code_signature_verification.h" />
|
<ClInclude Include="..\Common\Ota_PAL\Win32\Code_Signature_Verification\code_signature_verification.h" />
|
||||||
<ClInclude Include="..\Common\Ota_PAL\Win32\ota_pal.h" />
|
<ClInclude Include="..\Common\Ota_PAL\Win32\ota_pal.h" />
|
||||||
<ClInclude Include="..\Common\subscription-manager\subscription_manager.h" />
|
<ClInclude Include="..\Common\subscription-manager\subscription_manager.h" />
|
||||||
<ClInclude Include="core_mqtt_config.h" />
|
<ClInclude Include="core_mqtt_config.h" />
|
||||||
<ClInclude Include="demo_config.h" />
|
<ClInclude Include="demo_config.h" />
|
||||||
<ClInclude Include="ota_config.h" />
|
<ClInclude Include="ota_config.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,5 +1,5 @@
|
|||||||
[{000214A0-0000-0000-C000-000000000046}]
|
[{000214A0-0000-0000-C000-000000000046}]
|
||||||
Prop3=19,2
|
Prop3=19,2
|
||||||
[InternetShortcut]
|
[InternetShortcut]
|
||||||
URL=http://www.freertos.org/labs
|
URL=http://www.freertos.org/labs
|
||||||
IDList=
|
IDList=
|
||||||
|
@ -1,372 +1,385 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://github.com/FreeRTOS
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* Standard includes. */
|
/* Standard includes. */
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* FreeRTOS includes. */
|
/* FreeRTOS includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
/* FreeRTOS+TCP includes. */
|
/* FreeRTOS+TCP includes. */
|
||||||
#include "FreeRTOS_IP.h"
|
#include "FreeRTOS_IP.h"
|
||||||
#include "FreeRTOS_Sockets.h"
|
#include "FreeRTOS_Sockets.h"
|
||||||
#include "FreeRTOS_TCP_server.h"
|
#include "FreeRTOS_TCP_server.h"
|
||||||
#include "FreeRTOS_server_private.h"
|
#include "FreeRTOS_server_private.h"
|
||||||
|
|
||||||
/* Remove the entire file if TCP is not being used. */
|
/* Remove the entire file if TCP is not being used. */
|
||||||
#if( ipconfigUSE_TCP == 1 ) && ( ( ipconfigUSE_HTTP == 1 ) || ( ipconfigUSE_FTP == 1 ) )
|
#if ( ipconfigUSE_TCP == 1 ) && ( ( ipconfigUSE_HTTP == 1 ) || ( ipconfigUSE_FTP == 1 ) )
|
||||||
|
|
||||||
#if !defined( ARRAY_SIZE )
|
#if !defined( ARRAY_SIZE )
|
||||||
#define ARRAY_SIZE(x) ( BaseType_t ) (sizeof( x ) / sizeof( x )[ 0 ] )
|
#define ARRAY_SIZE( x ) ( BaseType_t ) ( sizeof( x ) / sizeof( x )[ 0 ] )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void prvReceiveNewClient( TCPServer_t *pxServer, BaseType_t xIndex, Socket_t xNexSocket );
|
static void prvReceiveNewClient( TCPServer_t * pxServer,
|
||||||
static char *strnew( const char *pcString );
|
BaseType_t xIndex,
|
||||||
/* Remove slashes at the end of a path. */
|
Socket_t xNexSocket );
|
||||||
static void prvRemoveSlash( char *pcDir );
|
static char * strnew( const char * pcString );
|
||||||
|
/* Remove slashes at the end of a path. */
|
||||||
TCPServer_t *FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG *pxConfigs, BaseType_t xCount )
|
static void prvRemoveSlash( char * pcDir );
|
||||||
{
|
|
||||||
TCPServer_t *pxServer;
|
TCPServer_t * FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG * pxConfigs,
|
||||||
SocketSet_t xSocketSet;
|
BaseType_t xCount )
|
||||||
|
{
|
||||||
/* Create a new server.
|
TCPServer_t * pxServer;
|
||||||
xPort / xPortAlt : Make the service available on 1 or 2 public port numbers. */
|
SocketSet_t xSocketSet;
|
||||||
xSocketSet = FreeRTOS_CreateSocketSet();
|
|
||||||
|
/* Create a new server.
|
||||||
if( xSocketSet != NULL )
|
* xPort / xPortAlt : Make the service available on 1 or 2 public port numbers. */
|
||||||
{
|
xSocketSet = FreeRTOS_CreateSocketSet();
|
||||||
BaseType_t xSize;
|
|
||||||
|
if( xSocketSet != NULL )
|
||||||
xSize = sizeof( *pxServer ) - sizeof( pxServer->xServers ) + xCount * sizeof( pxServer->xServers[ 0 ] );
|
{
|
||||||
|
BaseType_t xSize;
|
||||||
pxServer = ( TCPServer_t * ) pvPortMallocLarge( xSize );
|
|
||||||
if( pxServer != NULL )
|
xSize = sizeof( *pxServer ) - sizeof( pxServer->xServers ) + xCount * sizeof( pxServer->xServers[ 0 ] );
|
||||||
{
|
|
||||||
struct freertos_sockaddr xAddress;
|
pxServer = ( TCPServer_t * ) pvPortMallocLarge( xSize );
|
||||||
BaseType_t xNoTimeout = 0;
|
|
||||||
BaseType_t xIndex;
|
if( pxServer != NULL )
|
||||||
|
{
|
||||||
memset( pxServer, '\0', xSize );
|
struct freertos_sockaddr xAddress;
|
||||||
pxServer->xServerCount = xCount;
|
BaseType_t xNoTimeout = 0;
|
||||||
pxServer->xSocketSet = xSocketSet;
|
BaseType_t xIndex;
|
||||||
|
|
||||||
for( xIndex = 0; xIndex < xCount; xIndex++ )
|
memset( pxServer, '\0', xSize );
|
||||||
{
|
pxServer->xServerCount = xCount;
|
||||||
BaseType_t xPortNumber = pxConfigs[ xIndex ].xPortNumber;
|
pxServer->xSocketSet = xSocketSet;
|
||||||
|
|
||||||
if( xPortNumber > 0 )
|
for( xIndex = 0; xIndex < xCount; xIndex++ )
|
||||||
{
|
{
|
||||||
Socket_t xSocket;
|
BaseType_t xPortNumber = pxConfigs[ xIndex ].xPortNumber;
|
||||||
|
|
||||||
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
|
if( xPortNumber > 0 )
|
||||||
FreeRTOS_printf( ( "TCP socket on port %d\n", ( int )xPortNumber ) );
|
{
|
||||||
|
Socket_t xSocket;
|
||||||
if( xSocket != FREERTOS_INVALID_SOCKET )
|
|
||||||
{
|
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
FreeRTOS_printf( ( "TCP socket on port %d\n", ( int ) xPortNumber ) );
|
||||||
{
|
|
||||||
xAddress.sin_address.ulIP_IPv4 = FreeRTOS_GetIPAddress(); /* Single NIC, currently not used */
|
if( xSocket != FREERTOS_INVALID_SOCKET )
|
||||||
}
|
{
|
||||||
#else
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
{
|
{
|
||||||
xAddress.sin_addr = FreeRTOS_GetIPAddress(); /* Single NIC, currently not used */
|
xAddress.sin_address.ulIP_IPv4 = FreeRTOS_GetIPAddress(); /* Single NIC, currently not used */
|
||||||
}
|
}
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
#else
|
||||||
|
{
|
||||||
xAddress.sin_port = FreeRTOS_htons( xPortNumber );
|
xAddress.sin_addr = FreeRTOS_GetIPAddress(); /* Single NIC, currently not used */
|
||||||
xAddress.sin_family = FREERTOS_AF_INET;
|
}
|
||||||
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );
|
|
||||||
FreeRTOS_listen( xSocket, pxConfigs[ xIndex ].xBackLog );
|
xAddress.sin_port = FreeRTOS_htons( xPortNumber );
|
||||||
|
xAddress.sin_family = FREERTOS_AF_INET;
|
||||||
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, ( void * ) &xNoTimeout, sizeof( BaseType_t ) );
|
|
||||||
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, ( void * ) &xNoTimeout, sizeof( BaseType_t ) );
|
FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );
|
||||||
|
FreeRTOS_listen( xSocket, pxConfigs[ xIndex ].xBackLog );
|
||||||
#if( ipconfigHTTP_RX_BUFSIZE > 0 )
|
|
||||||
{
|
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, ( void * ) &xNoTimeout, sizeof( BaseType_t ) );
|
||||||
if( pxConfigs[ xIndex ].eType == eSERVER_HTTP )
|
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, ( void * ) &xNoTimeout, sizeof( BaseType_t ) );
|
||||||
{
|
|
||||||
WinProperties_t xWinProps;
|
#if ( ipconfigHTTP_RX_BUFSIZE > 0 )
|
||||||
|
{
|
||||||
memset( &xWinProps, '\0', sizeof( xWinProps ) );
|
if( pxConfigs[ xIndex ].eType == eSERVER_HTTP )
|
||||||
/* The parent socket itself won't get connected. The properties below
|
{
|
||||||
will be inherited by each new child socket. */
|
WinProperties_t xWinProps;
|
||||||
xWinProps.lTxBufSize = ipconfigHTTP_TX_BUFSIZE;
|
|
||||||
xWinProps.lTxWinSize = ipconfigHTTP_TX_WINSIZE;
|
memset( &xWinProps, '\0', sizeof( xWinProps ) );
|
||||||
xWinProps.lRxBufSize = ipconfigHTTP_RX_BUFSIZE;
|
|
||||||
xWinProps.lRxWinSize = ipconfigHTTP_RX_WINSIZE;
|
/* The parent socket itself won't get connected. The properties below
|
||||||
|
* will be inherited by each new child socket. */
|
||||||
/* Set the window and buffer sizes. */
|
xWinProps.lTxBufSize = ipconfigHTTP_TX_BUFSIZE;
|
||||||
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_WIN_PROPERTIES, ( void * ) &xWinProps, sizeof( xWinProps ) );
|
xWinProps.lTxWinSize = ipconfigHTTP_TX_WINSIZE;
|
||||||
}
|
xWinProps.lRxBufSize = ipconfigHTTP_RX_BUFSIZE;
|
||||||
}
|
xWinProps.lRxWinSize = ipconfigHTTP_RX_WINSIZE;
|
||||||
#endif
|
|
||||||
|
/* Set the window and buffer sizes. */
|
||||||
FreeRTOS_FD_SET( xSocket, xSocketSet, eSELECT_READ|eSELECT_EXCEPT );
|
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_WIN_PROPERTIES, ( void * ) &xWinProps, sizeof( xWinProps ) );
|
||||||
pxServer->xServers[ xIndex ].xSocket = xSocket;
|
}
|
||||||
pxServer->xServers[ xIndex ].eType = pxConfigs[ xIndex ].eType;
|
}
|
||||||
pxServer->xServers[ xIndex ].pcRootDir = strnew( pxConfigs[ xIndex ].pcRootDir );
|
#endif /* if ( ipconfigHTTP_RX_BUFSIZE > 0 ) */
|
||||||
prvRemoveSlash( ( char * ) pxServer->xServers[ xIndex ].pcRootDir );
|
|
||||||
}
|
FreeRTOS_FD_SET( xSocket, xSocketSet, eSELECT_READ | eSELECT_EXCEPT );
|
||||||
}
|
pxServer->xServers[ xIndex ].xSocket = xSocket;
|
||||||
}
|
pxServer->xServers[ xIndex ].eType = pxConfigs[ xIndex ].eType;
|
||||||
}
|
pxServer->xServers[ xIndex ].pcRootDir = strnew( pxConfigs[ xIndex ].pcRootDir );
|
||||||
else
|
prvRemoveSlash( ( char * ) pxServer->xServers[ xIndex ].pcRootDir );
|
||||||
{
|
}
|
||||||
/* Could not allocate the server, delete the socket set */
|
}
|
||||||
FreeRTOS_DeleteSocketSet( xSocketSet );
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
/* Could not allocate the server, delete the socket set */
|
||||||
/* Could not create a socket set, return NULL */
|
FreeRTOS_DeleteSocketSet( xSocketSet );
|
||||||
pxServer = NULL;
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return pxServer;
|
{
|
||||||
}
|
/* Could not create a socket set, return NULL */
|
||||||
/*-----------------------------------------------------------*/
|
pxServer = NULL;
|
||||||
|
}
|
||||||
static void prvReceiveNewClient( TCPServer_t *pxServer, BaseType_t xIndex, Socket_t xNexSocket )
|
|
||||||
{
|
return pxServer;
|
||||||
TCPClient_t *pxClient = NULL;
|
}
|
||||||
BaseType_t xSize = 0;
|
/*-----------------------------------------------------------*/
|
||||||
FTCPWorkFunction fWorkFunc = NULL;
|
|
||||||
FTCPDeleteFunction fDeleteFunc = NULL;
|
static void prvReceiveNewClient( TCPServer_t * pxServer,
|
||||||
const char *pcType = "Unknown";
|
BaseType_t xIndex,
|
||||||
|
Socket_t xNexSocket )
|
||||||
/*_RB_ Can the work and delete functions be part of the xSERVER_CONFIG structure
|
{
|
||||||
becomes generic, with no pre-processing required? */
|
TCPClient_t * pxClient = NULL;
|
||||||
#if( ipconfigUSE_HTTP != 0 )
|
BaseType_t xSize = 0;
|
||||||
{
|
FTCPWorkFunction fWorkFunc = NULL;
|
||||||
if( pxServer->xServers[ xIndex ].eType == eSERVER_HTTP )
|
FTCPDeleteFunction fDeleteFunc = NULL;
|
||||||
{
|
const char * pcType = "Unknown";
|
||||||
xSize = sizeof( HTTPClient_t );
|
|
||||||
fWorkFunc = xHTTPClientWork;
|
/*_RB_ Can the work and delete functions be part of the xSERVER_CONFIG structure
|
||||||
fDeleteFunc = vHTTPClientDelete;
|
* becomes generic, with no pre-processing required? */
|
||||||
pcType = "HTTP";
|
#if ( ipconfigUSE_HTTP != 0 )
|
||||||
}
|
{
|
||||||
}
|
if( pxServer->xServers[ xIndex ].eType == eSERVER_HTTP )
|
||||||
#endif /* ipconfigUSE_HTTP != 0 */
|
{
|
||||||
|
xSize = sizeof( HTTPClient_t );
|
||||||
#if( ipconfigUSE_FTP != 0 )
|
fWorkFunc = xHTTPClientWork;
|
||||||
{
|
fDeleteFunc = vHTTPClientDelete;
|
||||||
if( pxServer->xServers[ xIndex ].eType == eSERVER_FTP )
|
pcType = "HTTP";
|
||||||
{
|
}
|
||||||
xSize = sizeof( FTPClient_t );
|
}
|
||||||
fWorkFunc = xFTPClientWork;
|
#endif /* ipconfigUSE_HTTP != 0 */
|
||||||
fDeleteFunc = vFTPClientDelete;
|
|
||||||
pcType = "FTP";
|
#if ( ipconfigUSE_FTP != 0 )
|
||||||
}
|
{
|
||||||
}
|
if( pxServer->xServers[ xIndex ].eType == eSERVER_FTP )
|
||||||
#endif /* ipconfigUSE_FTP != 0 */
|
{
|
||||||
|
xSize = sizeof( FTPClient_t );
|
||||||
/* Malloc enough space for a new HTTP-client */
|
fWorkFunc = xFTPClientWork;
|
||||||
if( xSize )
|
fDeleteFunc = vFTPClientDelete;
|
||||||
{
|
pcType = "FTP";
|
||||||
pxClient = ( TCPClient_t* ) pvPortMallocLarge( xSize );
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* ipconfigUSE_FTP != 0 */
|
||||||
if( pxClient != NULL )
|
|
||||||
{
|
/* Malloc enough space for a new HTTP-client */
|
||||||
memset( pxClient, '\0', xSize );
|
if( xSize )
|
||||||
|
{
|
||||||
/* Put the new client in front of the list. */
|
pxClient = ( TCPClient_t * ) pvPortMallocLarge( xSize );
|
||||||
pxClient->eType = pxServer->xServers[ xIndex ].eType;
|
}
|
||||||
pxClient->pcRootDir = pxServer->xServers[ xIndex ].pcRootDir;
|
|
||||||
pxClient->pxParent = pxServer;
|
if( pxClient != NULL )
|
||||||
pxClient->xSocket = xNexSocket;
|
{
|
||||||
pxClient->pxNextClient = pxServer->pxClients;
|
memset( pxClient, '\0', xSize );
|
||||||
pxClient->fWorkFunction = fWorkFunc;
|
|
||||||
pxClient->fDeleteFunction = fDeleteFunc;
|
/* Put the new client in front of the list. */
|
||||||
pxServer->pxClients = pxClient;
|
pxClient->eType = pxServer->xServers[ xIndex ].eType;
|
||||||
|
pxClient->pcRootDir = pxServer->xServers[ xIndex ].pcRootDir;
|
||||||
FreeRTOS_FD_SET( xNexSocket, pxServer->xSocketSet, eSELECT_READ|eSELECT_EXCEPT );
|
pxClient->pxParent = pxServer;
|
||||||
}
|
pxClient->xSocket = xNexSocket;
|
||||||
else
|
pxClient->pxNextClient = pxServer->pxClients;
|
||||||
{
|
pxClient->fWorkFunction = fWorkFunc;
|
||||||
pcType = "closed";
|
pxClient->fDeleteFunction = fDeleteFunc;
|
||||||
FreeRTOS_closesocket( xNexSocket );
|
pxServer->pxClients = pxClient;
|
||||||
}
|
|
||||||
{
|
FreeRTOS_FD_SET( xNexSocket, pxServer->xSocketSet, eSELECT_READ | eSELECT_EXCEPT );
|
||||||
struct freertos_sockaddr xRemoteAddress;
|
}
|
||||||
FreeRTOS_GetRemoteAddress( pxClient->xSocket, &xRemoteAddress );
|
else
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
{
|
||||||
{
|
pcType = "closed";
|
||||||
FreeRTOS_printf( ( "TPC-server: new %s client %xip\n", pcType, (unsigned)FreeRTOS_ntohl( xRemoteAddress.sin_address.ulIP_IPv4 ) ) );
|
FreeRTOS_closesocket( xNexSocket );
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
{
|
{
|
||||||
FreeRTOS_printf( ( "TPC-server: new %s client %xip\n", pcType, (unsigned)FreeRTOS_ntohl( xRemoteAddress.sin_addr ) ) );
|
struct freertos_sockaddr xRemoteAddress;
|
||||||
}
|
FreeRTOS_GetRemoteAddress( pxClient->xSocket, &xRemoteAddress );
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
}
|
{
|
||||||
|
FreeRTOS_printf( ( "TPC-server: new %s client %xip\n", pcType, ( unsigned ) FreeRTOS_ntohl( xRemoteAddress.sin_address.ulIP_IPv4 ) ) );
|
||||||
/* Remove compiler warnings in case FreeRTOS_printf() is not used. */
|
}
|
||||||
( void ) pcType;
|
#else
|
||||||
}
|
{
|
||||||
/*-----------------------------------------------------------*/
|
FreeRTOS_printf( ( "TPC-server: new %s client %xip\n", pcType, ( unsigned ) FreeRTOS_ntohl( xRemoteAddress.sin_addr ) ) );
|
||||||
|
}
|
||||||
void FreeRTOS_TCPServerWork( TCPServer_t *pxServer, TickType_t xBlockingTime )
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
{
|
}
|
||||||
TCPClient_t **ppxClient;
|
|
||||||
BaseType_t xIndex;
|
/* Remove compiler warnings in case FreeRTOS_printf() is not used. */
|
||||||
BaseType_t xRc;
|
( void ) pcType;
|
||||||
|
}
|
||||||
/* Let the server do one working cycle */
|
/*-----------------------------------------------------------*/
|
||||||
xRc = FreeRTOS_select( pxServer->xSocketSet, xBlockingTime );
|
|
||||||
|
void FreeRTOS_TCPServerWork( TCPServer_t * pxServer,
|
||||||
if( xRc != 0 )
|
TickType_t xBlockingTime )
|
||||||
{
|
{
|
||||||
for( xIndex = 0; xIndex < pxServer->xServerCount; xIndex++ )
|
TCPClient_t ** ppxClient;
|
||||||
{
|
BaseType_t xIndex;
|
||||||
struct freertos_sockaddr xAddress;
|
BaseType_t xRc;
|
||||||
Socket_t xNexSocket;
|
|
||||||
socklen_t xSocketLength;
|
/* Let the server do one working cycle */
|
||||||
|
xRc = FreeRTOS_select( pxServer->xSocketSet, xBlockingTime );
|
||||||
if( pxServer->xServers[ xIndex ].xSocket == FREERTOS_NO_SOCKET )
|
|
||||||
{
|
if( xRc != 0 )
|
||||||
continue;
|
{
|
||||||
}
|
for( xIndex = 0; xIndex < pxServer->xServerCount; xIndex++ )
|
||||||
|
{
|
||||||
xSocketLength = sizeof( xAddress );
|
struct freertos_sockaddr xAddress;
|
||||||
xNexSocket = FreeRTOS_accept( pxServer->xServers[ xIndex ].xSocket, &xAddress, &xSocketLength);
|
Socket_t xNexSocket;
|
||||||
|
socklen_t xSocketLength;
|
||||||
if( ( xNexSocket != FREERTOS_NO_SOCKET ) && ( xNexSocket != FREERTOS_INVALID_SOCKET ) )
|
|
||||||
{
|
if( pxServer->xServers[ xIndex ].xSocket == FREERTOS_NO_SOCKET )
|
||||||
prvReceiveNewClient( pxServer, xIndex, xNexSocket );
|
{
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
xSocketLength = sizeof( xAddress );
|
||||||
ppxClient = &pxServer->pxClients;
|
xNexSocket = FreeRTOS_accept( pxServer->xServers[ xIndex ].xSocket, &xAddress, &xSocketLength );
|
||||||
|
|
||||||
while( ( * ppxClient ) != NULL )
|
if( ( xNexSocket != FREERTOS_NO_SOCKET ) && ( xNexSocket != FREERTOS_INVALID_SOCKET ) )
|
||||||
{
|
{
|
||||||
TCPClient_t *pxThis = *ppxClient;
|
prvReceiveNewClient( pxServer, xIndex, xNexSocket );
|
||||||
|
}
|
||||||
/* Almost C++ */
|
}
|
||||||
xRc = pxThis->fWorkFunction( pxThis );
|
}
|
||||||
|
|
||||||
if (xRc < 0 )
|
ppxClient = &pxServer->pxClients;
|
||||||
{
|
|
||||||
*ppxClient = pxThis->pxNextClient;
|
while( ( *ppxClient ) != NULL )
|
||||||
/* Close handles, resources */
|
{
|
||||||
pxThis->fDeleteFunction( pxThis );
|
TCPClient_t * pxThis = *ppxClient;
|
||||||
/* Free the space */
|
|
||||||
vPortFreeLarge( pxThis );
|
/* Almost C++ */
|
||||||
}
|
xRc = pxThis->fWorkFunction( pxThis );
|
||||||
else
|
|
||||||
{
|
if( xRc < 0 )
|
||||||
ppxClient = &( pxThis->pxNextClient );
|
{
|
||||||
}
|
*ppxClient = pxThis->pxNextClient;
|
||||||
}
|
/* Close handles, resources */
|
||||||
}
|
pxThis->fDeleteFunction( pxThis );
|
||||||
/*-----------------------------------------------------------*/
|
/* Free the space */
|
||||||
|
vPortFreeLarge( pxThis );
|
||||||
static char *strnew( const char *pcString )
|
}
|
||||||
{
|
else
|
||||||
BaseType_t xLength;
|
{
|
||||||
char *pxBuffer;
|
ppxClient = &( pxThis->pxNextClient );
|
||||||
|
}
|
||||||
xLength = strlen( pcString ) + 1;
|
}
|
||||||
pxBuffer = ( char * ) pvPortMalloc( xLength );
|
}
|
||||||
if( pxBuffer != NULL )
|
/*-----------------------------------------------------------*/
|
||||||
{
|
|
||||||
memcpy( pxBuffer, pcString, xLength );
|
static char * strnew( const char * pcString )
|
||||||
}
|
{
|
||||||
|
BaseType_t xLength;
|
||||||
return pxBuffer;
|
char * pxBuffer;
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
xLength = strlen( pcString ) + 1;
|
||||||
|
pxBuffer = ( char * ) pvPortMalloc( xLength );
|
||||||
static void prvRemoveSlash( char *pcDir )
|
|
||||||
{
|
if( pxBuffer != NULL )
|
||||||
BaseType_t xLength = strlen( pcDir );
|
{
|
||||||
|
memcpy( pxBuffer, pcString, xLength );
|
||||||
while( ( xLength > 0 ) && ( pcDir[ xLength - 1 ] == '/' ) )
|
}
|
||||||
{
|
|
||||||
pcDir[ --xLength ] = '\0';
|
return pxBuffer;
|
||||||
}
|
}
|
||||||
}
|
/*-----------------------------------------------------------*/
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
static void prvRemoveSlash( char * pcDir )
|
||||||
#if( ipconfigSUPPORT_SIGNALS != 0 )
|
{
|
||||||
|
BaseType_t xLength = strlen( pcDir );
|
||||||
/* FreeRTOS_TCPServerWork() calls select().
|
|
||||||
The two functions below provide a possibility to interrupt
|
while( ( xLength > 0 ) && ( pcDir[ xLength - 1 ] == '/' ) )
|
||||||
the call to select(). After the interruption, resume
|
{
|
||||||
by calling FreeRTOS_TCPServerWork() again. */
|
pcDir[ --xLength ] = '\0';
|
||||||
BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t *pxServer )
|
}
|
||||||
{
|
}
|
||||||
BaseType_t xIndex;
|
/*-----------------------------------------------------------*/
|
||||||
BaseType_t xResult = pdFALSE;
|
|
||||||
for( xIndex = 0; xIndex < pxServer->xServerCount; xIndex++ )
|
#if ( ipconfigSUPPORT_SIGNALS != 0 )
|
||||||
{
|
|
||||||
if( pxServer->xServers[ xIndex ].xSocket != FREERTOS_NO_SOCKET )
|
/* FreeRTOS_TCPServerWork() calls select().
|
||||||
{
|
* The two functions below provide a possibility to interrupt
|
||||||
FreeRTOS_SignalSocket( pxServer->xServers[ xIndex ].xSocket );
|
* the call to select(). After the interruption, resume
|
||||||
xResult = pdTRUE;
|
* by calling FreeRTOS_TCPServerWork() again. */
|
||||||
break;
|
BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t * pxServer )
|
||||||
}
|
{
|
||||||
}
|
BaseType_t xIndex;
|
||||||
|
BaseType_t xResult = pdFALSE;
|
||||||
return xResult;
|
|
||||||
}
|
for( xIndex = 0; xIndex < pxServer->xServerCount; xIndex++ )
|
||||||
|
{
|
||||||
#endif /* ipconfigSUPPORT_SIGNALS */
|
if( pxServer->xServers[ xIndex ].xSocket != FREERTOS_NO_SOCKET )
|
||||||
/*-----------------------------------------------------------*/
|
{
|
||||||
|
FreeRTOS_SignalSocket( pxServer->xServers[ xIndex ].xSocket );
|
||||||
#if( ipconfigSUPPORT_SIGNALS != 0 )
|
xResult = pdTRUE;
|
||||||
|
break;
|
||||||
/* Same as above: this function may be called from an ISR,
|
}
|
||||||
for instance a GPIO interrupt. */
|
}
|
||||||
BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t *pxServer, BaseType_t *pxHigherPriorityTaskWoken )
|
|
||||||
{
|
return xResult;
|
||||||
BaseType_t xIndex;
|
}
|
||||||
BaseType_t xResult = pdFALSE;
|
|
||||||
for( xIndex = 0; xIndex < pxServer->xServerCount; xIndex++ )
|
#endif /* ipconfigSUPPORT_SIGNALS */
|
||||||
{
|
/*-----------------------------------------------------------*/
|
||||||
if( pxServer->xServers[ xIndex ].xSocket != FREERTOS_NO_SOCKET )
|
|
||||||
{
|
#if ( ipconfigSUPPORT_SIGNALS != 0 )
|
||||||
FreeRTOS_SignalSocketFromISR( pxServer->xServers[ xIndex ].xSocket, pxHigherPriorityTaskWoken );
|
|
||||||
xResult = pdTRUE;
|
/* Same as above: this function may be called from an ISR,
|
||||||
break;
|
* for instance a GPIO interrupt. */
|
||||||
}
|
BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t * pxServer,
|
||||||
}
|
BaseType_t * pxHigherPriorityTaskWoken )
|
||||||
|
{
|
||||||
return xResult;
|
BaseType_t xIndex;
|
||||||
}
|
BaseType_t xResult = pdFALSE;
|
||||||
#endif /* ipconfigSUPPORT_SIGNALS */
|
|
||||||
/*-----------------------------------------------------------*/
|
for( xIndex = 0; xIndex < pxServer->xServerCount; xIndex++ )
|
||||||
|
{
|
||||||
#endif /* ( ipconfigUSE_TCP == 1 ) && ( ( ipconfigUSE_HTTP == 1 ) || ( ipconfigUSE_FTP == 1 ) ) */
|
if( pxServer->xServers[ xIndex ].xSocket != FREERTOS_NO_SOCKET )
|
||||||
|
{
|
||||||
|
FreeRTOS_SignalSocketFromISR( pxServer->xServers[ xIndex ].xSocket, pxHigherPriorityTaskWoken );
|
||||||
|
xResult = pdTRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return xResult;
|
||||||
|
}
|
||||||
|
#endif /* ipconfigSUPPORT_SIGNALS */
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* ( ipconfigUSE_TCP == 1 ) && ( ( ipconfigUSE_HTTP == 1 ) || ( ipconfigUSE_FTP == 1 ) ) */
|
||||||
|
@ -1,74 +1,75 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS+TCP V2.0.3
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://aws.amazon.com/freertos
|
* https://www.FreeRTOS.org
|
||||||
* https://www.FreeRTOS.org
|
* https://github.com/FreeRTOS
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
/* FreeRTOS includes. */
|
|
||||||
#include "FreeRTOS.h"
|
/* FreeRTOS includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
/* FreeRTOS+TCP includes. */
|
|
||||||
#include "FreeRTOS_FTP_commands.h"
|
/* FreeRTOS+TCP includes. */
|
||||||
|
#include "FreeRTOS_FTP_commands.h"
|
||||||
const FTPCommand_t xFTPCommands[ FTP_CMD_COUNT ] =
|
|
||||||
{
|
const FTPCommand_t xFTPCommands[ FTP_CMD_COUNT ] =
|
||||||
/* cmdLen cmdName[7] cmdType checkLogin checkNullArg */
|
{
|
||||||
{ 4, "USER", ECMD_USER, pdFALSE, pdFALSE },
|
/* cmdLen cmdName[7] cmdType checkLogin checkNullArg */
|
||||||
{ 4, "PASS", ECMD_PASS, pdFALSE, pdFALSE },
|
{ 4, "USER", ECMD_USER, pdFALSE, pdFALSE },
|
||||||
{ 4, "ACCT", ECMD_ACCT, pdTRUE, pdFALSE },
|
{ 4, "PASS", ECMD_PASS, pdFALSE, pdFALSE },
|
||||||
{ 3, "CWD", ECMD_CWD, pdTRUE, pdTRUE },
|
{ 4, "ACCT", ECMD_ACCT, pdTRUE, pdFALSE },
|
||||||
{ 4, "CDUP", ECMD_CDUP, pdTRUE, pdFALSE },
|
{ 3, "CWD", ECMD_CWD, pdTRUE, pdTRUE },
|
||||||
{ 4, "SMNT", ECMD_SMNT, pdTRUE, pdFALSE },
|
{ 4, "CDUP", ECMD_CDUP, pdTRUE, pdFALSE },
|
||||||
{ 4, "QUIT", ECMD_QUIT, pdTRUE, pdFALSE },
|
{ 4, "SMNT", ECMD_SMNT, pdTRUE, pdFALSE },
|
||||||
{ 4, "REIN", ECMD_REIN, pdTRUE, pdFALSE },
|
{ 4, "QUIT", ECMD_QUIT, pdTRUE, pdFALSE },
|
||||||
{ 4, "PORT", ECMD_PORT, pdTRUE, pdFALSE },
|
{ 4, "REIN", ECMD_REIN, pdTRUE, pdFALSE },
|
||||||
{ 4, "PASV", ECMD_PASV, pdTRUE, pdFALSE },
|
{ 4, "PORT", ECMD_PORT, pdTRUE, pdFALSE },
|
||||||
{ 4, "TYPE", ECMD_TYPE, pdTRUE, pdFALSE },
|
{ 4, "PASV", ECMD_PASV, pdTRUE, pdFALSE },
|
||||||
{ 4, "STRU", ECMD_STRU, pdTRUE, pdFALSE },
|
{ 4, "TYPE", ECMD_TYPE, pdTRUE, pdFALSE },
|
||||||
{ 4, "MODE", ECMD_MODE, pdTRUE, pdFALSE },
|
{ 4, "STRU", ECMD_STRU, pdTRUE, pdFALSE },
|
||||||
{ 4, "RETR", ECMD_RETR, pdTRUE, pdTRUE },
|
{ 4, "MODE", ECMD_MODE, pdTRUE, pdFALSE },
|
||||||
{ 4, "STOR", ECMD_STOR, pdTRUE, pdTRUE },
|
{ 4, "RETR", ECMD_RETR, pdTRUE, pdTRUE },
|
||||||
{ 4, "STOU", ECMD_STOU, pdTRUE, pdFALSE },
|
{ 4, "STOR", ECMD_STOR, pdTRUE, pdTRUE },
|
||||||
{ 4, "APPE", ECMD_APPE, pdTRUE, pdFALSE },
|
{ 4, "STOU", ECMD_STOU, pdTRUE, pdFALSE },
|
||||||
{ 4, "ALLO", ECMD_ALLO, pdTRUE, pdFALSE },
|
{ 4, "APPE", ECMD_APPE, pdTRUE, pdFALSE },
|
||||||
{ 4, "REST", ECMD_REST, pdTRUE, pdFALSE },
|
{ 4, "ALLO", ECMD_ALLO, pdTRUE, pdFALSE },
|
||||||
{ 4, "RNFR", ECMD_RNFR, pdTRUE, pdTRUE },
|
{ 4, "REST", ECMD_REST, pdTRUE, pdFALSE },
|
||||||
{ 4, "RNTO", ECMD_RNTO, pdTRUE, pdTRUE },
|
{ 4, "RNFR", ECMD_RNFR, pdTRUE, pdTRUE },
|
||||||
{ 4, "ABOR", ECMD_ABOR, pdTRUE, pdFALSE },
|
{ 4, "RNTO", ECMD_RNTO, pdTRUE, pdTRUE },
|
||||||
{ 4, "SIZE", ECMD_SIZE, pdTRUE, pdTRUE },
|
{ 4, "ABOR", ECMD_ABOR, pdTRUE, pdFALSE },
|
||||||
{ 4, "MDTM", ECMD_MDTM, pdTRUE, pdTRUE },
|
{ 4, "SIZE", ECMD_SIZE, pdTRUE, pdTRUE },
|
||||||
{ 4, "DELE", ECMD_DELE, pdTRUE, pdTRUE },
|
{ 4, "MDTM", ECMD_MDTM, pdTRUE, pdTRUE },
|
||||||
{ 3, "RMD", ECMD_RMD, pdTRUE, pdTRUE },
|
{ 4, "DELE", ECMD_DELE, pdTRUE, pdTRUE },
|
||||||
{ 3, "MKD", ECMD_MKD, pdTRUE, pdTRUE },
|
{ 3, "RMD", ECMD_RMD, pdTRUE, pdTRUE },
|
||||||
{ 3, "PWD", ECMD_PWD, pdTRUE, pdFALSE },
|
{ 3, "MKD", ECMD_MKD, pdTRUE, pdTRUE },
|
||||||
{ 4, "LIST", ECMD_LIST, pdTRUE, pdFALSE },
|
{ 3, "PWD", ECMD_PWD, pdTRUE, pdFALSE },
|
||||||
{ 4, "NLST", ECMD_NLST, pdTRUE, pdFALSE },
|
{ 4, "LIST", ECMD_LIST, pdTRUE, pdFALSE },
|
||||||
{ 4, "SITE", ECMD_SITE, pdTRUE, pdFALSE },
|
{ 4, "NLST", ECMD_NLST, pdTRUE, pdFALSE },
|
||||||
{ 4, "SYST", ECMD_SYST, pdFALSE, pdFALSE },
|
{ 4, "SITE", ECMD_SITE, pdTRUE, pdFALSE },
|
||||||
{ 4, "FEAT", ECMD_FEAT, pdFALSE, pdFALSE },
|
{ 4, "SYST", ECMD_SYST, pdFALSE, pdFALSE },
|
||||||
{ 4, "STAT", ECMD_STAT, pdTRUE, pdFALSE },
|
{ 4, "FEAT", ECMD_FEAT, pdFALSE, pdFALSE },
|
||||||
{ 4, "HELP", ECMD_HELP, pdFALSE, pdFALSE },
|
{ 4, "STAT", ECMD_STAT, pdTRUE, pdFALSE },
|
||||||
{ 4, "NOOP", ECMD_NOOP, pdFALSE, pdFALSE },
|
{ 4, "HELP", ECMD_HELP, pdFALSE, pdFALSE },
|
||||||
{ 4, "EMPT", ECMD_EMPTY, pdFALSE, pdFALSE },
|
{ 4, "NOOP", ECMD_NOOP, pdFALSE, pdFALSE },
|
||||||
{ 4, "CLOS", ECMD_CLOSE, pdTRUE, pdFALSE },
|
{ 4, "EMPT", ECMD_EMPTY, pdFALSE, pdFALSE },
|
||||||
{ 4, "UNKN", ECMD_UNKNOWN, pdFALSE, pdFALSE },
|
{ 4, "CLOS", ECMD_CLOSE, pdTRUE, pdFALSE },
|
||||||
};
|
{ 4, "UNKN", ECMD_UNKNOWN, pdFALSE, pdFALSE },
|
||||||
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,76 +1,87 @@
|
|||||||
/*
|
/*
|
||||||
*!
|
* FreeRTOS V202212.00
|
||||||
*! The protocols implemented in this file are intended to be demo quality only,
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*! and not for production devices.
|
*
|
||||||
*!
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
*
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* FreeRTOS+TCP V2.0.3
|
* the Software without restriction, including without limitation the rights to
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
*
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* subject to the following conditions:
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
*
|
||||||
* the Software without restriction, including without limitation the rights to
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* copies or substantial portions of the Software.
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
*
|
||||||
* subject to the following conditions:
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
*
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* copies or substantial portions of the Software.
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
*
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
*
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* https://www.FreeRTOS.org
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* https://github.com/FreeRTOS
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
*
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
*/
|
||||||
*
|
|
||||||
* https://aws.amazon.com/freertos
|
/**
|
||||||
* https://www.FreeRTOS.org
|
*!
|
||||||
*/
|
*! The protocols implemented in this file are intended to be demo quality only,
|
||||||
|
*! and not for production devices.
|
||||||
|
*!
|
||||||
/* Standard includes. */
|
*/
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
/* Standard includes. */
|
||||||
|
#include <stdio.h>
|
||||||
/* FreeRTOS includes. */
|
#include <stdlib.h>
|
||||||
#include "FreeRTOS.h"
|
|
||||||
|
/* FreeRTOS includes. */
|
||||||
#include "FreeRTOS_HTTP_commands.h"
|
#include "FreeRTOS.h"
|
||||||
|
|
||||||
const struct xWEB_COMMAND xWebCommands[ WEB_CMD_COUNT ] =
|
#include "FreeRTOS_HTTP_commands.h"
|
||||||
{
|
|
||||||
{ 3, "GET", ECMD_GET },
|
const struct xWEB_COMMAND xWebCommands[ WEB_CMD_COUNT ] =
|
||||||
{ 4, "HEAD", ECMD_HEAD },
|
{
|
||||||
{ 4, "POST", ECMD_POST },
|
{ 3, "GET", ECMD_GET },
|
||||||
{ 3, "PUT", ECMD_PUT },
|
{ 4, "HEAD", ECMD_HEAD },
|
||||||
{ 6, "DELETE", ECMD_DELETE },
|
{ 4, "POST", ECMD_POST },
|
||||||
{ 5, "TRACE", ECMD_TRACE },
|
{ 3, "PUT", ECMD_PUT },
|
||||||
{ 7, "OPTIONS", ECMD_OPTIONS },
|
{ 6, "DELETE", ECMD_DELETE },
|
||||||
{ 7, "CONNECT", ECMD_CONNECT },
|
{ 5, "TRACE", ECMD_TRACE },
|
||||||
{ 5, "PATCH", ECMD_PATCH },
|
{ 7, "OPTIONS", ECMD_OPTIONS },
|
||||||
{ 4, "UNKN", ECMD_UNK },
|
{ 7, "CONNECT", ECMD_CONNECT },
|
||||||
};
|
{ 5, "PATCH", ECMD_PATCH },
|
||||||
|
{ 4, "UNKN", ECMD_UNK },
|
||||||
const char *webCodename (int aCode)
|
};
|
||||||
{
|
|
||||||
switch (aCode) {
|
const char * webCodename( int aCode )
|
||||||
case WEB_REPLY_OK: // = 200,
|
{
|
||||||
return "OK";
|
switch( aCode )
|
||||||
case WEB_NO_CONTENT: // 204
|
{
|
||||||
return "No content";
|
case WEB_REPLY_OK: /* = 200, */
|
||||||
case WEB_BAD_REQUEST: // = 400,
|
return "OK";
|
||||||
return "Bad request";
|
|
||||||
case WEB_UNAUTHORIZED: // = 401,
|
case WEB_NO_CONTENT: /* 204 */
|
||||||
return "Authorization Required";
|
return "No content";
|
||||||
case WEB_NOT_FOUND: // = 404,
|
|
||||||
return "Not Found";
|
case WEB_BAD_REQUEST: /* = 400, */
|
||||||
case WEB_GONE: // = 410,
|
return "Bad request";
|
||||||
return "Done";
|
|
||||||
case WEB_PRECONDITION_FAILED: // = 412,
|
case WEB_UNAUTHORIZED: /* = 401, */
|
||||||
return "Precondition Failed";
|
return "Authorization Required";
|
||||||
case WEB_INTERNAL_SERVER_ERROR: // = 500,
|
|
||||||
return "Internal Server Error";
|
case WEB_NOT_FOUND: /* = 404, */
|
||||||
}
|
return "Not Found";
|
||||||
return "Unknown";
|
|
||||||
}
|
case WEB_GONE: /* = 410, */
|
||||||
|
return "Done";
|
||||||
|
|
||||||
|
case WEB_PRECONDITION_FAILED: /* = 412, */
|
||||||
|
return "Precondition Failed";
|
||||||
|
|
||||||
|
case WEB_INTERNAL_SERVER_ERROR: /* = 500, */
|
||||||
|
return "Internal Server Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
@ -1,433 +1,464 @@
|
|||||||
/*
|
/*
|
||||||
*!
|
* FreeRTOS V202212.00
|
||||||
*! The protocols implemented in this file are intended to be demo quality only,
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*! and not for production devices.
|
*
|
||||||
*!
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
*
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* FreeRTOS+TCP V2.0.3
|
* the Software without restriction, including without limitation the rights to
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
*
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* subject to the following conditions:
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
*
|
||||||
* the Software without restriction, including without limitation the rights to
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* copies or substantial portions of the Software.
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
*
|
||||||
* subject to the following conditions:
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
*
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* copies or substantial portions of the Software.
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
*
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
*
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* https://www.FreeRTOS.org
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* https://github.com/FreeRTOS
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
*
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
*/
|
||||||
*
|
|
||||||
* https://aws.amazon.com/freertos
|
/**
|
||||||
* https://www.FreeRTOS.org
|
*!
|
||||||
*/
|
*! The protocols implemented in this file are intended to be demo quality only,
|
||||||
|
*! and not for production devices.
|
||||||
/* Standard includes. */
|
*!
|
||||||
#include <stdio.h>
|
*/
|
||||||
#include <stdlib.h>
|
|
||||||
|
/* Standard includes. */
|
||||||
/* FreeRTOS includes. */
|
#include <stdio.h>
|
||||||
#include "FreeRTOS.h"
|
#include <stdlib.h>
|
||||||
#include "task.h"
|
|
||||||
|
/* FreeRTOS includes. */
|
||||||
/* FreeRTOS+TCP includes. */
|
#include "FreeRTOS.h"
|
||||||
#include "FreeRTOS_IP.h"
|
#include "task.h"
|
||||||
#include "FreeRTOS_Sockets.h"
|
|
||||||
|
/* FreeRTOS+TCP includes. */
|
||||||
/* FreeRTOS Protocol includes. */
|
#include "FreeRTOS_IP.h"
|
||||||
#include "FreeRTOS_HTTP_commands.h"
|
#include "FreeRTOS_Sockets.h"
|
||||||
#include "FreeRTOS_TCP_server.h"
|
|
||||||
#include "FreeRTOS_server_private.h"
|
/* FreeRTOS Protocol includes. */
|
||||||
|
#include "FreeRTOS_HTTP_commands.h"
|
||||||
/* Remove the whole file if HTTP is not supported. */
|
#include "FreeRTOS_TCP_server.h"
|
||||||
#if( ipconfigUSE_HTTP == 1 )
|
#include "FreeRTOS_server_private.h"
|
||||||
|
|
||||||
/* FreeRTOS+FAT includes. */
|
/* Remove the whole file if HTTP is not supported. */
|
||||||
#include "ff_stdio.h"
|
#if ( ipconfigUSE_HTTP == 1 )
|
||||||
|
|
||||||
#ifndef HTTP_SERVER_BACKLOG
|
/* FreeRTOS+FAT includes. */
|
||||||
#define HTTP_SERVER_BACKLOG ( 12 )
|
#include "ff_stdio.h"
|
||||||
#endif
|
|
||||||
|
#ifndef HTTP_SERVER_BACKLOG
|
||||||
#ifndef USE_HTML_CHUNKS
|
#define HTTP_SERVER_BACKLOG ( 12 )
|
||||||
#define USE_HTML_CHUNKS ( 0 )
|
#endif
|
||||||
#endif
|
|
||||||
|
#ifndef USE_HTML_CHUNKS
|
||||||
#if !defined( ARRAY_SIZE )
|
#define USE_HTML_CHUNKS ( 0 )
|
||||||
#define ARRAY_SIZE(x) ( BaseType_t ) (sizeof( x ) / sizeof( x )[ 0 ] )
|
#endif
|
||||||
#endif
|
|
||||||
|
#if !defined( ARRAY_SIZE )
|
||||||
/* Some defines to make the code more readbale */
|
#define ARRAY_SIZE( x ) ( BaseType_t ) ( sizeof( x ) / sizeof( x )[ 0 ] )
|
||||||
#define pcCOMMAND_BUFFER pxClient->pxParent->pcCommandBuffer
|
#endif
|
||||||
#define pcNEW_DIR pxClient->pxParent->pcNewDir
|
|
||||||
#define pcFILE_BUFFER pxClient->pxParent->pcFileBuffer
|
/* Some defines to make the code more readbale */
|
||||||
|
#define pcCOMMAND_BUFFER pxClient->pxParent->pcCommandBuffer
|
||||||
#ifndef ipconfigHTTP_REQUEST_CHARACTER
|
#define pcNEW_DIR pxClient->pxParent->pcNewDir
|
||||||
#define ipconfigHTTP_REQUEST_CHARACTER '?'
|
#define pcFILE_BUFFER pxClient->pxParent->pcFileBuffer
|
||||||
#endif
|
|
||||||
|
#ifndef ipconfigHTTP_REQUEST_CHARACTER
|
||||||
/*_RB_ Need comment block, although fairly self evident. */
|
#define ipconfigHTTP_REQUEST_CHARACTER '?'
|
||||||
static void prvFileClose( HTTPClient_t *pxClient );
|
#endif
|
||||||
static BaseType_t prvProcessCmd( HTTPClient_t *pxClient, BaseType_t xIndex );
|
|
||||||
static const char *pcGetContentsType( const char *apFname );
|
/*_RB_ Need comment block, although fairly self evident. */
|
||||||
static BaseType_t prvOpenURL( HTTPClient_t *pxClient );
|
static void prvFileClose( HTTPClient_t * pxClient );
|
||||||
static BaseType_t prvSendFile( HTTPClient_t *pxClient );
|
static BaseType_t prvProcessCmd( HTTPClient_t * pxClient,
|
||||||
static BaseType_t prvSendReply( HTTPClient_t *pxClient, BaseType_t xCode );
|
BaseType_t xIndex );
|
||||||
|
static const char * pcGetContentsType( const char * apFname );
|
||||||
static const char pcEmptyString[1] = { '\0' };
|
static BaseType_t prvOpenURL( HTTPClient_t * pxClient );
|
||||||
|
static BaseType_t prvSendFile( HTTPClient_t * pxClient );
|
||||||
typedef struct xTYPE_COUPLE
|
static BaseType_t prvSendReply( HTTPClient_t * pxClient,
|
||||||
{
|
BaseType_t xCode );
|
||||||
const char *pcExtension;
|
|
||||||
const char *pcType;
|
static const char pcEmptyString[ 1 ] = { '\0' };
|
||||||
} TypeCouple_t;
|
|
||||||
|
typedef struct xTYPE_COUPLE
|
||||||
static TypeCouple_t pxTypeCouples[ ] =
|
{
|
||||||
{
|
const char * pcExtension;
|
||||||
{ "html", "text/html" },
|
const char * pcType;
|
||||||
{ "css", "text/css" },
|
} TypeCouple_t;
|
||||||
{ "js", "text/javascript" },
|
|
||||||
{ "png", "image/png" },
|
static TypeCouple_t pxTypeCouples[] =
|
||||||
{ "jpg", "image/jpeg" },
|
{
|
||||||
{ "gif", "image/gif" },
|
{ "html", "text/html" },
|
||||||
{ "txt", "text/plain" },
|
{ "css", "text/css" },
|
||||||
{ "mp3", "audio/mpeg3" },
|
{ "js", "text/javascript" },
|
||||||
{ "wav", "audio/wav" },
|
{ "png", "image/png" },
|
||||||
{ "flac", "audio/ogg" },
|
{ "jpg", "image/jpeg" },
|
||||||
{ "pdf", "application/pdf" },
|
{ "gif", "image/gif" },
|
||||||
{ "ttf", "application/x-font-ttf" },
|
{ "txt", "text/plain" },
|
||||||
{ "ttc", "application/x-font-ttf" }
|
{ "mp3", "audio/mpeg3" },
|
||||||
};
|
{ "wav", "audio/wav" },
|
||||||
|
{ "flac", "audio/ogg" },
|
||||||
void vHTTPClientDelete( TCPClient_t *pxTCPClient )
|
{ "pdf", "application/pdf" },
|
||||||
{
|
{ "ttf", "application/x-font-ttf" },
|
||||||
HTTPClient_t *pxClient = ( HTTPClient_t * ) pxTCPClient;
|
{ "ttc", "application/x-font-ttf" }
|
||||||
|
};
|
||||||
/* This HTTP client stops, close / release all resources. */
|
|
||||||
if( pxClient->xSocket != FREERTOS_NO_SOCKET )
|
void vHTTPClientDelete( TCPClient_t * pxTCPClient )
|
||||||
{
|
{
|
||||||
FreeRTOS_FD_CLR( pxClient->xSocket, pxClient->pxParent->xSocketSet, eSELECT_ALL );
|
HTTPClient_t * pxClient = ( HTTPClient_t * ) pxTCPClient;
|
||||||
FreeRTOS_closesocket( pxClient->xSocket );
|
|
||||||
pxClient->xSocket = FREERTOS_NO_SOCKET;
|
/* This HTTP client stops, close / release all resources. */
|
||||||
}
|
if( pxClient->xSocket != FREERTOS_NO_SOCKET )
|
||||||
prvFileClose( pxClient );
|
{
|
||||||
}
|
FreeRTOS_FD_CLR( pxClient->xSocket, pxClient->pxParent->xSocketSet, eSELECT_ALL );
|
||||||
/*-----------------------------------------------------------*/
|
FreeRTOS_closesocket( pxClient->xSocket );
|
||||||
|
pxClient->xSocket = FREERTOS_NO_SOCKET;
|
||||||
static void prvFileClose( HTTPClient_t *pxClient )
|
}
|
||||||
{
|
|
||||||
if( pxClient->pxFileHandle != NULL )
|
prvFileClose( pxClient );
|
||||||
{
|
}
|
||||||
FreeRTOS_printf( ( "Closing file: %s\n", pxClient->pcCurrentFilename ) );
|
/*-----------------------------------------------------------*/
|
||||||
ff_fclose( pxClient->pxFileHandle );
|
|
||||||
pxClient->pxFileHandle = NULL;
|
static void prvFileClose( HTTPClient_t * pxClient )
|
||||||
}
|
{
|
||||||
}
|
if( pxClient->pxFileHandle != NULL )
|
||||||
/*-----------------------------------------------------------*/
|
{
|
||||||
|
FreeRTOS_printf( ( "Closing file: %s\n", pxClient->pcCurrentFilename ) );
|
||||||
static BaseType_t prvSendReply( HTTPClient_t *pxClient, BaseType_t xCode )
|
ff_fclose( pxClient->pxFileHandle );
|
||||||
{
|
pxClient->pxFileHandle = NULL;
|
||||||
struct xTCP_SERVER *pxParent = pxClient->pxParent;
|
}
|
||||||
BaseType_t xRc;
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
/* A normal command reply on the main socket (port 21). */
|
|
||||||
char *pcBuffer = pxParent->pcFileBuffer;
|
static BaseType_t prvSendReply( HTTPClient_t * pxClient,
|
||||||
|
BaseType_t xCode )
|
||||||
xRc = snprintf( pcBuffer, sizeof( pxParent->pcFileBuffer ),
|
{
|
||||||
"HTTP/1.1 %d %s\r\n"
|
struct xTCP_SERVER * pxParent = pxClient->pxParent;
|
||||||
#if USE_HTML_CHUNKS
|
BaseType_t xRc;
|
||||||
"Transfer-Encoding: chunked\r\n"
|
|
||||||
#endif
|
/* A normal command reply on the main socket (port 21). */
|
||||||
"Content-Type: %s\r\n"
|
char * pcBuffer = pxParent->pcFileBuffer;
|
||||||
"Connection: keep-alive\r\n"
|
|
||||||
"%s\r\n",
|
xRc = snprintf( pcBuffer, sizeof( pxParent->pcFileBuffer ),
|
||||||
( int ) xCode,
|
"HTTP/1.1 %d %s\r\n"
|
||||||
webCodename (xCode),
|
#if USE_HTML_CHUNKS
|
||||||
pxParent->pcContentsType[0] ? pxParent->pcContentsType : "text/html",
|
"Transfer-Encoding: chunked\r\n"
|
||||||
pxParent->pcExtraContents );
|
#endif
|
||||||
|
"Content-Type: %s\r\n"
|
||||||
pxParent->pcContentsType[0] = '\0';
|
"Connection: keep-alive\r\n"
|
||||||
pxParent->pcExtraContents[0] = '\0';
|
"%s\r\n",
|
||||||
|
( int ) xCode,
|
||||||
xRc = FreeRTOS_send( pxClient->xSocket, ( const void * ) pcBuffer, xRc, 0 );
|
webCodename( xCode ),
|
||||||
pxClient->bits.bReplySent = pdTRUE_UNSIGNED;
|
pxParent->pcContentsType[ 0 ] ? pxParent->pcContentsType : "text/html",
|
||||||
|
pxParent->pcExtraContents );
|
||||||
return xRc;
|
|
||||||
}
|
pxParent->pcContentsType[ 0 ] = '\0';
|
||||||
/*-----------------------------------------------------------*/
|
pxParent->pcExtraContents[ 0 ] = '\0';
|
||||||
|
|
||||||
static BaseType_t prvSendFile( HTTPClient_t *pxClient )
|
xRc = FreeRTOS_send( pxClient->xSocket, ( const void * ) pcBuffer, xRc, 0 );
|
||||||
{
|
pxClient->bits.bReplySent = pdTRUE_UNSIGNED;
|
||||||
size_t uxSpace;
|
|
||||||
size_t uxCount;
|
return xRc;
|
||||||
BaseType_t xRc = 0;
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
if( pxClient->bits.bReplySent == pdFALSE_UNSIGNED )
|
|
||||||
{
|
static BaseType_t prvSendFile( HTTPClient_t * pxClient )
|
||||||
pxClient->bits.bReplySent = pdTRUE_UNSIGNED;
|
{
|
||||||
|
size_t uxSpace;
|
||||||
strcpy( pxClient->pxParent->pcContentsType, pcGetContentsType( pxClient->pcCurrentFilename ) );
|
size_t uxCount;
|
||||||
snprintf( pxClient->pxParent->pcExtraContents, sizeof( pxClient->pxParent->pcExtraContents ),
|
BaseType_t xRc = 0;
|
||||||
"Content-Length: %d\r\n", ( int ) pxClient->uxBytesLeft );
|
|
||||||
|
if( pxClient->bits.bReplySent == pdFALSE_UNSIGNED )
|
||||||
/* "Requested file action OK". */
|
{
|
||||||
xRc = prvSendReply( pxClient, WEB_REPLY_OK );
|
pxClient->bits.bReplySent = pdTRUE_UNSIGNED;
|
||||||
}
|
|
||||||
|
strcpy( pxClient->pxParent->pcContentsType, pcGetContentsType( pxClient->pcCurrentFilename ) );
|
||||||
if( xRc >= 0 ) do
|
snprintf( pxClient->pxParent->pcExtraContents, sizeof( pxClient->pxParent->pcExtraContents ),
|
||||||
{
|
"Content-Length: %d\r\n", ( int ) pxClient->uxBytesLeft );
|
||||||
uxSpace = FreeRTOS_tx_space( pxClient->xSocket );
|
|
||||||
|
/* "Requested file action OK". */
|
||||||
if( pxClient->uxBytesLeft < uxSpace )
|
xRc = prvSendReply( pxClient, WEB_REPLY_OK );
|
||||||
{
|
}
|
||||||
uxCount = pxClient->uxBytesLeft;
|
|
||||||
}
|
if( xRc >= 0 )
|
||||||
else
|
{
|
||||||
{
|
do
|
||||||
uxCount = uxSpace;
|
{
|
||||||
}
|
uxSpace = FreeRTOS_tx_space( pxClient->xSocket );
|
||||||
|
|
||||||
if( uxCount > 0u )
|
if( pxClient->uxBytesLeft < uxSpace )
|
||||||
{
|
{
|
||||||
if( uxCount > sizeof( pxClient->pxParent->pcFileBuffer ) )
|
uxCount = pxClient->uxBytesLeft;
|
||||||
{
|
}
|
||||||
uxCount = sizeof( pxClient->pxParent->pcFileBuffer );
|
else
|
||||||
}
|
{
|
||||||
ff_fread( pxClient->pxParent->pcFileBuffer, 1, uxCount, pxClient->pxFileHandle );
|
uxCount = uxSpace;
|
||||||
pxClient->uxBytesLeft -= uxCount;
|
}
|
||||||
|
|
||||||
xRc = FreeRTOS_send( pxClient->xSocket, pxClient->pxParent->pcFileBuffer, uxCount, 0 );
|
if( uxCount > 0u )
|
||||||
if( xRc < 0 )
|
{
|
||||||
{
|
if( uxCount > sizeof( pxClient->pxParent->pcFileBuffer ) )
|
||||||
break;
|
{
|
||||||
}
|
uxCount = sizeof( pxClient->pxParent->pcFileBuffer );
|
||||||
}
|
}
|
||||||
} while( uxCount > 0u );
|
|
||||||
|
ff_fread( pxClient->pxParent->pcFileBuffer, 1, uxCount, pxClient->pxFileHandle );
|
||||||
if( pxClient->uxBytesLeft == 0u )
|
pxClient->uxBytesLeft -= uxCount;
|
||||||
{
|
|
||||||
/* Writing is ready, no need for further 'eSELECT_WRITE' events. */
|
xRc = FreeRTOS_send( pxClient->xSocket, pxClient->pxParent->pcFileBuffer, uxCount, 0 );
|
||||||
FreeRTOS_FD_CLR( pxClient->xSocket, pxClient->pxParent->xSocketSet, eSELECT_WRITE );
|
|
||||||
prvFileClose( pxClient );
|
if( xRc < 0 )
|
||||||
}
|
{
|
||||||
else
|
break;
|
||||||
{
|
}
|
||||||
/* Wake up the TCP task as soon as this socket may be written to. */
|
}
|
||||||
FreeRTOS_FD_SET( pxClient->xSocket, pxClient->pxParent->xSocketSet, eSELECT_WRITE );
|
} while( uxCount > 0u );
|
||||||
}
|
}
|
||||||
|
|
||||||
return xRc;
|
if( pxClient->uxBytesLeft == 0u )
|
||||||
}
|
{
|
||||||
/*-----------------------------------------------------------*/
|
/* Writing is ready, no need for further 'eSELECT_WRITE' events. */
|
||||||
|
FreeRTOS_FD_CLR( pxClient->xSocket, pxClient->pxParent->xSocketSet, eSELECT_WRITE );
|
||||||
static BaseType_t prvOpenURL( HTTPClient_t *pxClient )
|
prvFileClose( pxClient );
|
||||||
{
|
}
|
||||||
BaseType_t xRc;
|
else
|
||||||
char pcSlash[ 2 ];
|
{
|
||||||
|
/* Wake up the TCP task as soon as this socket may be written to. */
|
||||||
pxClient->bits.ulFlags = 0;
|
FreeRTOS_FD_SET( pxClient->xSocket, pxClient->pxParent->xSocketSet, eSELECT_WRITE );
|
||||||
|
}
|
||||||
#if( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )
|
|
||||||
{
|
return xRc;
|
||||||
if( strchr( pxClient->pcUrlData, ipconfigHTTP_REQUEST_CHARACTER ) != NULL )
|
}
|
||||||
{
|
/*-----------------------------------------------------------*/
|
||||||
size_t xResult;
|
|
||||||
|
static BaseType_t prvOpenURL( HTTPClient_t * pxClient )
|
||||||
xResult = uxApplicationHTTPHandleRequestHook( pxClient->pcUrlData, pxClient->pcCurrentFilename, sizeof( pxClient->pcCurrentFilename ) );
|
{
|
||||||
if( xResult > 0 )
|
BaseType_t xRc;
|
||||||
{
|
char pcSlash[ 2 ];
|
||||||
strcpy( pxClient->pxParent->pcContentsType, "text/html" );
|
|
||||||
snprintf( pxClient->pxParent->pcExtraContents, sizeof( pxClient->pxParent->pcExtraContents ),
|
pxClient->bits.ulFlags = 0;
|
||||||
"Content-Length: %d\r\n", ( int ) xResult );
|
|
||||||
xRc = prvSendReply( pxClient, WEB_REPLY_OK ); /* "Requested file action OK" */
|
#if ( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )
|
||||||
if( xRc > 0 )
|
{
|
||||||
{
|
if( strchr( pxClient->pcUrlData, ipconfigHTTP_REQUEST_CHARACTER ) != NULL )
|
||||||
xRc = FreeRTOS_send( pxClient->xSocket, pxClient->pcCurrentFilename, xResult, 0 );
|
{
|
||||||
}
|
size_t xResult;
|
||||||
/* Although against the coding standard of FreeRTOS, a return is
|
|
||||||
done here to simplify this conditional code. */
|
xResult = uxApplicationHTTPHandleRequestHook( pxClient->pcUrlData, pxClient->pcCurrentFilename, sizeof( pxClient->pcCurrentFilename ) );
|
||||||
return xRc;
|
|
||||||
}
|
if( xResult > 0 )
|
||||||
}
|
{
|
||||||
}
|
strcpy( pxClient->pxParent->pcContentsType, "text/html" );
|
||||||
#endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */
|
snprintf( pxClient->pxParent->pcExtraContents, sizeof( pxClient->pxParent->pcExtraContents ),
|
||||||
|
"Content-Length: %d\r\n", ( int ) xResult );
|
||||||
if( pxClient->pcUrlData[ 0 ] != '/' )
|
xRc = prvSendReply( pxClient, WEB_REPLY_OK ); /* "Requested file action OK" */
|
||||||
{
|
|
||||||
/* Insert a slash before the file name. */
|
if( xRc > 0 )
|
||||||
pcSlash[ 0 ] = '/';
|
{
|
||||||
pcSlash[ 1 ] = '\0';
|
xRc = FreeRTOS_send( pxClient->xSocket, pxClient->pcCurrentFilename, xResult, 0 );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
/* Although against the coding standard of FreeRTOS, a return is
|
||||||
/* The browser provided a starting '/' already. */
|
* done here to simplify this conditional code. */
|
||||||
pcSlash[ 0 ] = '\0';
|
return xRc;
|
||||||
}
|
}
|
||||||
snprintf( pxClient->pcCurrentFilename, sizeof( pxClient->pcCurrentFilename ), "%s%s%s",
|
}
|
||||||
pxClient->pcRootDir,
|
}
|
||||||
pcSlash,
|
#endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */
|
||||||
pxClient->pcUrlData);
|
|
||||||
|
if( pxClient->pcUrlData[ 0 ] != '/' )
|
||||||
pxClient->pxFileHandle = ff_fopen( pxClient->pcCurrentFilename, "rb" );
|
{
|
||||||
|
/* Insert a slash before the file name. */
|
||||||
FreeRTOS_printf( ( "Open file '%s': %s\n", pxClient->pcCurrentFilename,
|
pcSlash[ 0 ] = '/';
|
||||||
pxClient->pxFileHandle != NULL ? "Ok" : strerror( stdioGET_ERRNO() ) ) );
|
pcSlash[ 1 ] = '\0';
|
||||||
|
}
|
||||||
if( pxClient->pxFileHandle == NULL )
|
else
|
||||||
{
|
{
|
||||||
/* "404 File not found". */
|
/* The browser provided a starting '/' already. */
|
||||||
xRc = prvSendReply( pxClient, WEB_NOT_FOUND );
|
pcSlash[ 0 ] = '\0';
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
snprintf( pxClient->pcCurrentFilename, sizeof( pxClient->pcCurrentFilename ), "%s%s%s",
|
||||||
pxClient->uxBytesLeft = ( size_t ) pxClient->pxFileHandle->ulFileSize;
|
pxClient->pcRootDir,
|
||||||
xRc = prvSendFile( pxClient );
|
pcSlash,
|
||||||
}
|
pxClient->pcUrlData );
|
||||||
|
|
||||||
return xRc;
|
pxClient->pxFileHandle = ff_fopen( pxClient->pcCurrentFilename, "rb" );
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
FreeRTOS_printf( ( "Open file '%s': %s\n", pxClient->pcCurrentFilename,
|
||||||
|
pxClient->pxFileHandle != NULL ? "Ok" : strerror( stdioGET_ERRNO() ) ) );
|
||||||
static BaseType_t prvProcessCmd( HTTPClient_t *pxClient, BaseType_t xIndex )
|
|
||||||
{
|
if( pxClient->pxFileHandle == NULL )
|
||||||
BaseType_t xResult = 0;
|
{
|
||||||
|
/* "404 File not found". */
|
||||||
/* A new command has been received. Process it. */
|
xRc = prvSendReply( pxClient, WEB_NOT_FOUND );
|
||||||
switch( xIndex )
|
}
|
||||||
{
|
else
|
||||||
case ECMD_GET:
|
{
|
||||||
xResult = prvOpenURL( pxClient );
|
pxClient->uxBytesLeft = ( size_t ) pxClient->pxFileHandle->ulFileSize;
|
||||||
break;
|
xRc = prvSendFile( pxClient );
|
||||||
|
}
|
||||||
case ECMD_HEAD:
|
|
||||||
case ECMD_POST:
|
return xRc;
|
||||||
case ECMD_PUT:
|
}
|
||||||
case ECMD_DELETE:
|
/*-----------------------------------------------------------*/
|
||||||
case ECMD_TRACE:
|
|
||||||
case ECMD_OPTIONS:
|
static BaseType_t prvProcessCmd( HTTPClient_t * pxClient,
|
||||||
case ECMD_CONNECT:
|
BaseType_t xIndex )
|
||||||
case ECMD_PATCH:
|
{
|
||||||
case ECMD_UNK:
|
BaseType_t xResult = 0;
|
||||||
{
|
|
||||||
FreeRTOS_printf( ( "prvProcessCmd: Not implemented: %s\n",
|
/* A new command has been received. Process it. */
|
||||||
xWebCommands[xIndex].pcCommandName ) );
|
switch( xIndex )
|
||||||
}
|
{
|
||||||
break;
|
case ECMD_GET:
|
||||||
}
|
xResult = prvOpenURL( pxClient );
|
||||||
|
break;
|
||||||
return xResult;
|
|
||||||
}
|
case ECMD_HEAD:
|
||||||
/*-----------------------------------------------------------*/
|
case ECMD_POST:
|
||||||
|
case ECMD_PUT:
|
||||||
BaseType_t xHTTPClientWork( TCPClient_t *pxTCPClient )
|
case ECMD_DELETE:
|
||||||
{
|
case ECMD_TRACE:
|
||||||
BaseType_t xRc;
|
case ECMD_OPTIONS:
|
||||||
HTTPClient_t *pxClient = ( HTTPClient_t * ) pxTCPClient;
|
case ECMD_CONNECT:
|
||||||
|
case ECMD_PATCH:
|
||||||
if( pxClient->pxFileHandle != NULL )
|
case ECMD_UNK:
|
||||||
{
|
FreeRTOS_printf( ( "prvProcessCmd: Not implemented: %s\n",
|
||||||
prvSendFile( pxClient );
|
xWebCommands[ xIndex ].pcCommandName ) );
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
xRc = FreeRTOS_recv( pxClient->xSocket, ( void * )pcCOMMAND_BUFFER, sizeof( pcCOMMAND_BUFFER ), 0 );
|
|
||||||
|
return xResult;
|
||||||
if( xRc > 0 )
|
}
|
||||||
{
|
/*-----------------------------------------------------------*/
|
||||||
BaseType_t xIndex;
|
|
||||||
const char *pcEndOfCmd;
|
BaseType_t xHTTPClientWork( TCPClient_t * pxTCPClient )
|
||||||
const struct xWEB_COMMAND *curCmd;
|
{
|
||||||
char *pcBuffer = pcCOMMAND_BUFFER;
|
BaseType_t xRc;
|
||||||
|
HTTPClient_t * pxClient = ( HTTPClient_t * ) pxTCPClient;
|
||||||
if( xRc < ( BaseType_t ) sizeof( pcCOMMAND_BUFFER ) )
|
|
||||||
{
|
if( pxClient->pxFileHandle != NULL )
|
||||||
pcBuffer[ xRc ] = '\0';
|
{
|
||||||
}
|
prvSendFile( pxClient );
|
||||||
while( xRc && ( pcBuffer[ xRc - 1 ] == 13 || pcBuffer[ xRc - 1 ] == 10 ) )
|
}
|
||||||
{
|
|
||||||
pcBuffer[ --xRc ] = '\0';
|
xRc = FreeRTOS_recv( pxClient->xSocket, ( void * ) pcCOMMAND_BUFFER, sizeof( pcCOMMAND_BUFFER ), 0 );
|
||||||
}
|
|
||||||
pcEndOfCmd = pcBuffer + xRc;
|
if( xRc > 0 )
|
||||||
|
{
|
||||||
curCmd = xWebCommands;
|
BaseType_t xIndex;
|
||||||
|
const char * pcEndOfCmd;
|
||||||
/* Pointing to "/index.html HTTP/1.1". */
|
const struct xWEB_COMMAND * curCmd;
|
||||||
pxClient->pcUrlData = pcBuffer;
|
char * pcBuffer = pcCOMMAND_BUFFER;
|
||||||
|
|
||||||
/* Pointing to "HTTP/1.1". */
|
if( xRc < ( BaseType_t ) sizeof( pcCOMMAND_BUFFER ) )
|
||||||
pxClient->pcRestData = pcEmptyString;
|
{
|
||||||
|
pcBuffer[ xRc ] = '\0';
|
||||||
/* Last entry is "ECMD_UNK". */
|
}
|
||||||
for( xIndex = 0; xIndex < WEB_CMD_COUNT - 1; xIndex++, curCmd++ )
|
|
||||||
{
|
while( xRc && ( pcBuffer[ xRc - 1 ] == 13 || pcBuffer[ xRc - 1 ] == 10 ) )
|
||||||
BaseType_t xLength;
|
{
|
||||||
|
pcBuffer[ --xRc ] = '\0';
|
||||||
xLength = curCmd->xCommandLength;
|
}
|
||||||
if( ( xRc >= xLength ) && ( memcmp( curCmd->pcCommandName, pcBuffer, xLength ) == 0 ) )
|
|
||||||
{
|
pcEndOfCmd = pcBuffer + xRc;
|
||||||
char *pcLastPtr;
|
|
||||||
|
curCmd = xWebCommands;
|
||||||
pxClient->pcUrlData += xLength + 1;
|
|
||||||
for( pcLastPtr = (char *)pxClient->pcUrlData; pcLastPtr < pcEndOfCmd; pcLastPtr++ )
|
/* Pointing to "/index.html HTTP/1.1". */
|
||||||
{
|
pxClient->pcUrlData = pcBuffer;
|
||||||
char ch = *pcLastPtr;
|
|
||||||
if( ( ch == '\0' ) || ( strchr( "\n\r \t", ch ) != NULL ) )
|
/* Pointing to "HTTP/1.1". */
|
||||||
{
|
pxClient->pcRestData = pcEmptyString;
|
||||||
*pcLastPtr = '\0';
|
|
||||||
pxClient->pcRestData = pcLastPtr + 1;
|
/* Last entry is "ECMD_UNK". */
|
||||||
break;
|
for( xIndex = 0; xIndex < WEB_CMD_COUNT - 1; xIndex++, curCmd++ )
|
||||||
}
|
{
|
||||||
}
|
BaseType_t xLength;
|
||||||
break;
|
|
||||||
}
|
xLength = curCmd->xCommandLength;
|
||||||
}
|
|
||||||
|
if( ( xRc >= xLength ) && ( memcmp( curCmd->pcCommandName, pcBuffer, xLength ) == 0 ) )
|
||||||
if( xIndex < ( WEB_CMD_COUNT - 1 ) )
|
{
|
||||||
{
|
char * pcLastPtr;
|
||||||
xRc = prvProcessCmd( pxClient, xIndex );
|
|
||||||
}
|
pxClient->pcUrlData += xLength + 1;
|
||||||
}
|
|
||||||
else if( xRc < 0 )
|
for( pcLastPtr = ( char * ) pxClient->pcUrlData; pcLastPtr < pcEndOfCmd; pcLastPtr++ )
|
||||||
{
|
{
|
||||||
/* The connection will be closed and the client will be deleted. */
|
char ch = *pcLastPtr;
|
||||||
FreeRTOS_printf( ( "xHTTPClientWork: rc = %ld\n", xRc ) );
|
|
||||||
}
|
if( ( ch == '\0' ) || ( strchr( "\n\r \t", ch ) != NULL ) )
|
||||||
return xRc;
|
{
|
||||||
}
|
*pcLastPtr = '\0';
|
||||||
/*-----------------------------------------------------------*/
|
pxClient->pcRestData = pcLastPtr + 1;
|
||||||
|
break;
|
||||||
static const char *pcGetContentsType (const char *apFname)
|
}
|
||||||
{
|
}
|
||||||
const char *slash = NULL;
|
|
||||||
const char *dot = NULL;
|
break;
|
||||||
const char *ptr;
|
}
|
||||||
const char *pcResult = "text/html";
|
}
|
||||||
BaseType_t x;
|
|
||||||
|
if( xIndex < ( WEB_CMD_COUNT - 1 ) )
|
||||||
for( ptr = apFname; *ptr; ptr++ )
|
{
|
||||||
{
|
xRc = prvProcessCmd( pxClient, xIndex );
|
||||||
if (*ptr == '.') dot = ptr;
|
}
|
||||||
if (*ptr == '/') slash = ptr;
|
}
|
||||||
}
|
else if( xRc < 0 )
|
||||||
if( dot > slash )
|
{
|
||||||
{
|
/* The connection will be closed and the client will be deleted. */
|
||||||
dot++;
|
FreeRTOS_printf( ( "xHTTPClientWork: rc = %ld\n", xRc ) );
|
||||||
for( x = 0; x < ARRAY_SIZE( pxTypeCouples ); x++ )
|
}
|
||||||
{
|
|
||||||
if( strcasecmp( dot, pxTypeCouples[ x ].pcExtension ) == 0 )
|
return xRc;
|
||||||
{
|
}
|
||||||
pcResult = pxTypeCouples[ x ].pcType;
|
/*-----------------------------------------------------------*/
|
||||||
break;
|
|
||||||
}
|
static const char * pcGetContentsType( const char * apFname )
|
||||||
}
|
{
|
||||||
}
|
const char * slash = NULL;
|
||||||
return pcResult;
|
const char * dot = NULL;
|
||||||
}
|
const char * ptr;
|
||||||
|
const char * pcResult = "text/html";
|
||||||
#endif /* ipconfigUSE_HTTP */
|
BaseType_t x;
|
||||||
|
|
||||||
|
for( ptr = apFname; *ptr; ptr++ )
|
||||||
|
{
|
||||||
|
if( *ptr == '.' )
|
||||||
|
{
|
||||||
|
dot = ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( *ptr == '/' )
|
||||||
|
{
|
||||||
|
slash = ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( dot > slash )
|
||||||
|
{
|
||||||
|
dot++;
|
||||||
|
|
||||||
|
for( x = 0; x < ARRAY_SIZE( pxTypeCouples ); x++ )
|
||||||
|
{
|
||||||
|
if( strcasecmp( dot, pxTypeCouples[ x ].pcExtension ) == 0 )
|
||||||
|
{
|
||||||
|
pcResult = pxTypeCouples[ x ].pcType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pcResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ipconfigUSE_HTTP */
|
||||||
|
@ -1,469 +1,498 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://github.com/FreeRTOS
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*!
|
*!
|
||||||
*! The protocols implemented in this file are intended to be demo quality only,
|
*! The protocols implemented in this file are intended to be demo quality only,
|
||||||
*! and not for production devices.
|
*! and not for production devices.
|
||||||
*!
|
*!
|
||||||
*
|
*
|
||||||
* NTPDemo.c
|
* NTPDemo.c
|
||||||
*
|
*
|
||||||
* An example of how to lookup a domain using DNS
|
* An example of how to lookup a domain using DNS
|
||||||
* And also how to send and receive UDP messages to get the NTP time
|
* And also how to send and receive UDP messages to get the NTP time
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Standard includes. */
|
/* Standard includes. */
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
/* FreeRTOS includes. */
|
/* FreeRTOS includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
|
|
||||||
/* FreeRTOS+TCP includes. */
|
/* FreeRTOS+TCP includes. */
|
||||||
#include "FreeRTOS_IP.h"
|
#include "FreeRTOS_IP.h"
|
||||||
#include "FreeRTOS_Sockets.h"
|
#include "FreeRTOS_Sockets.h"
|
||||||
#include "FreeRTOS_DNS.h"
|
#include "FreeRTOS_DNS.h"
|
||||||
#include "FreeRTOS_Stream_Buffer.h"
|
#include "FreeRTOS_Stream_Buffer.h"
|
||||||
|
|
||||||
/* Use the date & time functions from +FAT. */
|
/* Use the date & time functions from +FAT. */
|
||||||
#include "ff_time.h"
|
#include "ff_time.h"
|
||||||
|
|
||||||
#include "NTPDemo.h"
|
#include "NTPDemo.h"
|
||||||
#include "ntpClient.h"
|
#include "ntpClient.h"
|
||||||
|
|
||||||
#include "date_and_time.h"
|
#include "date_and_time.h"
|
||||||
|
|
||||||
enum EStatus {
|
enum EStatus
|
||||||
EStatusLookup,
|
{
|
||||||
EStatusAsking,
|
EStatusLookup,
|
||||||
EStatusPause,
|
EStatusAsking,
|
||||||
EStatusFailed,
|
EStatusPause,
|
||||||
};
|
EStatusFailed,
|
||||||
|
};
|
||||||
static struct SNtpPacket xNTPPacket;
|
|
||||||
|
static struct SNtpPacket xNTPPacket;
|
||||||
#if( ipconfigUSE_CALLBACKS == 0 )
|
|
||||||
static char cRecvBuffer[ sizeof( struct SNtpPacket ) + 64 ];
|
#if ( ipconfigUSE_CALLBACKS == 0 )
|
||||||
#endif
|
static char cRecvBuffer[ sizeof( struct SNtpPacket ) + 64 ];
|
||||||
|
#endif
|
||||||
static enum EStatus xStatus = EStatusLookup;
|
|
||||||
|
static enum EStatus xStatus = EStatusLookup;
|
||||||
static const char *pcTimeServers[] = {
|
|
||||||
"0.asia.pool.ntp.org",
|
static const char * pcTimeServers[] =
|
||||||
"0.europe.pool.ntp.org",
|
{
|
||||||
"0.id.pool.ntp.org",
|
"0.asia.pool.ntp.org",
|
||||||
"0.south-america.pool.ntp.org",
|
"0.europe.pool.ntp.org",
|
||||||
"0.oceania.pool.ntp.org",
|
"0.id.pool.ntp.org",
|
||||||
"0.north-america.pool.ntp.org"
|
"0.south-america.pool.ntp.org",
|
||||||
};
|
"0.oceania.pool.ntp.org",
|
||||||
|
"0.north-america.pool.ntp.org"
|
||||||
static SemaphoreHandle_t xNTPWakeupSem = NULL;
|
};
|
||||||
static uint32_t ulIPAddressFound;
|
|
||||||
static Socket_t xUDPSocket = NULL;
|
static SemaphoreHandle_t xNTPWakeupSem = NULL;
|
||||||
static TaskHandle_t xNTPTaskhandle = NULL;
|
static uint32_t ulIPAddressFound;
|
||||||
static TickType_t uxSendTime;
|
static Socket_t xUDPSocket = NULL;
|
||||||
|
static TaskHandle_t xNTPTaskhandle = NULL;
|
||||||
static void prvNTPTask( void *pvParameters );
|
static TickType_t uxSendTime;
|
||||||
|
|
||||||
static void vSignalTask( void )
|
static void prvNTPTask( void * pvParameters );
|
||||||
{
|
|
||||||
#if( ipconfigUSE_CALLBACKS == 0 )
|
static void vSignalTask( void )
|
||||||
if( xUDPSocket != NULL )
|
{
|
||||||
{
|
#if ( ipconfigUSE_CALLBACKS == 0 )
|
||||||
/* Send a signal to the socket so that the
|
if( xUDPSocket != NULL )
|
||||||
FreeRTOS_recvfrom will get interrupted. */
|
{
|
||||||
FreeRTOS_SignalSocket( xUDPSocket );
|
/* Send a signal to the socket so that the
|
||||||
}
|
* FreeRTOS_recvfrom will get interrupted. */
|
||||||
else
|
FreeRTOS_SignalSocket( xUDPSocket );
|
||||||
#endif
|
}
|
||||||
if( xNTPWakeupSem != NULL )
|
else
|
||||||
{
|
#endif
|
||||||
xSemaphoreGive( xNTPWakeupSem );
|
|
||||||
}
|
if( xNTPWakeupSem != NULL )
|
||||||
}
|
{
|
||||||
|
xSemaphoreGive( xNTPWakeupSem );
|
||||||
void vStartNTPTask( uint16_t usTaskStackSize, UBaseType_t uxTaskPriority )
|
}
|
||||||
{
|
}
|
||||||
/* The only public function in this module: start a task to contact
|
|
||||||
some NTP server. */
|
void vStartNTPTask( uint16_t usTaskStackSize,
|
||||||
|
UBaseType_t uxTaskPriority )
|
||||||
if( xNTPTaskhandle != NULL )
|
{
|
||||||
{
|
/* The only public function in this module: start a task to contact
|
||||||
switch( xStatus )
|
* some NTP server. */
|
||||||
{
|
|
||||||
case EStatusPause:
|
if( xNTPTaskhandle != NULL )
|
||||||
xStatus = EStatusAsking;
|
{
|
||||||
vSignalTask();
|
switch( xStatus )
|
||||||
break;
|
{
|
||||||
case EStatusLookup:
|
case EStatusPause:
|
||||||
FreeRTOS_printf( ( "NTP looking up server\n" ) );
|
xStatus = EStatusAsking;
|
||||||
break;
|
vSignalTask();
|
||||||
case EStatusAsking:
|
break;
|
||||||
FreeRTOS_printf( ( "NTP still asking\n" ) );
|
|
||||||
break;
|
case EStatusLookup:
|
||||||
case EStatusFailed:
|
FreeRTOS_printf( ( "NTP looking up server\n" ) );
|
||||||
FreeRTOS_printf( ( "NTP failed somehow\n" ) );
|
break;
|
||||||
ulIPAddressFound = 0ul;
|
|
||||||
xStatus = EStatusLookup;
|
case EStatusAsking:
|
||||||
vSignalTask();
|
FreeRTOS_printf( ( "NTP still asking\n" ) );
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
case EStatusFailed:
|
||||||
else
|
FreeRTOS_printf( ( "NTP failed somehow\n" ) );
|
||||||
{
|
ulIPAddressFound = 0ul;
|
||||||
xUDPSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
xStatus = EStatusLookup;
|
||||||
if( xUDPSocket != FREERTOS_INVALID_SOCKET )
|
vSignalTask();
|
||||||
{
|
break;
|
||||||
struct freertos_sockaddr xAddress;
|
}
|
||||||
#if( ipconfigUSE_CALLBACKS != 0 )
|
}
|
||||||
BaseType_t xReceiveTimeOut = pdMS_TO_TICKS( 0 );
|
else
|
||||||
#else
|
{
|
||||||
BaseType_t xReceiveTimeOut = pdMS_TO_TICKS( 5000 );
|
xUDPSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
|
||||||
#endif
|
|
||||||
|
if( xUDPSocket != FREERTOS_INVALID_SOCKET )
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
{
|
||||||
{
|
struct freertos_sockaddr xAddress;
|
||||||
xAddress.sin_address.ulIP_IPv4 = 0ul;
|
#if ( ipconfigUSE_CALLBACKS != 0 )
|
||||||
}
|
BaseType_t xReceiveTimeOut = pdMS_TO_TICKS( 0 );
|
||||||
#else
|
#else
|
||||||
{
|
BaseType_t xReceiveTimeOut = pdMS_TO_TICKS( 5000 );
|
||||||
xAddress.sin_addr = 0ul;
|
#endif
|
||||||
}
|
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
|
{
|
||||||
xAddress.sin_port = FreeRTOS_htons( NTP_PORT );
|
xAddress.sin_address.ulIP_IPv4 = 0ul;
|
||||||
xAddress.sin_family = FREERTOS_AF_INET;
|
}
|
||||||
|
#else
|
||||||
FreeRTOS_bind( xUDPSocket, &xAddress, sizeof( xAddress ) );
|
{
|
||||||
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_RCVTIMEO, &xReceiveTimeOut, sizeof( xReceiveTimeOut ) );
|
xAddress.sin_addr = 0ul;
|
||||||
xTaskCreate( prvNTPTask, /* The function that implements the task. */
|
}
|
||||||
( const char * ) "NTP client", /* Just a text name for the task to aid debugging. */
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */
|
|
||||||
NULL, /* The task parameter, not used in this case. */
|
xAddress.sin_port = FreeRTOS_htons( NTP_PORT );
|
||||||
uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */
|
xAddress.sin_family = FREERTOS_AF_INET;
|
||||||
&xNTPTaskhandle ); /* The task handle. */
|
|
||||||
}
|
FreeRTOS_bind( xUDPSocket, &xAddress, sizeof( xAddress ) );
|
||||||
else
|
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_RCVTIMEO, &xReceiveTimeOut, sizeof( xReceiveTimeOut ) );
|
||||||
{
|
xTaskCreate( prvNTPTask, /* The function that implements the task. */
|
||||||
FreeRTOS_printf( ( "Creating socket failed\n" ) );
|
( const char * ) "NTP client", /* Just a text name for the task to aid debugging. */
|
||||||
}
|
usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */
|
||||||
}
|
NULL, /* The task parameter, not used in this case. */
|
||||||
}
|
uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */
|
||||||
/*-----------------------------------------------------------*/
|
&xNTPTaskhandle ); /* The task handle. */
|
||||||
|
}
|
||||||
static void vDNS_callback( const char *pcName, void *pvSearchID, uint32_t ulIPAddress )
|
else
|
||||||
{
|
{
|
||||||
char pcBuf[16];
|
FreeRTOS_printf( ( "Creating socket failed\n" ) );
|
||||||
|
}
|
||||||
/* The DNS lookup has a result, or it has reached the time-out. */
|
}
|
||||||
FreeRTOS_inet_ntoa( ulIPAddress, pcBuf );
|
}
|
||||||
FreeRTOS_printf( ( "IP address of %s found: %s\n", pcName, pcBuf ) );
|
/*-----------------------------------------------------------*/
|
||||||
if( ulIPAddressFound == 0ul )
|
|
||||||
{
|
static void vDNS_callback( const char * pcName,
|
||||||
ulIPAddressFound = ulIPAddress;
|
void * pvSearchID,
|
||||||
}
|
uint32_t ulIPAddress )
|
||||||
/* For testing: in case DNS doen't respond, still try some NTP server
|
{
|
||||||
with a known IP-address. */
|
char pcBuf[ 16 ];
|
||||||
if( ulIPAddressFound == 0ul )
|
|
||||||
{
|
/* The DNS lookup has a result, or it has reached the time-out. */
|
||||||
ulIPAddressFound = FreeRTOS_inet_addr_quick( 184, 105, 182, 7 );
|
FreeRTOS_inet_ntoa( ulIPAddress, pcBuf );
|
||||||
/* ulIPAddressFound = FreeRTOS_inet_addr_quick( 103, 242, 70, 4 ); */
|
FreeRTOS_printf( ( "IP address of %s found: %s\n", pcName, pcBuf ) );
|
||||||
}
|
|
||||||
xStatus = EStatusAsking;
|
if( ulIPAddressFound == 0ul )
|
||||||
|
{
|
||||||
vSignalTask();
|
ulIPAddressFound = ulIPAddress;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
/* For testing: in case DNS doesn't respond, still try some NTP server
|
||||||
static void prvSwapFields( struct SNtpPacket *pxPacket)
|
* with a known IP-address. */
|
||||||
{
|
if( ulIPAddressFound == 0ul )
|
||||||
/* NTP messages are big-endian */
|
{
|
||||||
pxPacket->rootDelay = FreeRTOS_htonl( pxPacket->rootDelay );
|
ulIPAddressFound = FreeRTOS_inet_addr_quick( 184, 105, 182, 7 );
|
||||||
pxPacket->rootDispersion = FreeRTOS_htonl( pxPacket->rootDispersion );
|
/* ulIPAddressFound = FreeRTOS_inet_addr_quick( 103, 242, 70, 4 ); */
|
||||||
|
}
|
||||||
pxPacket->referenceTimestamp.seconds = FreeRTOS_htonl( pxPacket->referenceTimestamp.seconds );
|
|
||||||
pxPacket->referenceTimestamp.fraction = FreeRTOS_htonl( pxPacket->referenceTimestamp.fraction );
|
xStatus = EStatusAsking;
|
||||||
|
|
||||||
pxPacket->originateTimestamp.seconds = FreeRTOS_htonl( pxPacket->originateTimestamp.seconds );
|
vSignalTask();
|
||||||
pxPacket->originateTimestamp.fraction = FreeRTOS_htonl( pxPacket->originateTimestamp.fraction );
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
pxPacket->receiveTimestamp.seconds = FreeRTOS_htonl( pxPacket->receiveTimestamp.seconds );
|
|
||||||
pxPacket->receiveTimestamp.fraction = FreeRTOS_htonl( pxPacket->receiveTimestamp.fraction );
|
static void prvSwapFields( struct SNtpPacket * pxPacket )
|
||||||
|
{
|
||||||
pxPacket->transmitTimestamp.seconds = FreeRTOS_htonl( pxPacket->transmitTimestamp.seconds );
|
/* NTP messages are big-endian */
|
||||||
pxPacket->transmitTimestamp.fraction = FreeRTOS_htonl( pxPacket->transmitTimestamp.fraction );
|
pxPacket->rootDelay = FreeRTOS_htonl( pxPacket->rootDelay );
|
||||||
}
|
pxPacket->rootDispersion = FreeRTOS_htonl( pxPacket->rootDispersion );
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
pxPacket->referenceTimestamp.seconds = FreeRTOS_htonl( pxPacket->referenceTimestamp.seconds );
|
||||||
static void prvNTPPacketInit( )
|
pxPacket->referenceTimestamp.fraction = FreeRTOS_htonl( pxPacket->referenceTimestamp.fraction );
|
||||||
{
|
|
||||||
memset (&xNTPPacket, '\0', sizeof( xNTPPacket ) );
|
pxPacket->originateTimestamp.seconds = FreeRTOS_htonl( pxPacket->originateTimestamp.seconds );
|
||||||
|
pxPacket->originateTimestamp.fraction = FreeRTOS_htonl( pxPacket->originateTimestamp.fraction );
|
||||||
xNTPPacket.flags = 0xDB; /* value 0xDB : mode 3 (client), version 3, leap indicator unknown 3 */
|
|
||||||
xNTPPacket.poll = 10; /* 10 means 1 << 10 = 1024 seconds */
|
pxPacket->receiveTimestamp.seconds = FreeRTOS_htonl( pxPacket->receiveTimestamp.seconds );
|
||||||
xNTPPacket.precision = 0xFA; /* = 250 = 0.015625 seconds */
|
pxPacket->receiveTimestamp.fraction = FreeRTOS_htonl( pxPacket->receiveTimestamp.fraction );
|
||||||
xNTPPacket.rootDelay = 0x5D2E; /* 0x5D2E = 23854 or (23854/65535)= 0.3640 sec */
|
|
||||||
xNTPPacket.rootDispersion = 0x0008CAC8; /* 0x0008CAC8 = 8.7912 seconds */
|
pxPacket->transmitTimestamp.seconds = FreeRTOS_htonl( pxPacket->transmitTimestamp.seconds );
|
||||||
|
pxPacket->transmitTimestamp.fraction = FreeRTOS_htonl( pxPacket->transmitTimestamp.fraction );
|
||||||
/* use the recorded NTP time */
|
}
|
||||||
time_t uxSecs = FreeRTOS_time( NULL );/* apTime may be NULL, returns seconds */
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
xNTPPacket.referenceTimestamp.seconds = uxSecs; /* Current time */
|
static void prvNTPPacketInit()
|
||||||
xNTPPacket.transmitTimestamp.seconds = uxSecs + 3;
|
{
|
||||||
|
memset( &xNTPPacket, '\0', sizeof( xNTPPacket ) );
|
||||||
/* Transform the contents of the fields from native to big endian. */
|
|
||||||
prvSwapFields( &xNTPPacket );
|
xNTPPacket.flags = 0xDB; /* value 0xDB : mode 3 (client), version 3, leap indicator unknown 3 */
|
||||||
}
|
xNTPPacket.poll = 10; /* 10 means 1 << 10 = 1024 seconds */
|
||||||
/*-----------------------------------------------------------*/
|
xNTPPacket.precision = 0xFA; /* = 250 = 0.015625 seconds */
|
||||||
|
xNTPPacket.rootDelay = 0x5D2E; /* 0x5D2E = 23854 or (23854/65535)= 0.3640 sec */
|
||||||
static void prvReadTime( struct SNtpPacket * pxPacket )
|
xNTPPacket.rootDispersion = 0x0008CAC8; /* 0x0008CAC8 = 8.7912 seconds */
|
||||||
{
|
|
||||||
FF_TimeStruct_t xTimeStruct;
|
/* use the recorded NTP time */
|
||||||
time_t uxPreviousSeconds;
|
time_t uxSecs = FreeRTOS_time( NULL ); /* apTime may be NULL, returns seconds */
|
||||||
time_t uxPreviousMS;
|
|
||||||
|
xNTPPacket.referenceTimestamp.seconds = uxSecs; /* Current time */
|
||||||
time_t uxCurrentSeconds;
|
xNTPPacket.transmitTimestamp.seconds = uxSecs + 3;
|
||||||
time_t uxCurrentMS;
|
|
||||||
|
/* Transform the contents of the fields from native to big endian. */
|
||||||
const char *pcTimeUnit;
|
prvSwapFields( &xNTPPacket );
|
||||||
int32_t ilDiff;
|
}
|
||||||
TickType_t uxTravelTime;
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
uxTravelTime = xTaskGetTickCount() - uxSendTime;
|
static void prvReadTime( struct SNtpPacket * pxPacket )
|
||||||
|
{
|
||||||
/* Transform the contents of the fields from big to native endian. */
|
FF_TimeStruct_t xTimeStruct;
|
||||||
prvSwapFields( pxPacket );
|
time_t uxPreviousSeconds;
|
||||||
|
time_t uxPreviousMS;
|
||||||
uxCurrentSeconds = pxPacket->receiveTimestamp.seconds - TIME1970;
|
|
||||||
uxCurrentMS = pxPacket->receiveTimestamp.fraction / 4294967;
|
time_t uxCurrentSeconds;
|
||||||
uxCurrentSeconds += uxCurrentMS / 1000;
|
time_t uxCurrentMS;
|
||||||
uxCurrentMS = uxCurrentMS % 1000;
|
|
||||||
|
const char * pcTimeUnit;
|
||||||
// Get the last time recorded
|
int32_t ilDiff;
|
||||||
uxPreviousSeconds = FreeRTOS_get_secs_msec( &uxPreviousMS );
|
TickType_t uxTravelTime;
|
||||||
|
|
||||||
// Set the new time with precision in msec. */
|
uxTravelTime = xTaskGetTickCount() - uxSendTime;
|
||||||
FreeRTOS_set_secs_msec( &uxCurrentSeconds, &uxCurrentMS );
|
|
||||||
|
/* Transform the contents of the fields from big to native endian. */
|
||||||
if( uxCurrentSeconds >= uxPreviousSeconds )
|
prvSwapFields( pxPacket );
|
||||||
{
|
|
||||||
ilDiff = ( int32_t ) ( uxCurrentSeconds - uxPreviousSeconds );
|
uxCurrentSeconds = pxPacket->receiveTimestamp.seconds - TIME1970;
|
||||||
}
|
uxCurrentMS = pxPacket->receiveTimestamp.fraction / 4294967;
|
||||||
else
|
uxCurrentSeconds += uxCurrentMS / 1000;
|
||||||
{
|
uxCurrentMS = uxCurrentMS % 1000;
|
||||||
ilDiff = 0 - ( int32_t ) ( uxPreviousSeconds - uxCurrentSeconds );
|
|
||||||
}
|
/* Get the last time recorded */
|
||||||
|
uxPreviousSeconds = FreeRTOS_get_secs_msec( &uxPreviousMS );
|
||||||
if( ( ilDiff < -5 ) || ( ilDiff > 5 ) )
|
|
||||||
{
|
/* Set the new time with precision in msec. * / */
|
||||||
/* More than 5 seconds difference. */
|
FreeRTOS_set_secs_msec( &uxCurrentSeconds, &uxCurrentMS );
|
||||||
pcTimeUnit = "sec";
|
|
||||||
}
|
if( uxCurrentSeconds >= uxPreviousSeconds )
|
||||||
else
|
{
|
||||||
{
|
ilDiff = ( int32_t ) ( uxCurrentSeconds - uxPreviousSeconds );
|
||||||
/* Less than or equal to 5 second difference. */
|
}
|
||||||
pcTimeUnit = "ms";
|
else
|
||||||
uint32_t ulLowest = ( uxCurrentSeconds <= uxPreviousSeconds ) ? uxCurrentSeconds : uxPreviousSeconds;
|
{
|
||||||
int32_t iCurMS = 1000 * ( uxCurrentSeconds - ulLowest ) + uxCurrentMS;
|
ilDiff = 0 - ( int32_t ) ( uxPreviousSeconds - uxCurrentSeconds );
|
||||||
int32_t iPrevMS = 1000 * ( uxPreviousSeconds - ulLowest ) + uxPreviousMS;
|
}
|
||||||
ilDiff = iCurMS - iPrevMS;
|
|
||||||
}
|
if( ( ilDiff < -5 ) || ( ilDiff > 5 ) )
|
||||||
uxCurrentSeconds -= iTimeZone;
|
{
|
||||||
|
/* More than 5 seconds difference. */
|
||||||
FreeRTOS_gmtime_r( &uxCurrentSeconds, &xTimeStruct );
|
pcTimeUnit = "sec";
|
||||||
|
}
|
||||||
/*
|
else
|
||||||
378.067 [NTP client] NTP time: 9/11/2015 16:11:19.559 Diff -20 ms (289 ms)
|
{
|
||||||
379.441 [NTP client] NTP time: 9/11/2015 16:11:20.933 Diff 0 ms (263 ms)
|
/* Less than or equal to 5 second difference. */
|
||||||
*/
|
pcTimeUnit = "ms";
|
||||||
|
uint32_t ulLowest = ( uxCurrentSeconds <= uxPreviousSeconds ) ? uxCurrentSeconds : uxPreviousSeconds;
|
||||||
FreeRTOS_printf( ("NTP time: %d/%d/%02d %2d:%02d:%02d.%03u Diff %d %s (%lu ms)\n",
|
int32_t iCurMS = 1000 * ( uxCurrentSeconds - ulLowest ) + uxCurrentMS;
|
||||||
xTimeStruct.tm_mday,
|
int32_t iPrevMS = 1000 * ( uxPreviousSeconds - ulLowest ) + uxPreviousMS;
|
||||||
xTimeStruct.tm_mon + 1,
|
ilDiff = iCurMS - iPrevMS;
|
||||||
xTimeStruct.tm_year + 1900,
|
}
|
||||||
xTimeStruct.tm_hour,
|
|
||||||
xTimeStruct.tm_min,
|
uxCurrentSeconds -= iTimeZone;
|
||||||
xTimeStruct.tm_sec,
|
|
||||||
( unsigned )uxCurrentMS,
|
FreeRTOS_gmtime_r( &uxCurrentSeconds, &xTimeStruct );
|
||||||
( unsigned )ilDiff,
|
|
||||||
pcTimeUnit,
|
/*
|
||||||
uxTravelTime ) );
|
* 378.067 [NTP client] NTP time: 9/11/2015 16:11:19.559 Diff -20 ms (289 ms)
|
||||||
|
* 379.441 [NTP client] NTP time: 9/11/2015 16:11:20.933 Diff 0 ms (263 ms)
|
||||||
/* Remove compiler warnings in case FreeRTOS_printf() is not used. */
|
*/
|
||||||
( void ) pcTimeUnit;
|
|
||||||
( void ) uxTravelTime;
|
FreeRTOS_printf( ( "NTP time: %d/%d/%02d %2d:%02d:%02d.%03u Diff %d %s (%lu ms)\n",
|
||||||
}
|
xTimeStruct.tm_mday,
|
||||||
/*-----------------------------------------------------------*/
|
xTimeStruct.tm_mon + 1,
|
||||||
|
xTimeStruct.tm_year + 1900,
|
||||||
#if( ipconfigUSE_CALLBACKS != 0 )
|
xTimeStruct.tm_hour,
|
||||||
|
xTimeStruct.tm_min,
|
||||||
static BaseType_t xOnUDPReceive( Socket_t xSocket, void * pvData, size_t xLength,
|
xTimeStruct.tm_sec,
|
||||||
const struct freertos_sockaddr *pxFrom, const struct freertos_sockaddr *pxDest )
|
( unsigned ) uxCurrentMS,
|
||||||
{
|
( unsigned ) ilDiff,
|
||||||
if( xLength >= sizeof( xNTPPacket ) )
|
pcTimeUnit,
|
||||||
{
|
uxTravelTime ) );
|
||||||
prvReadTime( ( struct SNtpPacket *)pvData );
|
|
||||||
if( xStatus != EStatusPause )
|
/* Remove compiler warnings in case FreeRTOS_printf() is not used. */
|
||||||
{
|
( void ) pcTimeUnit;
|
||||||
xStatus = EStatusPause;
|
( void ) uxTravelTime;
|
||||||
}
|
}
|
||||||
}
|
/*-----------------------------------------------------------*/
|
||||||
vSignalTask();
|
|
||||||
/* Tell the driver not to store the RX data */
|
#if ( ipconfigUSE_CALLBACKS != 0 )
|
||||||
return 1;
|
|
||||||
}
|
static BaseType_t xOnUDPReceive( Socket_t xSocket,
|
||||||
/*-----------------------------------------------------------*/
|
void * pvData,
|
||||||
|
size_t xLength,
|
||||||
#endif /* ipconfigUSE_CALLBACKS != 0 */
|
const struct freertos_sockaddr * pxFrom,
|
||||||
|
const struct freertos_sockaddr * pxDest )
|
||||||
static void prvNTPTask( void *pvParameters )
|
{
|
||||||
{
|
if( xLength >= sizeof( xNTPPacket ) )
|
||||||
BaseType_t xServerIndex = 3;
|
{
|
||||||
struct freertos_sockaddr xAddress;
|
prvReadTime( ( struct SNtpPacket * ) pvData );
|
||||||
#if( ipconfigUSE_CALLBACKS != 0 )
|
|
||||||
F_TCP_UDP_Handler_t xHandler;
|
if( xStatus != EStatusPause )
|
||||||
#endif /* ipconfigUSE_CALLBACKS != 0 */
|
{
|
||||||
|
xStatus = EStatusPause;
|
||||||
xStatus = EStatusLookup;
|
}
|
||||||
#if( ipconfigSOCKET_HAS_USER_SEMAPHORE != 0 ) || ( ipconfigUSE_CALLBACKS != 0 )
|
}
|
||||||
{
|
|
||||||
xNTPWakeupSem = xSemaphoreCreateBinary();
|
vSignalTask();
|
||||||
}
|
/* Tell the driver not to store the RX data */
|
||||||
#endif
|
return 1;
|
||||||
|
}
|
||||||
#if( ipconfigUSE_CALLBACKS != 0 )
|
/*-----------------------------------------------------------*/
|
||||||
{
|
|
||||||
memset( &xHandler, '\0', sizeof( xHandler ) );
|
#endif /* ipconfigUSE_CALLBACKS != 0 */
|
||||||
xHandler.pxOnUDPReceive = xOnUDPReceive;
|
|
||||||
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_UDP_RECV_HANDLER, ( void * ) &xHandler, sizeof( xHandler ) );
|
static void prvNTPTask( void * pvParameters )
|
||||||
}
|
{
|
||||||
#endif
|
BaseType_t xServerIndex = 3;
|
||||||
#if( ipconfigSOCKET_HAS_USER_SEMAPHORE != 0 )
|
struct freertos_sockaddr xAddress;
|
||||||
{
|
|
||||||
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_SET_SEMAPHORE, ( void * ) &xNTPWakeupSem, sizeof( xNTPWakeupSem ) );
|
#if ( ipconfigUSE_CALLBACKS != 0 )
|
||||||
}
|
F_TCP_UDP_Handler_t xHandler;
|
||||||
#endif
|
#endif /* ipconfigUSE_CALLBACKS != 0 */
|
||||||
for( ; ; )
|
|
||||||
{
|
xStatus = EStatusLookup;
|
||||||
switch( xStatus )
|
#if ( ipconfigSOCKET_HAS_USER_SEMAPHORE != 0 ) || ( ipconfigUSE_CALLBACKS != 0 )
|
||||||
{
|
{
|
||||||
case EStatusLookup:
|
xNTPWakeupSem = xSemaphoreCreateBinary();
|
||||||
if( ( ulIPAddressFound == 0ul ) || ( ulIPAddressFound == ~0ul ) )
|
}
|
||||||
{
|
#endif
|
||||||
if( ++xServerIndex == sizeof( pcTimeServers ) / sizeof( pcTimeServers[ 0 ] ) )
|
|
||||||
{
|
#if ( ipconfigUSE_CALLBACKS != 0 )
|
||||||
xServerIndex = 0;
|
{
|
||||||
}
|
memset( &xHandler, '\0', sizeof( xHandler ) );
|
||||||
FreeRTOS_printf( ( "Looking up server '%s'\n", pcTimeServers[ xServerIndex ] ) );
|
xHandler.pxOnUDPReceive = xOnUDPReceive;
|
||||||
FreeRTOS_gethostbyname_a( pcTimeServers[ xServerIndex ], vDNS_callback, (void *)NULL, 1200 );
|
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_UDP_RECV_HANDLER, ( void * ) &xHandler, sizeof( xHandler ) );
|
||||||
}
|
}
|
||||||
else
|
#endif
|
||||||
{
|
#if ( ipconfigSOCKET_HAS_USER_SEMAPHORE != 0 )
|
||||||
xStatus = EStatusAsking;
|
{
|
||||||
}
|
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_SET_SEMAPHORE, ( void * ) &xNTPWakeupSem, sizeof( xNTPWakeupSem ) );
|
||||||
break;
|
}
|
||||||
|
#endif
|
||||||
case EStatusAsking:
|
|
||||||
{
|
for( ; ; )
|
||||||
char pcBuf[16];
|
{
|
||||||
|
switch( xStatus )
|
||||||
prvNTPPacketInit( );
|
{
|
||||||
|
case EStatusLookup:
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
|
||||||
{
|
if( ( ulIPAddressFound == 0ul ) || ( ulIPAddressFound == ~0ul ) )
|
||||||
xAddress.sin_address.ulIP_IPv4 = ulIPAddressFound;
|
{
|
||||||
xAddress.sin_port = FreeRTOS_htons( NTP_PORT );
|
if( ++xServerIndex == sizeof( pcTimeServers ) / sizeof( pcTimeServers[ 0 ] ) )
|
||||||
FreeRTOS_inet_ntoa( xAddress.sin_address.ulIP_IPv4, pcBuf );
|
{
|
||||||
}
|
xServerIndex = 0;
|
||||||
#else
|
}
|
||||||
{
|
|
||||||
xAddress.sin_addr = ulIPAddressFound;
|
FreeRTOS_printf( ( "Looking up server '%s'\n", pcTimeServers[ xServerIndex ] ) );
|
||||||
xAddress.sin_port = FreeRTOS_htons( NTP_PORT );
|
FreeRTOS_gethostbyname_a( pcTimeServers[ xServerIndex ], vDNS_callback, ( void * ) NULL, 1200 );
|
||||||
FreeRTOS_inet_ntoa( xAddress.sin_addr, pcBuf );
|
}
|
||||||
}
|
else
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
{
|
||||||
|
xStatus = EStatusAsking;
|
||||||
xAddress.sin_family = FREERTOS_AF_INET;
|
}
|
||||||
|
|
||||||
FreeRTOS_printf( ( "Sending UDP message to %s:%u\n",
|
break;
|
||||||
pcBuf,
|
|
||||||
FreeRTOS_ntohs( xAddress.sin_port ) ) );
|
case EStatusAsking:
|
||||||
|
{
|
||||||
uxSendTime = xTaskGetTickCount( );
|
char pcBuf[ 16 ];
|
||||||
FreeRTOS_sendto( xUDPSocket, ( void * )&xNTPPacket, sizeof( xNTPPacket ), 0, &xAddress, sizeof( xAddress ) );
|
|
||||||
}
|
prvNTPPacketInit();
|
||||||
break;
|
|
||||||
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
case EStatusPause:
|
{
|
||||||
break;
|
xAddress.sin_address.ulIP_IPv4 = ulIPAddressFound;
|
||||||
|
xAddress.sin_port = FreeRTOS_htons( NTP_PORT );
|
||||||
case EStatusFailed:
|
FreeRTOS_inet_ntoa( xAddress.sin_address.ulIP_IPv4, pcBuf );
|
||||||
break;
|
}
|
||||||
}
|
#else
|
||||||
|
{
|
||||||
#if( ipconfigUSE_CALLBACKS != 0 )
|
xAddress.sin_addr = ulIPAddressFound;
|
||||||
{
|
xAddress.sin_port = FreeRTOS_htons( NTP_PORT );
|
||||||
xSemaphoreTake( xNTPWakeupSem, 5000 );
|
FreeRTOS_inet_ntoa( xAddress.sin_addr, pcBuf );
|
||||||
}
|
}
|
||||||
#else
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
{
|
|
||||||
uint32_t xAddressSize;
|
xAddress.sin_family = FREERTOS_AF_INET;
|
||||||
BaseType_t xReturned;
|
|
||||||
|
FreeRTOS_printf( ( "Sending UDP message to %s:%u\n",
|
||||||
xAddressSize = sizeof( xAddress );
|
pcBuf,
|
||||||
xReturned = FreeRTOS_recvfrom( xUDPSocket, ( void * ) cRecvBuffer, sizeof( cRecvBuffer ), 0, &xAddress, &xAddressSize );
|
FreeRTOS_ntohs( xAddress.sin_port ) ) );
|
||||||
switch( xReturned )
|
|
||||||
{
|
uxSendTime = xTaskGetTickCount();
|
||||||
case 0:
|
FreeRTOS_sendto( xUDPSocket, ( void * ) &xNTPPacket, sizeof( xNTPPacket ), 0, &xAddress, sizeof( xAddress ) );
|
||||||
case -pdFREERTOS_ERRNO_EAGAIN:
|
}
|
||||||
case -pdFREERTOS_ERRNO_EINTR:
|
break;
|
||||||
break;
|
|
||||||
default:
|
case EStatusPause:
|
||||||
if( xReturned < sizeof( xNTPPacket ) )
|
break;
|
||||||
{
|
|
||||||
FreeRTOS_printf( ( "FreeRTOS_recvfrom: returns %ld\n", xReturned ) );
|
case EStatusFailed:
|
||||||
}
|
break;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
prvReadTime( ( struct SNtpPacket *)cRecvBuffer );
|
#if ( ipconfigUSE_CALLBACKS != 0 )
|
||||||
if( xStatus != EStatusPause )
|
{
|
||||||
{
|
xSemaphoreTake( xNTPWakeupSem, 5000 );
|
||||||
xStatus = EStatusPause;
|
}
|
||||||
}
|
#else
|
||||||
}
|
{
|
||||||
break;
|
uint32_t xAddressSize;
|
||||||
}
|
BaseType_t xReturned;
|
||||||
}
|
|
||||||
#endif
|
xAddressSize = sizeof( xAddress );
|
||||||
}
|
xReturned = FreeRTOS_recvfrom( xUDPSocket, ( void * ) cRecvBuffer, sizeof( cRecvBuffer ), 0, &xAddress, &xAddressSize );
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
switch( xReturned )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case -pdFREERTOS_ERRNO_EAGAIN:
|
||||||
|
case -pdFREERTOS_ERRNO_EINTR:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
if( xReturned < sizeof( xNTPPacket ) )
|
||||||
|
{
|
||||||
|
FreeRTOS_printf( ( "FreeRTOS_recvfrom: returns %ld\n", xReturned ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prvReadTime( ( struct SNtpPacket * ) cRecvBuffer );
|
||||||
|
|
||||||
|
if( xStatus != EStatusPause )
|
||||||
|
{
|
||||||
|
xStatus = EStatusPause;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* if ( ipconfigUSE_CALLBACKS != 0 ) */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
FreeRTOS 2020107.00 adds a new SNTPv4 client library, [FreeRTOS/coreSNTP](https://github.com/FreeRTOS/coreSNTP),
|
FreeRTOS 2020107.00 adds a new SNTPv4 client library, [FreeRTOS/coreSNTP](https://github.com/FreeRTOS/coreSNTP),
|
||||||
and an [accompanying demo](..\..\..\coreSNTP_Windows_Simulator) to showcase the setup of an SNTP client and system
|
and an [accompanying demo](..\..\..\coreSNTP_Windows_Simulator) to showcase the setup of an SNTP client and system
|
||||||
wall-clock time using the library. Refer to
|
wall-clock time using the library. Refer to
|
||||||
The protocols implemented in this directory are intended to be demo quality
|
The protocols implemented in this directory are intended to be demo quality
|
||||||
examples only. They are not intended for inclusion in production devices.
|
examples only. They are not intended for inclusion in production devices.
|
||||||
|
@ -1,133 +1,136 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS+TCP V2.0.1
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://aws.amazon.com/freertos
|
* https://www.FreeRTOS.org
|
||||||
* https://www.FreeRTOS.org
|
* https://github.com/FreeRTOS
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef __FTPCMD_H__
|
|
||||||
|
#ifndef __FTPCMD_H__
|
||||||
#define __FTPCMD_H__
|
|
||||||
|
#define __FTPCMD_H__
|
||||||
#define REPL_110 "110 Restart marker reply.\r\n"
|
|
||||||
#define REPL_120 "120 Try again in 2 minutes.\r\n"
|
#define REPL_110 "110 Restart marker reply.\r\n"
|
||||||
#define REPL_125 "125 Data connection already open; transfer starting.\r\n"
|
#define REPL_120 "120 Try again in 2 minutes.\r\n"
|
||||||
#define REPL_150 "150 File status okay; about to open data connection.\r\n"
|
#define REPL_125 "125 Data connection already open; transfer starting.\r\n"
|
||||||
#define REPL_200 "200 NOOP command successful.\r\n"
|
#define REPL_150 "150 File status okay; about to open data connection.\r\n"
|
||||||
#define REPL_200_PROGRESS "200 NOOP: data transfer in progress.\r\n"
|
#define REPL_200 "200 NOOP command successful.\r\n"
|
||||||
#define REPL_202 "202 Command not implemented, superfluous at this site.\r\n"
|
#define REPL_200_PROGRESS "200 NOOP: data transfer in progress.\r\n"
|
||||||
#define REPL_211 "221 System status, or system help reply.\r\n"
|
#define REPL_202 "202 Command not implemented, superfluous at this site.\r\n"
|
||||||
#define REPL_211_STATUS "221-status of %s.\r\n"
|
#define REPL_211 "221 System status, or system help reply.\r\n"
|
||||||
#define REPL_211_END "221 End of status.\r\n"
|
#define REPL_211_STATUS "221-status of %s.\r\n"
|
||||||
#define REPL_212 "212 Directory status.\r\n"
|
#define REPL_211_END "221 End of status.\r\n"
|
||||||
#define REPL_213 "213 File status.\r\n"
|
#define REPL_212 "212 Directory status.\r\n"
|
||||||
#define REPL_214 "214 Help message.\r\n"
|
#define REPL_213 "213 File status.\r\n"
|
||||||
#define REPL_214_END "214 End Help message.\r\n"
|
#define REPL_214 "214 Help message.\r\n"
|
||||||
#define REPL_215 "215 %s system type.\r\n"
|
#define REPL_214_END "214 End Help message.\r\n"
|
||||||
#define REPL_220 "220 Service ready for new user.\r\n"
|
#define REPL_215 "215 %s system type.\r\n"
|
||||||
#define REPL_221 "221 Service closing control connection.\r\n"
|
#define REPL_220 "220 Service ready for new user.\r\n"
|
||||||
#define REPL_225 "225 Data connection open; no transfer in progress.\r\n"
|
#define REPL_221 "221 Service closing control connection.\r\n"
|
||||||
#define REPL_226 "226 Closing data connection.\r\n"
|
#define REPL_225 "225 Data connection open; no transfer in progress.\r\n"
|
||||||
#define REPL_227 "227 Entering Passive Mode (%s,%s,%s,%s,%s,%s).\r\n"
|
#define REPL_226 "226 Closing data connection.\r\n"
|
||||||
#define REPL_227_D "227 Entering Passive Mode (%u,%u,%u,%u,%u,%u).\r\n"
|
#define REPL_227 "227 Entering Passive Mode (%s,%s,%s,%s,%s,%s).\r\n"
|
||||||
#define REPL_230 "230 User logged in, proceed.\r\n"
|
#define REPL_227_D "227 Entering Passive Mode (%u,%u,%u,%u,%u,%u).\r\n"
|
||||||
#define REPL_250 "250 Requested file action okay, completed.\r\n"
|
#define REPL_230 "230 User logged in, proceed.\r\n"
|
||||||
#define REPL_257 "257 %s created.\r\n"
|
#define REPL_250 "250 Requested file action okay, completed.\r\n"
|
||||||
// #define REPL_257_PWD "257 \"%s\" is current working dir.\r\n"
|
#define REPL_257 "257 %s created.\r\n"
|
||||||
#define REPL_257_PWD "257 \"%s\"\r\n"
|
/* #define REPL_257_PWD "257 \"%s\" is current working dir.\r\n" */
|
||||||
#define REPL_331 "331 Only anonymous user is accepted.\r\n"
|
#define REPL_257_PWD "257 \"%s\"\r\n"
|
||||||
#define REPL_331_ANON "331 Anonymous login okay\r\n"
|
#define REPL_331 "331 Only anonymous user is accepted.\r\n"
|
||||||
#define REPL_332 "332 Need account for login.\r\n"
|
#define REPL_331_ANON "331 Anonymous login okay\r\n"
|
||||||
#define REPL_350 "350 Requested file action pending further information.\r\n"
|
#define REPL_332 "332 Need account for login.\r\n"
|
||||||
#define REPL_421 "421 Service not available, closing control connection.\r\n"
|
#define REPL_350 "350 Requested file action pending further information.\r\n"
|
||||||
#define REPL_425 "425 Can't open data connection.\r\n"
|
#define REPL_421 "421 Service not available, closing control connection.\r\n"
|
||||||
#define REPL_426 "426 Connection closed; transfer aborted.\r\n"
|
#define REPL_425 "425 Can't open data connection.\r\n"
|
||||||
#define REPL_450 "450 Requested file action not taken.\r\n"
|
#define REPL_426 "426 Connection closed; transfer aborted.\r\n"
|
||||||
#define REPL_451 "451 Requested action aborted. Local error in processing.\r\n"
|
#define REPL_450 "450 Requested file action not taken.\r\n"
|
||||||
#define REPL_452 "452 Requested action not taken.\r\n"
|
#define REPL_451 "451 Requested action aborted. Local error in processing.\r\n"
|
||||||
#define REPL_500 "500 Syntax error, command unrecognized.\r\n"
|
#define REPL_452 "452 Requested action not taken.\r\n"
|
||||||
#define REPL_501 "501 Syntax error in parameters or arguments.\r\n"
|
#define REPL_500 "500 Syntax error, command unrecognized.\r\n"
|
||||||
#define REPL_502 "502 Command not implemented.\r\n"
|
#define REPL_501 "501 Syntax error in parameters or arguments.\r\n"
|
||||||
#define REPL_503 "503 Bad sequence of commands.\r\n"
|
#define REPL_502 "502 Command not implemented.\r\n"
|
||||||
#define REPL_504 "504 Command not implemented for that parameter.\r\n"
|
#define REPL_503 "503 Bad sequence of commands.\r\n"
|
||||||
#define REPL_530 "530 Not logged in.\r\n"
|
#define REPL_504 "504 Command not implemented for that parameter.\r\n"
|
||||||
#define REPL_532 "532 Need account for storing files.\r\n"
|
#define REPL_530 "530 Not logged in.\r\n"
|
||||||
#define REPL_550 "550 Requested action not taken.\r\n"
|
#define REPL_532 "532 Need account for storing files.\r\n"
|
||||||
#define REPL_551 "551 Requested action aborted. Page type unknown.\r\n"
|
#define REPL_550 "550 Requested action not taken.\r\n"
|
||||||
#define REPL_552 "552 Requested file action aborted.\r\n"
|
#define REPL_551 "551 Requested action aborted. Page type unknown.\r\n"
|
||||||
#define REPL_553 "553 Requested action not taken.\r\n"
|
#define REPL_552 "552 Requested file action aborted.\r\n"
|
||||||
#define REPL_553_READ_ONLY "553 Read-only file-system.\r\n"
|
#define REPL_553 "553 Requested action not taken.\r\n"
|
||||||
|
#define REPL_553_READ_ONLY "553 Read-only file-system.\r\n"
|
||||||
enum EFTPCommand {
|
|
||||||
ECMD_USER,
|
enum EFTPCommand
|
||||||
ECMD_PASS,
|
{
|
||||||
ECMD_ACCT,
|
ECMD_USER,
|
||||||
ECMD_CWD,
|
ECMD_PASS,
|
||||||
ECMD_CDUP,
|
ECMD_ACCT,
|
||||||
ECMD_SMNT,
|
ECMD_CWD,
|
||||||
ECMD_QUIT,
|
ECMD_CDUP,
|
||||||
ECMD_REIN,
|
ECMD_SMNT,
|
||||||
ECMD_PORT,
|
ECMD_QUIT,
|
||||||
ECMD_PASV,
|
ECMD_REIN,
|
||||||
ECMD_TYPE,
|
ECMD_PORT,
|
||||||
ECMD_STRU,
|
ECMD_PASV,
|
||||||
ECMD_MODE,
|
ECMD_TYPE,
|
||||||
ECMD_RETR,
|
ECMD_STRU,
|
||||||
ECMD_STOR,
|
ECMD_MODE,
|
||||||
ECMD_STOU,
|
ECMD_RETR,
|
||||||
ECMD_APPE,
|
ECMD_STOR,
|
||||||
ECMD_ALLO,
|
ECMD_STOU,
|
||||||
ECMD_REST,
|
ECMD_APPE,
|
||||||
ECMD_RNFR,
|
ECMD_ALLO,
|
||||||
ECMD_RNTO,
|
ECMD_REST,
|
||||||
ECMD_ABOR,
|
ECMD_RNFR,
|
||||||
ECMD_SIZE,
|
ECMD_RNTO,
|
||||||
ECMD_MDTM,
|
ECMD_ABOR,
|
||||||
ECMD_DELE,
|
ECMD_SIZE,
|
||||||
ECMD_RMD,
|
ECMD_MDTM,
|
||||||
ECMD_MKD,
|
ECMD_DELE,
|
||||||
ECMD_PWD,
|
ECMD_RMD,
|
||||||
ECMD_LIST,
|
ECMD_MKD,
|
||||||
ECMD_NLST,
|
ECMD_PWD,
|
||||||
ECMD_SITE,
|
ECMD_LIST,
|
||||||
ECMD_SYST,
|
ECMD_NLST,
|
||||||
ECMD_FEAT,
|
ECMD_SITE,
|
||||||
ECMD_STAT,
|
ECMD_SYST,
|
||||||
ECMD_HELP,
|
ECMD_FEAT,
|
||||||
ECMD_NOOP,
|
ECMD_STAT,
|
||||||
ECMD_EMPTY,
|
ECMD_HELP,
|
||||||
ECMD_CLOSE,
|
ECMD_NOOP,
|
||||||
ECMD_UNKNOWN,
|
ECMD_EMPTY,
|
||||||
};
|
ECMD_CLOSE,
|
||||||
|
ECMD_UNKNOWN,
|
||||||
typedef struct xFTP_COMMAND {
|
};
|
||||||
BaseType_t xCommandLength;
|
|
||||||
const char pcCommandName[7];
|
typedef struct xFTP_COMMAND
|
||||||
const unsigned char ucCommandType;
|
{
|
||||||
const unsigned char checkLogin;
|
BaseType_t xCommandLength;
|
||||||
const unsigned char checkNullArg;
|
const char pcCommandName[ 7 ];
|
||||||
} FTPCommand_t;
|
const unsigned char ucCommandType;
|
||||||
|
const unsigned char checkLogin;
|
||||||
#define FTP_CMD_COUNT (ECMD_UNKNOWN+1)
|
const unsigned char checkNullArg;
|
||||||
|
} FTPCommand_t;
|
||||||
extern const FTPCommand_t xFTPCommands[ FTP_CMD_COUNT ];
|
|
||||||
|
#define FTP_CMD_COUNT ( ECMD_UNKNOWN + 1 )
|
||||||
#endif // __FTPCMD_H__
|
|
||||||
|
extern const FTPCommand_t xFTPCommands[ FTP_CMD_COUNT ];
|
||||||
|
|
||||||
|
#endif // __FTPCMD_H__
|
||||||
|
@ -1,67 +1,68 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS+TCP V2.0.3
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://aws.amazon.com/freertos
|
* https://www.FreeRTOS.org
|
||||||
* https://www.FreeRTOS.org
|
* https://github.com/FreeRTOS
|
||||||
*/
|
*
|
||||||
#ifndef FREERTOS_HTTP_COMMANDS_H
|
*/
|
||||||
#define FREERTOS_HTTP_COMMANDS_H
|
#ifndef FREERTOS_HTTP_COMMANDS_H
|
||||||
|
#define FREERTOS_HTTP_COMMANDS_H
|
||||||
enum {
|
|
||||||
WEB_REPLY_OK = 200,
|
enum
|
||||||
WEB_NO_CONTENT = 204,
|
{
|
||||||
WEB_BAD_REQUEST = 400,
|
WEB_REPLY_OK = 200,
|
||||||
WEB_UNAUTHORIZED = 401,
|
WEB_NO_CONTENT = 204,
|
||||||
WEB_NOT_FOUND = 404,
|
WEB_BAD_REQUEST = 400,
|
||||||
WEB_GONE = 410,
|
WEB_UNAUTHORIZED = 401,
|
||||||
WEB_PRECONDITION_FAILED = 412,
|
WEB_NOT_FOUND = 404,
|
||||||
WEB_INTERNAL_SERVER_ERROR = 500,
|
WEB_GONE = 410,
|
||||||
};
|
WEB_PRECONDITION_FAILED = 412,
|
||||||
|
WEB_INTERNAL_SERVER_ERROR = 500,
|
||||||
enum EWebCommand {
|
};
|
||||||
ECMD_GET,
|
|
||||||
ECMD_HEAD,
|
enum EWebCommand
|
||||||
ECMD_POST,
|
{
|
||||||
ECMD_PUT,
|
ECMD_GET,
|
||||||
ECMD_DELETE,
|
ECMD_HEAD,
|
||||||
ECMD_TRACE,
|
ECMD_POST,
|
||||||
ECMD_OPTIONS,
|
ECMD_PUT,
|
||||||
ECMD_CONNECT,
|
ECMD_DELETE,
|
||||||
ECMD_PATCH,
|
ECMD_TRACE,
|
||||||
ECMD_UNK,
|
ECMD_OPTIONS,
|
||||||
};
|
ECMD_CONNECT,
|
||||||
|
ECMD_PATCH,
|
||||||
struct xWEB_COMMAND
|
ECMD_UNK,
|
||||||
{
|
};
|
||||||
BaseType_t xCommandLength;
|
|
||||||
const char *pcCommandName;
|
struct xWEB_COMMAND
|
||||||
const unsigned char ucCommandType;
|
{
|
||||||
};
|
BaseType_t xCommandLength;
|
||||||
|
const char * pcCommandName;
|
||||||
#define WEB_CMD_COUNT (ECMD_UNK+1)
|
const unsigned char ucCommandType;
|
||||||
|
};
|
||||||
extern const struct xWEB_COMMAND xWebCommands[WEB_CMD_COUNT];
|
|
||||||
|
#define WEB_CMD_COUNT ( ECMD_UNK + 1 )
|
||||||
extern const char *webCodename (int aCode);
|
|
||||||
|
extern const struct xWEB_COMMAND xWebCommands[ WEB_CMD_COUNT ];
|
||||||
#endif /* FREERTOS_HTTP_COMMANDS_H */
|
|
||||||
|
extern const char * webCodename( int aCode );
|
||||||
|
|
||||||
|
#endif /* FREERTOS_HTTP_COMMANDS_H */
|
||||||
|
@ -1,125 +1,141 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS+TCP V2.0.3
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://aws.amazon.com/freertos
|
* https://www.FreeRTOS.org
|
||||||
* https://www.FreeRTOS.org
|
* https://github.com/FreeRTOS
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
/*
|
|
||||||
Some code which is common to TCP servers like HTTP en FTP
|
/*
|
||||||
*/
|
* Some code which is common to TCP servers like HTTP en FTP
|
||||||
|
*/
|
||||||
#ifndef FREERTOS_TCP_SERVER_H
|
|
||||||
#define FREERTOS_TCP_SERVER_H
|
#ifndef FREERTOS_TCP_SERVER_H
|
||||||
|
#define FREERTOS_TCP_SERVER_H
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
#ifdef __cplusplus
|
||||||
#endif
|
extern "C" {
|
||||||
|
#endif
|
||||||
#ifndef FTP_SERVER_USES_RELATIVE_DIRECTORY
|
|
||||||
#define FTP_SERVER_USES_RELATIVE_DIRECTORY 0
|
#ifndef FTP_SERVER_USES_RELATIVE_DIRECTORY
|
||||||
#endif
|
#define FTP_SERVER_USES_RELATIVE_DIRECTORY 0
|
||||||
|
#endif
|
||||||
enum eSERVER_TYPE
|
|
||||||
{
|
enum eSERVER_TYPE
|
||||||
eSERVER_NONE,
|
{
|
||||||
eSERVER_HTTP,
|
eSERVER_NONE,
|
||||||
eSERVER_FTP,
|
eSERVER_HTTP,
|
||||||
};
|
eSERVER_FTP,
|
||||||
|
};
|
||||||
struct xFTP_CLIENT;
|
|
||||||
|
struct xFTP_CLIENT;
|
||||||
#if( ipconfigFTP_HAS_RECEIVED_HOOK != 0 )
|
|
||||||
extern void vApplicationFTPReceivedHook( const char *pcFileName, uint32_t ulSize, struct xFTP_CLIENT *pxFTPClient );
|
#if ( ipconfigFTP_HAS_RECEIVED_HOOK != 0 )
|
||||||
extern void vFTPReplyMessage( struct xFTP_CLIENT *pxFTPClient, const char *pcMessage );
|
extern void vApplicationFTPReceivedHook( const char * pcFileName,
|
||||||
#endif /* ipconfigFTP_HAS_RECEIVED_HOOK != 0 */
|
uint32_t ulSize,
|
||||||
|
struct xFTP_CLIENT * pxFTPClient );
|
||||||
#if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )
|
extern void vFTPReplyMessage( struct xFTP_CLIENT * pxFTPClient,
|
||||||
/*
|
const char * pcMessage );
|
||||||
* Function is called when a user name has been submitted.
|
#endif /* ipconfigFTP_HAS_RECEIVED_HOOK != 0 */
|
||||||
* The function may return a string such as: "331 Please enter your password"
|
|
||||||
* or return NULL to use the default reply.
|
#if ( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )
|
||||||
*/
|
|
||||||
extern const char *pcApplicationFTPUserHook( const char *pcUserName );
|
/*
|
||||||
#endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
|
* Function is called when a user name has been submitted.
|
||||||
|
* The function may return a string such as: "331 Please enter your password"
|
||||||
#if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )
|
* or return NULL to use the default reply.
|
||||||
/*
|
*/
|
||||||
* Function is called when a password was received.
|
extern const char * pcApplicationFTPUserHook( const char * pcUserName );
|
||||||
* Return positive value to allow the user
|
#endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
|
||||||
*/
|
|
||||||
extern BaseType_t xApplicationFTPPasswordHook( const char *pcUserName, const char *pcPassword );
|
#if ( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )
|
||||||
#endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
|
|
||||||
|
/*
|
||||||
#if( ipconfigFTP_HAS_USER_PROPERTIES_HOOK != 0 )
|
* Function is called when a password was received.
|
||||||
/*
|
* Return positive value to allow the user
|
||||||
* The FTP server is asking for user-specific properties
|
*/
|
||||||
*/
|
extern BaseType_t xApplicationFTPPasswordHook( const char * pcUserName,
|
||||||
typedef struct
|
const char * pcPassword );
|
||||||
{
|
#endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
|
||||||
uint16_t usPortNumber; /* For reference only. Host-endian. */
|
|
||||||
const char *pcRootDir;
|
#if ( ipconfigFTP_HAS_USER_PROPERTIES_HOOK != 0 )
|
||||||
BaseType_t xReadOnly;
|
|
||||||
}
|
/*
|
||||||
FTPUserProperties_t;
|
* The FTP server is asking for user-specific properties
|
||||||
extern void vApplicationFTPUserPropertiesHook( const char *pcUserName, FTPUserProperties_t *pxProperties );
|
*/
|
||||||
#endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
|
typedef struct
|
||||||
|
{
|
||||||
#if( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )
|
uint16_t usPortNumber; /* For reference only. Host-endian. */
|
||||||
/*
|
const char * pcRootDir;
|
||||||
* A GET request is received containing a special character,
|
BaseType_t xReadOnly;
|
||||||
* usually a question mark.
|
}
|
||||||
* const char *pcURLData; // A request, e.g. "/request?limit=75"
|
FTPUserProperties_t;
|
||||||
* char *pcBuffer; // Here the answer can be written
|
extern void vApplicationFTPUserPropertiesHook( const char * pcUserName,
|
||||||
* size_t uxBufferLength; // Size of the buffer
|
FTPUserProperties_t * pxProperties );
|
||||||
*
|
#endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
|
||||||
*/
|
|
||||||
extern size_t uxApplicationHTTPHandleRequestHook( const char *pcURLData, char *pcBuffer, size_t uxBufferLength );
|
#if ( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )
|
||||||
#endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */
|
|
||||||
|
/*
|
||||||
struct xSERVER_CONFIG
|
* A GET request is received containing a special character,
|
||||||
{
|
* usually a question mark.
|
||||||
enum eSERVER_TYPE eType; /* eSERVER_HTTP | eSERVER_FTP */
|
* const char *pcURLData; // A request, e.g. "/request?limit=75"
|
||||||
BaseType_t xPortNumber; /* e.g. 80, 8080, 21 */
|
* char *pcBuffer; // Here the answer can be written
|
||||||
BaseType_t xBackLog; /* e.g. 10, maximum number of connected TCP clients */
|
* size_t uxBufferLength; // Size of the buffer
|
||||||
const char * const pcRootDir; /* Treat this directory as the root directory */
|
*
|
||||||
};
|
*/
|
||||||
|
extern size_t uxApplicationHTTPHandleRequestHook( const char * pcURLData,
|
||||||
struct xTCP_SERVER;
|
char * pcBuffer,
|
||||||
typedef struct xTCP_SERVER TCPServer_t;
|
size_t uxBufferLength );
|
||||||
|
#endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */
|
||||||
TCPServer_t *FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG *pxConfigs, BaseType_t xCount );
|
|
||||||
void FreeRTOS_TCPServerWork( TCPServer_t *pxServer, TickType_t xBlockingTime );
|
struct xSERVER_CONFIG
|
||||||
|
{
|
||||||
#if( ipconfigSUPPORT_SIGNALS != 0 )
|
enum eSERVER_TYPE eType; /* eSERVER_HTTP | eSERVER_FTP */
|
||||||
/* FreeRTOS_TCPServerWork() calls select().
|
BaseType_t xPortNumber; /* e.g. 80, 8080, 21 */
|
||||||
The two functions below provide a possibility to interrupt
|
BaseType_t xBackLog; /* e.g. 10, maximum number of connected TCP clients */
|
||||||
the call to select(). After the interruption, resume
|
const char * const pcRootDir; /* Treat this directory as the root directory */
|
||||||
by calling FreeRTOS_TCPServerWork() again. */
|
};
|
||||||
BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t *pxServer );
|
|
||||||
BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t *pxServer, BaseType_t *pxHigherPriorityTaskWoken );
|
struct xTCP_SERVER;
|
||||||
#endif
|
typedef struct xTCP_SERVER TCPServer_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
TCPServer_t * FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG * pxConfigs,
|
||||||
} /* extern "C" */
|
BaseType_t xCount );
|
||||||
#endif
|
void FreeRTOS_TCPServerWork( TCPServer_t * pxServer,
|
||||||
|
TickType_t xBlockingTime );
|
||||||
#endif /* FREERTOS_TCP_SERVER_H */
|
|
||||||
|
#if ( ipconfigSUPPORT_SIGNALS != 0 )
|
||||||
|
|
||||||
|
/* FreeRTOS_TCPServerWork() calls select().
|
||||||
|
* The two functions below provide a possibility to interrupt
|
||||||
|
* the call to select(). After the interruption, resume
|
||||||
|
* by calling FreeRTOS_TCPServerWork() again. */
|
||||||
|
BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t * pxServer );
|
||||||
|
BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t * pxServer,
|
||||||
|
BaseType_t * pxHigherPriorityTaskWoken );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* FREERTOS_TCP_SERVER_H */
|
||||||
|
@ -1,185 +1,201 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS+TCP V2.0.3
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://aws.amazon.com/freertos
|
* https://www.FreeRTOS.org
|
||||||
* https://www.FreeRTOS.org
|
* https://github.com/FreeRTOS
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
/*
|
|
||||||
Some code which is common to TCP servers like HTTP and FTP
|
/*
|
||||||
*/
|
* Some code which is common to TCP servers like HTTP and FTP
|
||||||
|
*/
|
||||||
#ifndef FREERTOS_SERVER_PRIVATE_H
|
|
||||||
#define FREERTOS_SERVER_PRIVATE_H
|
#ifndef FREERTOS_SERVER_PRIVATE_H
|
||||||
|
#define FREERTOS_SERVER_PRIVATE_H
|
||||||
#define FREERTOS_NO_SOCKET NULL
|
|
||||||
|
#define FREERTOS_NO_SOCKET NULL
|
||||||
/* FreeRTOS+FAT */
|
|
||||||
#include "ff_stdio.h"
|
/* FreeRTOS+FAT */
|
||||||
|
#include "ff_stdio.h"
|
||||||
/* Each HTTP server has 1, at most 2 sockets */
|
|
||||||
#define HTTP_SOCKET_COUNT 2
|
/* Each HTTP server has 1, at most 2 sockets */
|
||||||
|
#define HTTP_SOCKET_COUNT 2
|
||||||
/*
|
|
||||||
* ipconfigTCP_COMMAND_BUFFER_SIZE sets the size of:
|
/*
|
||||||
* pcCommandBuffer': a buffer to receive and send TCP commands
|
* ipconfigTCP_COMMAND_BUFFER_SIZE sets the size of:
|
||||||
*
|
* pcCommandBuffer': a buffer to receive and send TCP commands
|
||||||
* ipconfigTCP_FILE_BUFFER_SIZE sets the size of:
|
*
|
||||||
* pcFileBuffer' : a buffer to access the file system: read or write data.
|
* ipconfigTCP_FILE_BUFFER_SIZE sets the size of:
|
||||||
*
|
* pcFileBuffer' : a buffer to access the file system: read or write data.
|
||||||
* The buffers are both used for FTP as well as HTTP.
|
*
|
||||||
*/
|
* The buffers are both used for FTP as well as HTTP.
|
||||||
|
*/
|
||||||
#ifndef ipconfigTCP_COMMAND_BUFFER_SIZE
|
|
||||||
#define ipconfigTCP_COMMAND_BUFFER_SIZE ( 2048 )
|
#ifndef ipconfigTCP_COMMAND_BUFFER_SIZE
|
||||||
#endif
|
#define ipconfigTCP_COMMAND_BUFFER_SIZE ( 2048 )
|
||||||
|
#endif
|
||||||
#ifndef ipconfigTCP_FILE_BUFFER_SIZE
|
|
||||||
#define ipconfigTCP_FILE_BUFFER_SIZE ( 2048 )
|
#ifndef ipconfigTCP_FILE_BUFFER_SIZE
|
||||||
#endif
|
#define ipconfigTCP_FILE_BUFFER_SIZE ( 2048 )
|
||||||
|
#endif
|
||||||
struct xTCP_CLIENT;
|
|
||||||
|
struct xTCP_CLIENT;
|
||||||
typedef BaseType_t ( * FTCPWorkFunction ) ( struct xTCP_CLIENT * /* pxClient */ );
|
|
||||||
typedef void ( * FTCPDeleteFunction ) ( struct xTCP_CLIENT * /* pxClient */ );
|
typedef BaseType_t ( * FTCPWorkFunction ) ( struct xTCP_CLIENT * /* pxClient */ );
|
||||||
|
typedef void ( * FTCPDeleteFunction ) ( struct xTCP_CLIENT * /* pxClient */ );
|
||||||
#define TCP_CLIENT_FIELDS \
|
|
||||||
enum eSERVER_TYPE eType; \
|
#define TCP_CLIENT_FIELDS \
|
||||||
struct xTCP_SERVER *pxParent; \
|
enum eSERVER_TYPE eType; \
|
||||||
Socket_t xSocket; \
|
struct xTCP_SERVER * pxParent; \
|
||||||
const char *pcRootDir; \
|
Socket_t xSocket; \
|
||||||
FTCPWorkFunction fWorkFunction; \
|
const char * pcRootDir; \
|
||||||
FTCPDeleteFunction fDeleteFunction; \
|
FTCPWorkFunction fWorkFunction; \
|
||||||
struct xTCP_CLIENT *pxNextClient
|
FTCPDeleteFunction fDeleteFunction; \
|
||||||
|
struct xTCP_CLIENT * pxNextClient
|
||||||
typedef struct xTCP_CLIENT
|
|
||||||
{
|
typedef struct xTCP_CLIENT
|
||||||
/* This define contains fields which must come first within each of the client structs */
|
{
|
||||||
TCP_CLIENT_FIELDS;
|
/* This define contains fields which must come first within each of the client structs */
|
||||||
/* --- Keep at the top --- */
|
TCP_CLIENT_FIELDS;
|
||||||
|
/* --- Keep at the top --- */
|
||||||
} TCPClient_t;
|
} TCPClient_t;
|
||||||
|
|
||||||
struct xHTTP_CLIENT
|
struct xHTTP_CLIENT
|
||||||
{
|
{
|
||||||
/* This define contains fields which must come first within each of the client structs */
|
/* This define contains fields which must come first within each of the client structs */
|
||||||
TCP_CLIENT_FIELDS;
|
TCP_CLIENT_FIELDS;
|
||||||
/* --- Keep at the top --- */
|
/* --- Keep at the top --- */
|
||||||
|
|
||||||
const char *pcUrlData;
|
const char * pcUrlData;
|
||||||
const char *pcRestData;
|
const char * pcRestData;
|
||||||
char pcCurrentFilename[ ffconfigMAX_FILENAME ];
|
char pcCurrentFilename[ ffconfigMAX_FILENAME ];
|
||||||
size_t uxBytesLeft;
|
size_t uxBytesLeft;
|
||||||
FF_FILE *pxFileHandle;
|
FF_FILE * pxFileHandle;
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
uint32_t
|
struct
|
||||||
bReplySent : 1;
|
{
|
||||||
};
|
uint32_t
|
||||||
uint32_t ulFlags;
|
bReplySent : 1;
|
||||||
} bits;
|
};
|
||||||
};
|
uint32_t ulFlags;
|
||||||
|
}
|
||||||
typedef struct xHTTP_CLIENT HTTPClient_t;
|
bits;
|
||||||
|
};
|
||||||
struct xFTP_CLIENT
|
|
||||||
{
|
typedef struct xHTTP_CLIENT HTTPClient_t;
|
||||||
/* This define contains fields which must come first within each of the client structs */
|
|
||||||
TCP_CLIENT_FIELDS;
|
struct xFTP_CLIENT
|
||||||
/* --- Keep at the top --- */
|
{
|
||||||
|
/* This define contains fields which must come first within each of the client structs */
|
||||||
uint32_t ulRestartOffset;
|
TCP_CLIENT_FIELDS;
|
||||||
uint32_t ulRecvBytes;
|
/* --- Keep at the top --- */
|
||||||
size_t uxBytesLeft; /* Bytes left to send */
|
|
||||||
uint32_t ulClientIP;
|
uint32_t ulRestartOffset;
|
||||||
TickType_t xStartTime;
|
uint32_t ulRecvBytes;
|
||||||
uint16_t usClientPort;
|
size_t uxBytesLeft; /* Bytes left to send */
|
||||||
Socket_t xTransferSocket;
|
uint32_t ulClientIP;
|
||||||
BaseType_t xTransType;
|
TickType_t xStartTime;
|
||||||
BaseType_t xDirCount;
|
uint16_t usClientPort;
|
||||||
FF_FindData_t xFindData;
|
Socket_t xTransferSocket;
|
||||||
FF_FILE *pxReadHandle;
|
BaseType_t xTransType;
|
||||||
FF_FILE *pxWriteHandle;
|
BaseType_t xDirCount;
|
||||||
char pcCurrentDir[ ffconfigMAX_FILENAME ];
|
FF_FindData_t xFindData;
|
||||||
char pcFileName[ ffconfigMAX_FILENAME ];
|
FF_FILE * pxReadHandle;
|
||||||
char pcConnectionAck[ 128 ];
|
FF_FILE * pxWriteHandle;
|
||||||
char pcClientAck[ 128 ];
|
char pcCurrentDir[ ffconfigMAX_FILENAME ];
|
||||||
union {
|
char pcFileName[ ffconfigMAX_FILENAME ];
|
||||||
struct {
|
char pcConnectionAck[ 128 ];
|
||||||
uint32_t
|
char pcClientAck[ 128 ];
|
||||||
bHelloSent : 1,
|
union
|
||||||
bLoggedIn : 1,
|
{
|
||||||
bStatusUser : 1,
|
struct
|
||||||
bInRename : 1,
|
{
|
||||||
bReadOnly : 1;
|
uint32_t
|
||||||
};
|
bHelloSent : 1,
|
||||||
uint32_t ulFTPFlags;
|
bLoggedIn : 1,
|
||||||
} bits;
|
bStatusUser : 1,
|
||||||
union {
|
bInRename : 1,
|
||||||
struct {
|
bReadOnly : 1;
|
||||||
uint32_t
|
};
|
||||||
bIsListen : 1, /* pdTRUE for passive data connections (using list()). */
|
uint32_t ulFTPFlags;
|
||||||
bDirHasEntry : 1, /* pdTRUE if ff_findfirst() was successful. */
|
}
|
||||||
bClientConnected : 1, /* pdTRUE after connect() or accept() has succeeded. */
|
bits;
|
||||||
bEmptyFile : 1, /* pdTRUE if a connection-without-data was received. */
|
union
|
||||||
bHadError : 1; /* pdTRUE if a transfer got aborted because of an error. */
|
{
|
||||||
};
|
struct
|
||||||
uint32_t ulConnFlags;
|
{
|
||||||
} bits1;
|
uint32_t
|
||||||
};
|
bIsListen : 1, /* pdTRUE for passive data connections (using list()). */
|
||||||
|
bDirHasEntry : 1, /* pdTRUE if ff_findfirst() was successful. */
|
||||||
typedef struct xFTP_CLIENT FTPClient_t;
|
bClientConnected : 1, /* pdTRUE after connect() or accept() has succeeded. */
|
||||||
|
bEmptyFile : 1, /* pdTRUE if a connection-without-data was received. */
|
||||||
BaseType_t xHTTPClientWork( TCPClient_t *pxClient );
|
bHadError : 1; /* pdTRUE if a transfer got aborted because of an error. */
|
||||||
BaseType_t xFTPClientWork( TCPClient_t *pxClient );
|
};
|
||||||
|
uint32_t ulConnFlags;
|
||||||
void vHTTPClientDelete( TCPClient_t *pxClient );
|
}
|
||||||
void vFTPClientDelete( TCPClient_t *pxClient );
|
bits1;
|
||||||
|
};
|
||||||
BaseType_t xMakeAbsolute( struct xFTP_CLIENT *pxClient, char *pcBuffer, BaseType_t xBufferLength, const char *pcFileName );
|
|
||||||
BaseType_t xMakeRelative( FTPClient_t *pxClient, char *pcBuffer, BaseType_t xBufferLength, const char *pcFileName );
|
typedef struct xFTP_CLIENT FTPClient_t;
|
||||||
|
|
||||||
struct xTCP_SERVER
|
BaseType_t xHTTPClientWork( TCPClient_t * pxClient );
|
||||||
{
|
BaseType_t xFTPClientWork( TCPClient_t * pxClient );
|
||||||
SocketSet_t xSocketSet;
|
|
||||||
/* A buffer to receive and send TCP commands, either HTTP of FTP. */
|
void vHTTPClientDelete( TCPClient_t * pxClient );
|
||||||
char pcCommandBuffer[ ipconfigTCP_COMMAND_BUFFER_SIZE ];
|
void vFTPClientDelete( TCPClient_t * pxClient );
|
||||||
/* A buffer to access the file system: read or write data. */
|
|
||||||
char pcFileBuffer[ ipconfigTCP_FILE_BUFFER_SIZE ];
|
BaseType_t xMakeAbsolute( struct xFTP_CLIENT * pxClient,
|
||||||
|
char * pcBuffer,
|
||||||
#if( ipconfigUSE_FTP != 0 )
|
BaseType_t xBufferLength,
|
||||||
char pcNewDir[ ffconfigMAX_FILENAME ];
|
const char * pcFileName );
|
||||||
#endif
|
BaseType_t xMakeRelative( FTPClient_t * pxClient,
|
||||||
#if( ipconfigUSE_HTTP != 0 )
|
char * pcBuffer,
|
||||||
char pcContentsType[40]; /* Space for the msg: "text/javascript" */
|
BaseType_t xBufferLength,
|
||||||
char pcExtraContents[40]; /* Space for the msg: "Content-Length: 346500" */
|
const char * pcFileName );
|
||||||
#endif
|
|
||||||
BaseType_t xServerCount;
|
struct xTCP_SERVER
|
||||||
TCPClient_t *pxClients;
|
{
|
||||||
struct xSERVER
|
SocketSet_t xSocketSet;
|
||||||
{
|
/* A buffer to receive and send TCP commands, either HTTP of FTP. */
|
||||||
enum eSERVER_TYPE eType; /* eSERVER_HTTP | eSERVER_FTP */
|
char pcCommandBuffer[ ipconfigTCP_COMMAND_BUFFER_SIZE ];
|
||||||
const char *pcRootDir;
|
/* A buffer to access the file system: read or write data. */
|
||||||
Socket_t xSocket;
|
char pcFileBuffer[ ipconfigTCP_FILE_BUFFER_SIZE ];
|
||||||
} xServers[ 1 ];
|
|
||||||
};
|
#if ( ipconfigUSE_FTP != 0 )
|
||||||
|
char pcNewDir[ ffconfigMAX_FILENAME ];
|
||||||
#endif /* FREERTOS_SERVER_PRIVATE_H */
|
#endif
|
||||||
|
#if ( ipconfigUSE_HTTP != 0 )
|
||||||
|
char pcContentsType[ 40 ]; /* Space for the msg: "text/javascript" */
|
||||||
|
char pcExtraContents[ 40 ]; /* Space for the msg: "Content-Length: 346500" */
|
||||||
|
#endif
|
||||||
|
BaseType_t xServerCount;
|
||||||
|
TCPClient_t * pxClients;
|
||||||
|
struct xSERVER
|
||||||
|
{
|
||||||
|
enum eSERVER_TYPE eType; /* eSERVER_HTTP | eSERVER_FTP */
|
||||||
|
const char * pcRootDir;
|
||||||
|
Socket_t xSocket;
|
||||||
|
}
|
||||||
|
xServers[ 1 ];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FREERTOS_SERVER_PRIVATE_H */
|
||||||
|
@ -1,71 +1,98 @@
|
|||||||
//
|
/*
|
||||||
// ntpClient.h
|
* FreeRTOS V202212.00
|
||||||
//
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
#ifndef __NTPCLIENT_H__
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
#define __NTPCLIENT_H__
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
#define NTP_PORT 123
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
typedef uint32_t quint32;
|
*
|
||||||
typedef int32_t qint32;
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
typedef uint8_t quint8;
|
* copies or substantial portions of the Software.
|
||||||
typedef int8_t qint8;
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
typedef union _SNtpFlags SNtpFlags;
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
/**
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* 64-bit NTP timestamp.
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
*/
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
struct __attribute__ ((__packed__)) _SNtpTimestamp {
|
*
|
||||||
/** Number of seconds passed since Jan 1 1900, in big-endian format. */
|
* https://www.FreeRTOS.org
|
||||||
quint32 seconds;
|
* https://github.com/FreeRTOS
|
||||||
|
*
|
||||||
/** Fractional time part, in <tt>1/0xFFFFFFFF</tt>s of a second. */
|
*/
|
||||||
quint32 fraction;
|
|
||||||
};
|
/* ntpClient.h */
|
||||||
|
|
||||||
typedef struct _SNtpTimestamp SNtpTimestamp;
|
#ifndef __NTPCLIENT_H__
|
||||||
/**
|
|
||||||
* Mandatory part of an NTP packet
|
#define __NTPCLIENT_H__
|
||||||
*/
|
|
||||||
struct SNtpPacket {
|
#define NTP_PORT 123
|
||||||
/** Flags. */
|
|
||||||
unsigned char flags; // value 0xDB : mode 3 (client), version 3, leap indicator unknown 3
|
typedef uint32_t quint32;
|
||||||
|
typedef int32_t qint32;
|
||||||
/** Stratum of the clock. */
|
typedef uint8_t quint8;
|
||||||
quint8 stratum; // value 0 : unspecified
|
typedef int8_t qint8;
|
||||||
|
|
||||||
/** Maximum interval between successive messages, in log2 seconds. Note that the value is signed. */
|
typedef union _SNtpFlags SNtpFlags;
|
||||||
qint8 poll; // 10 means 1 << 10 = 1024 seconds
|
|
||||||
|
/**
|
||||||
/** Precision of the clock, in log2 seconds. Note that the value is signed. */
|
* 64-bit NTP timestamp.
|
||||||
qint8 precision; // 0xFA = 250 = 0.015625 seconds
|
*/
|
||||||
|
struct __attribute__( ( __packed__ ) ) _SNtpTimestamp
|
||||||
/** Round trip time to the primary reference source, in NTP short format. */
|
{
|
||||||
qint32 rootDelay; // 0x5D2E = 23854 or (23854/65535)= 0.3640 sec
|
/** Number of seconds passed since Jan 1 1900, in big-endian format. */
|
||||||
|
quint32 seconds;
|
||||||
/** Nominal error relative to the primary reference source. */
|
|
||||||
qint32 rootDispersion; // 0x0008 CAC8 = 8.7912 seconds
|
/** Fractional time part, in <tt>1/0xFFFFFFFF</tt>s of a second. */
|
||||||
|
quint32 fraction;
|
||||||
/** Reference identifier (either a 4 character string or an IP address). */
|
};
|
||||||
qint8 referenceID[4]; // or just 0000
|
|
||||||
|
typedef struct _SNtpTimestamp SNtpTimestamp;
|
||||||
/** The time at which the clock was last set or corrected. */
|
|
||||||
SNtpTimestamp referenceTimestamp; // Current time
|
/**
|
||||||
|
* Mandatory part of an NTP packet
|
||||||
/** The time at which the request departed the client for the server. */
|
*/
|
||||||
SNtpTimestamp originateTimestamp; // Keep 0
|
struct SNtpPacket
|
||||||
|
{
|
||||||
/** The time at which the request arrived at the server. */
|
/** Flags. */
|
||||||
SNtpTimestamp receiveTimestamp; // Keep 0
|
unsigned char flags; /* value 0xDB : mode 3 (client), version 3, leap indicator unknown 3 */
|
||||||
|
|
||||||
/** The time at which the reply departed the server for client. */
|
/** Stratum of the clock. */
|
||||||
SNtpTimestamp transmitTimestamp;
|
quint8 stratum; /* value 0 : unspecified */
|
||||||
};
|
|
||||||
|
/** Maximum interval between successive messages, in log2 seconds. Note that the value is signed. */
|
||||||
/* Add this number to get secs since 1-1-1900 */
|
qint8 poll; /* 10 means 1 << 10 = 1024 seconds */
|
||||||
#define TIME1970 2208988800UL
|
|
||||||
|
/** Precision of the clock, in log2 seconds. Note that the value is signed. */
|
||||||
#endif // __NTPCLIENT_H__
|
qint8 precision; /* 0xFA = 250 = 0.015625 seconds */
|
||||||
|
|
||||||
|
/** Round trip time to the primary reference source, in NTP short format. */
|
||||||
|
qint32 rootDelay; /* 0x5D2E = 23854 or (23854/65535)= 0.3640 sec */
|
||||||
|
|
||||||
|
/** Nominal error relative to the primary reference source. */
|
||||||
|
qint32 rootDispersion; /* 0x0008 CAC8 = 8.7912 seconds */
|
||||||
|
|
||||||
|
/** Reference identifier (either a 4 character string or an IP address). */
|
||||||
|
qint8 referenceID[ 4 ]; /* or just 0000 */
|
||||||
|
|
||||||
|
/** The time at which the clock was last set or corrected. */
|
||||||
|
SNtpTimestamp referenceTimestamp; /* Current time */
|
||||||
|
|
||||||
|
/** The time at which the request departed the client for the server. */
|
||||||
|
SNtpTimestamp originateTimestamp; /* Keep 0 */
|
||||||
|
|
||||||
|
/** The time at which the request arrived at the server. */
|
||||||
|
SNtpTimestamp receiveTimestamp; /* Keep 0 */
|
||||||
|
|
||||||
|
/** The time at which the reply departed the server for client. */
|
||||||
|
SNtpTimestamp transmitTimestamp;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Add this number to get secs since 1-1-1900 */
|
||||||
|
#define TIME1970 2208988800UL
|
||||||
|
|
||||||
|
#endif // __NTPCLIENT_H__
|
||||||
|
@ -1,11 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* A simple demo for NTP using FreeRTOS+TCP
|
* FreeRTOS V202212.00
|
||||||
*/
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
#ifndef NTPDEMO_H
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
#define NTPDEMO_H
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
void vStartNTPTask( uint16_t usTaskStackSize, UBaseType_t uxTaskPriority );
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
#endif
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* https://www.FreeRTOS.org
|
||||||
|
* https://github.com/FreeRTOS
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NTPDEMO_H
|
||||||
|
|
||||||
|
#define NTPDEMO_H
|
||||||
|
|
||||||
|
void vStartNTPTask( uint16_t usTaskStackSize,
|
||||||
|
UBaseType_t uxTaskPriority );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,479 +1,507 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://aws.amazon.com/freertos
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org/cli
|
* https://www.FreeRTOS.org/cli
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* FreeRTOS includes. */
|
/* FreeRTOS includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
/* Standard includes. */
|
/* Standard includes. */
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* FreeRTOS+CLI includes. */
|
/* FreeRTOS+CLI includes. */
|
||||||
#include "FreeRTOS_CLI.h"
|
#include "FreeRTOS_CLI.h"
|
||||||
|
|
||||||
#ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS
|
#ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS
|
||||||
#define configINCLUDE_TRACE_RELATED_CLI_COMMANDS 0
|
#define configINCLUDE_TRACE_RELATED_CLI_COMMANDS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef configINCLUDE_QUERY_HEAP_COMMAND
|
#ifndef configINCLUDE_QUERY_HEAP_COMMAND
|
||||||
#define configINCLUDE_QUERY_HEAP_COMMAND 0
|
#define configINCLUDE_QUERY_HEAP_COMMAND 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The function that registers the commands that are defined within this file.
|
* The function that registers the commands that are defined within this file.
|
||||||
*/
|
*/
|
||||||
void vRegisterSampleCLICommands( void );
|
void vRegisterSampleCLICommands( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implements the task-stats command.
|
* Implements the task-stats command.
|
||||||
*/
|
*/
|
||||||
static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
static BaseType_t prvTaskStatsCommand( char * pcWriteBuffer,
|
||||||
|
size_t xWriteBufferLen,
|
||||||
/*
|
const char * pcCommandString );
|
||||||
* Implements the run-time-stats command.
|
|
||||||
*/
|
/*
|
||||||
#if( configGENERATE_RUN_TIME_STATS == 1 )
|
* Implements the run-time-stats command.
|
||||||
static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
*/
|
||||||
#endif /* configGENERATE_RUN_TIME_STATS */
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
|
static BaseType_t prvRunTimeStatsCommand( char * pcWriteBuffer,
|
||||||
/*
|
size_t xWriteBufferLen,
|
||||||
* Implements the echo-three-parameters command.
|
const char * pcCommandString );
|
||||||
*/
|
#endif /* configGENERATE_RUN_TIME_STATS */
|
||||||
static BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
|
||||||
|
/*
|
||||||
/*
|
* Implements the echo-three-parameters command.
|
||||||
* Implements the echo-parameters command.
|
*/
|
||||||
*/
|
static BaseType_t prvThreeParameterEchoCommand( char * pcWriteBuffer,
|
||||||
static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
size_t xWriteBufferLen,
|
||||||
|
const char * pcCommandString );
|
||||||
/*
|
|
||||||
* Implements the "query heap" command.
|
/*
|
||||||
*/
|
* Implements the echo-parameters command.
|
||||||
#if( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
*/
|
||||||
static BaseType_t prvQueryHeapCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
static BaseType_t prvParameterEchoCommand( char * pcWriteBuffer,
|
||||||
#endif
|
size_t xWriteBufferLen,
|
||||||
|
const char * pcCommandString );
|
||||||
/*
|
|
||||||
* Implements the "trace start" and "trace stop" commands;
|
/*
|
||||||
*/
|
* Implements the "query heap" command.
|
||||||
#if( configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 )
|
*/
|
||||||
static BaseType_t prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
#if ( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
||||||
#endif
|
static BaseType_t prvQueryHeapCommand( char * pcWriteBuffer,
|
||||||
|
size_t xWriteBufferLen,
|
||||||
/* Structure that defines the "task-stats" command line command. This generates
|
const char * pcCommandString );
|
||||||
a table that gives information on each task in the system. */
|
#endif
|
||||||
static const CLI_Command_Definition_t xTaskStats =
|
|
||||||
{
|
/*
|
||||||
"task-stats", /* The command string to type. */
|
* Implements the "trace start" and "trace stop" commands;
|
||||||
"\r\ntask-stats:\r\n Displays a table showing the state of each FreeRTOS task\r\n",
|
*/
|
||||||
prvTaskStatsCommand, /* The function to run. */
|
#if ( configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 )
|
||||||
0 /* No parameters are expected. */
|
static BaseType_t prvStartStopTraceCommand( char * pcWriteBuffer,
|
||||||
};
|
size_t xWriteBufferLen,
|
||||||
|
const char * pcCommandString );
|
||||||
/* Structure that defines the "echo_3_parameters" command line command. This
|
#endif
|
||||||
takes exactly three parameters that the command simply echos back one at a
|
|
||||||
time. */
|
/* Structure that defines the "task-stats" command line command. This generates
|
||||||
static const CLI_Command_Definition_t xThreeParameterEcho =
|
* a table that gives information on each task in the system. */
|
||||||
{
|
static const CLI_Command_Definition_t xTaskStats =
|
||||||
"echo-3-parameters",
|
{
|
||||||
"\r\necho-3-parameters <param1> <param2> <param3>:\r\n Expects three parameters, echos each in turn\r\n",
|
"task-stats", /* The command string to type. */
|
||||||
prvThreeParameterEchoCommand, /* The function to run. */
|
"\r\ntask-stats:\r\n Displays a table showing the state of each FreeRTOS task\r\n",
|
||||||
3 /* Three parameters are expected, which can take any value. */
|
prvTaskStatsCommand, /* The function to run. */
|
||||||
};
|
0 /* No parameters are expected. */
|
||||||
|
};
|
||||||
/* Structure that defines the "echo_parameters" command line command. This
|
|
||||||
takes a variable number of parameters that the command simply echos back one at
|
/* Structure that defines the "echo_3_parameters" command line command. This
|
||||||
a time. */
|
* takes exactly three parameters that the command simply echos back one at a
|
||||||
static const CLI_Command_Definition_t xParameterEcho =
|
* time. */
|
||||||
{
|
static const CLI_Command_Definition_t xThreeParameterEcho =
|
||||||
"echo-parameters",
|
{
|
||||||
"\r\necho-parameters <...>:\r\n Take variable number of parameters, echos each in turn\r\n",
|
"echo-3-parameters",
|
||||||
prvParameterEchoCommand, /* The function to run. */
|
"\r\necho-3-parameters <param1> <param2> <param3>:\r\n Expects three parameters, echos each in turn\r\n",
|
||||||
-1 /* The user can enter any number of commands. */
|
prvThreeParameterEchoCommand, /* The function to run. */
|
||||||
};
|
3 /* Three parameters are expected, which can take any value. */
|
||||||
|
};
|
||||||
#if( configGENERATE_RUN_TIME_STATS == 1 )
|
|
||||||
/* Structure that defines the "run-time-stats" command line command. This
|
/* Structure that defines the "echo_parameters" command line command. This
|
||||||
generates a table that shows how much run time each task has */
|
* takes a variable number of parameters that the command simply echos back one at
|
||||||
static const CLI_Command_Definition_t xRunTimeStats =
|
* a time. */
|
||||||
{
|
static const CLI_Command_Definition_t xParameterEcho =
|
||||||
"run-time-stats", /* The command string to type. */
|
{
|
||||||
"\r\nrun-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n",
|
"echo-parameters",
|
||||||
prvRunTimeStatsCommand, /* The function to run. */
|
"\r\necho-parameters <...>:\r\n Take variable number of parameters, echos each in turn\r\n",
|
||||||
0 /* No parameters are expected. */
|
prvParameterEchoCommand, /* The function to run. */
|
||||||
};
|
-1 /* The user can enter any number of commands. */
|
||||||
#endif /* configGENERATE_RUN_TIME_STATS */
|
};
|
||||||
|
|
||||||
#if( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
/* Structure that defines the "query_heap" command line command. */
|
|
||||||
static const CLI_Command_Definition_t xQueryHeap =
|
/* Structure that defines the "run-time-stats" command line command. This
|
||||||
{
|
* generates a table that shows how much run time each task has */
|
||||||
"query-heap",
|
static const CLI_Command_Definition_t xRunTimeStats =
|
||||||
"\r\nquery-heap:\r\n Displays the free heap space, and minimum ever free heap space.\r\n",
|
{
|
||||||
prvQueryHeapCommand, /* The function to run. */
|
"run-time-stats", /* The command string to type. */
|
||||||
0 /* The user can enter any number of commands. */
|
"\r\nrun-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n",
|
||||||
};
|
prvRunTimeStatsCommand, /* The function to run. */
|
||||||
#endif /* configQUERY_HEAP_COMMAND */
|
0 /* No parameters are expected. */
|
||||||
|
};
|
||||||
#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
|
#endif /* configGENERATE_RUN_TIME_STATS */
|
||||||
/* Structure that defines the "trace" command line command. This takes a single
|
|
||||||
parameter, which can be either "start" or "stop". */
|
#if ( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
||||||
static const CLI_Command_Definition_t xStartStopTrace =
|
/* Structure that defines the "query_heap" command line command. */
|
||||||
{
|
static const CLI_Command_Definition_t xQueryHeap =
|
||||||
"trace",
|
{
|
||||||
"\r\ntrace [start | stop]:\r\n Starts or stops a trace recording for viewing in FreeRTOS+Trace\r\n",
|
"query-heap",
|
||||||
prvStartStopTraceCommand, /* The function to run. */
|
"\r\nquery-heap:\r\n Displays the free heap space, and minimum ever free heap space.\r\n",
|
||||||
1 /* One parameter is expected. Valid values are "start" and "stop". */
|
prvQueryHeapCommand, /* The function to run. */
|
||||||
};
|
0 /* The user can enter any number of commands. */
|
||||||
#endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
|
};
|
||||||
|
#endif /* configQUERY_HEAP_COMMAND */
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
|
||||||
void vRegisterSampleCLICommands( void )
|
|
||||||
{
|
/* Structure that defines the "trace" command line command. This takes a single
|
||||||
/* Register all the command line commands defined immediately above. */
|
* parameter, which can be either "start" or "stop". */
|
||||||
FreeRTOS_CLIRegisterCommand( &xTaskStats );
|
static const CLI_Command_Definition_t xStartStopTrace =
|
||||||
FreeRTOS_CLIRegisterCommand( &xThreeParameterEcho );
|
{
|
||||||
FreeRTOS_CLIRegisterCommand( &xParameterEcho );
|
"trace",
|
||||||
|
"\r\ntrace [start | stop]:\r\n Starts or stops a trace recording for viewing in FreeRTOS+Trace\r\n",
|
||||||
#if( configGENERATE_RUN_TIME_STATS == 1 )
|
prvStartStopTraceCommand, /* The function to run. */
|
||||||
{
|
1 /* One parameter is expected. Valid values are "start" and "stop". */
|
||||||
FreeRTOS_CLIRegisterCommand( &xRunTimeStats );
|
};
|
||||||
}
|
#endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
|
||||||
#endif
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
#if( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
|
||||||
{
|
void vRegisterSampleCLICommands( void )
|
||||||
FreeRTOS_CLIRegisterCommand( &xQueryHeap );
|
{
|
||||||
}
|
/* Register all the command line commands defined immediately above. */
|
||||||
#endif
|
FreeRTOS_CLIRegisterCommand( &xTaskStats );
|
||||||
|
FreeRTOS_CLIRegisterCommand( &xThreeParameterEcho );
|
||||||
#if( configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 )
|
FreeRTOS_CLIRegisterCommand( &xParameterEcho );
|
||||||
{
|
|
||||||
FreeRTOS_CLIRegisterCommand( &xStartStopTrace );
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
}
|
{
|
||||||
#endif
|
FreeRTOS_CLIRegisterCommand( &xRunTimeStats );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
#endif
|
||||||
|
|
||||||
static BaseType_t prvTaskStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
#if ( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
||||||
{
|
{
|
||||||
const char *const pcHeader = " State Priority Stack #\r\n************************************************\r\n";
|
FreeRTOS_CLIRegisterCommand( &xQueryHeap );
|
||||||
BaseType_t xSpacePadding;
|
}
|
||||||
|
#endif
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
#if ( configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 )
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
{
|
||||||
( void ) pcCommandString;
|
FreeRTOS_CLIRegisterCommand( &xStartStopTrace );
|
||||||
( void ) xWriteBufferLen;
|
}
|
||||||
configASSERT( pcWriteBuffer );
|
#endif
|
||||||
|
}
|
||||||
/* Generate a table of task stats. */
|
/*-----------------------------------------------------------*/
|
||||||
strcpy( pcWriteBuffer, "Task" );
|
|
||||||
pcWriteBuffer += strlen( pcWriteBuffer );
|
static BaseType_t prvTaskStatsCommand( char * pcWriteBuffer,
|
||||||
|
size_t xWriteBufferLen,
|
||||||
/* Minus three for the null terminator and half the number of characters in
|
const char * pcCommandString )
|
||||||
"Task" so the column lines up with the centre of the heading. */
|
{
|
||||||
configASSERT( configMAX_TASK_NAME_LEN > 3 );
|
const char * const pcHeader = " State Priority Stack #\r\n************************************************\r\n";
|
||||||
for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ )
|
BaseType_t xSpacePadding;
|
||||||
{
|
|
||||||
/* Add a space to align columns after the task's name. */
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
*pcWriteBuffer = ' ';
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
pcWriteBuffer++;
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
|
( void ) pcCommandString;
|
||||||
/* Ensure always terminated. */
|
( void ) xWriteBufferLen;
|
||||||
*pcWriteBuffer = 0x00;
|
configASSERT( pcWriteBuffer );
|
||||||
}
|
|
||||||
strcpy( pcWriteBuffer, pcHeader );
|
/* Generate a table of task stats. */
|
||||||
vTaskList( pcWriteBuffer + strlen( pcHeader ) );
|
strcpy( pcWriteBuffer, "Task" );
|
||||||
|
pcWriteBuffer += strlen( pcWriteBuffer );
|
||||||
/* There is no more data to return after this single string, so return
|
|
||||||
pdFALSE. */
|
/* Minus three for the null terminator and half the number of characters in
|
||||||
return pdFALSE;
|
* "Task" so the column lines up with the centre of the heading. */
|
||||||
}
|
configASSERT( configMAX_TASK_NAME_LEN > 3 );
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ )
|
||||||
#if( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
{
|
||||||
|
/* Add a space to align columns after the task's name. */
|
||||||
static BaseType_t prvQueryHeapCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
*pcWriteBuffer = ' ';
|
||||||
{
|
pcWriteBuffer++;
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
/* Ensure always terminated. */
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
*pcWriteBuffer = 0x00;
|
||||||
( void ) pcCommandString;
|
}
|
||||||
( void ) xWriteBufferLen;
|
|
||||||
configASSERT( pcWriteBuffer );
|
strcpy( pcWriteBuffer, pcHeader );
|
||||||
|
vTaskList( pcWriteBuffer + strlen( pcHeader ) );
|
||||||
sprintf( pcWriteBuffer, "Current free heap %d bytes, minimum ever free heap %d bytes\r\n", ( int ) xPortGetFreeHeapSize(), ( int ) xPortGetMinimumEverFreeHeapSize() );
|
|
||||||
|
/* There is no more data to return after this single string, so return
|
||||||
/* There is no more data to return after this single string, so return
|
* pdFALSE. */
|
||||||
pdFALSE. */
|
return pdFALSE;
|
||||||
return pdFALSE;
|
}
|
||||||
}
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#endif /* configINCLUDE_QUERY_HEAP */
|
#if ( configINCLUDE_QUERY_HEAP_COMMAND == 1 )
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
static BaseType_t prvQueryHeapCommand( char * pcWriteBuffer,
|
||||||
#if( configGENERATE_RUN_TIME_STATS == 1 )
|
size_t xWriteBufferLen,
|
||||||
|
const char * pcCommandString )
|
||||||
static BaseType_t prvRunTimeStatsCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
{
|
||||||
{
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
const char * const pcHeader = " Abs Time % Time\r\n****************************************\r\n";
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
BaseType_t xSpacePadding;
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
|
( void ) pcCommandString;
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
( void ) xWriteBufferLen;
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
configASSERT( pcWriteBuffer );
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
|
||||||
( void ) pcCommandString;
|
sprintf( pcWriteBuffer, "Current free heap %d bytes, minimum ever free heap %d bytes\r\n", ( int ) xPortGetFreeHeapSize(), ( int ) xPortGetMinimumEverFreeHeapSize() );
|
||||||
( void ) xWriteBufferLen;
|
|
||||||
configASSERT( pcWriteBuffer );
|
/* There is no more data to return after this single string, so return
|
||||||
|
* pdFALSE. */
|
||||||
/* Generate a table of task stats. */
|
return pdFALSE;
|
||||||
strcpy( pcWriteBuffer, "Task" );
|
}
|
||||||
pcWriteBuffer += strlen( pcWriteBuffer );
|
|
||||||
|
#endif /* configINCLUDE_QUERY_HEAP */
|
||||||
/* Pad the string "task" with however many bytes necessary to make it the
|
/*-----------------------------------------------------------*/
|
||||||
length of a task name. Minus three for the null terminator and half the
|
|
||||||
number of characters in "Task" so the column lines up with the centre of
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
the heading. */
|
|
||||||
for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ )
|
static BaseType_t prvRunTimeStatsCommand( char * pcWriteBuffer,
|
||||||
{
|
size_t xWriteBufferLen,
|
||||||
/* Add a space to align columns after the task's name. */
|
const char * pcCommandString )
|
||||||
*pcWriteBuffer = ' ';
|
{
|
||||||
pcWriteBuffer++;
|
const char * const pcHeader = " Abs Time % Time\r\n****************************************\r\n";
|
||||||
|
BaseType_t xSpacePadding;
|
||||||
/* Ensure always terminated. */
|
|
||||||
*pcWriteBuffer = 0x00;
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
}
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
strcpy( pcWriteBuffer, pcHeader );
|
( void ) pcCommandString;
|
||||||
vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) );
|
( void ) xWriteBufferLen;
|
||||||
|
configASSERT( pcWriteBuffer );
|
||||||
/* There is no more data to return after this single string, so return
|
|
||||||
pdFALSE. */
|
/* Generate a table of task stats. */
|
||||||
return pdFALSE;
|
strcpy( pcWriteBuffer, "Task" );
|
||||||
}
|
pcWriteBuffer += strlen( pcWriteBuffer );
|
||||||
|
|
||||||
#endif /* configGENERATE_RUN_TIME_STATS */
|
/* Pad the string "task" with however many bytes necessary to make it the
|
||||||
/*-----------------------------------------------------------*/
|
* length of a task name. Minus three for the null terminator and half the
|
||||||
|
* number of characters in "Task" so the column lines up with the centre of
|
||||||
static BaseType_t prvThreeParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
* the heading. */
|
||||||
{
|
for( xSpacePadding = strlen( "Task" ); xSpacePadding < ( configMAX_TASK_NAME_LEN - 3 ); xSpacePadding++ )
|
||||||
const char *pcParameter;
|
{
|
||||||
BaseType_t xParameterStringLength, xReturn;
|
/* Add a space to align columns after the task's name. */
|
||||||
static UBaseType_t uxParameterNumber = 0;
|
*pcWriteBuffer = ' ';
|
||||||
|
pcWriteBuffer++;
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
/* Ensure always terminated. */
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
*pcWriteBuffer = 0x00;
|
||||||
( void ) pcCommandString;
|
}
|
||||||
( void ) xWriteBufferLen;
|
|
||||||
configASSERT( pcWriteBuffer );
|
strcpy( pcWriteBuffer, pcHeader );
|
||||||
|
vTaskGetRunTimeStats( pcWriteBuffer + strlen( pcHeader ) );
|
||||||
if( uxParameterNumber == 0 )
|
|
||||||
{
|
/* There is no more data to return after this single string, so return
|
||||||
/* The first time the function is called after the command has been
|
* pdFALSE. */
|
||||||
entered just a header string is returned. */
|
return pdFALSE;
|
||||||
sprintf( pcWriteBuffer, "The three parameters were:\r\n" );
|
}
|
||||||
|
|
||||||
/* Next time the function is called the first parameter will be echoed
|
#endif /* configGENERATE_RUN_TIME_STATS */
|
||||||
back. */
|
/*-----------------------------------------------------------*/
|
||||||
uxParameterNumber = 1U;
|
|
||||||
|
static BaseType_t prvThreeParameterEchoCommand( char * pcWriteBuffer,
|
||||||
/* There is more data to be returned as no parameters have been echoed
|
size_t xWriteBufferLen,
|
||||||
back yet. */
|
const char * pcCommandString )
|
||||||
xReturn = pdPASS;
|
{
|
||||||
}
|
const char * pcParameter;
|
||||||
else
|
BaseType_t xParameterStringLength, xReturn;
|
||||||
{
|
static UBaseType_t uxParameterNumber = 0;
|
||||||
/* Obtain the parameter string. */
|
|
||||||
pcParameter = FreeRTOS_CLIGetParameter
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
(
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
pcCommandString, /* The command string itself. */
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
uxParameterNumber, /* Return the next parameter. */
|
( void ) pcCommandString;
|
||||||
&xParameterStringLength /* Store the parameter string length. */
|
( void ) xWriteBufferLen;
|
||||||
);
|
configASSERT( pcWriteBuffer );
|
||||||
|
|
||||||
/* Sanity check something was returned. */
|
if( uxParameterNumber == 0 )
|
||||||
configASSERT( pcParameter );
|
{
|
||||||
|
/* The first time the function is called after the command has been
|
||||||
/* Return the parameter string. */
|
* entered just a header string is returned. */
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
sprintf( pcWriteBuffer, "The three parameters were:\r\n" );
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) uxParameterNumber );
|
|
||||||
strncat( pcWriteBuffer, pcParameter, ( size_t ) xParameterStringLength );
|
/* Next time the function is called the first parameter will be echoed
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
* back. */
|
||||||
|
uxParameterNumber = 1U;
|
||||||
/* If this is the last of the three parameters then there are no more
|
|
||||||
strings to return after this one. */
|
/* There is more data to be returned as no parameters have been echoed
|
||||||
if( uxParameterNumber == 3U )
|
* back yet. */
|
||||||
{
|
xReturn = pdPASS;
|
||||||
/* If this is the last of the three parameters then there are no more
|
}
|
||||||
strings to return after this one. */
|
else
|
||||||
xReturn = pdFALSE;
|
{
|
||||||
uxParameterNumber = 0;
|
/* Obtain the parameter string. */
|
||||||
}
|
pcParameter = FreeRTOS_CLIGetParameter
|
||||||
else
|
(
|
||||||
{
|
pcCommandString, /* The command string itself. */
|
||||||
/* There are more parameters to return after this one. */
|
uxParameterNumber, /* Return the next parameter. */
|
||||||
xReturn = pdTRUE;
|
&xParameterStringLength /* Store the parameter string length. */
|
||||||
uxParameterNumber++;
|
);
|
||||||
}
|
|
||||||
}
|
/* Sanity check something was returned. */
|
||||||
|
configASSERT( pcParameter );
|
||||||
return xReturn;
|
|
||||||
}
|
/* Return the parameter string. */
|
||||||
/*-----------------------------------------------------------*/
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
|
sprintf( pcWriteBuffer, "%d: ", ( int ) uxParameterNumber );
|
||||||
static BaseType_t prvParameterEchoCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
strncat( pcWriteBuffer, pcParameter, ( size_t ) xParameterStringLength );
|
||||||
{
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
const char *pcParameter;
|
|
||||||
BaseType_t xParameterStringLength, xReturn;
|
/* If this is the last of the three parameters then there are no more
|
||||||
static UBaseType_t uxParameterNumber = 0;
|
* strings to return after this one. */
|
||||||
|
if( uxParameterNumber == 3U )
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
{
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
/* If this is the last of the three parameters then there are no more
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
* strings to return after this one. */
|
||||||
( void ) pcCommandString;
|
xReturn = pdFALSE;
|
||||||
( void ) xWriteBufferLen;
|
uxParameterNumber = 0;
|
||||||
configASSERT( pcWriteBuffer );
|
}
|
||||||
|
else
|
||||||
if( uxParameterNumber == 0 )
|
{
|
||||||
{
|
/* There are more parameters to return after this one. */
|
||||||
/* The first time the function is called after the command has been
|
xReturn = pdTRUE;
|
||||||
entered just a header string is returned. */
|
uxParameterNumber++;
|
||||||
sprintf( pcWriteBuffer, "The parameters were:\r\n" );
|
}
|
||||||
|
}
|
||||||
/* Next time the function is called the first parameter will be echoed
|
|
||||||
back. */
|
return xReturn;
|
||||||
uxParameterNumber = 1U;
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
/* There is more data to be returned as no parameters have been echoed
|
|
||||||
back yet. */
|
static BaseType_t prvParameterEchoCommand( char * pcWriteBuffer,
|
||||||
xReturn = pdPASS;
|
size_t xWriteBufferLen,
|
||||||
}
|
const char * pcCommandString )
|
||||||
else
|
{
|
||||||
{
|
const char * pcParameter;
|
||||||
/* Obtain the parameter string. */
|
BaseType_t xParameterStringLength, xReturn;
|
||||||
pcParameter = FreeRTOS_CLIGetParameter
|
static UBaseType_t uxParameterNumber = 0;
|
||||||
(
|
|
||||||
pcCommandString, /* The command string itself. */
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
uxParameterNumber, /* Return the next parameter. */
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
&xParameterStringLength /* Store the parameter string length. */
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
);
|
( void ) pcCommandString;
|
||||||
|
( void ) xWriteBufferLen;
|
||||||
if( pcParameter != NULL )
|
configASSERT( pcWriteBuffer );
|
||||||
{
|
|
||||||
/* Return the parameter string. */
|
if( uxParameterNumber == 0 )
|
||||||
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
{
|
||||||
sprintf( pcWriteBuffer, "%d: ", ( int ) uxParameterNumber );
|
/* The first time the function is called after the command has been
|
||||||
strncat( pcWriteBuffer, ( char * ) pcParameter, ( size_t ) xParameterStringLength );
|
* entered just a header string is returned. */
|
||||||
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
sprintf( pcWriteBuffer, "The parameters were:\r\n" );
|
||||||
|
|
||||||
/* There might be more parameters to return after this one. */
|
/* Next time the function is called the first parameter will be echoed
|
||||||
xReturn = pdTRUE;
|
* back. */
|
||||||
uxParameterNumber++;
|
uxParameterNumber = 1U;
|
||||||
}
|
|
||||||
else
|
/* There is more data to be returned as no parameters have been echoed
|
||||||
{
|
* back yet. */
|
||||||
/* No more parameters were found. Make sure the write buffer does
|
xReturn = pdPASS;
|
||||||
not contain a valid string. */
|
}
|
||||||
pcWriteBuffer[ 0 ] = 0x00;
|
else
|
||||||
|
{
|
||||||
/* No more data to return. */
|
/* Obtain the parameter string. */
|
||||||
xReturn = pdFALSE;
|
pcParameter = FreeRTOS_CLIGetParameter
|
||||||
|
(
|
||||||
/* Start over the next time this command is executed. */
|
pcCommandString, /* The command string itself. */
|
||||||
uxParameterNumber = 0;
|
uxParameterNumber, /* Return the next parameter. */
|
||||||
}
|
&xParameterStringLength /* Store the parameter string length. */
|
||||||
}
|
);
|
||||||
|
|
||||||
return xReturn;
|
if( pcParameter != NULL )
|
||||||
}
|
{
|
||||||
/*-----------------------------------------------------------*/
|
/* Return the parameter string. */
|
||||||
|
memset( pcWriteBuffer, 0x00, xWriteBufferLen );
|
||||||
#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
|
sprintf( pcWriteBuffer, "%d: ", ( int ) uxParameterNumber );
|
||||||
|
strncat( pcWriteBuffer, ( char * ) pcParameter, ( size_t ) xParameterStringLength );
|
||||||
static BaseType_t prvStartStopTraceCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
strncat( pcWriteBuffer, "\r\n", strlen( "\r\n" ) );
|
||||||
{
|
|
||||||
const char *pcParameter;
|
/* There might be more parameters to return after this one. */
|
||||||
BaseType_t lParameterStringLength;
|
xReturn = pdTRUE;
|
||||||
|
uxParameterNumber++;
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
}
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
else
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
{
|
||||||
( void ) pcCommandString;
|
/* No more parameters were found. Make sure the write buffer does
|
||||||
( void ) xWriteBufferLen;
|
* not contain a valid string. */
|
||||||
configASSERT( pcWriteBuffer );
|
pcWriteBuffer[ 0 ] = 0x00;
|
||||||
|
|
||||||
/* Obtain the parameter string. */
|
/* No more data to return. */
|
||||||
pcParameter = FreeRTOS_CLIGetParameter
|
xReturn = pdFALSE;
|
||||||
(
|
|
||||||
pcCommandString, /* The command string itself. */
|
/* Start over the next time this command is executed. */
|
||||||
1, /* Return the first parameter. */
|
uxParameterNumber = 0;
|
||||||
&lParameterStringLength /* Store the parameter string length. */
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
/* Sanity check something was returned. */
|
return xReturn;
|
||||||
configASSERT( pcParameter );
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
/* There are only two valid parameter values. */
|
|
||||||
if( strncmp( pcParameter, "start", strlen( "start" ) ) == 0 )
|
#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1
|
||||||
{
|
|
||||||
/* Start or restart the trace. */
|
static BaseType_t prvStartStopTraceCommand( char * pcWriteBuffer,
|
||||||
vTraceStop();
|
size_t xWriteBufferLen,
|
||||||
vTraceClear();
|
const char * pcCommandString )
|
||||||
vTraceStart();
|
{
|
||||||
|
const char * pcParameter;
|
||||||
sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" );
|
BaseType_t lParameterStringLength;
|
||||||
}
|
|
||||||
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
{
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
/* End the trace, if one is running. */
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
vTraceStop();
|
( void ) pcCommandString;
|
||||||
sprintf( pcWriteBuffer, "Stopping trace recording.\r\n" );
|
( void ) xWriteBufferLen;
|
||||||
}
|
configASSERT( pcWriteBuffer );
|
||||||
else
|
|
||||||
{
|
/* Obtain the parameter string. */
|
||||||
sprintf( pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" );
|
pcParameter = FreeRTOS_CLIGetParameter
|
||||||
}
|
(
|
||||||
|
pcCommandString, /* The command string itself. */
|
||||||
/* There is no more data to return after this single string, so return
|
1, /* Return the first parameter. */
|
||||||
pdFALSE. */
|
&lParameterStringLength /* Store the parameter string length. */
|
||||||
return pdFALSE;
|
);
|
||||||
}
|
|
||||||
|
/* Sanity check something was returned. */
|
||||||
#endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
|
configASSERT( pcParameter );
|
||||||
|
|
||||||
|
/* There are only two valid parameter values. */
|
||||||
|
if( strncmp( pcParameter, "start", strlen( "start" ) ) == 0 )
|
||||||
|
{
|
||||||
|
/* Start or restart the trace. */
|
||||||
|
vTraceStop();
|
||||||
|
vTraceClear();
|
||||||
|
vTraceStart();
|
||||||
|
|
||||||
|
sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" );
|
||||||
|
}
|
||||||
|
else if( strncmp( pcParameter, "stop", strlen( "stop" ) ) == 0 )
|
||||||
|
{
|
||||||
|
/* End the trace, if one is running. */
|
||||||
|
vTraceStop();
|
||||||
|
sprintf( pcWriteBuffer, "Stopping trace recording.\r\n" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* There is no more data to return after this single string, so return
|
||||||
|
* pdFALSE. */
|
||||||
|
return pdFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */
|
||||||
|
@ -1,225 +1,227 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://aws.amazon.com/freertos
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: This file uses a third party USB CDC driver.
|
* NOTE: This file uses a third party USB CDC driver.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Standard includes. */
|
/* Standard includes. */
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
/* FreeRTOS includes. */
|
/* FreeRTOS includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
|
|
||||||
/* Example includes. */
|
/* Example includes. */
|
||||||
#include "FreeRTOS_CLI.h"
|
#include "FreeRTOS_CLI.h"
|
||||||
|
|
||||||
/* Demo application includes. */
|
/* Demo application includes. */
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
||||||
/* Dimensions the buffer into which input characters are placed. */
|
/* Dimensions the buffer into which input characters are placed. */
|
||||||
#define cmdMAX_INPUT_SIZE 50
|
#define cmdMAX_INPUT_SIZE 50
|
||||||
|
|
||||||
/* Dimentions a buffer to be used by the UART driver, if the UART driver uses a
|
/* Dimensions a buffer to be used by the UART driver, if the UART driver uses a
|
||||||
buffer at all. */
|
* buffer at all. */
|
||||||
#define cmdQUEUE_LENGTH 25
|
#define cmdQUEUE_LENGTH 25
|
||||||
|
|
||||||
/* DEL acts as a backspace. */
|
/* DEL acts as a backspace. */
|
||||||
#define cmdASCII_DEL ( 0x7F )
|
#define cmdASCII_DEL ( 0x7F )
|
||||||
|
|
||||||
/* The maximum time to wait for the mutex that guards the UART to become
|
/* The maximum time to wait for the mutex that guards the UART to become
|
||||||
available. */
|
* available. */
|
||||||
#define cmdMAX_MUTEX_WAIT pdMS_TO_TICKS( 300 )
|
#define cmdMAX_MUTEX_WAIT pdMS_TO_TICKS( 300 )
|
||||||
|
|
||||||
#ifndef configCLI_BAUD_RATE
|
#ifndef configCLI_BAUD_RATE
|
||||||
#define configCLI_BAUD_RATE 115200
|
#define configCLI_BAUD_RATE 115200
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The task that implements the command console processing.
|
* The task that implements the command console processing.
|
||||||
*/
|
*/
|
||||||
static void prvUARTCommandConsoleTask( void *pvParameters );
|
static void prvUARTCommandConsoleTask( void * pvParameters );
|
||||||
void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );
|
void vUARTCommandConsoleStart( uint16_t usStackSize,
|
||||||
|
UBaseType_t uxPriority );
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
/* Const messages output by the command console. */
|
|
||||||
static const char * const pcWelcomeMessage = "FreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";
|
/* Const messages output by the command console. */
|
||||||
static const char * const pcEndOfOutputMessage = "\r\n[Press ENTER to execute the previous command again]\r\n>";
|
static const char * const pcWelcomeMessage = "FreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";
|
||||||
static const char * const pcNewLine = "\r\n";
|
static const char * const pcEndOfOutputMessage = "\r\n[Press ENTER to execute the previous command again]\r\n>";
|
||||||
|
static const char * const pcNewLine = "\r\n";
|
||||||
/* Used to guard access to the UART in case messages are sent to the UART from
|
|
||||||
more than one task. */
|
/* Used to guard access to the UART in case messages are sent to the UART from
|
||||||
static SemaphoreHandle_t xTxMutex = NULL;
|
* more than one task. */
|
||||||
|
static SemaphoreHandle_t xTxMutex = NULL;
|
||||||
/* The handle to the UART port, which is not used by all ports. */
|
|
||||||
static xComPortHandle xPort = 0;
|
/* The handle to the UART port, which is not used by all ports. */
|
||||||
|
static xComPortHandle xPort = 0;
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority )
|
|
||||||
{
|
void vUARTCommandConsoleStart( uint16_t usStackSize,
|
||||||
/* Create the semaphore used to access the UART Tx. */
|
UBaseType_t uxPriority )
|
||||||
xTxMutex = xSemaphoreCreateMutex();
|
{
|
||||||
configASSERT( xTxMutex );
|
/* Create the semaphore used to access the UART Tx. */
|
||||||
|
xTxMutex = xSemaphoreCreateMutex();
|
||||||
/* Create that task that handles the console itself. */
|
configASSERT( xTxMutex );
|
||||||
xTaskCreate( prvUARTCommandConsoleTask, /* The task that implements the command console. */
|
|
||||||
"CLI", /* Text name assigned to the task. This is just to assist debugging. The kernel does not use this name itself. */
|
/* Create that task that handles the console itself. */
|
||||||
usStackSize, /* The size of the stack allocated to the task. */
|
xTaskCreate( prvUARTCommandConsoleTask, /* The task that implements the command console. */
|
||||||
NULL, /* The parameter is not used, so NULL is passed. */
|
"CLI", /* Text name assigned to the task. This is just to assist debugging. The kernel does not use this name itself. */
|
||||||
uxPriority, /* The priority allocated to the task. */
|
usStackSize, /* The size of the stack allocated to the task. */
|
||||||
NULL ); /* A handle is not required, so just pass NULL. */
|
NULL, /* The parameter is not used, so NULL is passed. */
|
||||||
}
|
uxPriority, /* The priority allocated to the task. */
|
||||||
/*-----------------------------------------------------------*/
|
NULL ); /* A handle is not required, so just pass NULL. */
|
||||||
|
}
|
||||||
static void prvUARTCommandConsoleTask( void *pvParameters )
|
/*-----------------------------------------------------------*/
|
||||||
{
|
|
||||||
signed char cRxedChar;
|
static void prvUARTCommandConsoleTask( void * pvParameters )
|
||||||
uint8_t ucInputIndex = 0;
|
{
|
||||||
char *pcOutputString;
|
signed char cRxedChar;
|
||||||
static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
|
uint8_t ucInputIndex = 0;
|
||||||
BaseType_t xReturned;
|
char * pcOutputString;
|
||||||
xComPortHandle xPort;
|
static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
|
||||||
|
BaseType_t xReturned;
|
||||||
( void ) pvParameters;
|
xComPortHandle xPort;
|
||||||
|
|
||||||
/* Obtain the address of the output buffer. Note there is no mutual
|
( void ) pvParameters;
|
||||||
exclusion on this buffer as it is assumed only one command console interface
|
|
||||||
will be used at any one time. */
|
/* Obtain the address of the output buffer. Note there is no mutual
|
||||||
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
|
* exclusion on this buffer as it is assumed only one command console interface
|
||||||
|
* will be used at any one time. */
|
||||||
/* Initialise the UART. */
|
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
|
||||||
xPort = xSerialPortInitMinimal( configCLI_BAUD_RATE, cmdQUEUE_LENGTH );
|
|
||||||
|
/* Initialise the UART. */
|
||||||
/* Send the welcome message. */
|
xPort = xSerialPortInitMinimal( configCLI_BAUD_RATE, cmdQUEUE_LENGTH );
|
||||||
vSerialPutString( xPort, ( signed char * ) pcWelcomeMessage, ( unsigned short ) strlen( pcWelcomeMessage ) );
|
|
||||||
|
/* Send the welcome message. */
|
||||||
for( ;; )
|
vSerialPutString( xPort, ( signed char * ) pcWelcomeMessage, ( unsigned short ) strlen( pcWelcomeMessage ) );
|
||||||
{
|
|
||||||
/* Wait for the next character. The while loop is used in case
|
for( ; ; )
|
||||||
INCLUDE_vTaskSuspend is not set to 1 - in which case portMAX_DELAY will
|
{
|
||||||
be a genuine block time rather than an infinite block time. */
|
/* Wait for the next character. The while loop is used in case
|
||||||
while( xSerialGetChar( xPort, &cRxedChar, portMAX_DELAY ) != pdPASS );
|
* INCLUDE_vTaskSuspend is not set to 1 - in which case portMAX_DELAY will
|
||||||
|
* be a genuine block time rather than an infinite block time. */
|
||||||
/* Ensure exclusive access to the UART Tx. */
|
while( xSerialGetChar( xPort, &cRxedChar, portMAX_DELAY ) != pdPASS )
|
||||||
if( xSemaphoreTake( xTxMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )
|
{
|
||||||
{
|
}
|
||||||
/* Echo the character back. */
|
|
||||||
xSerialPutChar( xPort, cRxedChar, portMAX_DELAY );
|
/* Ensure exclusive access to the UART Tx. */
|
||||||
|
if( xSemaphoreTake( xTxMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )
|
||||||
/* Was it the end of the line? */
|
{
|
||||||
if( cRxedChar == '\n' || cRxedChar == '\r' )
|
/* Echo the character back. */
|
||||||
{
|
xSerialPutChar( xPort, cRxedChar, portMAX_DELAY );
|
||||||
/* Just to space the output from the input. */
|
|
||||||
vSerialPutString( xPort, ( signed char * ) pcNewLine, ( unsigned short ) strlen( pcNewLine ) );
|
/* Was it the end of the line? */
|
||||||
|
if( ( cRxedChar == '\n' ) || ( cRxedChar == '\r' ) )
|
||||||
/* See if the command is empty, indicating that the last command
|
{
|
||||||
is to be executed again. */
|
/* Just to space the output from the input. */
|
||||||
if( ucInputIndex == 0 )
|
vSerialPutString( xPort, ( signed char * ) pcNewLine, ( unsigned short ) strlen( pcNewLine ) );
|
||||||
{
|
|
||||||
/* Copy the last command back into the input string. */
|
/* See if the command is empty, indicating that the last command
|
||||||
strcpy( cInputString, cLastInputString );
|
* is to be executed again. */
|
||||||
}
|
if( ucInputIndex == 0 )
|
||||||
|
{
|
||||||
/* Pass the received command to the command interpreter. The
|
/* Copy the last command back into the input string. */
|
||||||
command interpreter is called repeatedly until it returns
|
strcpy( cInputString, cLastInputString );
|
||||||
pdFALSE (indicating there is no more output) as it might
|
}
|
||||||
generate more than one string. */
|
|
||||||
do
|
/* Pass the received command to the command interpreter. The
|
||||||
{
|
* command interpreter is called repeatedly until it returns
|
||||||
/* Get the next output string from the command interpreter. */
|
* pdFALSE (indicating there is no more output) as it might
|
||||||
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
|
* generate more than one string. */
|
||||||
|
do
|
||||||
/* Write the generated string to the UART. */
|
{
|
||||||
vSerialPutString( xPort, ( signed char * ) pcOutputString, ( unsigned short ) strlen( pcOutputString ) );
|
/* Get the next output string from the command interpreter. */
|
||||||
|
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
|
||||||
} while( xReturned != pdFALSE );
|
|
||||||
|
/* Write the generated string to the UART. */
|
||||||
/* All the strings generated by the input command have been
|
vSerialPutString( xPort, ( signed char * ) pcOutputString, ( unsigned short ) strlen( pcOutputString ) );
|
||||||
sent. Clear the input string ready to receive the next command.
|
} while( xReturned != pdFALSE );
|
||||||
Remember the command that was just processed first in case it is
|
|
||||||
to be processed again. */
|
/* All the strings generated by the input command have been
|
||||||
strcpy( cLastInputString, cInputString );
|
* sent. Clear the input string ready to receive the next command.
|
||||||
ucInputIndex = 0;
|
* Remember the command that was just processed first in case it is
|
||||||
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
* to be processed again. */
|
||||||
|
strcpy( cLastInputString, cInputString );
|
||||||
vSerialPutString( xPort, ( signed char * ) pcEndOfOutputMessage, ( unsigned short ) strlen( pcEndOfOutputMessage ) );
|
ucInputIndex = 0;
|
||||||
}
|
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
|
||||||
else
|
|
||||||
{
|
vSerialPutString( xPort, ( signed char * ) pcEndOfOutputMessage, ( unsigned short ) strlen( pcEndOfOutputMessage ) );
|
||||||
if( cRxedChar == '\r' )
|
}
|
||||||
{
|
else
|
||||||
/* Ignore the character. */
|
{
|
||||||
}
|
if( cRxedChar == '\r' )
|
||||||
else if( ( cRxedChar == '\b' ) || ( cRxedChar == cmdASCII_DEL ) )
|
{
|
||||||
{
|
/* Ignore the character. */
|
||||||
/* Backspace was pressed. Erase the last character in the
|
}
|
||||||
string - if any. */
|
else if( ( cRxedChar == '\b' ) || ( cRxedChar == cmdASCII_DEL ) )
|
||||||
if( ucInputIndex > 0 )
|
{
|
||||||
{
|
/* Backspace was pressed. Erase the last character in the
|
||||||
ucInputIndex--;
|
* string - if any. */
|
||||||
cInputString[ ucInputIndex ] = '\0';
|
if( ucInputIndex > 0 )
|
||||||
}
|
{
|
||||||
}
|
ucInputIndex--;
|
||||||
else
|
cInputString[ ucInputIndex ] = '\0';
|
||||||
{
|
}
|
||||||
/* A character was entered. Add it to the string entered so
|
}
|
||||||
far. When a \n is entered the complete string will be
|
else
|
||||||
passed to the command interpreter. */
|
{
|
||||||
if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )
|
/* A character was entered. Add it to the string entered so
|
||||||
{
|
* far. When a \n is entered the complete string will be
|
||||||
if( ucInputIndex < cmdMAX_INPUT_SIZE )
|
* passed to the command interpreter. */
|
||||||
{
|
if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )
|
||||||
cInputString[ ucInputIndex ] = cRxedChar;
|
{
|
||||||
ucInputIndex++;
|
if( ucInputIndex < cmdMAX_INPUT_SIZE )
|
||||||
}
|
{
|
||||||
}
|
cInputString[ ucInputIndex ] = cRxedChar;
|
||||||
}
|
ucInputIndex++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Must ensure to give the mutex back. */
|
}
|
||||||
xSemaphoreGive( xTxMutex );
|
}
|
||||||
}
|
|
||||||
}
|
/* Must ensure to give the mutex back. */
|
||||||
}
|
xSemaphoreGive( xTxMutex );
|
||||||
/*-----------------------------------------------------------*/
|
}
|
||||||
|
}
|
||||||
void vOutputString( const char * const pcMessage )
|
}
|
||||||
{
|
/*-----------------------------------------------------------*/
|
||||||
if( xSemaphoreTake( xTxMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )
|
|
||||||
{
|
void vOutputString( const char * const pcMessage )
|
||||||
vSerialPutString( xPort, ( signed char * ) pcMessage, ( unsigned short ) strlen( pcMessage ) );
|
{
|
||||||
xSemaphoreGive( xTxMutex );
|
if( xSemaphoreTake( xTxMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )
|
||||||
}
|
{
|
||||||
}
|
vSerialPutString( xPort, ( signed char * ) pcMessage, ( unsigned short ) strlen( pcMessage ) );
|
||||||
/*-----------------------------------------------------------*/
|
xSemaphoreGive( xTxMutex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -1,328 +1,339 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://github.com/FreeRTOS
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* See the following URL for information on the commands defined in this file:
|
* See the following URL for information on the commands defined in this file:
|
||||||
* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Ethernet_Related_CLI_Commands.shtml
|
* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Ethernet_Related_CLI_Commands.shtml
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* FreeRTOS includes. */
|
/* FreeRTOS includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
/* Standard includes. */
|
/* Standard includes. */
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* FreeRTOS+CLI includes. */
|
/* FreeRTOS+CLI includes. */
|
||||||
#include "FreeRTOS_CLI.h"
|
#include "FreeRTOS_CLI.h"
|
||||||
|
|
||||||
/* FreeRTOS+UDP includes, just to make the stats available to the CLI
|
/* FreeRTOS+UDP includes, just to make the stats available to the CLI
|
||||||
commands. */
|
* commands. */
|
||||||
#include "FreeRTOS_UDP_IP.h"
|
#include "FreeRTOS_UDP_IP.h"
|
||||||
#include "FreeRTOS_Sockets.h"
|
#include "FreeRTOS_Sockets.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defines a command that prints out IP address information.
|
* Defines a command that prints out IP address information.
|
||||||
*/
|
*/
|
||||||
static BaseType_t prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
static BaseType_t prvDisplayIPConfig( char * pcWriteBuffer,
|
||||||
|
size_t xWriteBufferLen,
|
||||||
/*
|
const char * pcCommandString );
|
||||||
* Defines a command that prints out the gathered demo debug stats.
|
|
||||||
*/
|
/*
|
||||||
static BaseType_t prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
* Defines a command that prints out the gathered demo debug stats.
|
||||||
|
*/
|
||||||
/*
|
static BaseType_t prvDisplayIPDebugStats( char * pcWriteBuffer,
|
||||||
* Defines a command that sends an ICMP ping request to an IP address.
|
size_t xWriteBufferLen,
|
||||||
*/
|
const char * pcCommandString );
|
||||||
static BaseType_t prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString );
|
|
||||||
|
/*
|
||||||
/* Structure that defines the "ip-config" command line command. */
|
* Defines a command that sends an ICMP ping request to an IP address.
|
||||||
static const CLI_Command_Definition_t xIPConfig =
|
*/
|
||||||
{
|
static BaseType_t prvPingCommand( char * pcWriteBuffer,
|
||||||
"ip-config",
|
size_t xWriteBufferLen,
|
||||||
"ip-config:\r\n Displays IP address configuration\r\n\r\n",
|
const char * pcCommandString );
|
||||||
prvDisplayIPConfig,
|
|
||||||
0
|
/* Structure that defines the "ip-config" command line command. */
|
||||||
};
|
static const CLI_Command_Definition_t xIPConfig =
|
||||||
|
{
|
||||||
#if configINCLUDE_DEMO_DEBUG_STATS != 0
|
"ip-config",
|
||||||
/* Structure that defines the "ip-debug-stats" command line command. */
|
"ip-config:\r\n Displays IP address configuration\r\n\r\n",
|
||||||
static const CLI_Command_Definition_t xIPDebugStats =
|
prvDisplayIPConfig,
|
||||||
{
|
0
|
||||||
"ip-debug-stats", /* The command string to type. */
|
};
|
||||||
"ip-debug-stats:\r\n Shows some IP stack stats useful for debug - an example only.\r\n\r\n",
|
|
||||||
prvDisplayIPDebugStats, /* The function to run. */
|
#if configINCLUDE_DEMO_DEBUG_STATS != 0
|
||||||
0 /* No parameters are expected. */
|
/* Structure that defines the "ip-debug-stats" command line command. */
|
||||||
};
|
static const CLI_Command_Definition_t xIPDebugStats =
|
||||||
#endif /* configINCLUDE_DEMO_DEBUG_STATS */
|
{
|
||||||
|
"ip-debug-stats", /* The command string to type. */
|
||||||
#if ipconfigSUPPORT_OUTGOING_PINGS == 1
|
"ip-debug-stats:\r\n Shows some IP stack stats useful for debug - an example only.\r\n\r\n",
|
||||||
|
prvDisplayIPDebugStats, /* The function to run. */
|
||||||
/* Structure that defines the "ping" command line command. This takes an IP
|
0 /* No parameters are expected. */
|
||||||
address or host name and (optionally) the number of bytes to ping as
|
};
|
||||||
parameters. */
|
#endif /* configINCLUDE_DEMO_DEBUG_STATS */
|
||||||
static const CLI_Command_Definition_t xPing =
|
|
||||||
{
|
#if ipconfigSUPPORT_OUTGOING_PINGS == 1
|
||||||
"ping",
|
|
||||||
"ping <ipaddress> <optional:bytes to send>:\r\n for example, ping 192.168.0.3 8, or ping www.example.com\r\n\r\n",
|
/* Structure that defines the "ping" command line command. This takes an IP
|
||||||
prvPingCommand, /* The function to run. */
|
* address or host name and (optionally) the number of bytes to ping as
|
||||||
-1 /* Ping can take either one or two parameter, so the number of parameters has to be determined by the ping command implementation. */
|
* parameters. */
|
||||||
};
|
static const CLI_Command_Definition_t xPing =
|
||||||
|
{
|
||||||
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
|
"ping",
|
||||||
|
"ping <ipaddress> <optional:bytes to send>:\r\n for example, ping 192.168.0.3 8, or ping www.example.com\r\n\r\n",
|
||||||
|
prvPingCommand, /* The function to run. */
|
||||||
/*-----------------------------------------------------------*/
|
-1 /* Ping can take either one or two parameter, so the number of parameters has to be determined by the ping command implementation. */
|
||||||
|
};
|
||||||
void vRegisterUDPCLICommands( void )
|
|
||||||
{
|
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
|
||||||
/* Register all the command line commands defined immediately above. */
|
|
||||||
FreeRTOS_CLIRegisterCommand( &xIPConfig );
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
#if configINCLUDE_DEMO_DEBUG_STATS == 1
|
|
||||||
{
|
void vRegisterUDPCLICommands( void )
|
||||||
FreeRTOS_CLIRegisterCommand( &xIPDebugStats );
|
{
|
||||||
}
|
/* Register all the command line commands defined immediately above. */
|
||||||
#endif /* configINCLUDE_DEMO_DEBUG_STATS */
|
FreeRTOS_CLIRegisterCommand( &xIPConfig );
|
||||||
|
|
||||||
#if ipconfigSUPPORT_OUTGOING_PINGS == 1
|
#if configINCLUDE_DEMO_DEBUG_STATS == 1
|
||||||
{
|
{
|
||||||
FreeRTOS_CLIRegisterCommand( &xPing );
|
FreeRTOS_CLIRegisterCommand( &xIPDebugStats );
|
||||||
}
|
}
|
||||||
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
|
#endif /* configINCLUDE_DEMO_DEBUG_STATS */
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
#if ipconfigSUPPORT_OUTGOING_PINGS == 1
|
||||||
|
{
|
||||||
#if ipconfigSUPPORT_OUTGOING_PINGS == 1
|
FreeRTOS_CLIRegisterCommand( &xPing );
|
||||||
|
}
|
||||||
static BaseType_t prvPingCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
|
||||||
{
|
}
|
||||||
char * pcParameter;
|
/*-----------------------------------------------------------*/
|
||||||
BaseType_t lParameterStringLength, xReturn;
|
|
||||||
uint32_t ulIPAddress, ulBytesToPing;
|
#if ipconfigSUPPORT_OUTGOING_PINGS == 1
|
||||||
const uint32_t ulDefaultBytesToPing = 8UL;
|
|
||||||
char cBuffer[ 16 ];
|
static BaseType_t prvPingCommand( char * pcWriteBuffer,
|
||||||
|
size_t xWriteBufferLen,
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
const char * pcCommandString )
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
{
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
char * pcParameter;
|
||||||
( void ) pcCommandString;
|
BaseType_t lParameterStringLength, xReturn;
|
||||||
( void ) xWriteBufferLen;
|
uint32_t ulIPAddress, ulBytesToPing;
|
||||||
configASSERT( pcWriteBuffer );
|
const uint32_t ulDefaultBytesToPing = 8UL;
|
||||||
|
char cBuffer[ 16 ];
|
||||||
/* Start with an empty string. */
|
|
||||||
pcWriteBuffer[ 0 ] = 0x00;
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
/* Obtain the number of bytes to ping. */
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
pcParameter = ( char * ) FreeRTOS_CLIGetParameter
|
( void ) pcCommandString;
|
||||||
(
|
( void ) xWriteBufferLen;
|
||||||
pcCommandString, /* The command string itself. */
|
configASSERT( pcWriteBuffer );
|
||||||
2, /* Return the second parameter. */
|
|
||||||
&lParameterStringLength /* Store the parameter string length. */
|
/* Start with an empty string. */
|
||||||
);
|
pcWriteBuffer[ 0 ] = 0x00;
|
||||||
|
|
||||||
if( pcParameter == NULL )
|
/* Obtain the number of bytes to ping. */
|
||||||
{
|
pcParameter = ( char * ) FreeRTOS_CLIGetParameter
|
||||||
/* The number of bytes was not specified, so default it. */
|
(
|
||||||
ulBytesToPing = ulDefaultBytesToPing;
|
pcCommandString, /* The command string itself. */
|
||||||
}
|
2, /* Return the second parameter. */
|
||||||
else
|
&lParameterStringLength /* Store the parameter string length. */
|
||||||
{
|
);
|
||||||
ulBytesToPing = atol( pcParameter );
|
|
||||||
}
|
if( pcParameter == NULL )
|
||||||
|
{
|
||||||
/* Obtain the IP address string. */
|
/* The number of bytes was not specified, so default it. */
|
||||||
pcParameter = ( char * ) FreeRTOS_CLIGetParameter
|
ulBytesToPing = ulDefaultBytesToPing;
|
||||||
(
|
}
|
||||||
pcCommandString, /* The command string itself. */
|
else
|
||||||
1, /* Return the first parameter. */
|
{
|
||||||
&lParameterStringLength /* Store the parameter string length. */
|
ulBytesToPing = atol( pcParameter );
|
||||||
);
|
}
|
||||||
|
|
||||||
/* Sanity check something was returned. */
|
/* Obtain the IP address string. */
|
||||||
configASSERT( pcParameter );
|
pcParameter = ( char * ) FreeRTOS_CLIGetParameter
|
||||||
|
(
|
||||||
/* Attempt to obtain the IP address. If the first character is not a
|
pcCommandString, /* The command string itself. */
|
||||||
digit, assume the host name has been passed in. */
|
1, /* Return the first parameter. */
|
||||||
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
&lParameterStringLength /* Store the parameter string length. */
|
||||||
{
|
);
|
||||||
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
|
|
||||||
}
|
/* Sanity check something was returned. */
|
||||||
else
|
configASSERT( pcParameter );
|
||||||
{
|
|
||||||
/* Terminate the host name. */
|
/* Attempt to obtain the IP address. If the first character is not a
|
||||||
pcParameter[ lParameterStringLength ] = 0x00;
|
* digit, assume the host name has been passed in. */
|
||||||
|
if( ( *pcParameter >= '0' ) && ( *pcParameter <= '9' ) )
|
||||||
/* Attempt to resolve host. */
|
{
|
||||||
ulIPAddress = FreeRTOS_gethostbyname( pcParameter );
|
ulIPAddress = FreeRTOS_inet_addr( pcParameter );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Convert IP address, which may have come from a DNS lookup, to string. */
|
{
|
||||||
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
/* Terminate the host name. */
|
||||||
|
pcParameter[ lParameterStringLength ] = 0x00;
|
||||||
if( ulIPAddress != 0 )
|
|
||||||
{
|
/* Attempt to resolve host. */
|
||||||
xReturn = FreeRTOS_SendPingRequest( ulIPAddress, ( uint16_t ) ulBytesToPing, portMAX_DELAY );
|
ulIPAddress = FreeRTOS_gethostbyname( pcParameter );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
/* Convert IP address, which may have come from a DNS lookup, to string. */
|
||||||
xReturn = pdFALSE;
|
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
||||||
}
|
|
||||||
|
if( ulIPAddress != 0 )
|
||||||
if( xReturn == pdFALSE )
|
{
|
||||||
{
|
xReturn = FreeRTOS_SendPingRequest( ulIPAddress, ( uint16_t ) ulBytesToPing, portMAX_DELAY );
|
||||||
sprintf( pcWriteBuffer, "%s", "Could not send ping request\r\n" );
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
xReturn = pdFALSE;
|
||||||
sprintf( pcWriteBuffer, "Ping sent to %s with identifier %d\r\n", cBuffer, ( int ) xReturn );
|
}
|
||||||
}
|
|
||||||
|
if( xReturn == pdFALSE )
|
||||||
return pdFALSE;
|
{
|
||||||
}
|
sprintf( pcWriteBuffer, "%s", "Could not send ping request\r\n" );
|
||||||
/*-----------------------------------------------------------*/
|
}
|
||||||
|
else
|
||||||
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
|
{
|
||||||
|
sprintf( pcWriteBuffer, "Ping sent to %s with identifier %d\r\n", cBuffer, ( int ) xReturn );
|
||||||
#if configINCLUDE_DEMO_DEBUG_STATS != 0
|
}
|
||||||
|
|
||||||
static BaseType_t prvDisplayIPDebugStats( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
return pdFALSE;
|
||||||
{
|
}
|
||||||
static BaseType_t xIndex = -1;
|
/*-----------------------------------------------------------*/
|
||||||
extern xExampleDebugStatEntry_t xIPTraceValues[];
|
|
||||||
BaseType_t xReturn;
|
#endif /* ipconfigSUPPORT_OUTGOING_PINGS */
|
||||||
|
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
#if configINCLUDE_DEMO_DEBUG_STATS != 0
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
static BaseType_t prvDisplayIPDebugStats( char * pcWriteBuffer,
|
||||||
( void ) pcCommandString;
|
size_t xWriteBufferLen,
|
||||||
( void ) xWriteBufferLen;
|
const char * pcCommandString )
|
||||||
configASSERT( pcWriteBuffer );
|
{
|
||||||
|
static BaseType_t xIndex = -1;
|
||||||
xIndex++;
|
extern xExampleDebugStatEntry_t xIPTraceValues[];
|
||||||
|
BaseType_t xReturn;
|
||||||
if( xIndex < xExampleDebugStatEntries() )
|
|
||||||
{
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
sprintf( pcWriteBuffer, "%s %d\r\n", ( char * ) xIPTraceValues[ xIndex ].pucDescription, ( int ) xIPTraceValues[ xIndex ].ulData );
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
xReturn = pdPASS;
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
}
|
( void ) pcCommandString;
|
||||||
else
|
( void ) xWriteBufferLen;
|
||||||
{
|
configASSERT( pcWriteBuffer );
|
||||||
/* Reset the index for the next time it is called. */
|
|
||||||
xIndex = -1;
|
xIndex++;
|
||||||
|
|
||||||
/* Ensure nothing remains in the write buffer. */
|
if( xIndex < xExampleDebugStatEntries() )
|
||||||
pcWriteBuffer[ 0 ] = 0x00;
|
{
|
||||||
xReturn = pdFALSE;
|
sprintf( pcWriteBuffer, "%s %d\r\n", ( char * ) xIPTraceValues[ xIndex ].pucDescription, ( int ) xIPTraceValues[ xIndex ].ulData );
|
||||||
}
|
xReturn = pdPASS;
|
||||||
|
}
|
||||||
return xReturn;
|
else
|
||||||
}
|
{
|
||||||
/*-----------------------------------------------------------*/
|
/* Reset the index for the next time it is called. */
|
||||||
|
xIndex = -1;
|
||||||
#endif /* configINCLUDE_DEMO_DEBUG_STATS */
|
|
||||||
|
/* Ensure nothing remains in the write buffer. */
|
||||||
static BaseType_t prvDisplayIPConfig( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
|
pcWriteBuffer[ 0 ] = 0x00;
|
||||||
{
|
xReturn = pdFALSE;
|
||||||
static BaseType_t xIndex = 0;
|
}
|
||||||
BaseType_t xReturn;
|
|
||||||
uint32_t ulAddress;
|
return xReturn;
|
||||||
|
}
|
||||||
/* Remove compile time warnings about unused parameters, and check the
|
/*-----------------------------------------------------------*/
|
||||||
write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
|
||||||
write buffer length is adequate, so does not check for buffer overflows. */
|
#endif /* configINCLUDE_DEMO_DEBUG_STATS */
|
||||||
( void ) pcCommandString;
|
|
||||||
( void ) xWriteBufferLen;
|
static BaseType_t prvDisplayIPConfig( char * pcWriteBuffer,
|
||||||
configASSERT( pcWriteBuffer );
|
size_t xWriteBufferLen,
|
||||||
|
const char * pcCommandString )
|
||||||
switch( xIndex )
|
{
|
||||||
{
|
static BaseType_t xIndex = 0;
|
||||||
case 0 :
|
BaseType_t xReturn;
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
uint32_t ulAddress;
|
||||||
FreeRTOS_GetEndPointConfiguration( &ulAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
|
||||||
#else
|
/* Remove compile time warnings about unused parameters, and check the
|
||||||
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
* write buffer is not NULL. NOTE - for simplicity, this example assumes the
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
* write buffer length is adequate, so does not check for buffer overflows. */
|
||||||
sprintf( pcWriteBuffer, "\r\nIP address " );
|
( void ) pcCommandString;
|
||||||
xReturn = pdTRUE;
|
( void ) xWriteBufferLen;
|
||||||
xIndex++;
|
configASSERT( pcWriteBuffer );
|
||||||
break;
|
|
||||||
|
switch( xIndex )
|
||||||
case 1 :
|
{
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
case 0:
|
||||||
FreeRTOS_GetEndPointConfiguration( NULL, &ulAddress, NULL, NULL, pxNetworkEndPoints );
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
#else
|
FreeRTOS_GetEndPointConfiguration( &ulAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
#else
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
||||||
sprintf( pcWriteBuffer, "\r\nNet mask " );
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
xReturn = pdTRUE;
|
sprintf( pcWriteBuffer, "\r\nIP address " );
|
||||||
xIndex++;
|
xReturn = pdTRUE;
|
||||||
break;
|
xIndex++;
|
||||||
|
break;
|
||||||
case 2 :
|
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
case 1:
|
||||||
FreeRTOS_GetEndPointConfiguration( NULL, NULL, &ulAddress, NULL, pxNetworkEndPoints );
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
#else
|
FreeRTOS_GetEndPointConfiguration( NULL, &ulAddress, NULL, NULL, pxNetworkEndPoints );
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
#else
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
||||||
sprintf( pcWriteBuffer, "\r\nGateway address " );
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
xReturn = pdTRUE;
|
sprintf( pcWriteBuffer, "\r\nNet mask " );
|
||||||
xIndex++;
|
xReturn = pdTRUE;
|
||||||
break;
|
xIndex++;
|
||||||
|
break;
|
||||||
case 3 :
|
|
||||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
case 2:
|
||||||
FreeRTOS_GetEndPointConfiguration( NULL, NULL, NULL, &ulAddress, pxNetworkEndPoints );
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
#else
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, &ulAddress, NULL, pxNetworkEndPoints );
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
#else
|
||||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
||||||
sprintf( pcWriteBuffer, "\r\nDNS server address " );
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
xReturn = pdTRUE;
|
sprintf( pcWriteBuffer, "\r\nGateway address " );
|
||||||
xIndex++;
|
xReturn = pdTRUE;
|
||||||
break;
|
xIndex++;
|
||||||
|
break;
|
||||||
default :
|
|
||||||
ulAddress = 0;
|
case 3:
|
||||||
sprintf( pcWriteBuffer, "\r\n\r\n" );
|
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||||
xReturn = pdFALSE;
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, NULL, &ulAddress, pxNetworkEndPoints );
|
||||||
xIndex = 0;
|
#else
|
||||||
break;
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
||||||
}
|
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||||
|
sprintf( pcWriteBuffer, "\r\nDNS server address " );
|
||||||
if( ulAddress != 0 )
|
xReturn = pdTRUE;
|
||||||
{
|
xIndex++;
|
||||||
FreeRTOS_inet_ntoa( ulAddress, ( &( pcWriteBuffer[ strlen( pcWriteBuffer ) ] ) ) );
|
break;
|
||||||
}
|
|
||||||
|
default:
|
||||||
return xReturn;
|
ulAddress = 0;
|
||||||
}
|
sprintf( pcWriteBuffer, "\r\n\r\n" );
|
||||||
/*-----------------------------------------------------------*/
|
xReturn = pdFALSE;
|
||||||
|
xIndex = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ulAddress != 0 )
|
||||||
|
{
|
||||||
|
FreeRTOS_inet_ntoa( ulAddress, ( &( pcWriteBuffer[ strlen( pcWriteBuffer ) ] ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return xReturn;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -1,320 +1,316 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://aws.amazon.com/freertos
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* See the URL in the comments within main.c for the location of the online
|
* See the URL in the comments within main.c for the location of the online
|
||||||
* documentation.
|
* documentation.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/* Standard includes. */
|
/* Standard includes. */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* FreeRTOS includes. */
|
/* FreeRTOS includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
|
|
||||||
/* File system includes. */
|
/* File system includes. */
|
||||||
#include "fat_sl.h"
|
#include "fat_sl.h"
|
||||||
#include "api_mdriver_ram.h"
|
#include "api_mdriver_ram.h"
|
||||||
|
|
||||||
/* 8.3 format, plus null terminator. */
|
/* 8.3 format, plus null terminator. */
|
||||||
#define fsMAX_FILE_NAME_LEN 13
|
#define fsMAX_FILE_NAME_LEN 13
|
||||||
|
|
||||||
/* The number of bytes read/written to the example files at a time. */
|
/* The number of bytes read/written to the example files at a time. */
|
||||||
#define fsRAM_BUFFER_SIZE 200
|
#define fsRAM_BUFFER_SIZE 200
|
||||||
|
|
||||||
/* The number of bytes written to the file that uses f_putc() and f_getc(). */
|
/* The number of bytes written to the file that uses f_putc() and f_getc(). */
|
||||||
#define fsPUTC_FILE_SIZE 100
|
#define fsPUTC_FILE_SIZE 100
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates and verifies different files on the volume, demonstrating the use of
|
* Creates and verifies different files on the volume, demonstrating the use of
|
||||||
* various different API functions.
|
* various different API functions.
|
||||||
*/
|
*/
|
||||||
void vCreateAndVerifySampleFiles( void );
|
void vCreateAndVerifySampleFiles( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a set of example files in the root directory of the volume using
|
* Create a set of example files in the root directory of the volume using
|
||||||
* f_write().
|
* f_write().
|
||||||
*/
|
*/
|
||||||
static void prvCreateDemoFilesUsing_f_write( void );
|
static void prvCreateDemoFilesUsing_f_write( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use f_read() to read back and verify the files that were created by
|
* Use f_read() to read back and verify the files that were created by
|
||||||
* prvCreateDemoFilesUsing_f_write().
|
* prvCreateDemoFilesUsing_f_write().
|
||||||
*/
|
*/
|
||||||
static void prvVerifyDemoFileUsing_f_read( void );
|
static void prvVerifyDemoFileUsing_f_read( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create an example file in a sub-directory using f_putc().
|
* Create an example file in a sub-directory using f_putc().
|
||||||
*/
|
*/
|
||||||
static void prvCreateDemoFileUsing_f_putc( void );
|
static void prvCreateDemoFileUsing_f_putc( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use f_getc() to read back and verify the file that was created by
|
* Use f_getc() to read back and verify the file that was created by
|
||||||
* prvCreateDemoFileUsing_f_putc().
|
* prvCreateDemoFileUsing_f_putc().
|
||||||
*/
|
*/
|
||||||
static void prvVerifyDemoFileUsing_f_getc( void );
|
static void prvVerifyDemoFileUsing_f_getc( void );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* A buffer used to both create content to write to disk, and read content back
|
/* A buffer used to both create content to write to disk, and read content back
|
||||||
from a disk. Note there is no mutual exclusion on this buffer. */
|
* from a disk. Note there is no mutual exclusion on this buffer. */
|
||||||
static char cRAMBuffer[ fsRAM_BUFFER_SIZE ];
|
static char cRAMBuffer[ fsRAM_BUFFER_SIZE ];
|
||||||
|
|
||||||
/* Names of directories that are created. */
|
/* Names of directories that are created. */
|
||||||
static const char *pcRoot = "/", *pcDirectory1 = "SUB1", *pcDirectory2 = "SUB2", *pcFullPath = "/SUB1/SUB2";
|
static const char * pcRoot = "/", * pcDirectory1 = "SUB1", * pcDirectory2 = "SUB2", * pcFullPath = "/SUB1/SUB2";
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vCreateAndVerifySampleFiles( void )
|
void vCreateAndVerifySampleFiles( void )
|
||||||
{
|
{
|
||||||
unsigned char ucStatus;
|
unsigned char ucStatus;
|
||||||
|
|
||||||
/* First create the volume. */
|
/* First create the volume. */
|
||||||
ucStatus = f_initvolume( ram_initfunc );
|
ucStatus = f_initvolume( ram_initfunc );
|
||||||
|
|
||||||
/* It is expected that the volume is not formatted. */
|
/* It is expected that the volume is not formatted. */
|
||||||
if( ucStatus == F_ERR_NOTFORMATTED )
|
if( ucStatus == F_ERR_NOTFORMATTED )
|
||||||
{
|
{
|
||||||
/* Format the created volume. */
|
/* Format the created volume. */
|
||||||
ucStatus = f_format( F_FAT12_MEDIA );
|
ucStatus = f_format( F_FAT12_MEDIA );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ucStatus == F_NO_ERROR )
|
if( ucStatus == F_NO_ERROR )
|
||||||
{
|
{
|
||||||
/* Create a set of files using f_write(). */
|
/* Create a set of files using f_write(). */
|
||||||
prvCreateDemoFilesUsing_f_write();
|
prvCreateDemoFilesUsing_f_write();
|
||||||
|
|
||||||
/* Read back and verify the files that were created using f_write(). */
|
/* Read back and verify the files that were created using f_write(). */
|
||||||
prvVerifyDemoFileUsing_f_read();
|
prvVerifyDemoFileUsing_f_read();
|
||||||
|
|
||||||
/* Create sub directories two deep then create a file using putc. */
|
/* Create sub directories two deep then create a file using putc. */
|
||||||
prvCreateDemoFileUsing_f_putc();
|
prvCreateDemoFileUsing_f_putc();
|
||||||
|
|
||||||
/* Read back and verify the file created by
|
/* Read back and verify the file created by
|
||||||
prvCreateDemoFileUsing_f_putc(). */
|
* prvCreateDemoFileUsing_f_putc(). */
|
||||||
prvVerifyDemoFileUsing_f_getc();
|
prvVerifyDemoFileUsing_f_getc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvCreateDemoFilesUsing_f_write( void )
|
static void prvCreateDemoFilesUsing_f_write( void )
|
||||||
{
|
{
|
||||||
BaseType_t xFileNumber, xWriteNumber;
|
BaseType_t xFileNumber, xWriteNumber;
|
||||||
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
const BaseType_t xMaxFiles = 5;
|
const BaseType_t xMaxFiles = 5;
|
||||||
long lItemsWritten;
|
long lItemsWritten;
|
||||||
F_FILE *pxFile;
|
F_FILE * pxFile;
|
||||||
|
|
||||||
/* Create xMaxFiles files. Each created file will be
|
/* Create xMaxFiles files. Each created file will be
|
||||||
( xFileNumber * fsRAM_BUFFER_SIZE ) bytes in length, and filled
|
* ( xFileNumber * fsRAM_BUFFER_SIZE ) bytes in length, and filled
|
||||||
with a different repeating character. */
|
* with a different repeating character. */
|
||||||
for( xFileNumber = 1; xFileNumber <= xMaxFiles; xFileNumber++ )
|
for( xFileNumber = 1; xFileNumber <= xMaxFiles; xFileNumber++ )
|
||||||
{
|
{
|
||||||
/* Generate a file name. */
|
/* Generate a file name. */
|
||||||
sprintf( cFileName, "root%03d.txt", ( int ) xFileNumber );
|
sprintf( cFileName, "root%03d.txt", ( int ) xFileNumber );
|
||||||
|
|
||||||
/* Obtain the current working directory and print out the file name and
|
/* Obtain the current working directory and print out the file name and
|
||||||
the directory into which the file is being written. */
|
* the directory into which the file is being written. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
|
|
||||||
/* Open the file, creating the file if it does not already exist. */
|
/* Open the file, creating the file if it does not already exist. */
|
||||||
pxFile = f_open( cFileName, "w" );
|
pxFile = f_open( cFileName, "w" );
|
||||||
configASSERT( pxFile );
|
configASSERT( pxFile );
|
||||||
|
|
||||||
/* Fill the RAM buffer with data that will be written to the file. This
|
/* Fill the RAM buffer with data that will be written to the file. This
|
||||||
is just a repeating ascii character that indicates the file number. */
|
* is just a repeating ascii character that indicates the file number. */
|
||||||
memset( cRAMBuffer, ( int ) ( '0' + xFileNumber ), fsRAM_BUFFER_SIZE );
|
memset( cRAMBuffer, ( int ) ( '0' + xFileNumber ), fsRAM_BUFFER_SIZE );
|
||||||
|
|
||||||
/* Write the RAM buffer to the opened file a number of times. The
|
/* Write the RAM buffer to the opened file a number of times. The
|
||||||
number of times the RAM buffer is written to the file depends on the
|
* number of times the RAM buffer is written to the file depends on the
|
||||||
file number, so the length of each created file will be different. */
|
* file number, so the length of each created file will be different. */
|
||||||
for( xWriteNumber = 0; xWriteNumber < xFileNumber; xWriteNumber++ )
|
for( xWriteNumber = 0; xWriteNumber < xFileNumber; xWriteNumber++ )
|
||||||
{
|
{
|
||||||
lItemsWritten = f_write( cRAMBuffer, fsRAM_BUFFER_SIZE, 1, pxFile );
|
lItemsWritten = f_write( cRAMBuffer, fsRAM_BUFFER_SIZE, 1, pxFile );
|
||||||
configASSERT( lItemsWritten == 1 );
|
configASSERT( lItemsWritten == 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the file so another file can be created. */
|
/* Close the file so another file can be created. */
|
||||||
f_close( pxFile );
|
f_close( pxFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvVerifyDemoFileUsing_f_read( void )
|
static void prvVerifyDemoFileUsing_f_read( void )
|
||||||
{
|
{
|
||||||
BaseType_t xFileNumber, xReadNumber;
|
BaseType_t xFileNumber, xReadNumber;
|
||||||
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
const BaseType_t xMaxFiles = 5;
|
const BaseType_t xMaxFiles = 5;
|
||||||
long lItemsRead, lChar;
|
long lItemsRead, lChar;
|
||||||
F_FILE *pxFile;
|
F_FILE * pxFile;
|
||||||
|
|
||||||
/* Read back the files that were created by
|
/* Read back the files that were created by
|
||||||
prvCreateDemoFilesUsing_f_write(). */
|
* prvCreateDemoFilesUsing_f_write(). */
|
||||||
for( xFileNumber = 1; xFileNumber <= xMaxFiles; xFileNumber++ )
|
for( xFileNumber = 1; xFileNumber <= xMaxFiles; xFileNumber++ )
|
||||||
{
|
{
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "root%03d.txt", ( int ) xFileNumber );
|
sprintf( cFileName, "root%03d.txt", ( int ) xFileNumber );
|
||||||
|
|
||||||
/* Obtain the current working directory and print out the file name and
|
/* Obtain the current working directory and print out the file name and
|
||||||
the directory from which the file is being read. */
|
* the directory from which the file is being read. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
|
|
||||||
/* Open the file for reading. */
|
/* Open the file for reading. */
|
||||||
pxFile = f_open( cFileName, "r" );
|
pxFile = f_open( cFileName, "r" );
|
||||||
configASSERT( pxFile );
|
configASSERT( pxFile );
|
||||||
|
|
||||||
/* Read the file into the RAM buffer, checking the file contents are as
|
/* Read the file into the RAM buffer, checking the file contents are as
|
||||||
expected. The size of the file depends on the file number. */
|
* expected. The size of the file depends on the file number. */
|
||||||
for( xReadNumber = 0; xReadNumber < xFileNumber; xReadNumber++ )
|
for( xReadNumber = 0; xReadNumber < xFileNumber; xReadNumber++ )
|
||||||
{
|
{
|
||||||
/* Start with the RAM buffer clear. */
|
/* Start with the RAM buffer clear. */
|
||||||
memset( cRAMBuffer, 0x00, fsRAM_BUFFER_SIZE );
|
memset( cRAMBuffer, 0x00, fsRAM_BUFFER_SIZE );
|
||||||
|
|
||||||
lItemsRead = f_read( cRAMBuffer, fsRAM_BUFFER_SIZE, 1, pxFile );
|
lItemsRead = f_read( cRAMBuffer, fsRAM_BUFFER_SIZE, 1, pxFile );
|
||||||
configASSERT( lItemsRead == 1 );
|
configASSERT( lItemsRead == 1 );
|
||||||
|
|
||||||
/* Check the RAM buffer is filled with the expected data. Each
|
/* Check the RAM buffer is filled with the expected data. Each
|
||||||
file contains a different repeating ascii character that indicates
|
* file contains a different repeating ascii character that indicates
|
||||||
the number of the file. */
|
* the number of the file. */
|
||||||
for( lChar = 0; lChar < fsRAM_BUFFER_SIZE; lChar++ )
|
for( lChar = 0; lChar < fsRAM_BUFFER_SIZE; lChar++ )
|
||||||
{
|
{
|
||||||
configASSERT( cRAMBuffer[ lChar ] == ( '0' + ( char ) xFileNumber ) );
|
configASSERT( cRAMBuffer[ lChar ] == ( '0' + ( char ) xFileNumber ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the file. */
|
/* Close the file. */
|
||||||
f_close( pxFile );
|
f_close( pxFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvCreateDemoFileUsing_f_putc( void )
|
static void prvCreateDemoFileUsing_f_putc( void )
|
||||||
{
|
{
|
||||||
unsigned char ucReturn;
|
unsigned char ucReturn;
|
||||||
int iByte, iReturned;
|
int iByte, iReturned;
|
||||||
F_FILE *pxFile;
|
F_FILE * pxFile;
|
||||||
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
|
|
||||||
/* Create a sub directory. */
|
/* Create a sub directory. */
|
||||||
ucReturn = f_mkdir( pcDirectory1 );
|
ucReturn = f_mkdir( pcDirectory1 );
|
||||||
configASSERT( ucReturn == F_NO_ERROR );
|
configASSERT( ucReturn == F_NO_ERROR );
|
||||||
|
|
||||||
/* Move into the created sub-directory. */
|
/* Move into the created sub-directory. */
|
||||||
ucReturn = f_chdir( pcDirectory1 );
|
ucReturn = f_chdir( pcDirectory1 );
|
||||||
configASSERT( ucReturn == F_NO_ERROR );
|
configASSERT( ucReturn == F_NO_ERROR );
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
|
|
||||||
/* Create a subdirectory in the new directory. */
|
/* Create a subdirectory in the new directory. */
|
||||||
ucReturn = f_mkdir( pcDirectory2 );
|
ucReturn = f_mkdir( pcDirectory2 );
|
||||||
configASSERT( ucReturn == F_NO_ERROR );
|
configASSERT( ucReturn == F_NO_ERROR );
|
||||||
|
|
||||||
/* Move into the directory just created - now two directories down from
|
/* Move into the directory just created - now two directories down from
|
||||||
the root. */
|
* the root. */
|
||||||
ucReturn = f_chdir( pcDirectory2 );
|
ucReturn = f_chdir( pcDirectory2 );
|
||||||
configASSERT( ucReturn == F_NO_ERROR );
|
configASSERT( ucReturn == F_NO_ERROR );
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
|
||||||
/* Print out the file name and the directory into which the file is being
|
/* Print out the file name and the directory into which the file is being
|
||||||
written. */
|
* written. */
|
||||||
pxFile = f_open( cFileName, "w" );
|
pxFile = f_open( cFileName, "w" );
|
||||||
|
|
||||||
/* Create a file 1 byte at a time. The file is filled with incrementing
|
/* Create a file 1 byte at a time. The file is filled with incrementing
|
||||||
ascii characters starting from '0'. */
|
* ascii characters starting from '0'. */
|
||||||
for( iByte = 0; iByte < fsPUTC_FILE_SIZE; iByte++ )
|
for( iByte = 0; iByte < fsPUTC_FILE_SIZE; iByte++ )
|
||||||
{
|
{
|
||||||
iReturned = f_putc( ( ( int ) '0' + iByte ), pxFile );
|
iReturned = f_putc( ( ( int ) '0' + iByte ), pxFile );
|
||||||
configASSERT( iReturned == ( ( int ) '0' + iByte ) );
|
configASSERT( iReturned == ( ( int ) '0' + iByte ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finished so close the file. */
|
/* Finished so close the file. */
|
||||||
f_close( pxFile );
|
f_close( pxFile );
|
||||||
|
|
||||||
/* Move back to the root directory. */
|
/* Move back to the root directory. */
|
||||||
ucReturn = f_chdir( "../.." );
|
ucReturn = f_chdir( "../.." );
|
||||||
configASSERT( ucReturn == F_NO_ERROR );
|
configASSERT( ucReturn == F_NO_ERROR );
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
configASSERT( strcmp( cRAMBuffer, pcRoot ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcRoot ) == 0 );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvVerifyDemoFileUsing_f_getc( void )
|
static void prvVerifyDemoFileUsing_f_getc( void )
|
||||||
{
|
{
|
||||||
unsigned char ucReturn;
|
unsigned char ucReturn;
|
||||||
int iByte, iReturned;
|
int iByte, iReturned;
|
||||||
F_FILE *pxFile;
|
F_FILE * pxFile;
|
||||||
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
char cFileName[ fsMAX_FILE_NAME_LEN ];
|
||||||
|
|
||||||
/* Move into the directory in which the file was created. */
|
/* Move into the directory in which the file was created. */
|
||||||
ucReturn = f_chdir( pcFullPath );
|
ucReturn = f_chdir( pcFullPath );
|
||||||
configASSERT( ucReturn == F_NO_ERROR );
|
configASSERT( ucReturn == F_NO_ERROR );
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
configASSERT( strcmp( cRAMBuffer, pcFullPath ) == 0 );
|
||||||
|
|
||||||
/* Generate the file name. */
|
/* Generate the file name. */
|
||||||
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
sprintf( cFileName, "%s.txt", pcDirectory2 );
|
||||||
|
|
||||||
/* This time the file is opened for reading. */
|
/* This time the file is opened for reading. */
|
||||||
pxFile = f_open( cFileName, "r" );
|
pxFile = f_open( cFileName, "r" );
|
||||||
|
|
||||||
/* Read the file 1 byte at a time. */
|
/* Read the file 1 byte at a time. */
|
||||||
for( iByte = 0; iByte < fsPUTC_FILE_SIZE; iByte++ )
|
for( iByte = 0; iByte < fsPUTC_FILE_SIZE; iByte++ )
|
||||||
{
|
{
|
||||||
iReturned = f_getc( pxFile );
|
iReturned = f_getc( pxFile );
|
||||||
configASSERT( iReturned == ( ( int ) '0' + iByte ) );
|
configASSERT( iReturned == ( ( int ) '0' + iByte ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finished so close the file. */
|
/* Finished so close the file. */
|
||||||
f_close( pxFile );
|
f_close( pxFile );
|
||||||
|
|
||||||
/* Move back to the root directory. */
|
/* Move back to the root directory. */
|
||||||
ucReturn = f_chdir( "../.." );
|
ucReturn = f_chdir( "../.." );
|
||||||
configASSERT( ucReturn == F_NO_ERROR );
|
configASSERT( ucReturn == F_NO_ERROR );
|
||||||
|
|
||||||
/* Obtain and print out the working directory. */
|
/* Obtain and print out the working directory. */
|
||||||
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
f_getcwd( cRAMBuffer, fsRAM_BUFFER_SIZE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,32 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://aws.amazon.com/freertos
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef UDP_COMMAND_INTERPRETER_H
|
#ifndef UDP_COMMAND_INTERPRETER_H
|
||||||
#define UDP_COMMAND_INTERPRETER_H
|
#define UDP_COMMAND_INTERPRETER_H
|
||||||
|
|
||||||
void vStartUDPCommandInterpreterTask( uint16_t usStackSize, uint32_t ulPort, UBaseType_t uxPriority );
|
void vStartUDPCommandInterpreterTask( uint16_t usStackSize,
|
||||||
|
uint32_t ulPort,
|
||||||
#endif /* UDP_COMMAND_INTERPRETER_H */
|
UBaseType_t uxPriority );
|
||||||
|
|
||||||
|
#endif /* UDP_COMMAND_INTERPRETER_H */
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue