From 96f541355aa17e7c423b3ca2c4ef4bc9c63764a0 Mon Sep 17 00:00:00 2001 From: blue <1607918099@qq.com> Date: Thu, 7 Apr 2022 16:14:48 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=AE=9E=E7=8E=B0=E7=8A=B6=E6=80=81=E6=8C=87?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .settings/org.eclipse.cdt.codan.core.prefs | 109 +++++++++++++++++++++ .settings/org.eclipse.cdt.ui.prefs | 2 + .settings/org.eclipse.core.resources.prefs | 4 + .settings/org.eclipse.core.runtime.prefs | 2 + components/rtk/rtk.c | 11 ++- main/app_main.c | 58 +++++------ main/led.c | 107 +++++++++++++------- main/led.h | 14 ++- main/provisioning.c | 15 +-- 9 files changed, 239 insertions(+), 83 deletions(-) create mode 100644 .settings/org.eclipse.cdt.codan.core.prefs create mode 100644 .settings/org.eclipse.cdt.ui.prefs create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.core.runtime.prefs diff --git a/.settings/org.eclipse.cdt.codan.core.prefs b/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000..da30759 --- /dev/null +++ b/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,109 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"} +org.eclipse.cdt.codan.checkers.localvarreturn=-Warning +org.eclipse.cdt.codan.checkers.localvarreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Returning the address of a local variable\\")"} +org.eclipse.cdt.codan.checkers.nocommentinside=-Error +org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"} +org.eclipse.cdt.codan.checkers.nolinecomment=-Error +org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"} +org.eclipse.cdt.codan.internal.checkers.BlacklistProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.BlacklistProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function or method is blacklisted\\")",blacklist\=>()} +org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"C-Style cast instead of C++ cast\\")",checkMacro\=>true} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true} +org.eclipse.cdt.codan.internal.checkers.CopyrightProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.CopyrightProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Lack of copyright information\\")",regex\=>".*Copyright.*"} +org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error +org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.FloatCompareProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.FloatCompareProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Direct float comparison\\")"} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Goto statement used\\")"} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"} +org.eclipse.cdt.codan.internal.checkers.MagicNumberProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MagicNumberProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Avoid magic numbers\\")",checkArray\=>true,checkOperatorParen\=>true,exceptions\=>(1,0,-1,2,1.0,0.0,-1.0)} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.MissCaseProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissCaseProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing cases in switch\\")"} +org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing default in switch\\")",defaultWithAllEnums\=>false} +org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing reference return value in assignment operator\\")"} +org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing self check in assignment operator\\")"} +org.eclipse.cdt.codan.internal.checkers.MultipleDeclarationsProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.MultipleDeclarationsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Multiple variable declaration\\")"} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NoDiscardProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NoDiscardProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return value not evaluated\\")",macro\=>true} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"} +org.eclipse.cdt.codan.internal.checkers.ShallowCopyProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ShallowCopyProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Miss copy constructor or assignment operator\\")",onlynew\=>false} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.StaticVariableInHeaderProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.StaticVariableInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Static variable in header file\\")"} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.SymbolShadowingProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.SymbolShadowingProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol shadowing\\")",paramFuncParameters\=>true} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Using directive in header\\")"} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"} +org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem=-Error +org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Virtual method call in constructor/destructor\\")"} diff --git a/.settings/org.eclipse.cdt.ui.prefs b/.settings/org.eclipse.cdt.ui.prefs new file mode 100644 index 0000000..4ee12a4 --- /dev/null +++ b/.settings/org.eclipse.cdt.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +formatter_settings_version=1 diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..d1cbb65 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//main/app_main.c=GBK +encoding//main/led.c=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.core.runtime.prefs b/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000..deae05a --- /dev/null +++ b/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/components/rtk/rtk.c b/components/rtk/rtk.c index 2e4b06e..f9e5e70 100644 --- a/components/rtk/rtk.c +++ b/components/rtk/rtk.c @@ -40,6 +40,8 @@ static const char *RTK_TAG = "RTK"; static const char *NMEA_TAG = "NMEA"; static const char *NTRIP_TAG = "NTRIP"; +extern int led2; + /** * @brief GPS parser library runtime structure * @@ -652,11 +654,11 @@ static void nmea_task_entry(void *arg) } /** - * @brief HTTP事件处理 + * @brief HTTP锟铰硷拷锟斤拷锟斤拷 * - * @param evt HTTP事件 + * @param evt HTTP锟铰硷拷 * - * @return esp_err_t 操作状态 + * @return esp_err_t 锟斤拷锟斤拷状态 */ static esp_err_t http_event_handler(esp_http_client_event_t *evt) { @@ -835,11 +837,14 @@ rtk_handle_t rtk_init(const rtk_config_t *config) /*Error Handling*/ err_nmea_task_create: + led2 = 1; esp_event_loop_delete(esp_gps->event_loop_hdl); err_ntrip_task_create: + led2 = 1; vTaskDelete(esp_gps->ntrip_tsk_hdl); err_eloop: err_uart_install: + led2 = 1; uart_driver_delete(esp_gps->uart_port); err_uart_config: err_buffer: diff --git a/main/app_main.c b/main/app_main.c index c3f3005..cf30a8d 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -60,6 +60,10 @@ static char sub_topic_voice[TOPIC_LEN_MAX]=""; static char sub_topic_beep[TOPIC_LEN_MAX]=""; static char sub_topic_light[TOPIC_LEN_MAX]=""; +extern int led1; +extern int led2; +extern int led3; + static void beep_init(void) { /*beep gpio set*/ @@ -81,7 +85,7 @@ static void beep_off(void) static void topic_fill_device_id(void) { - //获取nodeid + //锟斤拷取nodeid uint64_t nodeid; dwm_init(); assert(RV_OK == dwm_node_id_get(&nodeid)); @@ -89,12 +93,12 @@ static void topic_fill_device_id(void) nodeid &= 0xffff; ESP_LOGI(TAG,"Node ID:%04x",(uint16_t)nodeid); - //设备端发布Topic + //锟借备锟剿凤拷锟斤拷Topic snprintf(pub_topic_status,TOPIC_LEN_MAX,"status/%04x",(uint16_t)nodeid); snprintf(pub_topic_nmea,TOPIC_LEN_MAX,"rtk/%04x/nmea",(uint16_t)nodeid); snprintf(pub_topic_rtk_location,TOPIC_LEN_MAX,"rtk/%04x/location",(uint16_t)nodeid); - //设备端订阅Topic + //锟借备锟剿讹拷锟斤拷Topic snprintf(sub_topic_voice,TOPIC_LEN_MAX,"alarm/%04x/voice",(uint16_t)nodeid); snprintf(sub_topic_beep,TOPIC_LEN_MAX,"alarm/%04x/beep",(uint16_t)nodeid); snprintf(sub_topic_light,TOPIC_LEN_MAX,"alarm/%04x/light",(uint16_t)nodeid); @@ -158,7 +162,7 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) else if(0 == strncmp(event->topic, sub_topic_light, event->topic_len)) { strncpy(string, event->data, event->data_len); - led_set_rgb(string); + led_set_rgb(string,1); } else if(0 == strncmp(event->topic, sub_topic_voice, event->topic_len)) { @@ -229,8 +233,14 @@ static void mqtt_app_start(void) #endif /* CONFIG_BROKER_URL_FROM_STDIN */ client = esp_mqtt_client_init(&mqtt_cfg); - esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client); - esp_mqtt_client_start(client); + esp_err_t err = esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client); + if(err ==0){ + led2 = 0; + } + err = esp_mqtt_client_start(client); + if(err != ESP_OK){ + led2 = 0; + } } /** @@ -249,8 +259,8 @@ static void gps_event_handler(void *event_handler_arg, esp_event_base_t event_ba gps = (gps_t *)event_data; /* print information parsed from GPS statements */ // ESP_LOGI(TAG, "%d/%d/%d %d:%d:%d => \r\n" -// "\t\t\t\t\t\tlatitude = %.05f°N\r\n" -// "\t\t\t\t\t\tlongitude = %.05f°E\r\n" +// "\t\t\t\t\t\tlatitude = %.05f锟斤拷N\r\n" +// "\t\t\t\t\t\tlongitude = %.05f锟斤拷E\r\n" // "\t\t\t\t\t\taltitude = %.02fm\r\n" // "\t\t\t\t\t\tspeed = %fm/s\r\n" // "\t\t\t\t\t\tfixmode = %d\r\n" @@ -287,6 +297,10 @@ void app_main(void) esp_log_level_set("TRANSPORT", ESP_LOG_VERBOSE); esp_log_level_set("OUTBOX", ESP_LOG_VERBOSE); + led1=0; + led2=3; + led3 = 0; + topic_fill_device_id(); led_set_rgb_int(); @@ -297,34 +311,8 @@ void app_main(void) frst_init(); - //initialized - //beep x2 - beep_on(); - usleep(50*1000); - beep_off(); - usleep(50*1000); - beep_on(); - usleep(50*1000); - beep_off(); - usleep(50*1000); - provisioning(); - //connected - //beep x3 - beep_on(); - usleep(50*1000); - beep_off(); - usleep(50*1000); - beep_on(); - usleep(50*1000); - beep_off(); - usleep(50*1000); - beep_on(); - usleep(50*1000); - beep_off(); - usleep(50*1000); - mqtt_app_start(); /* NMEA parser configuration */ @@ -335,4 +323,6 @@ void app_main(void) /* register event handler for NMEA parser library */ rtk_add_handler(rtk_hdl, gps_event_handler, NULL); + led1 = 1; + } diff --git a/main/led.c b/main/led.c index aee6955..a09b660 100644 --- a/main/led.c +++ b/main/led.c @@ -1,7 +1,7 @@ /* * led.c * - * Created on: 2022年3月8日 + * Created on: 2022閿熸枻鎷3閿熸枻鎷8閿熸枻鎷 * Author: yinjunlin */ #include "sdkconfig.h" @@ -27,16 +27,20 @@ int c2i(char ch); int hex2dec(char *hex); static led_strip_t *strip; +int led1; +int led2; +int led3; + /* - * 将字符转换为数值 + * 閿熸枻鎷烽敓琛楀嚖鎷疯浆閿熸枻鎷蜂负閿熸枻鎷峰 * */ int c2i(char ch) { - // 如果是数字,则用数字的ASCII码减去48, 如果ch = '2' ,则 '2' - 48 = 2 + // 閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閮戦敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷峰奸敓绱窼CII閿熸枻鎷烽敓楗猴拷48, 閿熸枻鎷烽敓绲歨 = '2' ,閿熸枻鎷 '2' - 48 = 2 if (isdigit(ch)) return ch - 48; - // 如果是字母,但不是A~F,a~f则返回 + // 閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓渚ラ潻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熺锤~F,a~f閿熸触杩斾紮鎷 if (ch < 'A' || (ch > 'F' && ch < 'a') || ch > 'z') { if (ch == '#') @@ -45,17 +49,17 @@ int c2i(char ch) } return -1; } - // 如果是大写字母,则用数字的ASCII码减去55, 如果ch = 'A' ,则 'A' - 55 = 10 - // 如果是小写字母,则用数字的ASCII码减去87, 如果ch = 'a' ,则 'a' - 87 = 10 + // 閿熸枻鎷烽敓鏂ゆ嫹璋撮敓鍙揪鎷烽敓渚ラ潻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷峰奸敓绱窼CII閿熸枻鎷烽敓楗猴拷55, 閿熸枻鎷烽敓绲歨 = 'A' ,閿熸枻鎷 'A' - 55 = 10 + // 閿熸枻鎷烽敓鏂ゆ嫹閿熷彨鈱掕揪鎷烽敓渚ラ潻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷峰奸敓绱窼CII閿熸枻鎷烽敓楗猴拷87, 閿熸枻鎷烽敓绲歨 = 'a' ,閿熸枻鎷 'a' - 87 = 10 if (isalpha(ch)) return isupper(ch) ? ch - 55 : ch - 87; - //以上情况都不是 + //閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿燂拷 return -1; } /* - * 功能:将十六进制字符串转换为整型(int)数值 + * 閿熸枻鎷烽敓鏉帮綇鎷烽敓鏂ゆ嫹鍗侀敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熻鍑ゆ嫹閿熸枻鎷疯浆閿熸枻鎷蜂负閿熸枻鎷烽敓鏂ゆ嫹(int)閿熸枻鎷峰 * */ int hex2dec(char *hex) @@ -66,55 +70,88 @@ int hex2dec(char *hex) int bits; int i; - // 当 字符hex = "1de" 长度为3, hex是main函数传递的,得到的返回值是0x1de + // 閿熸枻鎷 閿熻鍑ゆ嫹hex = "1de" 閿熸枻鎷烽敓鏂ゆ嫹涓3, hex閿熸枻鎷穖ain閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鎹风殑锝忔嫹閿熺煫纰夋嫹閿熶茎鍑ゆ嫹閿熸枻鎷峰奸敓鏂ゆ嫹0x1de len = strlen(hex); for (i = 0, temp = 0; i < len; i++, temp = 0) { - // 第一次:i=0, *(hex + i) = *(hex + 0) = '1', 即temp = 1 - // 第二次:i=1, *(hex + i) = *(hex + 1) = 'd', 即temp = 13 - // 第三次:i=2, *(hex + i) = *(hex + 2) = 'e', 即temp = 14 + // 閿熸枻鎷蜂竴閿熻娇锝忔嫹i=0, *(hex + i) = *(hex + 0) = '1', 閿熸枻鎷穞emp = 1 + // 閿熻妭璁规嫹閿熻娇锝忔嫹i=1, *(hex + i) = *(hex + 1) = 'd', 閿熸枻鎷穞emp = 13 + // 閿熸枻鎷烽敓鏂ゆ嫹閿熻娇锝忔嫹i=2, *(hex + i) = *(hex + 2) = 'e', 閿熸枻鎷穞emp = 14 temp = c2i(*(hex + i)); - // 总共3位,一个16进制位用 4 bit保存 - // 第一次:'1'为最高位,所以temp左移 (len - i -1) * 4 = 2 * 4 = 8 位 - // 第二次:'d'为次高位,所以temp左移 (len - i -1) * 4 = 1 * 4 = 4 位 - // 第三次:'e'为最低位,所以temp左移 (len - i -1) * 4 = 0 * 4 = 0 位 + // 閿熸澃鐧告嫹3浣嶉敓鏂ゆ嫹涓閿熸枻鎷16閿熸枻鎷烽敓鏂ゆ嫹浣嶉敓鏂ゆ嫹 4 bit閿熸枻鎷烽敓鏂ゆ嫹 + // 閿熸枻鎷蜂竴閿熻娇锝忔嫹'1'涓洪敓鏂ゆ嫹閿熻娇浼欐嫹閿熸枻鎷烽敓鏂ゆ嫹閿熺但emp閿熸枻鎷烽敓鏂ゆ嫹 (len - i -1) * 4 = 2 * 4 = 8 浣 + // 閿熻妭璁规嫹閿熻娇锝忔嫹'd'涓洪敓杞块潻鎷蜂綅閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷穞emp閿熸枻鎷烽敓鏂ゆ嫹 (len - i -1) * 4 = 1 * 4 = 4 浣 + // 閿熸枻鎷烽敓鏂ゆ嫹閿熻娇锝忔嫹'e'涓洪敓鏂ゆ嫹閿熻娇浼欐嫹閿熸枻鎷烽敓鏂ゆ嫹閿熺但emp閿熸枻鎷烽敓鏂ゆ嫹 (len - i -1) * 4 = 0 * 4 = 0 浣 bits = (len - i - 1) * 4; temp = temp << bits; - // 此处也可以用 num += temp;进行累加 + // 閿熷壙杈炬嫹涔熼敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹 num += temp;閿熸枻鎷烽敓鏂ゆ嫹閿熸纭锋嫹 num = num | temp; } - // 返回结果 + // 閿熸枻鎷烽敓鎴枻鎷烽敓锟 return num; } +void led_set_rgb(char* string,int num) +{ + int rgb = hex2dec(string); + uint32_t green = 0x00ff00 & rgb; + green = green >> 8; + uint32_t red = 0xff0000 & rgb; + red = red >> 16; + uint32_t blue = 0x0000ff & rgb; + //Write RGB values to strip driver + ESP_ERROR_CHECK(strip->set_pixel(strip, num, red, green, blue));//Set RGB for a specific pixel + ESP_ERROR_CHECK(strip->refresh(strip, 100));//Refresh memory colors to LEDs +} + +void alarm_task_entry(void * pvParameters){ + //led_set_rgb("#b1d85c"); + while(1){ + switch(led1){ + case 1: //MQTT NTRIP CONNECTED + led_set_rgb("#00FF00",0); break; + case 0: //DISCONNECTED + led_set_rgb("#FF0000",0); break; + } + switch(led2){ + case 0: //MQTT ERROR + led_set_rgb("#0000FF",1); break; + case 1: //WIFI ERROR + led_set_rgb("#00FF00",1); break; + case 2: //NTRIP ERROR + led_set_rgb("#FF0000",1); break; + case 3: + led_set_rgb("#000000",1); break; + } + switch(led3){ + case 0: + led_set_rgb("#000000",2); break; + case 1: + led_set_rgb("#0000FF",2); + break; + } + } + +} void led_set_rgb_int(void) { rmt_config_t config = - RMT_DEFAULT_CONFIG_TX(CONFIG_EXAMPLE_RMT_TX_GPIO, RMT_TX_CHANNEL);//GPIO_26输出 + RMT_DEFAULT_CONFIG_TX(CONFIG_EXAMPLE_RMT_TX_GPIO, RMT_TX_CHANNEL);//GPIO_26閿熸枻鎷烽敓锟 config.clk_div = 2; rmt_config(&config); rmt_driver_install(config.channel, 0, 0); led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(CONFIG_EXAMPLE_STRIP_LED_NUMBER, (led_strip_dev_t)config.channel); strip = led_strip_new_rmt_ws2812(&strip_config); + xTaskCreate( + alarm_task_entry, + "alarm", + 2048, + ( void * ) 1, + 3, + NULL); } -void led_set_rgb(char* string ) -{ - int rgb = hex2dec(string); - uint32_t green = 0x00ff00 & rgb; - green = green >> 8; - uint32_t red = 0xff0000 & rgb; - red = red >> 16; - uint32_t blue = 0x0000ff & rgb; - for (int j = 0; j < CONFIG_EXAMPLE_STRIP_LED_NUMBER; j += 1) - { - //Write RGB values to strip driver - ESP_ERROR_CHECK(strip->set_pixel(strip, j, red, green, blue));//Set RGB for a specific pixel - } - ESP_ERROR_CHECK(strip->refresh(strip, 100));//Refresh memory colors to LEDs - -} diff --git a/main/led.h b/main/led.h index 038c5b2..23f269a 100644 --- a/main/led.h +++ b/main/led.h @@ -1,19 +1,23 @@ /* * led.h * - * Created on: 2022年3月8日 + * Created on: 2022锟斤拷3锟斤拷8锟斤拷 * Author: yinjunlin */ #ifndef MAIN_LED_H_ #define MAIN_LED_H_ +#define MQTT_ NTRIP_CONNECTED 0 + /* - * 功能:控制指示灯亮灭 - * @param string:RGB888格式的颜色值 + * 锟斤拷锟杰o拷锟斤拷锟斤拷指示锟斤拷锟斤拷锟斤拷 + * @param string:RGB888锟斤拷式锟斤拷锟斤拷色值 * */ -void led_set_rgb(char* string); +void led_set_rgb(char* string,int num); /* - * 功能:led硬件初始化 + * 锟斤拷锟杰o拷led硬锟斤拷锟斤拷始锟斤拷 * */ void led_set_rgb_int(void); +void alarm_task_entry(void * pvParameters); + #endif /* MAIN_LED_H_ */ diff --git a/main/provisioning.c b/main/provisioning.c index d4fbe7e..17c4bd9 100644 --- a/main/provisioning.c +++ b/main/provisioning.c @@ -1,7 +1,7 @@ /* * provisioning.c * - * Created on: 2022年3月20日 + * Created on: 2022锟斤拷3锟斤拷20锟斤拷 * Author: soliber */ #include @@ -30,6 +30,8 @@ static const char *TAG = "provision"; +extern int led3; + /* Signal Wi-Fi events on this event-group */ const int WIFI_CONNECTED_EVENT = BIT0; static EventGroupHandle_t wifi_event_group; @@ -112,7 +114,8 @@ static void IRAM_ATTR gpio_isr_handler(void *arg) { t_rise = esp_timer_get_time(); t_press = t_rise - t_fall; } - if (t_press > 10000000) { //大于10s,清除配网信息并重启 + if (t_press > 10000000) { //锟斤拷锟斤拷10s锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟较拷锟斤拷锟斤拷锟 + led3 = 1; ESP_ERROR_CHECK(nvs_flash_erase()); esp_wifi_restore(); esp_restart(); @@ -121,10 +124,10 @@ static void IRAM_ATTR gpio_isr_handler(void *arg) { void frst_init(void) { gpio_config_t io_conf; - io_conf.intr_type = GPIO_INTR_NEGEDGE; // 下降沿触发中断 - io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL; // 设置GPIO号 - io_conf.mode = GPIO_MODE_INPUT; // 模式输入 - io_conf.pull_up_en = GPIO_PULLUP_ENABLE; // 端口上拉使能 + io_conf.intr_type = GPIO_INTR_NEGEDGE; // 锟铰斤拷锟截达拷锟斤拷锟叫讹拷 + io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL; // 锟斤拷锟斤拷GPIO锟斤拷 + io_conf.mode = GPIO_MODE_INPUT; // 模式锟斤拷锟斤拷 + io_conf.pull_up_en = GPIO_PULLUP_ENABLE; // 锟剿匡拷锟斤拷锟斤拷使锟斤拷 gpio_config(&io_conf); gpio_set_intr_type(0, GPIO_INTR_ANYEDGE); gpio_install_isr_service(0); -- Gitee From d7a56836767b63b41deac0c1ec3956e4b1335464 Mon Sep 17 00:00:00 2001 From: blue <1607918099@qq.com> Date: Thu, 7 Apr 2022 17:50:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=B0=B1=E5=B7=AE=E9=85=8D=E7=BD=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/app_main.c | 23 ------------ main/led.c | 87 ++++++++++++++++++++++++++++++++------------- main/led.h | 4 ++- main/provisioning.c | 2 +- 4 files changed, 67 insertions(+), 49 deletions(-) diff --git a/main/app_main.c b/main/app_main.c index cf30a8d..eb05680 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -41,8 +41,6 @@ #include "tts.h" #include "dwm_api.h" -#define BEEP_PIN 33 - static const char *TAG = "FHPL_ESP32_DEMO"; #define TIME_ZONE (+8) //Beijing Time @@ -64,25 +62,6 @@ extern int led1; extern int led2; extern int led3; -static void beep_init(void) -{ - /*beep gpio set*/ - gpio_set_level(BEEP_PIN, 0); - gpio_reset_pin(BEEP_PIN); - gpio_pad_select_gpio(BEEP_PIN); - gpio_set_direction(BEEP_PIN, GPIO_MODE_OUTPUT); -} - -static void beep_on(void) -{ - gpio_set_level(BEEP_PIN, 1); -} - -static void beep_off(void) -{ - gpio_set_level(BEEP_PIN, 0); -} - static void topic_fill_device_id(void) { //锟斤拷取nodeid @@ -307,8 +286,6 @@ void app_main(void) tts_init(); - beep_init(); - frst_init(); provisioning(); diff --git a/main/led.c b/main/led.c index a09b660..a8a3ee3 100644 --- a/main/led.c +++ b/main/led.c @@ -1,7 +1,7 @@ /* * led.c * - * Created on: 2022閿熸枻鎷3閿熸枻鎷8閿熸枻鎷 + * Created on: 2022闁跨喐鏋婚幏锟3闁跨喐鏋婚幏锟8闁跨喐鏋婚幏锟 * Author: yinjunlin */ #include "sdkconfig.h" @@ -24,6 +24,7 @@ #include "driver/rmt.h" #include "led_strip.h" #define RMT_TX_CHANNEL RMT_CHANNEL_0 //RMT channel number 0 +#define BEEP_PIN 33 int c2i(char ch); int hex2dec(char *hex); static led_strip_t *strip; @@ -31,16 +32,33 @@ int led1; int led2; int led3; +void beep_init(void) +{ + /*beep gpio set*/ + gpio_set_level(BEEP_PIN, 0); + gpio_reset_pin(BEEP_PIN); + gpio_pad_select_gpio(BEEP_PIN); + gpio_set_direction(BEEP_PIN, GPIO_MODE_OUTPUT); +} +void beep_on(void) +{ + gpio_set_level(BEEP_PIN, 1); +} + +void beep_off(void) +{ + gpio_set_level(BEEP_PIN, 0); +} /* - * 閿熸枻鎷烽敓琛楀嚖鎷疯浆閿熸枻鎷蜂负閿熸枻鎷峰 + * 闁跨喐鏋婚幏鐑芥晸鐞涙鍤栭幏鐤祮闁跨喐鏋婚幏铚傝礋闁跨喐鏋婚幏宄帮拷锟 * */ int c2i(char ch) { - // 閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閮戦敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷峰奸敓绱窼CII閿熸枻鎷烽敓楗猴拷48, 閿熸枻鎷烽敓绲歨 = '2' ,閿熸枻鎷 '2' - 48 = 2 + // 闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔告灮閹风兘鏁撻弬銈嗗闁垿鏁撻弬銈嗗闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔告灮閹峰嘲锟藉ジ鏁撶槐绐糃II闁跨喐鏋婚幏鐑芥晸妤楃尨鎷48, 闁跨喐鏋婚幏鐑芥晸缁叉 = '2' ,闁跨喐鏋婚幏锟 '2' - 48 = 2 if (isdigit(ch)) return ch - 48; - // 閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓渚ラ潻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熺锤~F,a~f閿熸触杩斾紮鎷 + // 闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔告灮閹风兘鏁撴笟銉╂交閹风兘鏁撻弬銈嗗闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔洪敜~F,a~f闁跨喐瑙︽潻鏂剧串閹凤拷 if (ch < 'A' || (ch > 'F' && ch < 'a') || ch > 'z') { if (ch == '#') @@ -49,17 +67,17 @@ int c2i(char ch) } return -1; } - // 閿熸枻鎷烽敓鏂ゆ嫹璋撮敓鍙揪鎷烽敓渚ラ潻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷峰奸敓绱窼CII閿熸枻鎷烽敓楗猴拷55, 閿熸枻鎷烽敓绲歨 = 'A' ,閿熸枻鎷 'A' - 55 = 10 - // 閿熸枻鎷烽敓鏂ゆ嫹閿熷彨鈱掕揪鎷烽敓渚ラ潻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷峰奸敓绱窼CII閿熸枻鎷烽敓楗猴拷87, 閿熸枻鎷烽敓绲歨 = 'a' ,閿熸枻鎷 'a' - 87 = 10 + // 闁跨喐鏋婚幏鐑芥晸閺傘倖瀚圭拫鎾晸閸欘偉鎻幏鐑芥晸娓氥儵娼婚幏鐑芥晸閺傘倖瀚归柨鐔告灮閹风兘鏁撻弬銈嗗闁跨喐鏋婚幏宄帮拷濂告晸缁辩CII闁跨喐鏋婚幏鐑芥晸妤楃尨鎷55, 闁跨喐鏋婚幏鐑芥晸缁叉 = 'A' ,闁跨喐鏋婚幏锟 'A' - 55 = 10 + // 闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔峰建閳辨帟鎻幏鐑芥晸娓氥儵娼婚幏鐑芥晸閺傘倖瀚归柨鐔告灮閹风兘鏁撻弬銈嗗闁跨喐鏋婚幏宄帮拷濂告晸缁辩CII闁跨喐鏋婚幏鐑芥晸妤楃尨鎷87, 闁跨喐鏋婚幏鐑芥晸缁叉 = 'a' ,闁跨喐鏋婚幏锟 'a' - 87 = 10 if (isalpha(ch)) return isupper(ch) ? ch - 55 : ch - 87; - //閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿燂拷 + //闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔告灮閹风兘鏁撻弬銈嗗闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐕傛嫹 return -1; } /* - * 閿熸枻鎷烽敓鏉帮綇鎷烽敓鏂ゆ嫹鍗侀敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹閿熻鍑ゆ嫹閿熸枻鎷疯浆閿熸枻鎷蜂负閿熸枻鎷烽敓鏂ゆ嫹(int)閿熸枻鎷峰 + * 闁跨喐鏋婚幏鐑芥晸閺夊府缍囬幏鐑芥晸閺傘倖瀚归崡渚鏁撻弬銈嗗闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔活敎閸戙倖瀚归柨鐔告灮閹风柉娴嗛柨鐔告灮閹疯渹璐熼柨鐔告灮閹风兘鏁撻弬銈嗗(int)闁跨喐鏋婚幏宄帮拷锟 * */ int hex2dec(char *hex) @@ -70,27 +88,27 @@ int hex2dec(char *hex) int bits; int i; - // 閿熸枻鎷 閿熻鍑ゆ嫹hex = "1de" 閿熸枻鎷烽敓鏂ゆ嫹涓3, hex閿熸枻鎷穖ain閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷烽敓鎹风殑锝忔嫹閿熺煫纰夋嫹閿熶茎鍑ゆ嫹閿熸枻鎷峰奸敓鏂ゆ嫹0x1de + // 闁跨喐鏋婚幏锟 闁跨喕顢滈崙銈嗗hex = "1de" 闁跨喐鏋婚幏鐑芥晸閺傘倖瀚规稉锟3, hex闁跨喐鏋婚幏绌朼in闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔告灮閹风兘鏁撻幑椋庢畱閿濆繑瀚归柨鐔虹叓绾板瀚归柨鐔惰寧閸戙倖瀚归柨鐔告灮閹峰嘲锟藉ジ鏁撻弬銈嗗0x1de len = strlen(hex); for (i = 0, temp = 0; i < len; i++, temp = 0) { - // 閿熸枻鎷蜂竴閿熻娇锝忔嫹i=0, *(hex + i) = *(hex + 0) = '1', 閿熸枻鎷穞emp = 1 - // 閿熻妭璁规嫹閿熻娇锝忔嫹i=1, *(hex + i) = *(hex + 1) = 'd', 閿熸枻鎷穞emp = 13 - // 閿熸枻鎷烽敓鏂ゆ嫹閿熻娇锝忔嫹i=2, *(hex + i) = *(hex + 2) = 'e', 閿熸枻鎷穞emp = 14 + // 闁跨喐鏋婚幏铚傜闁跨喕濞囬敐蹇斿i=0, *(hex + i) = *(hex + 0) = '1', 闁跨喐鏋婚幏绌瀍mp = 1 + // 闁跨喕濡拋瑙勫闁跨喕濞囬敐蹇斿i=1, *(hex + i) = *(hex + 1) = 'd', 闁跨喐鏋婚幏绌瀍mp = 13 + // 闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔诲▏閿濆繑瀚筰=2, *(hex + i) = *(hex + 2) = 'e', 闁跨喐鏋婚幏绌瀍mp = 14 temp = c2i(*(hex + i)); - // 閿熸澃鐧告嫹3浣嶉敓鏂ゆ嫹涓閿熸枻鎷16閿熸枻鎷烽敓鏂ゆ嫹浣嶉敓鏂ゆ嫹 4 bit閿熸枻鎷烽敓鏂ゆ嫹 - // 閿熸枻鎷蜂竴閿熻娇锝忔嫹'1'涓洪敓鏂ゆ嫹閿熻娇浼欐嫹閿熸枻鎷烽敓鏂ゆ嫹閿熺但emp閿熸枻鎷烽敓鏂ゆ嫹 (len - i -1) * 4 = 2 * 4 = 8 浣 - // 閿熻妭璁规嫹閿熻娇锝忔嫹'd'涓洪敓杞块潻鎷蜂綅閿熸枻鎷烽敓鏂ゆ嫹閿熸枻鎷穞emp閿熸枻鎷烽敓鏂ゆ嫹 (len - i -1) * 4 = 1 * 4 = 4 浣 - // 閿熸枻鎷烽敓鏂ゆ嫹閿熻娇锝忔嫹'e'涓洪敓鏂ゆ嫹閿熻娇浼欐嫹閿熸枻鎷烽敓鏂ゆ嫹閿熺但emp閿熸枻鎷烽敓鏂ゆ嫹 (len - i -1) * 4 = 0 * 4 = 0 浣 + // 闁跨喐婢冮惂鍛婂3娴e秹鏁撻弬銈嗗娑擄拷闁跨喐鏋婚幏锟16闁跨喐鏋婚幏鐑芥晸閺傘倖瀚规担宥夋晸閺傘倖瀚 4 bit闁跨喐鏋婚幏鐑芥晸閺傘倖瀚 + // 闁跨喐鏋婚幏铚傜闁跨喕濞囬敐蹇斿'1'娑撴椽鏁撻弬銈嗗闁跨喕濞囨导娆愬闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔轰絾emp闁跨喐鏋婚幏鐑芥晸閺傘倖瀚 (len - i -1) * 4 = 2 * 4 = 8 娴o拷 + // 闁跨喕濡拋瑙勫闁跨喕濞囬敐蹇斿'd'娑撴椽鏁撴潪鍧楁交閹疯渹缍呴柨鐔告灮閹风兘鏁撻弬銈嗗闁跨喐鏋婚幏绌瀍mp闁跨喐鏋婚幏鐑芥晸閺傘倖瀚 (len - i -1) * 4 = 1 * 4 = 4 娴o拷 + // 闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔诲▏閿濆繑瀚'e'娑撴椽鏁撻弬銈嗗闁跨喕濞囨导娆愬闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔轰絾emp闁跨喐鏋婚幏鐑芥晸閺傘倖瀚 (len - i -1) * 4 = 0 * 4 = 0 娴o拷 bits = (len - i - 1) * 4; temp = temp << bits; - // 閿熷壙杈炬嫹涔熼敓鏂ゆ嫹閿熸枻鎷烽敓鏂ゆ嫹 num += temp;閿熸枻鎷烽敓鏂ゆ嫹閿熸纭锋嫹 + // 闁跨喎澹欐潏鐐娑旂喖鏁撻弬銈嗗闁跨喐鏋婚幏鐑芥晸閺傘倖瀚 num += temp;闁跨喐鏋婚幏鐑芥晸閺傘倖瀚归柨鐔割敊绾攱瀚 num = num | temp; } - // 閿熸枻鎷烽敓鎴枻鎷烽敓锟 + // 闁跨喐鏋婚幏鐑芥晸閹搭亝鏋婚幏鐑芥晸閿燂拷 return num; } void led_set_rgb(char* string,int num) @@ -111,17 +129,33 @@ void alarm_task_entry(void * pvParameters){ while(1){ switch(led1){ case 1: //MQTT NTRIP CONNECTED - led_set_rgb("#00FF00",0); break; + led_set_rgb("#00FF00",0); + beep_on(); + usleep(50*1000); + beep_off(); + break; case 0: //DISCONNECTED led_set_rgb("#FF0000",0); break; } switch(led2){ case 0: //MQTT ERROR - led_set_rgb("#0000FF",1); break; + led_set_rgb("#0000FF",1); + beep_on(); + usleep(50*1000); + beep_off(); + break; case 1: //WIFI ERROR - led_set_rgb("#00FF00",1); break; + led_set_rgb("#00FF00",1); + beep_on(); + usleep(50*1000); + beep_off(); + break; case 2: //NTRIP ERROR - led_set_rgb("#FF0000",1); break; + led_set_rgb("#FF0000",1); + beep_on(); + usleep(50*1000); + beep_off(); + break; case 3: led_set_rgb("#000000",1); break; } @@ -129,7 +163,11 @@ void alarm_task_entry(void * pvParameters){ case 0: led_set_rgb("#000000",2); break; case 1: - led_set_rgb("#0000FF",2); + for(int i=1;i<11;i++){ + usleep(1000*1000); + printf("time:%d",i); + } + led_set_rgb("#FF0000",2); break; } } @@ -137,8 +175,9 @@ void alarm_task_entry(void * pvParameters){ } void led_set_rgb_int(void) { + beep_init(); rmt_config_t config = - RMT_DEFAULT_CONFIG_TX(CONFIG_EXAMPLE_RMT_TX_GPIO, RMT_TX_CHANNEL);//GPIO_26閿熸枻鎷烽敓锟 + RMT_DEFAULT_CONFIG_TX(CONFIG_EXAMPLE_RMT_TX_GPIO, RMT_TX_CHANNEL);//GPIO_26闁跨喐鏋婚幏鐑芥晸閿燂拷 config.clk_div = 2; rmt_config(&config); rmt_driver_install(config.channel, 0, 0); diff --git a/main/led.h b/main/led.h index 23f269a..828589a 100644 --- a/main/led.h +++ b/main/led.h @@ -8,7 +8,6 @@ #ifndef MAIN_LED_H_ #define MAIN_LED_H_ #define MQTT_ NTRIP_CONNECTED 0 - /* * 锟斤拷锟杰o拷锟斤拷锟斤拷指示锟斤拷锟斤拷锟斤拷 * @param string:RGB888锟斤拷式锟斤拷锟斤拷色值 @@ -19,5 +18,8 @@ void led_set_rgb(char* string,int num); * */ void led_set_rgb_int(void); void alarm_task_entry(void * pvParameters); +void beep_init(void); +void beep_on(void); +void beep_off(void); #endif /* MAIN_LED_H_ */ diff --git a/main/provisioning.c b/main/provisioning.c index 17c4bd9..5568664 100644 --- a/main/provisioning.c +++ b/main/provisioning.c @@ -110,12 +110,12 @@ static void IRAM_ATTR gpio_isr_handler(void *arg) { static int t_rise = 0; if (gpio_get_level(ResetPin) == 0) { t_fall = esp_timer_get_time(); //current time + led3=1; } else if (gpio_get_level(ResetPin) == 1) { t_rise = esp_timer_get_time(); t_press = t_rise - t_fall; } if (t_press > 10000000) { //锟斤拷锟斤拷10s锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟较拷锟斤拷锟斤拷锟 - led3 = 1; ESP_ERROR_CHECK(nvs_flash_erase()); esp_wifi_restore(); esp_restart(); -- Gitee From efed67131163d72c9a2d0ba3d423fa9a87bb7a40 Mon Sep 17 00:00:00 2001 From: blue <1607918099@qq.com> Date: Fri, 8 Apr 2022 15:44:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/rtk/rtk.c | 7 +++++- main/app_main.c | 21 ++++++++++------ main/led.c | 59 +++++++++++++++++++++++++++++++++++++++----- main/provisioning.c | 3 +++ 4 files changed, 75 insertions(+), 15 deletions(-) diff --git a/components/rtk/rtk.c b/components/rtk/rtk.c index f9e5e70..4ae8fc7 100644 --- a/components/rtk/rtk.c +++ b/components/rtk/rtk.c @@ -40,7 +40,9 @@ static const char *RTK_TAG = "RTK"; static const char *NMEA_TAG = "NMEA"; static const char *NTRIP_TAG = "NTRIP"; +extern int led1; extern int led2; +extern bool alarm_flag; /** * @brief GPS parser library runtime structure @@ -832,19 +834,22 @@ rtk_handle_t rtk_init(const rtk_config_t *config) goto err_nmea_task_create; } ESP_LOGI(RTK_TAG, "NMEA Parser init OK"); - + led1=1; return esp_gps; /*Error Handling*/ err_nmea_task_create: led2 = 1; + alarm_flag=true; esp_event_loop_delete(esp_gps->event_loop_hdl); err_ntrip_task_create: led2 = 1; + alarm_flag=true; vTaskDelete(esp_gps->ntrip_tsk_hdl); err_eloop: err_uart_install: led2 = 1; + alarm_flag=true; uart_driver_delete(esp_gps->uart_port); err_uart_config: err_buffer: diff --git a/main/app_main.c b/main/app_main.c index eb05680..162d8de 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -58,9 +58,13 @@ static char sub_topic_voice[TOPIC_LEN_MAX]=""; static char sub_topic_beep[TOPIC_LEN_MAX]=""; static char sub_topic_light[TOPIC_LEN_MAX]=""; + +extern int led0; extern int led1; extern int led2; extern int led3; +extern bool alarm_flag; + static void topic_fill_device_id(void) { @@ -212,13 +216,14 @@ static void mqtt_app_start(void) #endif /* CONFIG_BROKER_URL_FROM_STDIN */ client = esp_mqtt_client_init(&mqtt_cfg); - esp_err_t err = esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client); - if(err ==0){ - led2 = 0; - } - err = esp_mqtt_client_start(client); + esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client); + esp_err_t err = esp_mqtt_client_start(client); if(err != ESP_OK){ led2 = 0; + alarm_flag=true; + }else if(err == ESP_OK){ + led0=1; + alarm_flag=true; } } @@ -276,8 +281,9 @@ void app_main(void) esp_log_level_set("TRANSPORT", ESP_LOG_VERBOSE); esp_log_level_set("OUTBOX", ESP_LOG_VERBOSE); - led1=0; - led2=3; + led0 = 0; + led1 = 0; + led2 = 3; led3 = 0; topic_fill_device_id(); @@ -300,6 +306,5 @@ void app_main(void) /* register event handler for NMEA parser library */ rtk_add_handler(rtk_hdl, gps_event_handler, NULL); - led1 = 1; } diff --git a/main/led.c b/main/led.c index a8a3ee3..1351edc 100644 --- a/main/led.c +++ b/main/led.c @@ -23,14 +23,27 @@ #include "driver/rmt.h" #include "led_strip.h" + +#include "esp_event_base.h" #define RMT_TX_CHANNEL RMT_CHANNEL_0 //RMT channel number 0 #define BEEP_PIN 33 int c2i(char ch); int hex2dec(char *hex); static led_strip_t *strip; + +int led0; int led1; int led2; int led3; +bool alarm_flag=false; + +ESP_EVENT_DEFINE_BASE(TASK_EVENTS); +enum { + TASK_ITERATION_EVENT // raised during an iteration of the loop within the task +}; + +// Event loops +esp_event_loop_handle_t loop_with_task; void beep_init(void) { @@ -123,38 +136,62 @@ void led_set_rgb(char* string,int num) ESP_ERROR_CHECK(strip->set_pixel(strip, num, red, green, blue));//Set RGB for a specific pixel ESP_ERROR_CHECK(strip->refresh(strip, 100));//Refresh memory colors to LEDs } +void task_iteration_handler(void* handler_args, esp_event_base_t base, int32_t id, void* event_data) +{ + beep_on(); + usleep(50*1000); + beep_off(); +} void alarm_task_entry(void * pvParameters){ //led_set_rgb("#b1d85c"); while(1){ switch(led1){ case 1: //MQTT NTRIP CONNECTED + if(led0 == 1 && led1 == 1){ led_set_rgb("#00FF00",0); + if(alarm_flag){ beep_on(); - usleep(50*1000); + usleep(300*1000); beep_off(); + usleep(300*1000); + beep_on(); + usleep(300*1000); + beep_off(); + alarm_flag=false; + } + } break; case 0: //DISCONNECTED led_set_rgb("#FF0000",0); break; } switch(led2){ case 0: //MQTT ERROR - led_set_rgb("#0000FF",1); + led_set_rgb("#0000FF",1);\ + if(alarm_flag){ beep_on(); - usleep(50*1000); + usleep(300*1000); beep_off(); + alarm_flag=false; + } break; case 1: //WIFI ERROR led_set_rgb("#00FF00",1); + if(alarm_flag){ beep_on(); - usleep(50*1000); + usleep(300*1000); beep_off(); + alarm_flag=false; + } break; case 2: //NTRIP ERROR led_set_rgb("#FF0000",1); + if(alarm_flag){ beep_on(); - usleep(50*1000); + usleep(300*1000); beep_off(); + alarm_flag=false; + } break; case 3: led_set_rgb("#000000",1); break; @@ -183,7 +220,17 @@ void led_set_rgb_int(void) rmt_driver_install(config.channel, 0, 0); led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(CONFIG_EXAMPLE_STRIP_LED_NUMBER, (led_strip_dev_t)config.channel); - strip = led_strip_new_rmt_ws2812(&strip_config); + strip = led_strip_new_rmt_ws2812(&strip_config); + esp_event_loop_args_t loop_with_task_args = { + .queue_size = 5, + .task_name = "loop_task", // task will be created + .task_priority = uxTaskPriorityGet(NULL), + .task_stack_size = 2048, + .task_core_id = tskNO_AFFINITY + }; + // Create the event loops + ESP_ERROR_CHECK(esp_event_loop_create(&loop_with_task_args, &loop_with_task)); + ESP_ERROR_CHECK(esp_event_handler_instance_register_with(loop_with_task, TASK_EVENTS, TASK_ITERATION_EVENT, task_iteration_handler, loop_with_task, NULL)); xTaskCreate( alarm_task_entry, "alarm", diff --git a/main/provisioning.c b/main/provisioning.c index 5568664..8a465d1 100644 --- a/main/provisioning.c +++ b/main/provisioning.c @@ -30,6 +30,7 @@ static const char *TAG = "provision"; +extern int led2; extern int led3; /* Signal Wi-Fi events on this event-group */ @@ -68,6 +69,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, "\n\tPlease reset to factory and retry provisioning", (*reason == WIFI_PROV_STA_AUTH_ERROR) ? "Wi-Fi station authentication failed" : "Wi-Fi access-point not found"); + led2 = 1; #ifdef CONFIG_EXAMPLE_RESET_PROV_MGR_ON_FAILURE retries++; if (retries >= CONFIG_EXAMPLE_PROV_MGR_MAX_RETRY_CNT) { @@ -100,6 +102,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_EVENT); } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { ESP_LOGI(TAG, "Disconnected. Connecting to the AP again..."); + led2=1; esp_wifi_connect(); } } -- Gitee From df1130abe93d0144e49465a7edfd9891ea66c47a Mon Sep 17 00:00:00 2001 From: blue <1607918099@qq.com> Date: Fri, 8 Apr 2022 16:15:04 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/rtk/rtk.c | 10 +++++++--- main/app_main.c | 2 ++ main/led.c | 7 ++----- main/provisioning.c | 13 +++++++++++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/components/rtk/rtk.c b/components/rtk/rtk.c index 4ae8fc7..8a15f9d 100644 --- a/components/rtk/rtk.c +++ b/components/rtk/rtk.c @@ -667,6 +667,8 @@ static esp_err_t http_event_handler(esp_http_client_event_t *evt) switch(evt->event_id) { case HTTP_EVENT_ERROR: ESP_LOGI(NTRIP_TAG, "HTTP_EVENT_ERROR"); + led2=2; + alarm_flag=true; break; case HTTP_EVENT_ON_CONNECTED: ESP_LOGI(NTRIP_TAG, "HTTP_EVENT_ON_CONNECTED"); @@ -707,6 +709,8 @@ static void ntrip_task_entry(void *arg) if(status != HttpStatus_Ok) { ESP_LOGE(NTRIP_TAG, "NTRIP Connect failed(%d)!\n", status); + led2=2; + alarm_flag=true; } else { @@ -839,16 +843,16 @@ rtk_handle_t rtk_init(const rtk_config_t *config) /*Error Handling*/ err_nmea_task_create: - led2 = 1; + led2 = 2; alarm_flag=true; esp_event_loop_delete(esp_gps->event_loop_hdl); err_ntrip_task_create: - led2 = 1; + led2 = 2; alarm_flag=true; vTaskDelete(esp_gps->ntrip_tsk_hdl); err_eloop: err_uart_install: - led2 = 1; + led2 = 2; alarm_flag=true; uart_driver_delete(esp_gps->uart_port); err_uart_config: diff --git a/main/app_main.c b/main/app_main.c index 162d8de..a95ea9c 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -165,6 +165,8 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) log_error_if_nonzero("captured as transport's socket errno", event->error_handle->esp_transport_sock_errno); ESP_LOGI(TAG, "Last errno string (%s)", strerror(event->error_handle->esp_transport_sock_errno)); } + led2 = 0; + alarm_flag=true; break; default: ESP_LOGI(TAG, "Other event id:%d", event->event_id); diff --git a/main/led.c b/main/led.c index 1351edc..6d580ba 100644 --- a/main/led.c +++ b/main/led.c @@ -150,14 +150,11 @@ void alarm_task_entry(void * pvParameters){ case 1: //MQTT NTRIP CONNECTED if(led0 == 1 && led1 == 1){ led_set_rgb("#00FF00",0); + led_set_rgb("#000000",1); if(alarm_flag){ beep_on(); usleep(300*1000); beep_off(); - usleep(300*1000); - beep_on(); - usleep(300*1000); - beep_off(); alarm_flag=false; } } @@ -193,7 +190,7 @@ void alarm_task_entry(void * pvParameters){ alarm_flag=false; } break; - case 3: + case 3: //close led_set_rgb("#000000",1); break; } switch(led3){ diff --git a/main/provisioning.c b/main/provisioning.c index 8a465d1..ffb865b 100644 --- a/main/provisioning.c +++ b/main/provisioning.c @@ -30,8 +30,10 @@ static const char *TAG = "provision"; +extern int led1; extern int led2; extern int led3; +extern bool alarm_flag; /* Signal Wi-Fi events on this event-group */ const int WIFI_CONNECTED_EVENT = BIT0; @@ -70,6 +72,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, (*reason == WIFI_PROV_STA_AUTH_ERROR) ? "Wi-Fi station authentication failed" : "Wi-Fi access-point not found"); led2 = 1; + alarm_flag=true; #ifdef CONFIG_EXAMPLE_RESET_PROV_MGR_ON_FAILURE retries++; if (retries >= CONFIG_EXAMPLE_PROV_MGR_MAX_RETRY_CNT) { @@ -80,8 +83,10 @@ static void event_handler(void* arg, esp_event_base_t event_base, #endif break; } - case WIFI_PROV_CRED_SUCCESS: + case WIFI_PROV_CRED_SUCCESS:{ ESP_LOGI(TAG, "Provisioning successful"); + led2 = 3; + } #ifdef CONFIG_EXAMPLE_RESET_PROV_MGR_ON_FAILURE retries = 0; #endif @@ -89,6 +94,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, case WIFI_PROV_END: /* De-initialize manager once provisioning is finished */ wifi_prov_mgr_deinit(); + led2 = 3; break; default: break; @@ -98,11 +104,14 @@ static void event_handler(void* arg, esp_event_base_t event_base, } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; ESP_LOGI(TAG, "Connected with IP Address:" IPSTR, IP2STR(&event->ip_info.ip)); + led2 = 3; /* Signal main application to continue execution */ xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_EVENT); } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { ESP_LOGI(TAG, "Disconnected. Connecting to the AP again..."); - led2=1; + led2 = 1; + led1 = 0; + alarm_flag=true; esp_wifi_connect(); } } -- Gitee