mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 05:06:30 +04:00
Compare commits
410 Commits
un1-9b1384
...
un1-a6b98c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e30b14d90 | ||
|
|
c07e3a34dd | ||
|
|
be7e11e60f | ||
|
|
e96e414561 | ||
|
|
0c99cb52ec | ||
|
|
ad9e1ce4df | ||
|
|
22dc5190d1 | ||
|
|
f2fd97d9c5 | ||
|
|
08084d5763 | ||
|
|
add1ad6949 | ||
|
|
87654e60b8 | ||
|
|
6f92cd645e | ||
|
|
23f6ea2e05 | ||
|
|
a6b98ccbbe | ||
|
|
ba5f590dab | ||
|
|
f1048733d2 | ||
|
|
ea7f68fcab | ||
|
|
8013aacd94 | ||
|
|
be8f409098 | ||
|
|
97e6fe8f4e | ||
|
|
54757428e6 | ||
|
|
bd39d81324 | ||
|
|
2a2078d9b5 | ||
|
|
01ca588488 | ||
|
|
f86eada292 | ||
|
|
bc777b2eff | ||
|
|
6f91fa42f0 | ||
|
|
e6d22ed147 | ||
|
|
436f70b69b | ||
|
|
ec9ce0cad7 | ||
|
|
7e2008095e | ||
|
|
92e440c77d | ||
|
|
666821e9ce | ||
|
|
1bca477a43 | ||
|
|
41571ce9ad | ||
|
|
038d098c85 | ||
|
|
b03cc8ddc3 | ||
|
|
c8e3d9b040 | ||
|
|
aeb02500de | ||
|
|
eadd7801af | ||
|
|
6d2b0a3b6c | ||
|
|
32a7642761 | ||
|
|
e8bb45496d | ||
|
|
3846852f2b | ||
|
|
17d01f5c29 | ||
|
|
e6bcba6959 | ||
|
|
e13edc2f70 | ||
|
|
de6ff1d9c9 | ||
|
|
bea15134ba | ||
|
|
28a55bf576 | ||
|
|
e70121e20f | ||
|
|
432ff41d6a | ||
|
|
87393a086c | ||
|
|
6000d47a0f | ||
|
|
d986ef4104 | ||
|
|
f85dc1675d | ||
|
|
7c7ac07e6a | ||
|
|
ca02826cfd | ||
|
|
96ad7f3cef | ||
|
|
c213ff596a | ||
|
|
b2589698ff | ||
|
|
3360f818a1 | ||
|
|
066da4080b | ||
|
|
b2c118f267 | ||
|
|
a8db46124e | ||
|
|
672e27f258 | ||
|
|
e762a68265 | ||
|
|
8659becc9d | ||
|
|
82e1e8af6a | ||
|
|
a71d05a114 | ||
|
|
8d68bf62a5 | ||
|
|
2c85adb270 | ||
|
|
e2123c55bb | ||
|
|
f5ff6438d1 | ||
|
|
9f3b80e606 | ||
|
|
111656d2c1 | ||
|
|
2045a29d3f | ||
|
|
26e46f9267 | ||
|
|
d003db0404 | ||
|
|
5a31e35dc2 | ||
|
|
c7cd5721ed | ||
|
|
fb476c29e6 | ||
|
|
d80329b323 | ||
|
|
3d3c422751 | ||
|
|
ed385594a3 | ||
|
|
787df44c79 | ||
|
|
f0eedc3243 | ||
|
|
365d055dc5 | ||
|
|
650ba8a91f | ||
|
|
654d6dc6ec | ||
|
|
18b70ac6b5 | ||
|
|
51369d6219 | ||
|
|
181533df1b | ||
|
|
d85731636f | ||
|
|
6f66f87fab | ||
|
|
85d4dedb15 | ||
|
|
0a4cddb84c | ||
|
|
4e17230290 | ||
|
|
aa99ac53c7 | ||
|
|
875f70196b | ||
|
|
1e71d212fe | ||
|
|
269a6ce562 | ||
|
|
cd2014c51b | ||
|
|
08f80ab645 | ||
|
|
14bd8f2c49 | ||
|
|
8ce5fae626 | ||
|
|
087bf41392 | ||
|
|
d390381d5a | ||
|
|
c3e31663ef | ||
|
|
c28e4ea733 | ||
|
|
96a3da24c9 | ||
|
|
9d4b318357 | ||
|
|
ef5d0aa483 | ||
|
|
66487abaee | ||
|
|
d2bb1ef4d3 | ||
|
|
0e15090629 | ||
|
|
1413d7c937 | ||
|
|
d97a3ef161 | ||
|
|
870dfd188c | ||
|
|
71a6844a5f | ||
|
|
d67d5da034 | ||
|
|
c894948d4f | ||
|
|
e25148ce72 | ||
|
|
07301935b5 | ||
|
|
3a1705bcf9 | ||
|
|
df87b04fa9 | ||
|
|
75f5efce03 | ||
|
|
00585fa16a | ||
|
|
30aaae33be | ||
|
|
c0e7c2a929 | ||
|
|
286b4876ce | ||
|
|
10c2ae5a05 | ||
|
|
8915c0c66c | ||
|
|
ec7676182a | ||
|
|
e23dbb9f99 | ||
|
|
19d201085b | ||
|
|
17a4e03656 | ||
|
|
1fd9240481 | ||
|
|
fc9996377d | ||
|
|
7f4b586b13 | ||
|
|
72de4af6db | ||
|
|
5bbb13c5c9 | ||
|
|
3efb093125 | ||
|
|
60bce7b8d8 | ||
|
|
8b05bd1106 | ||
|
|
668b7857b4 | ||
|
|
8b3b5fa802 | ||
|
|
a6052be0f1 | ||
|
|
007a3d295e | ||
|
|
28beff1ab6 | ||
|
|
9c95562fad | ||
|
|
83e036da14 | ||
|
|
8fd4225939 | ||
|
|
a3234995db | ||
|
|
98312860a6 | ||
|
|
9dbcd43e66 | ||
|
|
ffce0aeec9 | ||
|
|
361a239d3e | ||
|
|
51ffdcd3bc | ||
|
|
d47fdce337 | ||
|
|
3fbaad1488 | ||
|
|
b9a766d909 | ||
|
|
1b8684eb53 | ||
|
|
7a2b5be137 | ||
|
|
873e1f114b | ||
|
|
abce958db9 | ||
|
|
d4c44d7500 | ||
|
|
444035d06a | ||
|
|
c8c75d5f14 | ||
|
|
1fda069579 | ||
|
|
fccb99d847 | ||
|
|
4a61a28f57 | ||
|
|
b00117e02c | ||
|
|
6b91c660d4 | ||
|
|
9c3406895c | ||
|
|
ee6b59ab9d | ||
|
|
bd594c7134 | ||
|
|
4417a37a2e | ||
|
|
1b6794ce7c | ||
|
|
c96bfba95a | ||
|
|
fe8ad22132 | ||
|
|
bcb5af1813 | ||
|
|
77be3db143 | ||
|
|
7a2a1d6007 | ||
|
|
1c00709ea6 | ||
|
|
9ad96f782e | ||
|
|
67955b6ab8 | ||
|
|
37ce143527 | ||
|
|
771e948cfc | ||
|
|
9dc337a02c | ||
|
|
3ea01f8413 | ||
|
|
5623842892 | ||
|
|
a8d37879cb | ||
|
|
bcaf898c57 | ||
|
|
248d222459 | ||
|
|
fd230b6d09 | ||
|
|
d55da415c2 | ||
|
|
f94517fdab | ||
|
|
177fabe50c | ||
|
|
7930f73a4e | ||
|
|
b0633af0b6 | ||
|
|
e0efb2bf37 | ||
|
|
239eca0543 | ||
|
|
de4e7b9dd9 | ||
|
|
8e986c58c3 | ||
|
|
bbe5c9cae1 | ||
|
|
a3193e3bbd | ||
|
|
f34dafeecc | ||
|
|
f4c2744f16 | ||
|
|
e66e7fabed | ||
|
|
30ed8c1598 | ||
|
|
c2eeadc41e | ||
|
|
a1f4b8065a | ||
|
|
bda69f7650 | ||
|
|
5e03086d7b | ||
|
|
8e9795eec0 | ||
|
|
9e4d7a0c9b | ||
|
|
0f6f9ad52e | ||
|
|
0cabefbc24 | ||
|
|
4ea5dc4b5a | ||
|
|
8abb9e8a2b | ||
|
|
a07ab6175f | ||
|
|
61e76bc85c | ||
|
|
b52c63f6da | ||
|
|
e9ab581771 | ||
|
|
b62096fb91 | ||
|
|
ff33bc6aea | ||
|
|
d65c7b5f4c | ||
|
|
563cf986d6 | ||
|
|
123bd6fc65 | ||
|
|
77b19ec0db | ||
|
|
7f464f8be4 | ||
|
|
23433ce161 | ||
|
|
7de9c957d2 | ||
|
|
18891ade89 | ||
|
|
4588f38ae9 | ||
|
|
015fcf239c | ||
|
|
251b747b00 | ||
|
|
8955388a60 | ||
|
|
7afb4d0f41 | ||
|
|
6decd6fc7d | ||
|
|
e9e0079e30 | ||
|
|
f28ecec835 | ||
|
|
456cd611e8 | ||
|
|
58a33a51eb | ||
|
|
d1c79a83de | ||
|
|
5378789d14 | ||
|
|
bb05ccacb1 | ||
|
|
107d574c02 | ||
|
|
84204a3233 | ||
|
|
48691b2296 | ||
|
|
3a767c9c02 | ||
|
|
1a4d928e5c | ||
|
|
a8858e38b5 | ||
|
|
120b5d7c90 | ||
|
|
b7a6d18186 | ||
|
|
8d8481b17f | ||
|
|
ca8217b692 | ||
|
|
361895c689 | ||
|
|
789230458b | ||
|
|
6f77f537e3 | ||
|
|
b6254227b9 | ||
|
|
8323877120 | ||
|
|
f99c1a8c0a | ||
|
|
c41555b579 | ||
|
|
97b27261d5 | ||
|
|
1853359d78 | ||
|
|
ed2c607dd3 | ||
|
|
bd54c2b342 | ||
|
|
53aa5c71a0 | ||
|
|
a3932cfa6d | ||
|
|
1d787e6da8 | ||
|
|
10b0a611cf | ||
|
|
f537ccfe14 | ||
|
|
d37dbb29bf | ||
|
|
0ee4573a65 | ||
|
|
311b60f815 | ||
|
|
9ff35c9fc3 | ||
|
|
f14874b0e0 | ||
|
|
6c7611c57e | ||
|
|
4d388f4bde | ||
|
|
613c729025 | ||
|
|
079cadaeda | ||
|
|
0c0fb57410 | ||
|
|
e7a5d19f9c | ||
|
|
8e9043003f | ||
|
|
b67aaad6d5 | ||
|
|
e4c6158d65 | ||
|
|
23217f4a6a | ||
|
|
4fcb90928c | ||
|
|
68da151320 | ||
|
|
f70ec8f70e | ||
|
|
5e2a90c6f1 | ||
|
|
5272b81ae6 | ||
|
|
782593eafc | ||
|
|
d76ba20652 | ||
|
|
611b7e15ed | ||
|
|
274f17ed5a | ||
|
|
f09c5889dd | ||
|
|
39f936ce12 | ||
|
|
1350dcaf63 | ||
|
|
4629aee29c | ||
|
|
ffa3ff5e7c | ||
|
|
bacc8fa669 | ||
|
|
9c748860bb | ||
|
|
79c4b617c1 | ||
|
|
194727515b | ||
|
|
c714a32ea5 | ||
|
|
689da15346 | ||
|
|
1a4a6d4625 | ||
|
|
99a7d06f71 | ||
|
|
db4976c501 | ||
|
|
fc62762ce4 | ||
|
|
a6597da4a5 | ||
|
|
ab5bcd71f5 | ||
|
|
eb28dc2e20 | ||
|
|
92db5e1afe | ||
|
|
885bb0c730 | ||
|
|
71f4bd0a7c | ||
|
|
66e361714f | ||
|
|
9bd6d956ca | ||
|
|
293d5f722d | ||
|
|
04f522487e | ||
|
|
ab4bb55d0f | ||
|
|
64edddeabf | ||
|
|
a0819df874 | ||
|
|
24265204b3 | ||
|
|
e828d15fe3 | ||
|
|
6c2cf68077 | ||
|
|
f6d38939c2 | ||
|
|
f9d3d6bf5c | ||
|
|
33176220f6 | ||
|
|
b31e4a36a8 | ||
|
|
ecbe42744d | ||
|
|
7abc49ea21 | ||
|
|
5b6f2cb80d | ||
|
|
1f68cf09eb | ||
|
|
273871013e | ||
|
|
ce7b943793 | ||
|
|
7e20df7e93 | ||
|
|
b10727435a | ||
|
|
fe7d089593 | ||
|
|
380fe2633a | ||
|
|
9ec0835012 | ||
|
|
432782344a | ||
|
|
94f440d286 | ||
|
|
64ee9dd674 | ||
|
|
3327093dae | ||
|
|
029f82dc82 | ||
|
|
803422c18e | ||
|
|
7c54fcf60a | ||
|
|
3a985eff4d | ||
|
|
11e73cc670 | ||
|
|
b0daa601ad | ||
|
|
baffcc5cf4 | ||
|
|
9bfb641d3e | ||
|
|
f92127c0a7 | ||
|
|
545dabadb7 | ||
|
|
ddd5d5a535 | ||
|
|
a7a9c38036 | ||
|
|
56907f0c9f | ||
|
|
73c28437d6 | ||
|
|
57328761cf | ||
|
|
9317ded1a9 | ||
|
|
8992f8ac36 | ||
|
|
9829145d8c | ||
|
|
5b4e732fa3 | ||
|
|
df4755bc06 | ||
|
|
84e2e321b4 | ||
|
|
4e1470cef2 | ||
|
|
cfc0383b96 | ||
|
|
0a6d775fa7 | ||
|
|
fdb181b158 | ||
|
|
71c27de8cc | ||
|
|
9609751517 | ||
|
|
2a452063c6 | ||
|
|
2e993b0a58 | ||
|
|
e243a0e0e4 | ||
|
|
9eb9a44ee4 | ||
|
|
58cc7c1814 | ||
|
|
7681e9a257 | ||
|
|
365d2977ef | ||
|
|
3aed4de1b4 | ||
|
|
a8895d56ea | ||
|
|
33fbf268b7 | ||
|
|
36784f95c8 | ||
|
|
7acd814970 | ||
|
|
2ad9aec802 | ||
|
|
be942ef7b2 | ||
|
|
f84d5e9b85 | ||
|
|
1a60093689 | ||
|
|
a8eb53af4e | ||
|
|
5cb074fc24 | ||
|
|
d9265164a3 | ||
|
|
b67dfb5821 | ||
|
|
4c2e38b51c | ||
|
|
d13b4e3bd5 | ||
|
|
91c7441fa8 | ||
|
|
b7922a2a49 | ||
|
|
f0937e91f1 | ||
|
|
ac08c92a35 | ||
|
|
b2ba7b5e59 | ||
|
|
9b89acfec0 | ||
|
|
7c1a48a377 | ||
|
|
c8ad361818 | ||
|
|
1a52e55a73 | ||
|
|
f6a071ed6b | ||
|
|
05b6f9a901 | ||
|
|
31e06da7e7 | ||
|
|
1bb1022d51 |
151
.clang-format
151
.clang-format
@@ -1,86 +1,191 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: false
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 99
|
||||
ColumnLimit: 99
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Leave
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: BinPack
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: false
|
||||
|
||||
IncludeBlocks: Preserve
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequires: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
|
||||
# Taken from git's rules
|
||||
PenaltyBreakAssignment: 10
|
||||
PenaltyBreakBeforeFirstCallParameter: 30
|
||||
PenaltyBreakComment: 10
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 10
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 100
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Left
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
PPIndentWidth: -1
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: false
|
||||
RemoveBracesLLVM: false
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: Never
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: Never
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: false
|
||||
AfterForeachMacros: false
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: false
|
||||
AfterOverloadedOperator: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp03
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: c++03
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
||||
|
||||
|
||||
28
.drone.yml
28
.drone.yml
@@ -28,29 +28,6 @@ steps:
|
||||
FBT_TOOLS_CUSTOM_LINK:
|
||||
from_secret: fbt_link
|
||||
|
||||
- name: "Bundle resources"
|
||||
image: kramos/alpine-zip
|
||||
commands:
|
||||
- mkdir sd-card
|
||||
- mkdir -p sd-card/subghz/assets
|
||||
- mkdir -p sd-card/nfc/assets
|
||||
- mkdir -p sd-card/infrared/assets
|
||||
- mkdir -p sd-card/unirf
|
||||
- mkdir -p sd-card/badusb/layouts
|
||||
- cp assets/resources/badusb/layouts/* sd-card/badusb/layouts/
|
||||
- cp assets/resources/subghz/assets/dangerous_settings sd-card/subghz/assets/dangerous_settings
|
||||
- cp assets/resources/subghz/assets/setting_user sd-card/subghz/assets/setting_user
|
||||
- cp assets/resources/subghz/assets/keeloq_mfcodes sd-card/subghz/assets/keeloq_mfcodes
|
||||
- cp assets/resources/nfc/assets/mf_classic_dict.nfc sd-card/nfc/assets/mf_classic_dict.nfc
|
||||
- cp assets/resources/infrared/assets/tv.ir sd-card/infrared/assets/tv.ir
|
||||
- cp assets/resources/infrared/assets/ac.ir sd-card/infrared/assets/ac.ir
|
||||
- cp assets/resources/infrared/assets/audio.ir sd-card/infrared/assets/audio.ir
|
||||
- cp assets/resources/unirf/unirf_map_example.txt sd-card/unirf/unirf_map_example.txt
|
||||
- cp assets/resources/Manifest sd-card/Manifest
|
||||
- zip -r artifacts-default/sd-card-${DRONE_TAG}.zip sd-card
|
||||
- rm -rf sd-card
|
||||
- ls -laS artifacts-default
|
||||
|
||||
- name: "Bundle self-update packages"
|
||||
image: kramos/alpine-zip
|
||||
commands:
|
||||
@@ -87,7 +64,6 @@ steps:
|
||||
files:
|
||||
- artifacts-default/*.tgz
|
||||
- artifacts-default/*.zip
|
||||
- artifacts-default/flipper-z-f7-full-${DRONE_TAG}.dfu
|
||||
title: ${DRONE_TAG}
|
||||
note: CHANGELOG.md
|
||||
checksum:
|
||||
@@ -114,9 +90,7 @@ steps:
|
||||
|
||||
[-Install via Web Updater-](https://my.flipp.dev/?url=https://unleashedflip.com/builds/flipper-z-f7-update-${DRONE_TAG}.tgz&channel=dev-cfw&version=${DRONE_TAG})"
|
||||
document:
|
||||
- artifacts-default/flipper-z-f7-full-${DRONE_TAG}.dfu
|
||||
- artifacts-default/flipper-z-f7-update-${DRONE_TAG}.zip
|
||||
- artifacts-default/sd-card-${DRONE_TAG}.zip
|
||||
- artifacts-default/flipper-z-f7-update-${DRONE_TAG}.tgz
|
||||
|
||||
- name: "Send discord notification"
|
||||
image: appleboy/drone-discord
|
||||
|
||||
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @xMasterX
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -51,3 +51,7 @@ build/
|
||||
|
||||
# openocd output file
|
||||
openocd.log
|
||||
|
||||
# PVS Studio temporary files
|
||||
.PVS-Studio/
|
||||
PVS-Studio.log
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -28,3 +28,6 @@
|
||||
[submodule "lib/mbedtls"]
|
||||
path = lib/mbedtls
|
||||
url = https://github.com/Mbed-TLS/mbedtls.git
|
||||
[submodule "lib/cxxheaderparser"]
|
||||
path = lib/cxxheaderparser
|
||||
url = https://github.com/robotpy/cxxheaderparser.git
|
||||
|
||||
22
.pvsconfig
Normal file
22
.pvsconfig
Normal file
@@ -0,0 +1,22 @@
|
||||
# MLib macros we can't do much about.
|
||||
//-V:M_EACH:1048,1044
|
||||
//-V:ARRAY_DEF:760,747,568,776,729,712,654
|
||||
//-V:LIST_DEF:760,747,568,712,729,654,776
|
||||
//-V:BPTREE_DEF2:779,1086,557,773,512
|
||||
//-V:DICT_DEF2:779,524,776,760,1044,1001,729,590,568,747,685
|
||||
//-V:ALGO_DEF:1048,747,1044
|
||||
|
||||
# Non-severe malloc/null pointer deref warnings
|
||||
//-V::522:2,3
|
||||
|
||||
# Warning about headers with copyleft license
|
||||
//-V::1042
|
||||
|
||||
# Potentially null argument warnings
|
||||
//-V:memset:575
|
||||
//-V:memcpy:575
|
||||
//-V:strcpy:575
|
||||
//-V:strchr:575
|
||||
|
||||
# For loop warning on M_FOREACH
|
||||
//-V:for:1044
|
||||
1
.pvsoptions
Normal file
1
.pvsoptions
Normal file
@@ -0,0 +1 @@
|
||||
--rules-config .pvsconfig -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/STM32CubeWB -e lib/u8g2 -e */arm-none-eabi/*
|
||||
17
.vscode/example/launch.json
vendored
17
.vscode/example/launch.json
vendored
@@ -9,6 +9,10 @@
|
||||
"type": "command",
|
||||
"command": "shellCommand.execute",
|
||||
"args": {
|
||||
"useSingleResult": true,
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder};${env:PATH}"
|
||||
},
|
||||
"command": "./fbt get_blackmagic",
|
||||
"description": "Get Blackmagic device",
|
||||
}
|
||||
@@ -31,7 +35,10 @@
|
||||
],
|
||||
"postAttachCommands": [
|
||||
// "attach 1",
|
||||
"compare-sections",
|
||||
// "compare-sections",
|
||||
"source debug/flipperapps.py",
|
||||
// "source debug/FreeRTOS/FreeRTOS.py",
|
||||
// "svd_load debug/STM32WB55_CM4.svd"
|
||||
]
|
||||
// "showDevDebugOutput": "raw",
|
||||
},
|
||||
@@ -50,7 +57,8 @@
|
||||
"attach 1",
|
||||
"set confirm off",
|
||||
"set mem inaccessible-by-default off",
|
||||
"compare-sections",
|
||||
"source debug/flipperapps.py",
|
||||
// "compare-sections",
|
||||
]
|
||||
// "showDevDebugOutput": "raw",
|
||||
},
|
||||
@@ -65,6 +73,9 @@
|
||||
"device": "STM32WB55RG",
|
||||
"svdFile": "./debug/STM32WB55_CM4.svd",
|
||||
"rtos": "FreeRTOS",
|
||||
"postAttachCommands": [
|
||||
"source debug/flipperapps.py",
|
||||
]
|
||||
// "showDevDebugOutput": "raw",
|
||||
},
|
||||
{
|
||||
@@ -73,7 +84,7 @@
|
||||
"request": "launch",
|
||||
"program": "./lib/scons/scripts/scons.py",
|
||||
"args": [
|
||||
"sdk"
|
||||
"plugin_dist"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
5
.vscode/example/settings.json
vendored
5
.vscode/example/settings.json
vendored
@@ -12,6 +12,9 @@
|
||||
"cortex-debug.openocdPath.windows": "${workspaceFolder}/toolchain/i686-windows/openocd/bin/openocd.exe",
|
||||
"cortex-debug.openocdPath.linux": "${workspaceFolder}/toolchain/x86_64-linux/openocd/bin/openocd",
|
||||
"cortex-debug.openocdPath.osx": "${workspaceFolder}/toolchain/x86_64-darwin/openocd/bin/openocd",
|
||||
"cortex-debug.gdbPath.windows": "${workspaceFolder}/toolchain/i686-windows/bin/arm-none-eabi-gdb-py.bat",
|
||||
"cortex-debug.gdbPath.linux": "${workspaceFolder}/toolchain/x86_64-linux/bin/arm-none-eabi-gdb-py",
|
||||
"cortex-debug.gdbPath.osx": "${workspaceFolder}/toolchain/x86_64-darwin/bin/arm-none-eabi-gdb-py",
|
||||
"editor.formatOnSave": true,
|
||||
"files.associations": {
|
||||
"*.scons": "python",
|
||||
@@ -19,4 +22,4 @@
|
||||
"SConstruct": "python",
|
||||
"*.fam": "python",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
.vscode/example/tasks.json
vendored
30
.vscode/example/tasks.json
vendored
@@ -93,11 +93,41 @@
|
||||
"type": "shell",
|
||||
"command": "./fbt FIRMWARE_APP_SET=unit_tests FORCE=1 flash_usb"
|
||||
},
|
||||
{
|
||||
"label": "[Debug] Flash (USB, with resources)",
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"command": "./fbt FORCE=1 flash_usb_full"
|
||||
},
|
||||
{
|
||||
"label": "[Release] Flash (USB, with resources)",
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"command": "./fbt COMPACT=1 DEBUG=0 FORCE=1 flash_usb_full"
|
||||
},
|
||||
{
|
||||
"label": "[Debug] Build FAPs",
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"command": "./fbt plugin_dist"
|
||||
},
|
||||
{
|
||||
"label": "[Release] Build FAPs",
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"command": "./fbt COMPACT=1 DEBUG=0 plugin_dist"
|
||||
},
|
||||
{
|
||||
"label": "[Debug] Launch App on Flipper",
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"command": "./fbt launch_app APPSRC=${relativeFileDirname}"
|
||||
},
|
||||
{
|
||||
"label": "[Release] Launch App on Flipper",
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"command": "./fbt COMPACT=1 DEBUG=0 launch_app APPSRC=${relativeFileDirname}"
|
||||
}
|
||||
]
|
||||
}
|
||||
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,19 +1,16 @@
|
||||
### New changes
|
||||
* Wifi Marauder app update (by @0xchocolate)
|
||||
* Updated Universal remote assets (by @Amec0e)
|
||||
* Fixed music player
|
||||
* Fixed typos in subghz encoders
|
||||
* OFW: New NFC info screens
|
||||
* OFW: U2F fixes
|
||||
* PR: SubGHz bruteforcer plugin - deep refactoring (huge thanks to @derskythe ! | PR #75)
|
||||
* OFW: Preliminary Rust support
|
||||
|
||||
**Note: Prefer installing using web updater or by self update package, all needed assets will be installed**
|
||||
#### **DFU files no longer included in releases to avoid issues with wrong manual installation of assets - use .tgz file with qFlipper, or install automatically via web updater or use microSD update package**
|
||||
|
||||
**Build naming has been changed - all same as before but `cg - codegrabber` changed to `un - unleashed`**
|
||||
[- How to install](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/HowToInstall.md)
|
||||
|
||||
Self-update package (update from microSD) - `flipper-z-f7-update-(version).zip`
|
||||
[- Download qFlipper 1.2.0 (allows .tgz installation) (official link)](https://update.flipperzero.one/builds/qFlipper/1.2.0/)
|
||||
|
||||
DFU for update using qFlipper - `flipper-z-f7-full-(version).dfu`
|
||||
**Note: To avoid issues with .dfu, prefer installing using .tgz with qFlipper, web updater or by self update package, all needed assets will be installed**
|
||||
|
||||
If using DFU update method, download this archive and unpack it to your microSD, replacing all files except files you have edited manually -
|
||||
`sd-card-(version).zip`
|
||||
Self-update package (update from microSD) - `flipper-z-f7-update-(version).zip` or download `.tgz` for iOS mobile app / qFlipper
|
||||
|
||||
Update using qFlipper (1.2.0) is now possible with `.tgz` update package! Also you can use Web Updater or self-update package.
|
||||
|
||||
|
||||
71
ReadMe.md
71
ReadMe.md
@@ -1,11 +1,13 @@
|
||||
# Flipper Zero Unleashed Firmware
|
||||
<h3 align="center">
|
||||
<a href="https://github.com/Eng1n33r/flipperzero-firmware">
|
||||
<img src="https://user-images.githubusercontent.com/10697207/186202043-26947e28-b1cc-459a-8f20-ffcc7fc0c71c.png" align="center" alt="fzCUSTOM" border="0">
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
<img src="https://i.ibb.co/wQ12PVc/fzCUSTOM.png" alt="fzCUSTOM" border="0">
|
||||
|
||||
Welcome to Flipper Zero's Custom Firmware repo!
|
||||
### Welcome to Flipper Zero Unleashed Firmware repo!
|
||||
Our goal is to make any features possible in this device without any limitations!
|
||||
|
||||
Please help us implement emulation for all subghz dynamic (rolling code) protocols and static code brute-force app!
|
||||
Please help us implement emulation for all subghz dynamic (rolling code) protocols!
|
||||
|
||||
<br>
|
||||
|
||||
@@ -14,7 +16,7 @@ Please help us implement emulation for all subghz dynamic (rolling code) protoco
|
||||
<br>
|
||||
Our Discord Community:
|
||||
<br>
|
||||
<a href="https://discord.gg/58D6E8BtTU"><img src="https://discordapp.com/api/guilds/937479784148115456/widget.png?style=banner4" alt="Unofficial Discord Community"></a>
|
||||
<a href="https://discord.gg/flipperzero-unofficial"><img src="https://discordapp.com/api/guilds/937479784148115456/widget.png?style=banner4" alt="Unofficial Discord Community"></a>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
@@ -25,25 +27,29 @@ Our Discord Community:
|
||||
* SubGHz frequecy range can be extended in settings file (Warning: It can damage flipper's hardware)
|
||||
* Many rolling code protocols now have the ability to save & send captured signals
|
||||
* FAAC SLH (Spa) & BFT Mitto (secure with seed) manual creation
|
||||
* Sub-GHz static code brute-force plugin
|
||||
* LFRFID Fuzzer plugin
|
||||
* Custom community plugins and games added
|
||||
* Extra SubGHz frequencies + extra Mifare Classic keys
|
||||
* Picopass/iClass plugin included in releases
|
||||
* Recompiled IR TV Universal Remote for ALL buttons
|
||||
* Universal A/C and Audio(soundbars, etc.) remote
|
||||
* Universal remote for Projectors, Fans, A/Cs and Audio(soundbars, etc.)
|
||||
* BadUSB keyboard layouts
|
||||
* Customizable Flipper name
|
||||
* Other small fixes and changes throughout
|
||||
|
||||
See changelog in releases for latest updates!
|
||||
|
||||
### Current modified and new SubGhz protocols list:
|
||||
### Current modified and new SubGHz protocols list:
|
||||
- HCS101
|
||||
- An-Motors
|
||||
- CAME Atomo
|
||||
- FAAC SLH (Spa) [if cloning existing remote - external seed calculation required]
|
||||
- BFT Mitto [if cloning existing remote - external seed calculation required]
|
||||
- Keeloq (+ proper manufacturer codes selection) [Not ALL systems supported yet!]
|
||||
- FAAC SLH (Spa) [External seed calculation required]
|
||||
- BFT Mitto [External seed calculation required]
|
||||
- Keeloq [Not ALL systems supported yet!]
|
||||
- Nice Flor S
|
||||
- Security+ v1 & v2
|
||||
- Star Line
|
||||
- Star Line (saving only)
|
||||
|
||||
## Support us so we can buy equipment and develop new features
|
||||
* ETH/BSC/ERC20-Tokens: `0xFebF1bBc8229418FF2408C07AF6Afa49152fEc6a`
|
||||
@@ -51,30 +57,36 @@ See changelog in releases for latest updates!
|
||||
* DOGE: `D6R6gYgBn5LwTNmPyvAQR6bZ9EtGgFCpvv`
|
||||
* LTC: `ltc1q3ex4ejkl0xpx3znwrmth4lyuadr5qgv8tmq8z9`
|
||||
|
||||
**Big thanks to all sponsors!**
|
||||
|
||||
### Community apps included:
|
||||
|
||||
- RFID Fuzzer plugin [(by Ganapati)](https://github.com/Eng1n33r/flipperzero-firmware/pull/54) with some changes by xMasterX
|
||||
- Sub-GHz bruteforce plugin [(by Ganapati & xMasterX)](https://github.com/Eng1n33r/flipperzero-firmware/pull/57)
|
||||
- Sub-GHz playlist plugin [(by darmiel)](https://github.com/Eng1n33r/flipperzero-firmware/pull/62)
|
||||
- ESP8266 Deauther plugin [(by SequoiaSan)](https://github.com/SequoiaSan/FlipperZero-Wifi-ESP8266-Deauther-Module)
|
||||
- WiFi Scanner plugin [(by SequoiaSan)](https://github.com/SequoiaSan/FlipperZero-WiFi-Scanner_Module)
|
||||
- Dec/Hex Converter plugin [(by theisolinearchip)](https://github.com/theisolinearchip/flipperzero_stuff/tree/main/applications/dec_hex_converter)
|
||||
- MultiConverter plugin [(by theisolinearchip)](https://github.com/theisolinearchip/flipperzero_stuff)
|
||||
- WAV player plugin (fixed) [(OFW: DrZlo13)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/wav-player)
|
||||
- UPC-A Barcode generator plugin [(by McAzzaMan)](https://github.com/McAzzaMan/flipperzero-firmware/tree/UPC-A_Barcode_Generator/applications/barcode_generator)
|
||||
- GPIO: Sentry Safe plugin [(by H4ckd4ddy)](https://github.com/H4ckd4ddy/flipperzero-sentry-safe-plugin)
|
||||
- ESP32: WiFi Marauder companion plugin [(by 0xchocolate)](https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion)
|
||||
- NRF24: Sniffer & MouseJacker (with changes) [(by mothball187)](https://github.com/mothball187/flipperzero-nrf24/tree/main/mousejacker)
|
||||
- HID Analyzer [(by Ownasaurus)](https://github.com/Ownasaurus/flipperzero-firmware/tree/hid-analyzer/applications/hid_analyzer)
|
||||
- Simple Clock (fixed) !! New version WIP, wait for updates !! [(Original by CompaqDisc)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61)
|
||||
- UniversalRF Remix (with changes)(only RAW subghz files) [(by ESurge)(Original UniversalRF by jimilinuxguy)](https://github.com/ESurge/flipperzero-firmware-unirfremix)
|
||||
- Tetris (with fixes) [(by jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game)
|
||||
- Simple Clock (timer by GMMan / settings by kowalski7cc) [(Original by CompaqDisc)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61)
|
||||
- UniversalRF Remix / Sub-GHz Remote [(by ESurge)](https://github.com/ESurge/flipperzero-firmware-unirfremix)[(updated and all protocol support added by darmiel & xMasterX)](https://github.com/darmiel/flipper-playlist/tree/feat/unirf-protocols)
|
||||
- Spectrum Analyzer (with changes) [(by jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) - [Ultra Narrow mode & scan channels non-consecutively](https://github.com/theY4Kman/flipperzero-firmware/commits?author=theY4Kman)
|
||||
- Arkanoid (with fixes) [(by gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins)
|
||||
- Tic Tac Toe (with fixes) [(by gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins)
|
||||
|
||||
Games:
|
||||
- DOOM (fixed) [(By p4nic4ttack)](https://github.com/p4nic4ttack/doom-flipper-zero/)
|
||||
- Zombiez [(Reworked By DevMilanIan)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/240) [(Original By Dooskington)](https://github.com/Dooskington/flipperzero-zombiez)
|
||||
- Flappy Bird [(By DroomOne)](https://github.com/DroomOne/flipperzero-firmware/tree/dev/applications/flappy_bird)
|
||||
- Arkanoid (refactored by xMasterX) [(by gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins)
|
||||
- Tic Tac Toe (refactored by xMasterX) [(by gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins)
|
||||
- Tetris (with fixes) [(by jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game)
|
||||
|
||||
### Other changes
|
||||
|
||||
- BadUSB Keyboard layouts [(by rien > dummy-decoy)](https://github.com/dummy-decoy/flipperzero-firmware/tree/dummy_decoy/bad_usb_keyboard_layout)
|
||||
- New frequency analyzer - [(by ClusterM)](https://github.com/ClusterM)
|
||||
- BadUSB -> Keyboard layouts [(by rien > dummy-decoy)](https://github.com/dummy-decoy/flipperzero-firmware/tree/dummy_decoy/bad_usb_keyboard_layout)
|
||||
- SubGHz -> New frequency analyzer - [(by ClusterM)](https://github.com/ClusterM)
|
||||
- SubGHz -> Detect RAW feature - [(by perspecdev)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/152)
|
||||
|
||||
# Instructions
|
||||
## [- How to install firmware](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/HowToInstall.md)
|
||||
@@ -87,12 +99,18 @@ See changelog in releases for latest updates!
|
||||
|
||||
### **Plugins**
|
||||
|
||||
## [- Configure UniversalRF Remix App](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/UniRFRemix.md)
|
||||
## [- 💎 Extra plugins precompiled for Unleashed](https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed)
|
||||
|
||||
## [- Configure Sub-GHz Remote App](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/SubGHzRemotePlugin.md)
|
||||
|
||||
## [- Barcode Generator](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/BarcodeGenerator.md)
|
||||
|
||||
## [- Multi Converter](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/MultiConverter.md)
|
||||
|
||||
## [- WAV Player sample files & how to convert](https://github.com/UberGuidoZ/Flipper/tree/main/Wav_Player#readme)
|
||||
|
||||
## [- SubGHz playlist generator script](https://github.com/darmiel/flipper-scripts/blob/main/playlist/playlist_creator_by_chunk.py)
|
||||
|
||||
### **Plugins that works with external hardware**
|
||||
|
||||
## [- How to use: [NRF24] plugins](https://github.com/Eng1n33r/flipperzero-firmware/blob/dev/documentation/NRF24.md)
|
||||
@@ -130,7 +148,7 @@ See changelog in releases for latest updates!
|
||||
|
||||
# Links
|
||||
|
||||
* Unofficial Discord: [discord.gg/58D6E8BtTU](https://discord.gg/58D6E8BtTU)
|
||||
* Unofficial Discord: [discord.gg/flipperzero-unofficial](https://discord.gg/flipperzero-unofficial)
|
||||
* Docs by atmanos / How to write your own app (outdated API): [https://flipper.atmanos.com/docs/overview/intro](https://flipper.atmanos.com/docs/overview/intro)
|
||||
|
||||
* Official Docs: [http://docs.flipperzero.one](http://docs.flipperzero.one)
|
||||
@@ -142,11 +160,10 @@ See changelog in releases for latest updates!
|
||||
- `assets` - Assets used by applications and services
|
||||
- `furi` - Furi Core: os level primitives and helpers
|
||||
- `debug` - Debug tool: GDB-plugins, SVD-file and etc
|
||||
- `docker` - Docker image sources (used for firmware build automation)
|
||||
- `documentation` - Documentation generation system configs and input files
|
||||
- `firmware` - Firmware source code
|
||||
- `lib` - Our and 3rd party libraries, drivers and etc...
|
||||
- `site_scons` - Build helpers
|
||||
- `scripts` - Supplementary scripts and python libraries home
|
||||
|
||||
Also pay attention to `ReadMe.md` files inside of those directories.
|
||||
Also pay attention to `ReadMe.md` files inside those directories.
|
||||
|
||||
45
SConstruct
45
SConstruct
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Main Fipper Build System entry point
|
||||
# Main Flipper Build System entry point
|
||||
#
|
||||
# This file is evaluated by scons (the build system) every time fbt is invoked.
|
||||
# Scons constructs all referenced environments & their targets' dependency
|
||||
@@ -9,13 +9,14 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
|
||||
EnsurePythonVersion(3, 8)
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
# Progress(["OwO\r", "owo\r", "uwu\r", "owo\r"], interval=15)
|
||||
|
||||
|
||||
# This environment is created only for loading options & validating file/dir existance
|
||||
# This environment is created only for loading options & validating file/dir existence
|
||||
fbt_variables = SConscript("site_scons/commandline.scons")
|
||||
cmd_environment = Environment(tools=[], variables=fbt_variables)
|
||||
Help(fbt_variables.GenerateHelpText(cmd_environment))
|
||||
@@ -43,6 +44,8 @@ distenv = coreenv.Clone(
|
||||
"target extended-remote ${GDBREMOTE}",
|
||||
"-ex",
|
||||
"set confirm off",
|
||||
"-ex",
|
||||
"set pagination off",
|
||||
],
|
||||
GDBOPTS_BLACKMAGIC=[
|
||||
"-ex",
|
||||
@@ -58,6 +61,8 @@ distenv = coreenv.Clone(
|
||||
"-ex",
|
||||
"source debug/FreeRTOS/FreeRTOS.py",
|
||||
"-ex",
|
||||
"source debug/flipperapps.py",
|
||||
"-ex",
|
||||
"source debug/PyCortexMDebug/PyCortexMDebug.py",
|
||||
"-ex",
|
||||
"svd_load ${SVD_FILE}",
|
||||
@@ -160,6 +165,28 @@ if GetOption("fullenv") or any(
|
||||
basic_dist = distenv.DistCommand("fw_dist", distenv["DIST_DEPENDS"])
|
||||
distenv.Default(basic_dist)
|
||||
|
||||
dist_dir = distenv.GetProjetDirName()
|
||||
plugin_dist = [
|
||||
distenv.Install(
|
||||
f"#/dist/{dist_dir}/apps/debug_elf",
|
||||
firmware_env["FW_EXTAPPS"]["debug"].values(),
|
||||
),
|
||||
*(
|
||||
distenv.Install(f"#/dist/{dist_dir}/apps/{dist_entry[0]}", dist_entry[1])
|
||||
for dist_entry in firmware_env["FW_EXTAPPS"]["dist"].values()
|
||||
),
|
||||
]
|
||||
Depends(plugin_dist, firmware_env["FW_EXTAPPS"]["validators"].values())
|
||||
Alias("plugin_dist", plugin_dist)
|
||||
# distenv.Default(plugin_dist)
|
||||
|
||||
plugin_resources_dist = list(
|
||||
distenv.Install(f"#/assets/resources/apps/{dist_entry[0]}", dist_entry[1])
|
||||
for dist_entry in firmware_env["FW_EXTAPPS"]["dist"].values()
|
||||
)
|
||||
distenv.Depends(firmware_env["FW_RESOURCES"], plugin_resources_dist)
|
||||
|
||||
|
||||
# Target for bundling core2 package for qFlipper
|
||||
copro_dist = distenv.CoproBuilder(
|
||||
distenv.Dir("assets/core2_firmware"),
|
||||
@@ -209,10 +236,19 @@ distenv.PhonyTarget(
|
||||
distenv.PhonyTarget(
|
||||
"debug_other",
|
||||
"${GDBPYCOM}",
|
||||
GDBPYOPTS='-ex "source debug/PyCortexMDebug/PyCortexMDebug.py" ',
|
||||
GDBOPTS="${GDBOPTS_BASE}",
|
||||
GDBREMOTE="${OPENOCD_GDB_PIPE}",
|
||||
GDBPYOPTS='-ex "source debug/PyCortexMDebug/PyCortexMDebug.py" ',
|
||||
)
|
||||
|
||||
distenv.PhonyTarget(
|
||||
"debug_other_blackmagic",
|
||||
"${GDBPYCOM}",
|
||||
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
|
||||
GDBREMOTE="$${BLACKMAGIC_ADDR}",
|
||||
)
|
||||
|
||||
|
||||
# Just start OpenOCD
|
||||
distenv.PhonyTarget(
|
||||
"openocd",
|
||||
@@ -240,7 +276,6 @@ firmware_env.Append(
|
||||
"site_scons",
|
||||
"scripts",
|
||||
# Extra files
|
||||
"applications/extapps.scons",
|
||||
"SConstruct",
|
||||
"firmware.scons",
|
||||
"fbt_options.py",
|
||||
|
||||
@@ -1,38 +1,89 @@
|
||||
# Structure
|
||||
|
||||
- `about` - Small About application that shows flipper info
|
||||
- `accessor` - Wiegand server
|
||||
## debug
|
||||
|
||||
Applications for factory testing the Flipper.
|
||||
|
||||
- `accessor` - Wiegand server
|
||||
- `battery_test_app` - Battery debug app
|
||||
- `blink_test` - LED blinker
|
||||
- `bt_debug_app` - BT test app. Requires full BT stack installed
|
||||
- `display_test` - Various display tests & tweaks
|
||||
- `file_browser_test` - Test UI for file picker
|
||||
- `keypad_test` - Keypad test
|
||||
- `lfrfid_debug` - LF RFID debug tool
|
||||
- `text_box_test` - UI tests
|
||||
- `uart_echo` - UART mode test
|
||||
- `unit_tests` - Unit tests
|
||||
- `usb_mouse` - USB HID test
|
||||
- `usb_test` - Other USB tests
|
||||
- `vibro_test` - Vibro test
|
||||
|
||||
|
||||
## main
|
||||
|
||||
Applications for main Flipper menu.
|
||||
|
||||
- `archive` - Archive and file manager
|
||||
- `bad_usb` - Bad USB application
|
||||
- `fap_loader` - External applications loader
|
||||
- `gpio` - GPIO application: includes USART bridge and GPIO control
|
||||
- `ibutton` - iButton application, onewire keys and more
|
||||
- `infrared` - Infrared application, controls your IR devices
|
||||
- `lfrfid` - LF RFID application
|
||||
- `nfc` - NFC application, HF rfid, EMV and etc
|
||||
- `subghz` - SubGhz application, 433 fobs and etc
|
||||
- `u2f` - U2F Application
|
||||
|
||||
|
||||
## plugins
|
||||
|
||||
Extra apps for Plugins & App Loader menus.
|
||||
|
||||
- `bt_hid_app` - BT Remote controller
|
||||
- `music_player` - Music player app (demo)
|
||||
- `picopass` - Picopass tool
|
||||
- `snake_game` - Snake game application
|
||||
|
||||
|
||||
## services
|
||||
|
||||
Background services providing system APIs to applications.
|
||||
|
||||
- `applications.h` - Firmware application list header
|
||||
|
||||
- `bt` - BLE service and application
|
||||
- `cli` - Console service and API
|
||||
- `crypto` - Crypto cli tools
|
||||
- `debug_tools` - Different tools that we use for debug
|
||||
- `desktop` - Desktop service
|
||||
- `dialogs` - Dialogs service: GUI Dialogs for your app
|
||||
- `dolphin` - Dolphin service and supplementary apps
|
||||
- `gpio` - GPIO application: includes USART bridge and GPIO control
|
||||
- `gui` - GUI service and API
|
||||
- `ibutton` - iButton application, onewire keys and more
|
||||
- `input` - Input service
|
||||
- `infrared` - Infrared application, controls your IR devices
|
||||
- `lfrfid` - LF RFID application
|
||||
- `lfrfid_debug` - LF RFID debug tool
|
||||
- `loader` - Application loader service
|
||||
- `music_player` - Music player app (demo)
|
||||
- `nfc` - NFC application, HF rfid, EMV and etc
|
||||
- `notification` - Notification service
|
||||
- `power` - Power service
|
||||
- `power_observer` - Power debug tool
|
||||
- `rpc` - RPC service and API
|
||||
- `scened_app_example` - C++ application example
|
||||
- `snake_game` - Snake game application
|
||||
- `storage` - Storage service, internal + sdcard
|
||||
- `storage_settings` - Storage settings app
|
||||
- `subghz` - SubGhz application, 433 fobs and etc
|
||||
- `system` - System settings, tools and API
|
||||
- `tests` - Unit tests and etc
|
||||
- `u2f` - U2F Application
|
||||
- `updater` - Update service & application
|
||||
|
||||
- `application.h` - Firmware application list header
|
||||
|
||||
## settings
|
||||
|
||||
Small applications providing configuration for basic firmware and its services.
|
||||
|
||||
- `about` - Small About application that shows flipper info
|
||||
- `bt_settings_app` - Bluetooth options
|
||||
- `desktop_settings` - Desktop configuration
|
||||
- `dolphin_passport` - Dolphin passport app
|
||||
- `notification_settings` - LCD brightness, sound volume, etc configuration
|
||||
- `power_settings_app` - Basic power options
|
||||
- `storage_settings` - Storage settings app
|
||||
- `system` - System settings
|
||||
|
||||
|
||||
## system
|
||||
|
||||
Utility apps not visible in other menus.
|
||||
|
||||
- `storage_move_to_sd` - Data migration tool for internal storage
|
||||
- `updater` - Update service & application
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#include "archive_i.h"
|
||||
#include "m-string.h"
|
||||
|
||||
bool archive_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
return scene_manager_handle_custom_event(archive->scene_manager, event);
|
||||
}
|
||||
|
||||
bool archive_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
return scene_manager_handle_back_event(archive->scene_manager);
|
||||
}
|
||||
|
||||
ArchiveApp* archive_alloc() {
|
||||
ArchiveApp* archive = malloc(sizeof(ArchiveApp));
|
||||
|
||||
archive->gui = furi_record_open(RECORD_GUI);
|
||||
archive->text_input = text_input_alloc();
|
||||
string_init(archive->fav_move_str);
|
||||
|
||||
archive->view_dispatcher = view_dispatcher_alloc();
|
||||
archive->scene_manager = scene_manager_alloc(&archive_scene_handlers, archive);
|
||||
|
||||
view_dispatcher_enable_queue(archive->view_dispatcher);
|
||||
view_dispatcher_attach_to_gui(
|
||||
archive->view_dispatcher, archive->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
view_dispatcher_set_event_callback_context(archive->view_dispatcher, archive);
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
archive->view_dispatcher, archive_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
archive->view_dispatcher, archive_back_event_callback);
|
||||
|
||||
archive->browser = browser_alloc();
|
||||
|
||||
view_dispatcher_add_view(
|
||||
archive->view_dispatcher, ArchiveViewBrowser, archive_browser_get_view(archive->browser));
|
||||
|
||||
view_dispatcher_add_view(
|
||||
archive->view_dispatcher, ArchiveViewTextInput, text_input_get_view(archive->text_input));
|
||||
|
||||
archive->widget = widget_alloc();
|
||||
view_dispatcher_add_view(
|
||||
archive->view_dispatcher, ArchiveViewWidget, widget_get_view(archive->widget));
|
||||
|
||||
return archive;
|
||||
}
|
||||
|
||||
void archive_free(ArchiveApp* archive) {
|
||||
furi_assert(archive);
|
||||
|
||||
view_dispatcher_remove_view(archive->view_dispatcher, ArchiveViewBrowser);
|
||||
view_dispatcher_remove_view(archive->view_dispatcher, ArchiveViewTextInput);
|
||||
view_dispatcher_remove_view(archive->view_dispatcher, ArchiveViewWidget);
|
||||
widget_free(archive->widget);
|
||||
view_dispatcher_free(archive->view_dispatcher);
|
||||
scene_manager_free(archive->scene_manager);
|
||||
browser_free(archive->browser);
|
||||
string_clear(archive->fav_move_str);
|
||||
|
||||
text_input_free(archive->text_input);
|
||||
|
||||
furi_record_close(RECORD_GUI);
|
||||
archive->gui = NULL;
|
||||
|
||||
free(archive);
|
||||
}
|
||||
|
||||
int32_t archive_app(void* p) {
|
||||
UNUSED(p);
|
||||
ArchiveApp* archive = archive_alloc();
|
||||
scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneBrowser);
|
||||
view_dispatcher_run(archive->view_dispatcher);
|
||||
archive_free(archive);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
#include "../archive_i.h"
|
||||
#include "../helpers/archive_favorites.h"
|
||||
#include "../helpers/archive_files.h"
|
||||
#include "../helpers/archive_browser.h"
|
||||
#include "archive/views/archive_browser_view.h"
|
||||
#include "toolbox/path.h"
|
||||
|
||||
#define SCENE_RENAME_CUSTOM_EVENT (0UL)
|
||||
#define MAX_TEXT_INPUT_LEN 22
|
||||
|
||||
void archive_scene_rename_text_input_callback(void* context) {
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
view_dispatcher_send_custom_event(archive->view_dispatcher, SCENE_RENAME_CUSTOM_EVENT);
|
||||
}
|
||||
|
||||
void archive_scene_rename_on_enter(void* context) {
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
|
||||
TextInput* text_input = archive->text_input;
|
||||
ArchiveFile_t* current = archive_get_current_file(archive->browser);
|
||||
|
||||
string_t filename;
|
||||
string_init(filename);
|
||||
path_extract_filename(current->path, filename, true);
|
||||
strlcpy(archive->text_store, string_get_cstr(filename), MAX_NAME_LEN);
|
||||
|
||||
path_extract_extension(current->path, archive->file_extension, MAX_EXT_LEN);
|
||||
|
||||
text_input_set_header_text(text_input, "Rename:");
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
archive_scene_rename_text_input_callback,
|
||||
archive,
|
||||
archive->text_store,
|
||||
MAX_TEXT_INPUT_LEN,
|
||||
false);
|
||||
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
string_get_cstr(archive->browser->path), archive->file_extension, "");
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
string_clear(filename);
|
||||
|
||||
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewTextInput);
|
||||
}
|
||||
|
||||
bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) {
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_RENAME_CUSTOM_EVENT) {
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
const char* path_src = archive_get_name(archive->browser);
|
||||
ArchiveFile_t* file = archive_get_current_file(archive->browser);
|
||||
|
||||
string_t path_dst;
|
||||
string_init(path_dst);
|
||||
path_extract_dirname(path_src, path_dst);
|
||||
string_cat_printf(path_dst, "/%s%s", archive->text_store, known_ext[file->type]);
|
||||
|
||||
storage_common_rename(fs_api, path_src, string_get_cstr(path_dst));
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
if(file->fav) {
|
||||
archive_favorites_rename(path_src, string_get_cstr(path_dst));
|
||||
}
|
||||
|
||||
string_clear(path_dst);
|
||||
|
||||
scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneBrowser);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void archive_scene_rename_on_exit(void* context) {
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
|
||||
// Clear view
|
||||
void* validator_context = text_input_get_validator_callback_context(archive->text_input);
|
||||
text_input_set_validator(archive->text_input, NULL, NULL);
|
||||
validator_is_file_free(validator_context);
|
||||
|
||||
text_input_reset(archive->text_input);
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
App(
|
||||
appid="bt",
|
||||
name="BtSrv",
|
||||
apptype=FlipperAppType.SERVICE,
|
||||
entry_point="bt_srv",
|
||||
cdefines=["SRV_BT"],
|
||||
requires=[
|
||||
"cli",
|
||||
"dialogs",
|
||||
],
|
||||
provides=[
|
||||
"bt_start",
|
||||
"bt_settings",
|
||||
"bt_debug",
|
||||
],
|
||||
stack_size=1 * 1024,
|
||||
order=20,
|
||||
)
|
||||
|
||||
App(
|
||||
appid="bt_start",
|
||||
apptype=FlipperAppType.STARTUP,
|
||||
entry_point="bt_on_system_start",
|
||||
order=70,
|
||||
)
|
||||
|
||||
App(
|
||||
appid="bt_settings",
|
||||
name="Bluetooth",
|
||||
apptype=FlipperAppType.SETTINGS,
|
||||
entry_point="bt_settings_app",
|
||||
stack_size=1 * 1024,
|
||||
requires=[
|
||||
"bt",
|
||||
"gui",
|
||||
],
|
||||
order=10,
|
||||
)
|
||||
|
||||
App(
|
||||
appid="bt_debug",
|
||||
name="Bluetooth Debug",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="bt_debug_app",
|
||||
stack_size=1 * 1024,
|
||||
requires=[
|
||||
"bt",
|
||||
"gui",
|
||||
"dialogs",
|
||||
],
|
||||
order=110,
|
||||
)
|
||||
|
||||
App(
|
||||
appid="bt_hid",
|
||||
name="Bluetooth Remote",
|
||||
apptype=FlipperAppType.PLUGIN,
|
||||
entry_point="bt_hid_app",
|
||||
stack_size=1 * 1024,
|
||||
cdefines=["APP_BLE_HID"],
|
||||
requires=[
|
||||
"bt",
|
||||
"gui",
|
||||
],
|
||||
order=10,
|
||||
)
|
||||
@@ -1,11 +0,0 @@
|
||||
App(
|
||||
appid="clock",
|
||||
name="Clock",
|
||||
apptype=FlipperAppType.APP,
|
||||
entry_point="clock_app",
|
||||
cdefines=["APP_CLOCK"],
|
||||
requires=["gui"],
|
||||
icon="A_Clock_14",
|
||||
stack_size=2 * 1024,
|
||||
order=9,
|
||||
)
|
||||
@@ -1,146 +0,0 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#include <gui/elements.h>
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <input/input.h>
|
||||
|
||||
#define TAG "Clock"
|
||||
#define CLOCK_DATE_FORMAT "%.4d-%.2d-%.2d"
|
||||
#define CLOCK_TIME_FORMAT "%.2d:%.2d:%.2d"
|
||||
|
||||
typedef enum {
|
||||
EventTypeTick,
|
||||
EventTypeKey,
|
||||
} EventType;
|
||||
|
||||
typedef struct {
|
||||
EventType type;
|
||||
InputEvent input;
|
||||
} PluginEvent;
|
||||
|
||||
typedef struct {
|
||||
FuriHalRtcDateTime datetime;
|
||||
} ClockState;
|
||||
|
||||
static void clock_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
|
||||
furi_assert(event_queue);
|
||||
|
||||
PluginEvent event = {.type = EventTypeKey, .input = *input_event};
|
||||
furi_message_queue_put(event_queue, &event, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void clock_render_callback(Canvas* const canvas, void* ctx) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
|
||||
ClockState* state = (ClockState*)acquire_mutex((ValueMutex*)ctx, 25);
|
||||
|
||||
char strings[2][20];
|
||||
|
||||
snprintf(
|
||||
strings[0],
|
||||
sizeof(strings[0]),
|
||||
CLOCK_DATE_FORMAT,
|
||||
state->datetime.year,
|
||||
state->datetime.month,
|
||||
state->datetime.day);
|
||||
snprintf(
|
||||
strings[1],
|
||||
sizeof(strings[1]),
|
||||
CLOCK_TIME_FORMAT,
|
||||
state->datetime.hour,
|
||||
state->datetime.minute,
|
||||
state->datetime.second);
|
||||
|
||||
release_mutex((ValueMutex*)ctx, state);
|
||||
canvas_set_font(canvas, FontBigNumbers);
|
||||
canvas_draw_str_aligned(canvas, 64, 42 - 16, AlignCenter, AlignCenter, strings[1]);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str_aligned(canvas, 64, 52 - 8, AlignCenter, AlignTop, strings[0]);
|
||||
}
|
||||
|
||||
static void clock_state_init(ClockState* const state) {
|
||||
furi_hal_rtc_get_datetime(&state->datetime);
|
||||
}
|
||||
|
||||
// Runs every 1000ms by default
|
||||
static void clock_tick(void* ctx) {
|
||||
furi_assert(ctx);
|
||||
FuriMessageQueue* event_queue = ctx;
|
||||
PluginEvent event = {.type = EventTypeTick};
|
||||
// It's OK to loose this event if system overloaded
|
||||
furi_message_queue_put(event_queue, &event, 0);
|
||||
}
|
||||
|
||||
int32_t clock_app(void* p) {
|
||||
UNUSED(p);
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
|
||||
|
||||
ClockState* plugin_state = malloc(sizeof(ClockState));
|
||||
clock_state_init(plugin_state);
|
||||
ValueMutex state_mutex;
|
||||
if(!init_mutex(&state_mutex, plugin_state, sizeof(ClockState))) {
|
||||
FURI_LOG_E(TAG, "cannot create mutex\r\n");
|
||||
furi_message_queue_free(event_queue);
|
||||
free(plugin_state);
|
||||
return 255;
|
||||
}
|
||||
|
||||
// Set system callbacks
|
||||
ViewPort* view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(view_port, clock_render_callback, &state_mutex);
|
||||
view_port_input_callback_set(view_port, clock_input_callback, event_queue);
|
||||
FuriTimer* timer = furi_timer_alloc(clock_tick, FuriTimerTypePeriodic, event_queue);
|
||||
furi_timer_start(timer, furi_kernel_get_tick_frequency());
|
||||
|
||||
// Open GUI and register view_port
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
|
||||
// Main loop
|
||||
PluginEvent event;
|
||||
for(bool processing = true; processing;) {
|
||||
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
|
||||
ClockState* plugin_state = (ClockState*)acquire_mutex_block(&state_mutex);
|
||||
|
||||
if(event_status == FuriStatusOk) {
|
||||
// press events
|
||||
if(event.type == EventTypeKey) {
|
||||
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
||||
switch(event.input.key) {
|
||||
case InputKeyUp:
|
||||
case InputKeyDown:
|
||||
case InputKeyRight:
|
||||
case InputKeyLeft:
|
||||
case InputKeyOk:
|
||||
break;
|
||||
case InputKeyBack:
|
||||
// Exit the plugin
|
||||
processing = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if(event.type == EventTypeTick) {
|
||||
furi_hal_rtc_get_datetime(&plugin_state->datetime);
|
||||
}
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "furi_message_queue: event timeout");
|
||||
// event timeout
|
||||
}
|
||||
|
||||
view_port_update(view_port);
|
||||
release_mutex(&state_mutex, plugin_state);
|
||||
}
|
||||
|
||||
furi_timer_free(timer);
|
||||
view_port_enabled_set(view_port, false);
|
||||
gui_remove_view_port(gui, view_port);
|
||||
furi_record_close(RECORD_GUI);
|
||||
view_port_free(view_port);
|
||||
furi_message_queue_free(event_queue);
|
||||
delete_mutex(&state_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -7,4 +7,5 @@ App(
|
||||
requires=["gui"],
|
||||
stack_size=4 * 1024,
|
||||
order=40,
|
||||
fap_category="Debug",
|
||||
)
|
||||
16
applications/debug/application.fam
Normal file
16
applications/debug/application.fam
Normal file
@@ -0,0 +1,16 @@
|
||||
App(
|
||||
appid="debug_apps",
|
||||
name="Basic debug apps bundle",
|
||||
apptype=FlipperAppType.METAPACKAGE,
|
||||
provides=[
|
||||
"blink_test",
|
||||
"vibro_test",
|
||||
"keypad_test",
|
||||
"usb_test",
|
||||
"usb_mouse",
|
||||
"uart_echo",
|
||||
"display_test",
|
||||
"text_box_test",
|
||||
"file_browser_test",
|
||||
],
|
||||
)
|
||||
14
applications/debug/battery_test_app/application.fam
Normal file
14
applications/debug/battery_test_app/application.fam
Normal file
@@ -0,0 +1,14 @@
|
||||
App(
|
||||
appid="battery_test",
|
||||
name="Battery Test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="battery_test_app",
|
||||
cdefines=["APP_BATTERY_TEST"],
|
||||
requires=[
|
||||
"gui",
|
||||
"power",
|
||||
],
|
||||
stack_size=1 * 1024,
|
||||
order=130,
|
||||
fap_category="Debug",
|
||||
)
|
||||
10
applications/power/battery_test_app/battery_test_app.c → applications/debug/battery_test_app/battery_test_app.c
Executable file → Normal file
10
applications/power/battery_test_app/battery_test_app.c → applications/debug/battery_test_app/battery_test_app.c
Executable file → Normal file
@@ -27,7 +27,7 @@ static void battery_test_battery_info_update_model(void* context) {
|
||||
.charge = app->info.charge,
|
||||
.health = app->info.health,
|
||||
};
|
||||
battery_info_set_data(app->batery_info, &battery_info_data);
|
||||
battery_info_set_data(app->battery_info, &battery_info_data);
|
||||
notification_message(app->notifications, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ BatteryTestApp* battery_test_alloc() {
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
// Views
|
||||
app->batery_info = battery_info_alloc();
|
||||
app->battery_info = battery_info_alloc();
|
||||
view_set_previous_callback(
|
||||
battery_info_get_view(app->batery_info), battery_test_exit_confirm_view);
|
||||
battery_info_get_view(app->battery_info), battery_test_exit_confirm_view);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
BatteryTestAppViewBatteryInfo,
|
||||
battery_info_get_view(app->batery_info));
|
||||
battery_info_get_view(app->battery_info));
|
||||
|
||||
app->dialog = dialog_ex_alloc();
|
||||
dialog_ex_set_header(app->dialog, "Close Battery Test?", 64, 12, AlignCenter, AlignTop);
|
||||
@@ -76,7 +76,7 @@ void battery_test_free(BatteryTestApp* app) {
|
||||
|
||||
// Views
|
||||
view_dispatcher_remove_view(app->view_dispatcher, BatteryTestAppViewBatteryInfo);
|
||||
battery_info_free(app->batery_info);
|
||||
battery_info_free(app->battery_info);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, BatteryTestAppViewExitDialog);
|
||||
dialog_ex_free(app->dialog);
|
||||
// View dispatcher
|
||||
@@ -6,14 +6,15 @@
|
||||
#include <notification/notification.h>
|
||||
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <power/power_settings_app/views/battery_info.h>
|
||||
// FIXME
|
||||
#include "../settings/power_settings_app/views/battery_info.h"
|
||||
|
||||
typedef struct {
|
||||
Power* power;
|
||||
Gui* gui;
|
||||
NotificationApp* notifications;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
BatteryInfo* batery_info;
|
||||
BatteryInfo* battery_info;
|
||||
DialogEx* dialog;
|
||||
PowerInfo info;
|
||||
} BatteryTestApp;
|
||||
11
applications/debug/blink_test/application.fam
Normal file
11
applications/debug/blink_test/application.fam
Normal file
@@ -0,0 +1,11 @@
|
||||
App(
|
||||
appid="blink_test",
|
||||
name="Blink Test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="blink_test_app",
|
||||
cdefines=["APP_BLINK"],
|
||||
requires=["gui"],
|
||||
stack_size=1 * 1024,
|
||||
order=10,
|
||||
fap_category="Debug",
|
||||
)
|
||||
18
applications/debug/bt_debug_app/application.fam
Normal file
18
applications/debug/bt_debug_app/application.fam
Normal file
@@ -0,0 +1,18 @@
|
||||
App(
|
||||
appid="bt_debug",
|
||||
name="Bluetooth Debug",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="bt_debug_app",
|
||||
cdefines=["SRV_BT"],
|
||||
requires=[
|
||||
"bt",
|
||||
"gui",
|
||||
"dialogs",
|
||||
],
|
||||
provides=[
|
||||
"bt_debug",
|
||||
],
|
||||
stack_size=1 * 1024,
|
||||
order=110,
|
||||
fap_category="Debug",
|
||||
)
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <gui/modules/submenu.h>
|
||||
#include "views/bt_carrier_test.h"
|
||||
#include "views/bt_packet_test.h"
|
||||
#include "../bt_settings.h"
|
||||
#include <bt/bt_settings.h>
|
||||
|
||||
typedef struct {
|
||||
BtSettings settings;
|
||||
0
applications/bt/bt_debug_app/views/bt_carrier_test.c → applications/debug/bt_debug_app/views/bt_carrier_test.c
Executable file → Normal file
0
applications/bt/bt_debug_app/views/bt_carrier_test.c → applications/debug/bt_debug_app/views/bt_carrier_test.c
Executable file → Normal file
0
applications/bt/bt_debug_app/views/bt_test.c → applications/debug/bt_debug_app/views/bt_test.c
Executable file → Normal file
0
applications/bt/bt_debug_app/views/bt_test.c → applications/debug/bt_debug_app/views/bt_test.c
Executable file → Normal file
0
applications/bt/bt_debug_app/views/bt_test.h → applications/debug/bt_debug_app/views/bt_test.h
Executable file → Normal file
0
applications/bt/bt_debug_app/views/bt_test.h → applications/debug/bt_debug_app/views/bt_test.h
Executable file → Normal file
11
applications/debug/display_test/application.fam
Normal file
11
applications/debug/display_test/application.fam
Normal file
@@ -0,0 +1,11 @@
|
||||
App(
|
||||
appid="display_test",
|
||||
name="Display Test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="display_test_app",
|
||||
cdefines=["APP_DISPLAY_TEST"],
|
||||
requires=["gui"],
|
||||
stack_size=1 * 1024,
|
||||
order=120,
|
||||
fap_category="Debug",
|
||||
)
|
||||
11
applications/debug/file_browser_test/application.fam
Normal file
11
applications/debug/file_browser_test/application.fam
Normal file
@@ -0,0 +1,11 @@
|
||||
App(
|
||||
appid="file_browser_test",
|
||||
name="File Browser Test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="file_browser_app",
|
||||
cdefines=["APP_FILE_BROWSER_TEST"],
|
||||
requires=["gui"],
|
||||
stack_size=2 * 1024,
|
||||
order=150,
|
||||
fap_category="Debug",
|
||||
)
|
||||
11
applications/debug/keypad_test/application.fam
Normal file
11
applications/debug/keypad_test/application.fam
Normal file
@@ -0,0 +1,11 @@
|
||||
App(
|
||||
appid="keypad_test",
|
||||
name="Keypad Test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="keypad_test_app",
|
||||
cdefines=["APP_KEYPAD_TEST"],
|
||||
requires=["gui"],
|
||||
stack_size=1 * 1024,
|
||||
order=30,
|
||||
fap_category="Debug",
|
||||
)
|
||||
@@ -5,8 +5,11 @@ App(
|
||||
entry_point="lfrfid_debug_app",
|
||||
requires=[
|
||||
"gui",
|
||||
"lfrfid",
|
||||
],
|
||||
provides=[
|
||||
"lfrfid_debug",
|
||||
],
|
||||
stack_size=1 * 1024,
|
||||
order=100,
|
||||
fap_category="Debug",
|
||||
)
|
||||
81
applications/debug/lfrfid_debug/lfrfid_debug.c
Normal file
81
applications/debug/lfrfid_debug/lfrfid_debug.c
Normal file
@@ -0,0 +1,81 @@
|
||||
#include "lfrfid_debug_i.h"
|
||||
|
||||
static bool lfrfid_debug_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
LfRfidDebug* app = context;
|
||||
return scene_manager_handle_custom_event(app->scene_manager, event);
|
||||
}
|
||||
|
||||
static bool lfrfid_debug_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
LfRfidDebug* app = context;
|
||||
return scene_manager_handle_back_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static LfRfidDebug* lfrfid_debug_alloc() {
|
||||
LfRfidDebug* app = malloc(sizeof(LfRfidDebug));
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
app->scene_manager = scene_manager_alloc(&lfrfid_debug_scene_handlers, app);
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
app->view_dispatcher, lfrfid_debug_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
app->view_dispatcher, lfrfid_debug_back_event_callback);
|
||||
|
||||
// Open GUI record
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
// Submenu
|
||||
app->submenu = submenu_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, LfRfidDebugViewSubmenu, submenu_get_view(app->submenu));
|
||||
|
||||
// Tune view
|
||||
app->tune_view = lfrfid_debug_view_tune_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
LfRfidDebugViewTune,
|
||||
lfrfid_debug_view_tune_get_view(app->tune_view));
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
static void lfrfid_debug_free(LfRfidDebug* app) {
|
||||
furi_assert(app);
|
||||
|
||||
// Submenu
|
||||
view_dispatcher_remove_view(app->view_dispatcher, LfRfidDebugViewSubmenu);
|
||||
submenu_free(app->submenu);
|
||||
|
||||
// Tune view
|
||||
view_dispatcher_remove_view(app->view_dispatcher, LfRfidDebugViewTune);
|
||||
lfrfid_debug_view_tune_free(app->tune_view);
|
||||
|
||||
// View Dispatcher
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
// Scene Manager
|
||||
scene_manager_free(app->scene_manager);
|
||||
|
||||
// GUI
|
||||
furi_record_close(RECORD_GUI);
|
||||
app->gui = NULL;
|
||||
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t lfrfid_debug_app(void* p) {
|
||||
UNUSED(p);
|
||||
LfRfidDebug* app = lfrfid_debug_alloc();
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidDebugSceneStart);
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
lfrfid_debug_free(app);
|
||||
|
||||
return 0;
|
||||
}
|
||||
30
applications/debug/lfrfid_debug/lfrfid_debug_i.h
Normal file
30
applications/debug/lfrfid_debug/lfrfid_debug_i.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
#include <gui/modules/submenu.h>
|
||||
|
||||
#include "views/lfrfid_debug_view_tune.h"
|
||||
#include "scenes/lfrfid_debug_scene.h"
|
||||
|
||||
typedef struct LfRfidDebug LfRfidDebug;
|
||||
|
||||
struct LfRfidDebug {
|
||||
Gui* gui;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
SceneManager* scene_manager;
|
||||
|
||||
// Common Views
|
||||
Submenu* submenu;
|
||||
LfRfidTuneView* tune_view;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LfRfidDebugViewSubmenu,
|
||||
LfRfidDebugViewTune,
|
||||
} LfRfidDebugView;
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "../lfrfid_debug_i.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexTune,
|
||||
} SubmenuIndex;
|
||||
|
||||
static void lfrfid_debug_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
LfRfidDebug* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void lfrfid_debug_scene_start_on_enter(void* context) {
|
||||
LfRfidDebug* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu, "Tune", SubmenuIndexTune, lfrfid_debug_scene_start_submenu_callback, app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, LfRfidDebugSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidDebugViewSubmenu);
|
||||
}
|
||||
|
||||
bool lfrfid_debug_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
LfRfidDebug* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexTune) {
|
||||
scene_manager_next_scene(app->scene_manager, LfRfidDebugSceneTune);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void lfrfid_debug_scene_start_on_exit(void* context) {
|
||||
LfRfidDebug* app = context;
|
||||
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "lfrfid_debug_app_scene_tune.h"
|
||||
#include "../lfrfid_debug_i.h"
|
||||
#include <furi_hal.h>
|
||||
|
||||
static void comparator_trigger_callback(bool level, void* comp_ctx) {
|
||||
@@ -6,32 +6,38 @@ static void comparator_trigger_callback(bool level, void* comp_ctx) {
|
||||
furi_hal_gpio_write(&gpio_ext_pa7, !level);
|
||||
}
|
||||
|
||||
void LfRfidDebugAppSceneTune::on_enter(LfRfidDebugApp* app, bool /* need_restore */) {
|
||||
app->view_controller.switch_to<LfRfidViewTuneVM>();
|
||||
void lfrfid_debug_scene_tune_on_enter(void* context) {
|
||||
LfRfidDebug* app = context;
|
||||
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa7, GpioModeOutputPushPull);
|
||||
|
||||
furi_hal_rfid_comp_set_callback(comparator_trigger_callback, this);
|
||||
furi_hal_rfid_comp_set_callback(comparator_trigger_callback, app);
|
||||
furi_hal_rfid_comp_start();
|
||||
|
||||
furi_hal_rfid_pins_read();
|
||||
furi_hal_rfid_tim_read(125000, 0.5);
|
||||
furi_hal_rfid_tim_read_start();
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidDebugViewTune);
|
||||
}
|
||||
|
||||
bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* /* event */) {
|
||||
bool lfrfid_debug_scene_tune_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(event);
|
||||
|
||||
LfRfidDebug* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
LfRfidViewTuneVM* tune = app->view_controller;
|
||||
|
||||
if(tune->is_dirty()) {
|
||||
furi_hal_rfid_set_read_period(tune->get_ARR());
|
||||
furi_hal_rfid_set_read_pulse(tune->get_CCR());
|
||||
if(lfrfid_debug_view_tune_is_dirty(app->tune_view)) {
|
||||
furi_hal_rfid_set_read_period(lfrfid_debug_view_tune_get_arr(app->tune_view));
|
||||
furi_hal_rfid_set_read_pulse(lfrfid_debug_view_tune_get_ccr(app->tune_view));
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void LfRfidDebugAppSceneTune::on_exit(LfRfidDebugApp* /* app */) {
|
||||
void lfrfid_debug_scene_tune_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
|
||||
furi_hal_rfid_comp_stop();
|
||||
furi_hal_rfid_comp_set_callback(NULL, NULL);
|
||||
|
||||
30
applications/debug/lfrfid_debug/scenes/lfrfid_debug_scene.c
Normal file
30
applications/debug/lfrfid_debug/scenes/lfrfid_debug_scene.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "lfrfid_debug_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const lfrfid_debug_on_enter_handlers[])(void*) = {
|
||||
#include "lfrfid_debug_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const lfrfid_debug_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "lfrfid_debug_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const lfrfid_debug_on_exit_handlers[])(void* context) = {
|
||||
#include "lfrfid_debug_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers lfrfid_debug_scene_handlers = {
|
||||
.on_enter_handlers = lfrfid_debug_on_enter_handlers,
|
||||
.on_event_handlers = lfrfid_debug_on_event_handlers,
|
||||
.on_exit_handlers = lfrfid_debug_on_exit_handlers,
|
||||
.scene_num = LfRfidDebugSceneNum,
|
||||
};
|
||||
29
applications/debug/lfrfid_debug/scenes/lfrfid_debug_scene.h
Normal file
29
applications/debug/lfrfid_debug/scenes/lfrfid_debug_scene.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) LfRfidDebugScene##id,
|
||||
typedef enum {
|
||||
#include "lfrfid_debug_scene_config.h"
|
||||
LfRfidDebugSceneNum,
|
||||
} LfRfidDebugScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers lfrfid_debug_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "lfrfid_debug_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "lfrfid_debug_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "lfrfid_debug_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
@@ -0,0 +1,2 @@
|
||||
ADD_SCENE(lfrfid_debug, start, Start)
|
||||
ADD_SCENE(lfrfid_debug, tune, Tune)
|
||||
229
applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.c
Normal file
229
applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.c
Normal file
@@ -0,0 +1,229 @@
|
||||
#include "lfrfid_debug_view_tune.h"
|
||||
#include <gui/elements.h>
|
||||
|
||||
#define TEMP_STR_LEN 128
|
||||
|
||||
struct LfRfidTuneView {
|
||||
View* view;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
bool dirty;
|
||||
bool fine;
|
||||
uint32_t ARR;
|
||||
uint32_t CCR;
|
||||
int pos;
|
||||
} LfRfidTuneViewModel;
|
||||
|
||||
static void lfrfid_debug_view_tune_draw_callback(Canvas* canvas, void* _model) {
|
||||
LfRfidTuneViewModel* model = _model;
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
|
||||
if(model->fine) {
|
||||
canvas_draw_box(
|
||||
canvas,
|
||||
128 - canvas_string_width(canvas, "Fine") - 4,
|
||||
0,
|
||||
canvas_string_width(canvas, "Fine") + 4,
|
||||
canvas_current_font_height(canvas) + 1);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
}
|
||||
canvas_draw_str_aligned(canvas, 128 - 2, 2, AlignRight, AlignTop, "Fine");
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
|
||||
char buffer[TEMP_STR_LEN + 1];
|
||||
double freq = ((float)SystemCoreClock / ((float)model->ARR + 1));
|
||||
double duty = ((float)model->CCR + 1) / ((float)model->ARR + 1) * 100.0f;
|
||||
snprintf(
|
||||
buffer,
|
||||
TEMP_STR_LEN,
|
||||
"%sARR: %lu\n"
|
||||
"freq = %.4f\n"
|
||||
"%sCCR: %lu\n"
|
||||
"duty = %.4f",
|
||||
model->pos == 0 ? ">" : "",
|
||||
model->ARR,
|
||||
freq,
|
||||
model->pos == 1 ? ">" : "",
|
||||
model->CCR,
|
||||
duty);
|
||||
elements_multiline_text_aligned(canvas, 2, 2, AlignLeft, AlignTop, buffer);
|
||||
}
|
||||
|
||||
static void lfrfid_debug_view_tune_button_up(LfRfidTuneView* tune_view) {
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
if(model->pos > 0) model->pos--;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
static void lfrfid_debug_view_tune_button_down(LfRfidTuneView* tune_view) {
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
if(model->pos < 1) model->pos++;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
static void lfrfid_debug_view_tune_button_left(LfRfidTuneView* tune_view) {
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
if(model->pos == 0) {
|
||||
if(model->fine) {
|
||||
model->ARR -= 1;
|
||||
} else {
|
||||
model->ARR -= 10;
|
||||
}
|
||||
} else if(model->pos == 1) {
|
||||
if(model->fine) {
|
||||
model->CCR -= 1;
|
||||
} else {
|
||||
model->CCR -= 10;
|
||||
}
|
||||
}
|
||||
|
||||
model->dirty = true;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
static void lfrfid_debug_view_tune_button_right(LfRfidTuneView* tune_view) {
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
if(model->pos == 0) {
|
||||
if(model->fine) {
|
||||
model->ARR += 1;
|
||||
} else {
|
||||
model->ARR += 10;
|
||||
}
|
||||
} else if(model->pos == 1) {
|
||||
if(model->fine) {
|
||||
model->CCR += 1;
|
||||
} else {
|
||||
model->CCR += 10;
|
||||
}
|
||||
}
|
||||
|
||||
model->dirty = true;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
static void lfrfid_debug_view_tune_button_ok(LfRfidTuneView* tune_view) {
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
model->fine = !model->fine;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
static bool lfrfid_debug_view_tune_input_callback(InputEvent* event, void* context) {
|
||||
LfRfidTuneView* tune_view = context;
|
||||
bool consumed = false;
|
||||
|
||||
// Process key presses only
|
||||
if(event->type == InputTypeShort || event->type == InputTypeRepeat) {
|
||||
consumed = true;
|
||||
|
||||
switch(event->key) {
|
||||
case InputKeyLeft:
|
||||
lfrfid_debug_view_tune_button_left(tune_view);
|
||||
break;
|
||||
case InputKeyRight:
|
||||
lfrfid_debug_view_tune_button_right(tune_view);
|
||||
break;
|
||||
case InputKeyUp:
|
||||
lfrfid_debug_view_tune_button_up(tune_view);
|
||||
break;
|
||||
case InputKeyDown:
|
||||
lfrfid_debug_view_tune_button_down(tune_view);
|
||||
break;
|
||||
case InputKeyOk:
|
||||
lfrfid_debug_view_tune_button_ok(tune_view);
|
||||
break;
|
||||
default:
|
||||
consumed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
LfRfidTuneView* lfrfid_debug_view_tune_alloc() {
|
||||
LfRfidTuneView* tune_view = malloc(sizeof(LfRfidTuneView));
|
||||
tune_view->view = view_alloc();
|
||||
view_set_context(tune_view->view, tune_view);
|
||||
view_allocate_model(tune_view->view, ViewModelTypeLocking, sizeof(LfRfidTuneViewModel));
|
||||
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
model->dirty = true;
|
||||
model->fine = false;
|
||||
model->ARR = 511;
|
||||
model->CCR = 255;
|
||||
model->pos = 0;
|
||||
return true;
|
||||
});
|
||||
|
||||
view_set_draw_callback(tune_view->view, lfrfid_debug_view_tune_draw_callback);
|
||||
view_set_input_callback(tune_view->view, lfrfid_debug_view_tune_input_callback);
|
||||
|
||||
return tune_view;
|
||||
}
|
||||
|
||||
void lfrfid_debug_view_tune_free(LfRfidTuneView* tune_view) {
|
||||
view_free(tune_view->view);
|
||||
free(tune_view);
|
||||
}
|
||||
|
||||
View* lfrfid_debug_view_tune_get_view(LfRfidTuneView* tune_view) {
|
||||
return tune_view->view;
|
||||
}
|
||||
|
||||
void lfrfid_debug_view_tune_clean(LfRfidTuneView* tune_view) {
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
model->dirty = true;
|
||||
model->fine = false;
|
||||
model->ARR = 511;
|
||||
model->CCR = 255;
|
||||
model->pos = 0;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool lfrfid_debug_view_tune_is_dirty(LfRfidTuneView* tune_view) {
|
||||
bool result = false;
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
result = model->dirty;
|
||||
model->dirty = false;
|
||||
return false;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t lfrfid_debug_view_tune_get_arr(LfRfidTuneView* tune_view) {
|
||||
uint32_t result = false;
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
result = model->ARR;
|
||||
return false;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t lfrfid_debug_view_tune_get_ccr(LfRfidTuneView* tune_view) {
|
||||
uint32_t result = false;
|
||||
with_view_model(
|
||||
tune_view->view, (LfRfidTuneViewModel * model) {
|
||||
result = model->CCR;
|
||||
return false;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <gui/view.h>
|
||||
|
||||
typedef struct LfRfidTuneView LfRfidTuneView;
|
||||
|
||||
LfRfidTuneView* lfrfid_debug_view_tune_alloc();
|
||||
|
||||
void lfrfid_debug_view_tune_free(LfRfidTuneView* tune_view);
|
||||
|
||||
View* lfrfid_debug_view_tune_get_view(LfRfidTuneView* tune_view);
|
||||
|
||||
void lfrfid_debug_view_tune_clean(LfRfidTuneView* tune_view);
|
||||
|
||||
bool lfrfid_debug_view_tune_is_dirty(LfRfidTuneView* tune_view);
|
||||
|
||||
uint32_t lfrfid_debug_view_tune_get_arr(LfRfidTuneView* tune_view);
|
||||
|
||||
uint32_t lfrfid_debug_view_tune_get_ccr(LfRfidTuneView* tune_view);
|
||||
11
applications/debug/text_box_test/application.fam
Normal file
11
applications/debug/text_box_test/application.fam
Normal file
@@ -0,0 +1,11 @@
|
||||
App(
|
||||
appid="text_box_test",
|
||||
name="Text Box Test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
entry_point="text_box_test_app",
|
||||
cdefines=["APP_TEXT_BOX_TEST"],
|
||||
requires=["gui"],
|
||||
stack_size=1 * 1024,
|
||||
order=140,
|
||||
fap_category="Debug",
|
||||
)
|
||||
12
applications/debug/uart_echo/application.fam
Normal file
12
applications/debug/uart_echo/application.fam
Normal file
@@ -0,0 +1,12 @@
|
||||
App(
|
||||
appid="uart_echo",
|
||||
name="UART Echo",
|
||||
apptype=FlipperAppType.PLUGIN,
|
||||
entry_point="uart_echo_app",
|
||||
cdefines=["APP_UART_ECHO"],
|
||||
requires=["gui"],
|
||||
stack_size=2 * 1024,
|
||||
order=70,
|
||||
fap_icon="../../../assets/icons/Archive/keyboard_10px.png",
|
||||
fap_category="Misc",
|
||||
)
|
||||
@@ -10,7 +10,7 @@ App(
|
||||
App(
|
||||
appid="delay_test",
|
||||
name="Delay Test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
apptype=FlipperAppType.SYSTEM,
|
||||
entry_point="delay_test_app",
|
||||
stack_size=1 * 1024,
|
||||
requires=["unit_tests"],
|
||||
473
applications/debug/unit_tests/lfrfid/bit_lib_test.c
Normal file
473
applications/debug/unit_tests/lfrfid/bit_lib_test.c
Normal file
@@ -0,0 +1,473 @@
|
||||
#include <furi.h>
|
||||
#include "../minunit.h"
|
||||
#include <lfrfid/tools/bit_lib.h>
|
||||
|
||||
MU_TEST(test_bit_lib_increment_index) {
|
||||
uint32_t index = 0;
|
||||
|
||||
// test increment
|
||||
for(uint32_t i = 0; i < 31; ++i) {
|
||||
bit_lib_increment_index(index, 32);
|
||||
mu_assert_int_eq(i + 1, index);
|
||||
}
|
||||
|
||||
// test wrap around
|
||||
for(uint32_t i = 0; i < 512; ++i) {
|
||||
bit_lib_increment_index(index, 32);
|
||||
mu_assert_int_less_than(32, index);
|
||||
}
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_is_set) {
|
||||
uint32_t value = 0x0000FFFF;
|
||||
|
||||
for(uint32_t i = 0; i < 16; ++i) {
|
||||
mu_check(bit_lib_bit_is_set(value, i));
|
||||
mu_check(!bit_lib_bit_is_not_set(value, i));
|
||||
}
|
||||
|
||||
for(uint32_t i = 16; i < 32; ++i) {
|
||||
mu_check(!bit_lib_bit_is_set(value, i));
|
||||
mu_check(bit_lib_bit_is_not_set(value, i));
|
||||
}
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_push) {
|
||||
#define TEST_BIT_LIB_PUSH_DATA_SIZE 4
|
||||
uint8_t data[TEST_BIT_LIB_PUSH_DATA_SIZE] = {0};
|
||||
uint8_t expected_data_1[TEST_BIT_LIB_PUSH_DATA_SIZE] = {0x00, 0x00, 0x0F, 0xFF};
|
||||
uint8_t expected_data_2[TEST_BIT_LIB_PUSH_DATA_SIZE] = {0x00, 0xFF, 0xF0, 0x00};
|
||||
uint8_t expected_data_3[TEST_BIT_LIB_PUSH_DATA_SIZE] = {0xFF, 0x00, 0x00, 0xFF};
|
||||
uint8_t expected_data_4[TEST_BIT_LIB_PUSH_DATA_SIZE] = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
uint8_t expected_data_5[TEST_BIT_LIB_PUSH_DATA_SIZE] = {0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t expected_data_6[TEST_BIT_LIB_PUSH_DATA_SIZE] = {0xCC, 0xCC, 0xCC, 0xCC};
|
||||
|
||||
for(uint32_t i = 0; i < 12; ++i) {
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, true);
|
||||
}
|
||||
mu_assert_mem_eq(expected_data_1, data, TEST_BIT_LIB_PUSH_DATA_SIZE);
|
||||
|
||||
for(uint32_t i = 0; i < 12; ++i) {
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, false);
|
||||
}
|
||||
mu_assert_mem_eq(expected_data_2, data, TEST_BIT_LIB_PUSH_DATA_SIZE);
|
||||
|
||||
for(uint32_t i = 0; i < 4; ++i) {
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, false);
|
||||
}
|
||||
for(uint32_t i = 0; i < 8; ++i) {
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, true);
|
||||
}
|
||||
mu_assert_mem_eq(expected_data_3, data, TEST_BIT_LIB_PUSH_DATA_SIZE);
|
||||
|
||||
for(uint32_t i = 0; i < TEST_BIT_LIB_PUSH_DATA_SIZE * 8; ++i) {
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, true);
|
||||
}
|
||||
mu_assert_mem_eq(expected_data_4, data, TEST_BIT_LIB_PUSH_DATA_SIZE);
|
||||
|
||||
for(uint32_t i = 0; i < TEST_BIT_LIB_PUSH_DATA_SIZE * 8; ++i) {
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, false);
|
||||
}
|
||||
mu_assert_mem_eq(expected_data_5, data, TEST_BIT_LIB_PUSH_DATA_SIZE);
|
||||
|
||||
for(uint32_t i = 0; i < TEST_BIT_LIB_PUSH_DATA_SIZE * 2; ++i) {
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, true);
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, true);
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, false);
|
||||
bit_lib_push_bit(data, TEST_BIT_LIB_PUSH_DATA_SIZE, false);
|
||||
}
|
||||
mu_assert_mem_eq(expected_data_6, data, TEST_BIT_LIB_PUSH_DATA_SIZE);
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_set_bit) {
|
||||
uint8_t value[2] = {0x00, 0xFF};
|
||||
bit_lib_set_bit(value, 15, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0xFE}), 2);
|
||||
bit_lib_set_bit(value, 14, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0xFC}), 2);
|
||||
bit_lib_set_bit(value, 13, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0xF8}), 2);
|
||||
bit_lib_set_bit(value, 12, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0xF0}), 2);
|
||||
bit_lib_set_bit(value, 11, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0xE0}), 2);
|
||||
bit_lib_set_bit(value, 10, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0xC0}), 2);
|
||||
bit_lib_set_bit(value, 9, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0x80}), 2);
|
||||
bit_lib_set_bit(value, 8, false);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x00, 0x00}), 2);
|
||||
|
||||
bit_lib_set_bit(value, 7, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x01, 0x00}), 2);
|
||||
bit_lib_set_bit(value, 6, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x03, 0x00}), 2);
|
||||
bit_lib_set_bit(value, 5, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x07, 0x00}), 2);
|
||||
bit_lib_set_bit(value, 4, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x0F, 0x00}), 2);
|
||||
bit_lib_set_bit(value, 3, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x1F, 0x00}), 2);
|
||||
bit_lib_set_bit(value, 2, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x3F, 0x00}), 2);
|
||||
bit_lib_set_bit(value, 1, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0x7F, 0x00}), 2);
|
||||
bit_lib_set_bit(value, 0, true);
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0xFF, 0x00}), 2);
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_set_bits) {
|
||||
uint8_t value[2] = {0b00000000, 0b11111111};
|
||||
// set 4 bits to 0b0100 from 12 index
|
||||
bit_lib_set_bits(value, 12, 0b0100, 4);
|
||||
// [0100]
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0b00000000, 0b11110100}), 2);
|
||||
|
||||
// set 2 bits to 0b11 from 11 index
|
||||
bit_lib_set_bits(value, 11, 0b11, 2);
|
||||
// [11]
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0b00000000, 0b11111100}), 2);
|
||||
|
||||
// set 3 bits to 0b111 from 0 index
|
||||
bit_lib_set_bits(value, 0, 0b111, 3);
|
||||
// [111]
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0b11100000, 0b11111100}), 2);
|
||||
|
||||
// set 8 bits to 0b11111000 from 3 index
|
||||
bit_lib_set_bits(value, 3, 0b11111000, 8);
|
||||
// [11111 000]
|
||||
mu_assert_mem_eq(value, ((uint8_t[]){0b11111111, 0b00011100}), 2);
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_get_bit) {
|
||||
uint8_t value[2] = {0b00000000, 0b11111111};
|
||||
for(uint32_t i = 0; i < 8; ++i) {
|
||||
mu_check(bit_lib_get_bit(value, i) == false);
|
||||
}
|
||||
for(uint32_t i = 8; i < 16; ++i) {
|
||||
mu_check(bit_lib_get_bit(value, i) == true);
|
||||
}
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_get_bits) {
|
||||
uint8_t value[2] = {0b00000000, 0b11111111};
|
||||
mu_assert_int_eq(0b00000000, bit_lib_get_bits(value, 0, 8));
|
||||
mu_assert_int_eq(0b00000001, bit_lib_get_bits(value, 1, 8));
|
||||
mu_assert_int_eq(0b00000011, bit_lib_get_bits(value, 2, 8));
|
||||
mu_assert_int_eq(0b00000111, bit_lib_get_bits(value, 3, 8));
|
||||
mu_assert_int_eq(0b00001111, bit_lib_get_bits(value, 4, 8));
|
||||
mu_assert_int_eq(0b00011111, bit_lib_get_bits(value, 5, 8));
|
||||
mu_assert_int_eq(0b00111111, bit_lib_get_bits(value, 6, 8));
|
||||
mu_assert_int_eq(0b01111111, bit_lib_get_bits(value, 7, 8));
|
||||
mu_assert_int_eq(0b11111111, bit_lib_get_bits(value, 8, 8));
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_get_bits_16) {
|
||||
uint8_t value[2] = {0b00001001, 0b10110001};
|
||||
mu_assert_int_eq(0b0, bit_lib_get_bits_16(value, 0, 1));
|
||||
mu_assert_int_eq(0b00, bit_lib_get_bits_16(value, 0, 2));
|
||||
mu_assert_int_eq(0b000, bit_lib_get_bits_16(value, 0, 3));
|
||||
mu_assert_int_eq(0b0000, bit_lib_get_bits_16(value, 0, 4));
|
||||
mu_assert_int_eq(0b00001, bit_lib_get_bits_16(value, 0, 5));
|
||||
mu_assert_int_eq(0b000010, bit_lib_get_bits_16(value, 0, 6));
|
||||
mu_assert_int_eq(0b0000100, bit_lib_get_bits_16(value, 0, 7));
|
||||
mu_assert_int_eq(0b00001001, bit_lib_get_bits_16(value, 0, 8));
|
||||
mu_assert_int_eq(0b000010011, bit_lib_get_bits_16(value, 0, 9));
|
||||
mu_assert_int_eq(0b0000100110, bit_lib_get_bits_16(value, 0, 10));
|
||||
mu_assert_int_eq(0b00001001101, bit_lib_get_bits_16(value, 0, 11));
|
||||
mu_assert_int_eq(0b000010011011, bit_lib_get_bits_16(value, 0, 12));
|
||||
mu_assert_int_eq(0b0000100110110, bit_lib_get_bits_16(value, 0, 13));
|
||||
mu_assert_int_eq(0b00001001101100, bit_lib_get_bits_16(value, 0, 14));
|
||||
mu_assert_int_eq(0b000010011011000, bit_lib_get_bits_16(value, 0, 15));
|
||||
mu_assert_int_eq(0b0000100110110001, bit_lib_get_bits_16(value, 0, 16));
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_get_bits_32) {
|
||||
uint8_t value[4] = {0b00001001, 0b10110001, 0b10001100, 0b01100010};
|
||||
mu_assert_int_eq(0b0, bit_lib_get_bits_32(value, 0, 1));
|
||||
mu_assert_int_eq(0b00, bit_lib_get_bits_32(value, 0, 2));
|
||||
mu_assert_int_eq(0b000, bit_lib_get_bits_32(value, 0, 3));
|
||||
mu_assert_int_eq(0b0000, bit_lib_get_bits_32(value, 0, 4));
|
||||
mu_assert_int_eq(0b00001, bit_lib_get_bits_32(value, 0, 5));
|
||||
mu_assert_int_eq(0b000010, bit_lib_get_bits_32(value, 0, 6));
|
||||
mu_assert_int_eq(0b0000100, bit_lib_get_bits_32(value, 0, 7));
|
||||
mu_assert_int_eq(0b00001001, bit_lib_get_bits_32(value, 0, 8));
|
||||
mu_assert_int_eq(0b000010011, bit_lib_get_bits_32(value, 0, 9));
|
||||
mu_assert_int_eq(0b0000100110, bit_lib_get_bits_32(value, 0, 10));
|
||||
mu_assert_int_eq(0b00001001101, bit_lib_get_bits_32(value, 0, 11));
|
||||
mu_assert_int_eq(0b000010011011, bit_lib_get_bits_32(value, 0, 12));
|
||||
mu_assert_int_eq(0b0000100110110, bit_lib_get_bits_32(value, 0, 13));
|
||||
mu_assert_int_eq(0b00001001101100, bit_lib_get_bits_32(value, 0, 14));
|
||||
mu_assert_int_eq(0b000010011011000, bit_lib_get_bits_32(value, 0, 15));
|
||||
mu_assert_int_eq(0b0000100110110001, bit_lib_get_bits_32(value, 0, 16));
|
||||
mu_assert_int_eq(0b00001001101100011, bit_lib_get_bits_32(value, 0, 17));
|
||||
mu_assert_int_eq(0b000010011011000110, bit_lib_get_bits_32(value, 0, 18));
|
||||
mu_assert_int_eq(0b0000100110110001100, bit_lib_get_bits_32(value, 0, 19));
|
||||
mu_assert_int_eq(0b00001001101100011000, bit_lib_get_bits_32(value, 0, 20));
|
||||
mu_assert_int_eq(0b000010011011000110001, bit_lib_get_bits_32(value, 0, 21));
|
||||
mu_assert_int_eq(0b0000100110110001100011, bit_lib_get_bits_32(value, 0, 22));
|
||||
mu_assert_int_eq(0b00001001101100011000110, bit_lib_get_bits_32(value, 0, 23));
|
||||
mu_assert_int_eq(0b000010011011000110001100, bit_lib_get_bits_32(value, 0, 24));
|
||||
mu_assert_int_eq(0b0000100110110001100011000, bit_lib_get_bits_32(value, 0, 25));
|
||||
mu_assert_int_eq(0b00001001101100011000110001, bit_lib_get_bits_32(value, 0, 26));
|
||||
mu_assert_int_eq(0b000010011011000110001100011, bit_lib_get_bits_32(value, 0, 27));
|
||||
mu_assert_int_eq(0b0000100110110001100011000110, bit_lib_get_bits_32(value, 0, 28));
|
||||
mu_assert_int_eq(0b00001001101100011000110001100, bit_lib_get_bits_32(value, 0, 29));
|
||||
mu_assert_int_eq(0b000010011011000110001100011000, bit_lib_get_bits_32(value, 0, 30));
|
||||
mu_assert_int_eq(0b0000100110110001100011000110001, bit_lib_get_bits_32(value, 0, 31));
|
||||
mu_assert_int_eq(0b00001001101100011000110001100010, bit_lib_get_bits_32(value, 0, 32));
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_test_parity_u32) {
|
||||
// test even parity
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000000, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000001, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000010, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000011, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000100, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000101, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000110, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000111, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001000, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001001, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001010, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001011, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001100, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001101, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001110, BitLibParityEven), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001111, BitLibParityEven), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00010000, BitLibParityEven), 1);
|
||||
|
||||
// test odd parity
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000000, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000001, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000010, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000011, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000100, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000101, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000110, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00000111, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001000, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001001, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001010, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001011, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001100, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001101, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001110, BitLibParityOdd), 0);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00001111, BitLibParityOdd), 1);
|
||||
mu_assert_int_eq(bit_lib_test_parity_32(0b00010000, BitLibParityOdd), 0);
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_test_parity) {
|
||||
// next data contains valid parity for 1-3 nibble and invalid for 4 nibble
|
||||
uint8_t data_always_0_parity[2] = {0b11101110, 0b11101111};
|
||||
uint8_t data_always_1_parity[2] = {0b00010001, 0b00010000};
|
||||
uint8_t data_always_odd_parity[2] = {0b00000011, 0b11110111};
|
||||
uint8_t data_always_even_parity[2] = {0b00010111, 0b10110011};
|
||||
|
||||
// test alawys 0 parity
|
||||
mu_check(bit_lib_test_parity(data_always_0_parity, 0, 12, BitLibParityAlways0, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_0_parity, 4, 8, BitLibParityAlways0, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_0_parity, 8, 4, BitLibParityAlways0, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_1_parity, 12, 4, BitLibParityAlways0, 4));
|
||||
|
||||
mu_check(!bit_lib_test_parity(data_always_0_parity, 0, 16, BitLibParityAlways0, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_0_parity, 4, 12, BitLibParityAlways0, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_0_parity, 8, 8, BitLibParityAlways0, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_0_parity, 12, 4, BitLibParityAlways0, 4));
|
||||
|
||||
// test alawys 1 parity
|
||||
mu_check(bit_lib_test_parity(data_always_1_parity, 0, 12, BitLibParityAlways1, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_1_parity, 4, 8, BitLibParityAlways1, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_1_parity, 8, 4, BitLibParityAlways1, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_0_parity, 12, 4, BitLibParityAlways1, 4));
|
||||
|
||||
mu_check(!bit_lib_test_parity(data_always_1_parity, 0, 16, BitLibParityAlways1, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_1_parity, 4, 12, BitLibParityAlways1, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_1_parity, 8, 8, BitLibParityAlways1, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_1_parity, 12, 4, BitLibParityAlways1, 4));
|
||||
|
||||
// test odd parity
|
||||
mu_check(bit_lib_test_parity(data_always_odd_parity, 0, 12, BitLibParityOdd, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_odd_parity, 4, 8, BitLibParityOdd, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_odd_parity, 8, 4, BitLibParityOdd, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_even_parity, 12, 4, BitLibParityOdd, 4));
|
||||
|
||||
mu_check(!bit_lib_test_parity(data_always_odd_parity, 0, 16, BitLibParityOdd, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_odd_parity, 4, 12, BitLibParityOdd, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_odd_parity, 8, 8, BitLibParityOdd, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_odd_parity, 12, 4, BitLibParityOdd, 4));
|
||||
|
||||
// test even parity
|
||||
mu_check(bit_lib_test_parity(data_always_even_parity, 0, 12, BitLibParityEven, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_even_parity, 4, 8, BitLibParityEven, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_even_parity, 8, 4, BitLibParityEven, 4));
|
||||
mu_check(bit_lib_test_parity(data_always_odd_parity, 12, 4, BitLibParityEven, 4));
|
||||
|
||||
mu_check(!bit_lib_test_parity(data_always_even_parity, 0, 16, BitLibParityEven, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_even_parity, 4, 12, BitLibParityEven, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_even_parity, 8, 8, BitLibParityEven, 4));
|
||||
mu_check(!bit_lib_test_parity(data_always_even_parity, 12, 4, BitLibParityEven, 4));
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_remove_bit_every_nth) {
|
||||
// TODO: more tests
|
||||
uint8_t data_i[1] = {0b00001111};
|
||||
uint8_t data_o[1] = {0b00011111};
|
||||
size_t length;
|
||||
|
||||
length = bit_lib_remove_bit_every_nth(data_i, 0, 8, 3);
|
||||
mu_assert_int_eq(6, length);
|
||||
mu_assert_mem_eq(data_o, data_i, 1);
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_reverse_bits) {
|
||||
uint8_t data_1_i[2] = {0b11001010, 0b00011111};
|
||||
uint8_t data_1_o[2] = {0b11111000, 0b01010011};
|
||||
|
||||
// reverse bits [0..15]
|
||||
bit_lib_reverse_bits(data_1_i, 0, 16);
|
||||
mu_assert_mem_eq(data_1_o, data_1_i, 2);
|
||||
|
||||
uint8_t data_2_i[2] = {0b11001010, 0b00011111};
|
||||
uint8_t data_2_o[2] = {0b11001000, 0b01011111};
|
||||
|
||||
// reverse bits [4..11]
|
||||
bit_lib_reverse_bits(data_2_i, 4, 8);
|
||||
mu_assert_mem_eq(data_2_o, data_2_i, 2);
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_copy_bits) {
|
||||
uint8_t data_1_i[2] = {0b11001010, 0b00011111};
|
||||
uint8_t data_1_o[2] = {0};
|
||||
|
||||
// data_1_o[0..15] = data_1_i[0..15]
|
||||
bit_lib_copy_bits(data_1_o, 0, 16, data_1_i, 0);
|
||||
mu_assert_mem_eq(data_1_i, data_1_o, 2);
|
||||
|
||||
memset(data_1_o, 0, 2);
|
||||
// data_1_o[4..11] = data_1_i[0..7]
|
||||
bit_lib_copy_bits(data_1_o, 4, 8, data_1_i, 0);
|
||||
mu_assert_mem_eq(((uint8_t[]){0b00001100, 0b10100000}), data_1_o, 2);
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_get_bit_count) {
|
||||
mu_assert_int_eq(0, bit_lib_get_bit_count(0));
|
||||
mu_assert_int_eq(1, bit_lib_get_bit_count(0b1));
|
||||
mu_assert_int_eq(1, bit_lib_get_bit_count(0b10));
|
||||
mu_assert_int_eq(2, bit_lib_get_bit_count(0b11));
|
||||
mu_assert_int_eq(4, bit_lib_get_bit_count(0b11000011));
|
||||
mu_assert_int_eq(6, bit_lib_get_bit_count(0b11000011000011));
|
||||
mu_assert_int_eq(8, bit_lib_get_bit_count(0b11111111));
|
||||
mu_assert_int_eq(16, bit_lib_get_bit_count(0b11111110000000000000000111111111));
|
||||
mu_assert_int_eq(32, bit_lib_get_bit_count(0b11111111111111111111111111111111));
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_reverse_16_fast) {
|
||||
mu_assert_int_eq(0b0000000000000000, bit_lib_reverse_16_fast(0b0000000000000000));
|
||||
mu_assert_int_eq(0b1000000000000000, bit_lib_reverse_16_fast(0b0000000000000001));
|
||||
mu_assert_int_eq(0b1100000000000000, bit_lib_reverse_16_fast(0b0000000000000011));
|
||||
mu_assert_int_eq(0b0000100000001001, bit_lib_reverse_16_fast(0b1001000000010000));
|
||||
}
|
||||
|
||||
MU_TEST(test_bit_lib_crc16) {
|
||||
uint8_t data[9] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
uint8_t data_size = 9;
|
||||
|
||||
// Algorithm
|
||||
// Check Poly Init RefIn RefOut XorOut
|
||||
// CRC-16/CCITT-FALSE
|
||||
// 0x29B1 0x1021 0xFFFF false false 0x0000
|
||||
mu_assert_int_eq(0x29B1, bit_lib_crc16(data, data_size, 0x1021, 0xFFFF, false, false, 0x0000));
|
||||
// CRC-16/ARC
|
||||
// 0xBB3D 0x8005 0x0000 true true 0x0000
|
||||
mu_assert_int_eq(0xBB3D, bit_lib_crc16(data, data_size, 0x8005, 0x0000, true, true, 0x0000));
|
||||
// CRC-16/AUG-CCITT
|
||||
// 0xE5CC 0x1021 0x1D0F false false 0x0000
|
||||
mu_assert_int_eq(0xE5CC, bit_lib_crc16(data, data_size, 0x1021, 0x1D0F, false, false, 0x0000));
|
||||
// CRC-16/BUYPASS
|
||||
// 0xFEE8 0x8005 0x0000 false false 0x0000
|
||||
mu_assert_int_eq(0xFEE8, bit_lib_crc16(data, data_size, 0x8005, 0x0000, false, false, 0x0000));
|
||||
// CRC-16/CDMA2000
|
||||
// 0x4C06 0xC867 0xFFFF false false 0x0000
|
||||
mu_assert_int_eq(0x4C06, bit_lib_crc16(data, data_size, 0xC867, 0xFFFF, false, false, 0x0000));
|
||||
// CRC-16/DDS-110
|
||||
// 0x9ECF 0x8005 0x800D false false 0x0000
|
||||
mu_assert_int_eq(0x9ECF, bit_lib_crc16(data, data_size, 0x8005, 0x800D, false, false, 0x0000));
|
||||
// CRC-16/DECT-R
|
||||
// 0x007E 0x0589 0x0000 false false 0x0001
|
||||
mu_assert_int_eq(0x007E, bit_lib_crc16(data, data_size, 0x0589, 0x0000, false, false, 0x0001));
|
||||
// CRC-16/DECT-X
|
||||
// 0x007F 0x0589 0x0000 false false 0x0000
|
||||
mu_assert_int_eq(0x007F, bit_lib_crc16(data, data_size, 0x0589, 0x0000, false, false, 0x0000));
|
||||
// CRC-16/DNP
|
||||
// 0xEA82 0x3D65 0x0000 true true 0xFFFF
|
||||
mu_assert_int_eq(0xEA82, bit_lib_crc16(data, data_size, 0x3D65, 0x0000, true, true, 0xFFFF));
|
||||
// CRC-16/EN-13757
|
||||
// 0xC2B7 0x3D65 0x0000 false false 0xFFFF
|
||||
mu_assert_int_eq(0xC2B7, bit_lib_crc16(data, data_size, 0x3D65, 0x0000, false, false, 0xFFFF));
|
||||
// CRC-16/GENIBUS
|
||||
// 0xD64E 0x1021 0xFFFF false false 0xFFFF
|
||||
mu_assert_int_eq(0xD64E, bit_lib_crc16(data, data_size, 0x1021, 0xFFFF, false, false, 0xFFFF));
|
||||
// CRC-16/MAXIM
|
||||
// 0x44C2 0x8005 0x0000 true true 0xFFFF
|
||||
mu_assert_int_eq(0x44C2, bit_lib_crc16(data, data_size, 0x8005, 0x0000, true, true, 0xFFFF));
|
||||
// CRC-16/MCRF4XX
|
||||
// 0x6F91 0x1021 0xFFFF true true 0x0000
|
||||
mu_assert_int_eq(0x6F91, bit_lib_crc16(data, data_size, 0x1021, 0xFFFF, true, true, 0x0000));
|
||||
// CRC-16/RIELLO
|
||||
// 0x63D0 0x1021 0xB2AA true true 0x0000
|
||||
mu_assert_int_eq(0x63D0, bit_lib_crc16(data, data_size, 0x1021, 0xB2AA, true, true, 0x0000));
|
||||
// CRC-16/T10-DIF
|
||||
// 0xD0DB 0x8BB7 0x0000 false false 0x0000
|
||||
mu_assert_int_eq(0xD0DB, bit_lib_crc16(data, data_size, 0x8BB7, 0x0000, false, false, 0x0000));
|
||||
// CRC-16/TELEDISK
|
||||
// 0x0FB3 0xA097 0x0000 false false 0x0000
|
||||
mu_assert_int_eq(0x0FB3, bit_lib_crc16(data, data_size, 0xA097, 0x0000, false, false, 0x0000));
|
||||
// CRC-16/TMS37157
|
||||
// 0x26B1 0x1021 0x89EC true true 0x0000
|
||||
mu_assert_int_eq(0x26B1, bit_lib_crc16(data, data_size, 0x1021, 0x89EC, true, true, 0x0000));
|
||||
// CRC-16/USB
|
||||
// 0xB4C8 0x8005 0xFFFF true true 0xFFFF
|
||||
mu_assert_int_eq(0xB4C8, bit_lib_crc16(data, data_size, 0x8005, 0xFFFF, true, true, 0xFFFF));
|
||||
// CRC-A
|
||||
// 0xBF05 0x1021 0xC6C6 true true 0x0000
|
||||
mu_assert_int_eq(0xBF05, bit_lib_crc16(data, data_size, 0x1021, 0xC6C6, true, true, 0x0000));
|
||||
// CRC-16/KERMIT
|
||||
// 0x2189 0x1021 0x0000 true true 0x0000
|
||||
mu_assert_int_eq(0x2189, bit_lib_crc16(data, data_size, 0x1021, 0x0000, true, true, 0x0000));
|
||||
// CRC-16/MODBUS
|
||||
// 0x4B37 0x8005 0xFFFF true true 0x0000
|
||||
mu_assert_int_eq(0x4B37, bit_lib_crc16(data, data_size, 0x8005, 0xFFFF, true, true, 0x0000));
|
||||
// CRC-16/X-25
|
||||
// 0x906E 0x1021 0xFFFF true true 0xFFFF
|
||||
mu_assert_int_eq(0x906E, bit_lib_crc16(data, data_size, 0x1021, 0xFFFF, true, true, 0xFFFF));
|
||||
// CRC-16/XMODEM
|
||||
// 0x31C3 0x1021 0x0000 false false 0x0000
|
||||
mu_assert_int_eq(0x31C3, bit_lib_crc16(data, data_size, 0x1021, 0x0000, false, false, 0x0000));
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_bit_lib) {
|
||||
MU_RUN_TEST(test_bit_lib_increment_index);
|
||||
MU_RUN_TEST(test_bit_lib_is_set);
|
||||
MU_RUN_TEST(test_bit_lib_push);
|
||||
MU_RUN_TEST(test_bit_lib_set_bit);
|
||||
MU_RUN_TEST(test_bit_lib_set_bits);
|
||||
MU_RUN_TEST(test_bit_lib_get_bit);
|
||||
MU_RUN_TEST(test_bit_lib_get_bits);
|
||||
MU_RUN_TEST(test_bit_lib_get_bits_16);
|
||||
MU_RUN_TEST(test_bit_lib_get_bits_32);
|
||||
MU_RUN_TEST(test_bit_lib_test_parity_u32);
|
||||
MU_RUN_TEST(test_bit_lib_test_parity);
|
||||
MU_RUN_TEST(test_bit_lib_remove_bit_every_nth);
|
||||
MU_RUN_TEST(test_bit_lib_copy_bits);
|
||||
MU_RUN_TEST(test_bit_lib_reverse_bits);
|
||||
MU_RUN_TEST(test_bit_lib_get_bit_count);
|
||||
MU_RUN_TEST(test_bit_lib_reverse_16_fast);
|
||||
MU_RUN_TEST(test_bit_lib_crc16);
|
||||
}
|
||||
|
||||
int run_minunit_test_bit_lib() {
|
||||
MU_RUN_SUITE(test_bit_lib);
|
||||
return MU_EXIT_CODE;
|
||||
}
|
||||
464
applications/debug/unit_tests/lfrfid/lfrfid_protocols.c
Normal file
464
applications/debug/unit_tests/lfrfid/lfrfid_protocols.c
Normal file
@@ -0,0 +1,464 @@
|
||||
#include <furi.h>
|
||||
#include "../minunit.h"
|
||||
#include <toolbox/protocols/protocol_dict.h>
|
||||
#include <lfrfid/protocols/lfrfid_protocols.h>
|
||||
#include <toolbox/pulse_protocols/pulse_glue.h>
|
||||
|
||||
#define LF_RFID_READ_TIMING_MULTIPLIER 8
|
||||
|
||||
#define EM_TEST_DATA \
|
||||
{ 0x58, 0x00, 0x85, 0x64, 0x02 }
|
||||
#define EM_TEST_DATA_SIZE 5
|
||||
#define EM_TEST_EMULATION_TIMINGS_COUNT (64 * 2)
|
||||
|
||||
const int8_t em_test_timings[EM_TEST_EMULATION_TIMINGS_COUNT] = {
|
||||
32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, -32,
|
||||
32, 32, -32, -32, 32, 32, -32, -32, 32, 32, -32, -32, 32, -32, 32, -32, 32, 32, -32,
|
||||
-32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32,
|
||||
32, 32, -32, -32, 32, -32, 32, -32, 32, 32, -32, -32, 32, 32, -32, -32, 32, 32, -32,
|
||||
-32, 32, -32, 32, 32, -32, 32, -32, -32, 32, -32, 32, -32, 32, 32, -32, -32, 32, -32,
|
||||
32, 32, -32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32, 32, -32,
|
||||
-32, 32, 32, -32, -32, 32, -32, 32, -32, 32, -32, 32, -32, 32,
|
||||
};
|
||||
|
||||
#define HID10301_TEST_DATA \
|
||||
{ 0x8D, 0x48, 0xA8 }
|
||||
#define HID10301_TEST_DATA_SIZE 3
|
||||
#define HID10301_TEST_EMULATION_TIMINGS_COUNT (541 * 2)
|
||||
|
||||
const int8_t hid10301_test_timings[HID10301_TEST_EMULATION_TIMINGS_COUNT] = {
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
};
|
||||
|
||||
#define IOPROX_XSF_TEST_DATA \
|
||||
{ 0x65, 0x01, 0x05, 0x39 }
|
||||
#define IOPROX_XSF_TEST_DATA_SIZE 4
|
||||
#define IOPROX_XSF_TEST_EMULATION_TIMINGS_COUNT (468 * 2)
|
||||
|
||||
const int8_t ioprox_xsf_test_timings[IOPROX_XSF_TEST_EMULATION_TIMINGS_COUNT] = {
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4, 4, -4,
|
||||
4, -4, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5,
|
||||
};
|
||||
|
||||
#define INDALA26_EMULATION_TIMINGS_COUNT (1024 * 2)
|
||||
#define INDALA26_TEST_DATA \
|
||||
{ 0x3B, 0x73, 0x64, 0xA8 }
|
||||
#define INDALA26_TEST_DATA_SIZE 4
|
||||
|
||||
const int8_t indala26_test_timings[INDALA26_EMULATION_TIMINGS_COUNT] = {
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,
|
||||
1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1,
|
||||
-1, 1, -1, 1, -1, 1, -1, 1,
|
||||
};
|
||||
|
||||
MU_TEST(test_lfrfid_protocol_em_read_simple) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
mu_assert_int_eq(EM_TEST_DATA_SIZE, protocol_dict_get_data_size(dict, LFRFIDProtocolEM4100));
|
||||
mu_assert_string_eq("EM4100", protocol_dict_get_name(dict, LFRFIDProtocolEM4100));
|
||||
mu_assert_string_eq("EM-Micro", protocol_dict_get_manufacturer(dict, LFRFIDProtocolEM4100));
|
||||
|
||||
const uint8_t data[EM_TEST_DATA_SIZE] = EM_TEST_DATA;
|
||||
|
||||
protocol_dict_decoders_start(dict);
|
||||
|
||||
ProtocolId protocol = PROTOCOL_NO;
|
||||
PulseGlue* pulse_glue = pulse_glue_alloc();
|
||||
|
||||
for(size_t i = 0; i < EM_TEST_EMULATION_TIMINGS_COUNT * 10; i++) {
|
||||
bool pulse_pop = pulse_glue_push(
|
||||
pulse_glue,
|
||||
em_test_timings[i % EM_TEST_EMULATION_TIMINGS_COUNT] >= 0,
|
||||
abs(em_test_timings[i % EM_TEST_EMULATION_TIMINGS_COUNT]) *
|
||||
LF_RFID_READ_TIMING_MULTIPLIER);
|
||||
|
||||
if(pulse_pop) {
|
||||
uint32_t length, period;
|
||||
pulse_glue_pop(pulse_glue, &length, &period);
|
||||
|
||||
protocol = protocol_dict_decoders_feed(dict, true, period);
|
||||
if(protocol != PROTOCOL_NO) break;
|
||||
|
||||
protocol = protocol_dict_decoders_feed(dict, false, length - period);
|
||||
if(protocol != PROTOCOL_NO) break;
|
||||
}
|
||||
}
|
||||
|
||||
pulse_glue_free(pulse_glue);
|
||||
|
||||
mu_assert_int_eq(LFRFIDProtocolEM4100, protocol);
|
||||
uint8_t received_data[EM_TEST_DATA_SIZE] = {0};
|
||||
protocol_dict_get_data(dict, protocol, received_data, EM_TEST_DATA_SIZE);
|
||||
|
||||
mu_assert_mem_eq(data, received_data, EM_TEST_DATA_SIZE);
|
||||
|
||||
protocol_dict_free(dict);
|
||||
}
|
||||
|
||||
MU_TEST(test_lfrfid_protocol_em_emulate_simple) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
mu_assert_int_eq(EM_TEST_DATA_SIZE, protocol_dict_get_data_size(dict, LFRFIDProtocolEM4100));
|
||||
mu_assert_string_eq("EM4100", protocol_dict_get_name(dict, LFRFIDProtocolEM4100));
|
||||
mu_assert_string_eq("EM-Micro", protocol_dict_get_manufacturer(dict, LFRFIDProtocolEM4100));
|
||||
|
||||
const uint8_t data[EM_TEST_DATA_SIZE] = EM_TEST_DATA;
|
||||
|
||||
protocol_dict_set_data(dict, LFRFIDProtocolEM4100, data, EM_TEST_DATA_SIZE);
|
||||
mu_check(protocol_dict_encoder_start(dict, LFRFIDProtocolEM4100));
|
||||
|
||||
for(size_t i = 0; i < EM_TEST_EMULATION_TIMINGS_COUNT; i++) {
|
||||
LevelDuration level_duration = protocol_dict_encoder_yield(dict, LFRFIDProtocolEM4100);
|
||||
|
||||
if(level_duration_get_level(level_duration)) {
|
||||
mu_assert_int_eq(em_test_timings[i], level_duration_get_duration(level_duration));
|
||||
} else {
|
||||
mu_assert_int_eq(em_test_timings[i], -level_duration_get_duration(level_duration));
|
||||
}
|
||||
}
|
||||
|
||||
protocol_dict_free(dict);
|
||||
}
|
||||
|
||||
MU_TEST(test_lfrfid_protocol_h10301_read_simple) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
mu_assert_int_eq(
|
||||
HID10301_TEST_DATA_SIZE, protocol_dict_get_data_size(dict, LFRFIDProtocolH10301));
|
||||
mu_assert_string_eq("H10301", protocol_dict_get_name(dict, LFRFIDProtocolH10301));
|
||||
mu_assert_string_eq("HID", protocol_dict_get_manufacturer(dict, LFRFIDProtocolH10301));
|
||||
|
||||
const uint8_t data[HID10301_TEST_DATA_SIZE] = HID10301_TEST_DATA;
|
||||
|
||||
protocol_dict_decoders_start(dict);
|
||||
|
||||
ProtocolId protocol = PROTOCOL_NO;
|
||||
PulseGlue* pulse_glue = pulse_glue_alloc();
|
||||
|
||||
for(size_t i = 0; i < HID10301_TEST_EMULATION_TIMINGS_COUNT * 10; i++) {
|
||||
bool pulse_pop = pulse_glue_push(
|
||||
pulse_glue,
|
||||
hid10301_test_timings[i % HID10301_TEST_EMULATION_TIMINGS_COUNT] >= 0,
|
||||
abs(hid10301_test_timings[i % HID10301_TEST_EMULATION_TIMINGS_COUNT]) *
|
||||
LF_RFID_READ_TIMING_MULTIPLIER);
|
||||
|
||||
if(pulse_pop) {
|
||||
uint32_t length, period;
|
||||
pulse_glue_pop(pulse_glue, &length, &period);
|
||||
|
||||
protocol = protocol_dict_decoders_feed(dict, true, period);
|
||||
if(protocol != PROTOCOL_NO) break;
|
||||
|
||||
protocol = protocol_dict_decoders_feed(dict, false, length - period);
|
||||
if(protocol != PROTOCOL_NO) break;
|
||||
}
|
||||
}
|
||||
|
||||
pulse_glue_free(pulse_glue);
|
||||
|
||||
mu_assert_int_eq(LFRFIDProtocolH10301, protocol);
|
||||
uint8_t received_data[HID10301_TEST_DATA_SIZE] = {0};
|
||||
protocol_dict_get_data(dict, protocol, received_data, HID10301_TEST_DATA_SIZE);
|
||||
|
||||
mu_assert_mem_eq(data, received_data, HID10301_TEST_DATA_SIZE);
|
||||
|
||||
protocol_dict_free(dict);
|
||||
}
|
||||
|
||||
MU_TEST(test_lfrfid_protocol_h10301_emulate_simple) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
mu_assert_int_eq(
|
||||
HID10301_TEST_DATA_SIZE, protocol_dict_get_data_size(dict, LFRFIDProtocolH10301));
|
||||
mu_assert_string_eq("H10301", protocol_dict_get_name(dict, LFRFIDProtocolH10301));
|
||||
mu_assert_string_eq("HID", protocol_dict_get_manufacturer(dict, LFRFIDProtocolH10301));
|
||||
|
||||
const uint8_t data[HID10301_TEST_DATA_SIZE] = HID10301_TEST_DATA;
|
||||
|
||||
protocol_dict_set_data(dict, LFRFIDProtocolH10301, data, HID10301_TEST_DATA_SIZE);
|
||||
mu_check(protocol_dict_encoder_start(dict, LFRFIDProtocolH10301));
|
||||
|
||||
for(size_t i = 0; i < HID10301_TEST_EMULATION_TIMINGS_COUNT; i++) {
|
||||
LevelDuration level_duration = protocol_dict_encoder_yield(dict, LFRFIDProtocolH10301);
|
||||
|
||||
if(level_duration_get_level(level_duration)) {
|
||||
mu_assert_int_eq(
|
||||
hid10301_test_timings[i], level_duration_get_duration(level_duration));
|
||||
} else {
|
||||
mu_assert_int_eq(
|
||||
hid10301_test_timings[i], -level_duration_get_duration(level_duration));
|
||||
}
|
||||
}
|
||||
|
||||
protocol_dict_free(dict);
|
||||
}
|
||||
|
||||
MU_TEST(test_lfrfid_protocol_ioprox_xsf_read_simple) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
mu_assert_int_eq(
|
||||
IOPROX_XSF_TEST_DATA_SIZE, protocol_dict_get_data_size(dict, LFRFIDProtocolIOProxXSF));
|
||||
mu_assert_string_eq("IoProxXSF", protocol_dict_get_name(dict, LFRFIDProtocolIOProxXSF));
|
||||
mu_assert_string_eq("Kantech", protocol_dict_get_manufacturer(dict, LFRFIDProtocolIOProxXSF));
|
||||
|
||||
const uint8_t data[IOPROX_XSF_TEST_DATA_SIZE] = IOPROX_XSF_TEST_DATA;
|
||||
|
||||
protocol_dict_decoders_start(dict);
|
||||
|
||||
ProtocolId protocol = PROTOCOL_NO;
|
||||
PulseGlue* pulse_glue = pulse_glue_alloc();
|
||||
|
||||
for(size_t i = 0; i < IOPROX_XSF_TEST_EMULATION_TIMINGS_COUNT * 10; i++) {
|
||||
bool pulse_pop = pulse_glue_push(
|
||||
pulse_glue,
|
||||
ioprox_xsf_test_timings[i % IOPROX_XSF_TEST_EMULATION_TIMINGS_COUNT] >= 0,
|
||||
abs(ioprox_xsf_test_timings[i % IOPROX_XSF_TEST_EMULATION_TIMINGS_COUNT]) *
|
||||
LF_RFID_READ_TIMING_MULTIPLIER);
|
||||
|
||||
if(pulse_pop) {
|
||||
uint32_t length, period;
|
||||
pulse_glue_pop(pulse_glue, &length, &period);
|
||||
|
||||
protocol = protocol_dict_decoders_feed(dict, true, period);
|
||||
if(protocol != PROTOCOL_NO) break;
|
||||
|
||||
protocol = protocol_dict_decoders_feed(dict, false, length - period);
|
||||
if(protocol != PROTOCOL_NO) break;
|
||||
}
|
||||
}
|
||||
|
||||
pulse_glue_free(pulse_glue);
|
||||
|
||||
mu_assert_int_eq(LFRFIDProtocolIOProxXSF, protocol);
|
||||
uint8_t received_data[IOPROX_XSF_TEST_DATA_SIZE] = {0};
|
||||
protocol_dict_get_data(dict, protocol, received_data, IOPROX_XSF_TEST_DATA_SIZE);
|
||||
|
||||
mu_assert_mem_eq(data, received_data, IOPROX_XSF_TEST_DATA_SIZE);
|
||||
|
||||
protocol_dict_free(dict);
|
||||
}
|
||||
|
||||
MU_TEST(test_lfrfid_protocol_ioprox_xsf_emulate_simple) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
mu_assert_int_eq(
|
||||
IOPROX_XSF_TEST_DATA_SIZE, protocol_dict_get_data_size(dict, LFRFIDProtocolIOProxXSF));
|
||||
mu_assert_string_eq("IoProxXSF", protocol_dict_get_name(dict, LFRFIDProtocolIOProxXSF));
|
||||
mu_assert_string_eq("Kantech", protocol_dict_get_manufacturer(dict, LFRFIDProtocolIOProxXSF));
|
||||
|
||||
const uint8_t data[IOPROX_XSF_TEST_DATA_SIZE] = IOPROX_XSF_TEST_DATA;
|
||||
|
||||
protocol_dict_set_data(dict, LFRFIDProtocolIOProxXSF, data, IOPROX_XSF_TEST_DATA_SIZE);
|
||||
mu_check(protocol_dict_encoder_start(dict, LFRFIDProtocolIOProxXSF));
|
||||
|
||||
for(size_t i = 0; i < IOPROX_XSF_TEST_EMULATION_TIMINGS_COUNT; i++) {
|
||||
LevelDuration level_duration = protocol_dict_encoder_yield(dict, LFRFIDProtocolIOProxXSF);
|
||||
|
||||
if(level_duration_get_level(level_duration)) {
|
||||
mu_assert_int_eq(
|
||||
ioprox_xsf_test_timings[i], level_duration_get_duration(level_duration));
|
||||
} else {
|
||||
mu_assert_int_eq(
|
||||
ioprox_xsf_test_timings[i], -level_duration_get_duration(level_duration));
|
||||
}
|
||||
}
|
||||
|
||||
protocol_dict_free(dict);
|
||||
}
|
||||
|
||||
MU_TEST(test_lfrfid_protocol_inadala26_emulate_simple) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
||||
mu_assert_int_eq(
|
||||
INDALA26_TEST_DATA_SIZE, protocol_dict_get_data_size(dict, LFRFIDProtocolIndala26));
|
||||
mu_assert_string_eq("Indala26", protocol_dict_get_name(dict, LFRFIDProtocolIndala26));
|
||||
mu_assert_string_eq("Motorola", protocol_dict_get_manufacturer(dict, LFRFIDProtocolIndala26));
|
||||
|
||||
const uint8_t data[INDALA26_TEST_DATA_SIZE] = INDALA26_TEST_DATA;
|
||||
|
||||
protocol_dict_set_data(dict, LFRFIDProtocolIndala26, data, INDALA26_TEST_DATA_SIZE);
|
||||
mu_check(protocol_dict_encoder_start(dict, LFRFIDProtocolIndala26));
|
||||
|
||||
for(size_t i = 0; i < INDALA26_EMULATION_TIMINGS_COUNT; i++) {
|
||||
LevelDuration level_duration = protocol_dict_encoder_yield(dict, LFRFIDProtocolIndala26);
|
||||
|
||||
if(level_duration_get_level(level_duration)) {
|
||||
mu_assert_int_eq(
|
||||
indala26_test_timings[i], level_duration_get_duration(level_duration));
|
||||
} else {
|
||||
mu_assert_int_eq(
|
||||
indala26_test_timings[i], -level_duration_get_duration(level_duration));
|
||||
}
|
||||
}
|
||||
|
||||
protocol_dict_free(dict);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_lfrfid_protocols_suite) {
|
||||
MU_RUN_TEST(test_lfrfid_protocol_em_read_simple);
|
||||
MU_RUN_TEST(test_lfrfid_protocol_em_emulate_simple);
|
||||
|
||||
MU_RUN_TEST(test_lfrfid_protocol_h10301_read_simple);
|
||||
MU_RUN_TEST(test_lfrfid_protocol_h10301_emulate_simple);
|
||||
|
||||
MU_RUN_TEST(test_lfrfid_protocol_ioprox_xsf_read_simple);
|
||||
MU_RUN_TEST(test_lfrfid_protocol_ioprox_xsf_emulate_simple);
|
||||
|
||||
MU_RUN_TEST(test_lfrfid_protocol_inadala26_emulate_simple);
|
||||
}
|
||||
|
||||
int run_minunit_test_lfrfid_protocols() {
|
||||
MU_RUN_SUITE(test_lfrfid_protocols_suite);
|
||||
return MU_EXIT_CODE;
|
||||
}
|
||||
@@ -151,46 +151,46 @@ void minunit_print_fail(const char* error);
|
||||
#define MU_EXIT_CODE minunit_fail
|
||||
|
||||
/* Assertions */
|
||||
#define mu_check(test) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(!(test)) { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %s", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
#test); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
#define mu_check(test) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(!(test)) { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\r\n\t%s:%d: %s", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
#test); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
} else { minunit_print_progress(); })
|
||||
|
||||
#define mu_fail(message) \
|
||||
MU__SAFE_BLOCK(minunit_assert++; snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %s", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
minunit_status = 1; \
|
||||
#define mu_fail(message) \
|
||||
MU__SAFE_BLOCK(minunit_assert++; snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\r\n\t%s:%d: %s", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
minunit_status = 1; \
|
||||
return;)
|
||||
|
||||
#define mu_assert(test, message) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(!(test)) { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %s", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
#define mu_assert(test, message) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(!(test)) { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\r\n\t%s:%d: %s", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
} else { minunit_print_progress(); })
|
||||
|
||||
#define mu_assert_int_eq(expected, result) \
|
||||
@@ -201,7 +201,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %d expected but was %d", \
|
||||
"%s failed:\r\n\t%s:%d: %d expected but was %d", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -219,7 +219,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: expected different results but both were %d", \
|
||||
"%s failed:\r\n\t%s:%d: expected different results but both were %d", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -236,7 +236,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %d <= %d", \
|
||||
"%s failed:\r\n\t%s:%d: %d <= %d", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -254,7 +254,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %d >= %d", \
|
||||
"%s failed:\r\n\t%s:%d: %d >= %d", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -274,7 +274,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %d was not between (inclusive) %d and %d", \
|
||||
"%s failed:\r\n\t%s:%d: %d was not between (inclusive) %d and %d", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -302,7 +302,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: expected to be one of %s but was %d", \
|
||||
"%s failed:\r\n\t%s:%d: expected to be one of %s but was %d", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -321,7 +321,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %.*g expected but was %.*g", \
|
||||
"%s failed:\r\n\t%s:%d: %.*g expected but was %.*g", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -341,7 +341,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %f <= %f", \
|
||||
"%s failed:\r\n\t%s:%d: %f <= %f", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -359,7 +359,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %f >= %f", \
|
||||
"%s failed:\r\n\t%s:%d: %f >= %f", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -379,7 +379,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: %f was not between (inclusive) %f and %f", \
|
||||
"%s failed:\r\n\t%s:%d: %f was not between (inclusive) %f and %f", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -400,7 +400,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: '%s' expected but was '%s'", \
|
||||
"%s failed:\r\n\t%s:%d: '%s' expected but was '%s'", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
@@ -410,13 +410,41 @@ void minunit_print_fail(const char* error);
|
||||
return; \
|
||||
} else { minunit_print_progress(); })
|
||||
|
||||
#define mu_assert_mem_eq(expected, result, size) \
|
||||
MU__SAFE_BLOCK( \
|
||||
const void* minunit_tmp_e = expected; const void* minunit_tmp_r = result; \
|
||||
minunit_assert++; \
|
||||
if(memcmp(minunit_tmp_e, minunit_tmp_r, size)) { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\r\n\t%s:%d: mem not equal\r\n\tEXP RES", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
for(size_t __index = 0; __index < size; __index++) { \
|
||||
if(strlen(minunit_last_message) > MINUNIT_MESSAGE_LEN - 20) break; \
|
||||
uint8_t __e = ((uint8_t*)minunit_tmp_e)[__index]; \
|
||||
uint8_t __r = ((uint8_t*)minunit_tmp_r)[__index]; \
|
||||
snprintf( \
|
||||
minunit_last_message + strlen(minunit_last_message), \
|
||||
MINUNIT_MESSAGE_LEN - strlen(minunit_last_message), \
|
||||
"\r\n\t%02X %s %02X", \
|
||||
__e, \
|
||||
((__e == __r) ? ".." : "!="), \
|
||||
__r); \
|
||||
} \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
} else { minunit_print_progress(); })
|
||||
|
||||
#define mu_assert_null(result) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(result == NULL) { minunit_print_progress(); } else { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: Expected result was not NULL", \
|
||||
"%s failed:\r\n\t%s:%d: Expected result was not NULL", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
@@ -430,7 +458,7 @@ void minunit_print_fail(const char* error);
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: Expected result was not NULL", \
|
||||
"%s failed:\r\n\t%s:%d: Expected result was not NULL", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
@@ -438,32 +466,32 @@ void minunit_print_fail(const char* error);
|
||||
return; \
|
||||
})
|
||||
|
||||
#define mu_assert_pointers_eq(pointer1, pointer2) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(pointer1 == pointer2) { minunit_print_progress(); } else { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
#define mu_assert_pointers_eq(pointer1, pointer2) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(pointer1 == pointer2) { minunit_print_progress(); } else { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\r\n\t%s:%d: Expected the pointers to point to the same memory location", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
})
|
||||
|
||||
#define mu_assert_pointers_not_eq(pointer1, pointer2) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(pointer1 != pointer2) { minunit_print_progress(); } else { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
#define mu_assert_pointers_not_eq(pointer1, pointer2) \
|
||||
MU__SAFE_BLOCK( \
|
||||
minunit_assert++; if(pointer1 != pointer2) { minunit_print_progress(); } else { \
|
||||
snprintf( \
|
||||
minunit_last_message, \
|
||||
MINUNIT_MESSAGE_LEN, \
|
||||
"%s failed:\r\n\t%s:%d: Expected the pointers to point to the same memory location", \
|
||||
__func__, \
|
||||
__FILE__, \
|
||||
__LINE__); \
|
||||
minunit_status = 1; \
|
||||
return; \
|
||||
})
|
||||
|
||||
/*
|
||||
@@ -1,8 +1,9 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <applications/storage/storage.h>
|
||||
#include <storage/storage.h>
|
||||
#include <lib/flipper_format/flipper_format.h>
|
||||
#include <lib/nfc/protocols/nfca.h>
|
||||
#include <lib/nfc/helpers/mf_classic_dict.h>
|
||||
#include <lib/digital_signal/digital_signal.h>
|
||||
|
||||
#include <lib/flipper_format/flipper_format_i.h>
|
||||
@@ -170,10 +171,59 @@ MU_TEST(nfc_digital_signal_test) {
|
||||
"NFC long digital signal test failed\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(mf_classic_dict_test) {
|
||||
MfClassicDict* instance = NULL;
|
||||
uint64_t key = 0;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
|
||||
instance = mf_classic_dict_alloc(MfClassicDictTypeUnitTest);
|
||||
mu_assert(instance != NULL, "mf_classic_dict_alloc\r\n");
|
||||
|
||||
mu_assert(
|
||||
mf_classic_dict_get_total_keys(instance) == 0,
|
||||
"mf_classic_dict_get_total_keys == 0 assert failed\r\n");
|
||||
|
||||
string_set(temp_str, "2196FAD8115B");
|
||||
mu_assert(
|
||||
mf_classic_dict_add_key_str(instance, temp_str),
|
||||
"mf_classic_dict_add_key == true assert failed\r\n");
|
||||
|
||||
mu_assert(
|
||||
mf_classic_dict_get_total_keys(instance) == 1,
|
||||
"mf_classic_dict_get_total_keys == 1 assert failed\r\n");
|
||||
|
||||
mu_assert(mf_classic_dict_rewind(instance), "mf_classic_dict_rewind == 1 assert failed\r\n");
|
||||
|
||||
mu_assert(
|
||||
mf_classic_dict_get_key_at_index_str(instance, temp_str, 0),
|
||||
"mf_classic_dict_get_key_at_index_str == true assert failed\r\n");
|
||||
mu_assert(
|
||||
string_cmp(temp_str, "2196FAD8115B") == 0,
|
||||
"string_cmp(temp_str, \"2196FAD8115B\") == 0 assert failed\r\n");
|
||||
|
||||
mu_assert(mf_classic_dict_rewind(instance), "mf_classic_dict_rewind == 1 assert failed\r\n");
|
||||
|
||||
mu_assert(
|
||||
mf_classic_dict_get_key_at_index(instance, &key, 0),
|
||||
"mf_classic_dict_get_key_at_index == true assert failed\r\n");
|
||||
mu_assert(key == 0x2196FAD8115B, "key == 0x2196FAD8115B assert failed\r\n");
|
||||
|
||||
mu_assert(mf_classic_dict_rewind(instance), "mf_classic_dict_rewind == 1 assert failed\r\n");
|
||||
|
||||
mu_assert(
|
||||
mf_classic_dict_delete_index(instance, 0),
|
||||
"mf_classic_dict_delete_index == true assert failed\r\n");
|
||||
|
||||
mf_classic_dict_free(instance);
|
||||
string_clear(temp_str);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(nfc) {
|
||||
nfc_test_alloc();
|
||||
|
||||
MU_RUN_TEST(nfc_digital_signal_test);
|
||||
MU_RUN_TEST(mf_classic_dict_test);
|
||||
|
||||
nfc_test_free();
|
||||
}
|
||||
222
applications/debug/unit_tests/protocol_dict/protocol_dict_test.c
Normal file
222
applications/debug/unit_tests/protocol_dict/protocol_dict_test.c
Normal file
@@ -0,0 +1,222 @@
|
||||
#include <furi.h>
|
||||
#include "../minunit.h"
|
||||
#include <toolbox/protocols/protocol_dict.h>
|
||||
|
||||
typedef enum {
|
||||
TestDictProtocol0,
|
||||
TestDictProtocol1,
|
||||
|
||||
TestDictProtocolMax,
|
||||
} TestDictProtocols;
|
||||
|
||||
/*********************** PROTOCOL 0 START ***********************/
|
||||
|
||||
typedef struct {
|
||||
uint32_t data;
|
||||
size_t encoder_counter;
|
||||
} Protocol0Data;
|
||||
|
||||
static const uint32_t protocol_0_decoder_result = 0xDEADBEEF;
|
||||
|
||||
static void* protocol_0_alloc() {
|
||||
void* data = malloc(sizeof(Protocol0Data));
|
||||
return data;
|
||||
}
|
||||
|
||||
static void protocol_0_free(Protocol0Data* data) {
|
||||
free(data);
|
||||
}
|
||||
|
||||
static uint8_t* protocol_0_get_data(Protocol0Data* data) {
|
||||
return (uint8_t*)&data->data;
|
||||
}
|
||||
|
||||
static void protocol_0_decoder_start(Protocol0Data* data) {
|
||||
data->data = 0;
|
||||
}
|
||||
|
||||
static bool protocol_0_decoder_feed(Protocol0Data* data, bool level, uint32_t duration) {
|
||||
if(level && duration == 666) {
|
||||
data->data = protocol_0_decoder_result;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool protocol_0_encoder_start(Protocol0Data* data) {
|
||||
data->encoder_counter = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static LevelDuration protocol_0_encoder_yield(Protocol0Data* data) {
|
||||
data->encoder_counter++;
|
||||
return level_duration_make(data->encoder_counter % 2, data->data);
|
||||
}
|
||||
|
||||
/*********************** PROTOCOL 1 START ***********************/
|
||||
|
||||
typedef struct {
|
||||
uint64_t data;
|
||||
size_t encoder_counter;
|
||||
} Protocol1Data;
|
||||
|
||||
static const uint64_t protocol_1_decoder_result = 0x1234567890ABCDEF;
|
||||
|
||||
static void* protocol_1_alloc() {
|
||||
void* data = malloc(sizeof(Protocol1Data));
|
||||
return data;
|
||||
}
|
||||
|
||||
static void protocol_1_free(Protocol1Data* data) {
|
||||
free(data);
|
||||
}
|
||||
|
||||
static uint8_t* protocol_1_get_data(Protocol1Data* data) {
|
||||
return (uint8_t*)&data->data;
|
||||
}
|
||||
|
||||
static void protocol_1_decoder_start(Protocol1Data* data) {
|
||||
data->data = 0;
|
||||
}
|
||||
|
||||
static bool protocol_1_decoder_feed(Protocol1Data* data, bool level, uint32_t duration) {
|
||||
if(level && duration == 543) {
|
||||
data->data = 0x1234567890ABCDEF;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool protocol_1_encoder_start(Protocol1Data* data) {
|
||||
data->encoder_counter = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static LevelDuration protocol_1_encoder_yield(Protocol1Data* data) {
|
||||
data->encoder_counter++;
|
||||
return level_duration_make(!(data->encoder_counter % 2), 100);
|
||||
}
|
||||
|
||||
/*********************** PROTOCOLS DESCRIPTION ***********************/
|
||||
static const ProtocolBase protocol_0 = {
|
||||
.name = "Protocol 0",
|
||||
.manufacturer = "Manufacturer 0",
|
||||
.data_size = 4,
|
||||
.alloc = (ProtocolAlloc)protocol_0_alloc,
|
||||
.free = (ProtocolFree)protocol_0_free,
|
||||
.get_data = (ProtocolGetData)protocol_0_get_data,
|
||||
.decoder =
|
||||
{
|
||||
.start = (ProtocolDecoderStart)protocol_0_decoder_start,
|
||||
.feed = (ProtocolDecoderFeed)protocol_0_decoder_feed,
|
||||
},
|
||||
.encoder =
|
||||
{
|
||||
.start = (ProtocolEncoderStart)protocol_0_encoder_start,
|
||||
.yield = (ProtocolEncoderYield)protocol_0_encoder_yield,
|
||||
},
|
||||
};
|
||||
|
||||
static const ProtocolBase protocol_1 = {
|
||||
.name = "Protocol 1",
|
||||
.manufacturer = "Manufacturer 1",
|
||||
.data_size = 8,
|
||||
.alloc = (ProtocolAlloc)protocol_1_alloc,
|
||||
.free = (ProtocolFree)protocol_1_free,
|
||||
.get_data = (ProtocolGetData)protocol_1_get_data,
|
||||
.decoder =
|
||||
{
|
||||
.start = (ProtocolDecoderStart)protocol_1_decoder_start,
|
||||
.feed = (ProtocolDecoderFeed)protocol_1_decoder_feed,
|
||||
},
|
||||
.encoder =
|
||||
{
|
||||
.start = (ProtocolEncoderStart)protocol_1_encoder_start,
|
||||
.yield = (ProtocolEncoderYield)protocol_1_encoder_yield,
|
||||
},
|
||||
};
|
||||
|
||||
static const ProtocolBase* test_protocols_base[] = {
|
||||
[TestDictProtocol0] = &protocol_0,
|
||||
[TestDictProtocol1] = &protocol_1,
|
||||
};
|
||||
|
||||
MU_TEST(test_protocol_dict) {
|
||||
ProtocolDict* dict = protocol_dict_alloc(test_protocols_base, TestDictProtocolMax);
|
||||
size_t max_data_size = protocol_dict_get_max_data_size(dict);
|
||||
mu_assert_int_eq(8, max_data_size);
|
||||
uint8_t* data = malloc(max_data_size);
|
||||
|
||||
protocol_dict_decoders_start(dict);
|
||||
ProtocolId protocol_id = PROTOCOL_NO;
|
||||
|
||||
for(size_t i = 0; i < 100; i++) {
|
||||
protocol_id = protocol_dict_decoders_feed(dict, i % 2, 100);
|
||||
mu_assert_int_eq(PROTOCOL_NO, protocol_id);
|
||||
}
|
||||
|
||||
// trigger protocol 1
|
||||
protocol_id = protocol_dict_decoders_feed(dict, true, 543);
|
||||
mu_assert_int_eq(TestDictProtocol1, protocol_id);
|
||||
|
||||
mu_assert_string_eq("Protocol 1", protocol_dict_get_name(dict, protocol_id));
|
||||
mu_assert_string_eq("Manufacturer 1", protocol_dict_get_manufacturer(dict, protocol_id));
|
||||
|
||||
size_t data_size = protocol_dict_get_data_size(dict, protocol_id);
|
||||
mu_assert_int_eq(8, data_size);
|
||||
|
||||
protocol_dict_get_data(dict, protocol_id, data, data_size);
|
||||
mu_assert_mem_eq(&protocol_1_decoder_result, data, data_size);
|
||||
|
||||
// trigger protocol 0
|
||||
protocol_id = protocol_dict_decoders_feed(dict, true, 666);
|
||||
mu_assert_int_eq(TestDictProtocol0, protocol_id);
|
||||
|
||||
mu_assert_string_eq("Protocol 0", protocol_dict_get_name(dict, protocol_id));
|
||||
mu_assert_string_eq("Manufacturer 0", protocol_dict_get_manufacturer(dict, protocol_id));
|
||||
|
||||
data_size = protocol_dict_get_data_size(dict, protocol_id);
|
||||
mu_assert_int_eq(4, data_size);
|
||||
|
||||
protocol_dict_get_data(dict, protocol_id, data, data_size);
|
||||
mu_assert_mem_eq(&protocol_0_decoder_result, data, data_size);
|
||||
|
||||
protocol_dict_decoders_start(dict);
|
||||
|
||||
protocol_id = TestDictProtocol0;
|
||||
|
||||
const uint8_t protocol_0_test_data[4] = {100, 0, 0, 0};
|
||||
protocol_dict_set_data(dict, protocol_id, protocol_0_test_data, 4);
|
||||
|
||||
mu_check(protocol_dict_encoder_start(dict, protocol_id));
|
||||
|
||||
LevelDuration level;
|
||||
level = protocol_dict_encoder_yield(dict, protocol_id);
|
||||
mu_assert_int_eq(true, level_duration_get_level(level));
|
||||
mu_assert_int_eq(100, level_duration_get_duration(level));
|
||||
level = protocol_dict_encoder_yield(dict, protocol_id);
|
||||
mu_assert_int_eq(false, level_duration_get_level(level));
|
||||
mu_assert_int_eq(100, level_duration_get_duration(level));
|
||||
level = protocol_dict_encoder_yield(dict, protocol_id);
|
||||
mu_assert_int_eq(true, level_duration_get_level(level));
|
||||
mu_assert_int_eq(100, level_duration_get_duration(level));
|
||||
|
||||
mu_check(protocol_dict_encoder_start(dict, protocol_id));
|
||||
level = protocol_dict_encoder_yield(dict, protocol_id);
|
||||
mu_assert_int_eq(true, level_duration_get_level(level));
|
||||
mu_assert_int_eq(100, level_duration_get_duration(level));
|
||||
|
||||
protocol_dict_free(dict);
|
||||
free(data);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_protocol_dict_suite) {
|
||||
MU_RUN_TEST(test_protocol_dict);
|
||||
}
|
||||
|
||||
int run_minunit_test_protocol_dict() {
|
||||
MU_RUN_SUITE(test_protocol_dict_suite);
|
||||
return MU_EXIT_CODE;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ static void test_rpc_print_message_list(MsgList_t msg_list) {
|
||||
MsgList_reverse(msg_list);
|
||||
for
|
||||
M_EACH(msg, msg_list, MsgList_t) {
|
||||
rpc_print_message(msg);
|
||||
rpc_debug_print_message(msg);
|
||||
}
|
||||
MsgList_reverse(msg_list);
|
||||
#else
|
||||
@@ -13,7 +13,7 @@
|
||||
#define CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo")
|
||||
#define NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s")
|
||||
#define TEST_RANDOM_DIR_NAME EXT_PATH("unit_tests/subghz/test_random_raw.sub")
|
||||
#define TEST_RANDOM_COUNT_PARSE 188
|
||||
#define TEST_RANDOM_COUNT_PARSE 233
|
||||
#define TEST_TIMEOUT 10000
|
||||
|
||||
static SubGhzEnvironment* environment_handler;
|
||||
@@ -127,7 +127,7 @@ static bool subghz_decode_random_test(const char* path) {
|
||||
}
|
||||
subghz_file_encoder_worker_free(file_worker_encoder_handler);
|
||||
}
|
||||
FURI_LOG_T(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
FURI_LOG_D(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
if(furi_get_tick() - test_start > TEST_TIMEOUT * 10) {
|
||||
printf("\033[0;31mRandom test ERROR TimeOut\033[0m\r\n");
|
||||
return false;
|
||||
@@ -412,6 +412,35 @@ MU_TEST(subghz_decoder_honeywell_wdb_test) {
|
||||
"Test decoder " SUBGHZ_PROTOCOL_HONEYWELL_WDB_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_magellen_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("unit_tests/subghz/magellen_raw.sub"), SUBGHZ_PROTOCOL_MAGELLEN_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_MAGELLEN_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_intertechno_v3_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("unit_tests/subghz/intertechno_v3_raw.sub"),
|
||||
SUBGHZ_PROTOCOL_INTERTECHNO_V3_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_INTERTECHNO_V3_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_clemsa_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("unit_tests/subghz/clemsa_raw.sub"), SUBGHZ_PROTOCOL_CLEMSA_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_CLEMSA_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_oregon2_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("unit_tests/subghz/oregon2_raw.sub"), SUBGHZ_PROTOCOL_OREGON2_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_OREGON2_NAME " error\r\n");
|
||||
}
|
||||
|
||||
//test encoders
|
||||
MU_TEST(subghz_encoder_princeton_test) {
|
||||
mu_assert(
|
||||
@@ -515,6 +544,24 @@ MU_TEST(subghz_encoder_honeywell_wdb_test) {
|
||||
"Test encoder " SUBGHZ_PROTOCOL_HONEYWELL_WDB_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_magellen_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/magellen.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_MAGELLEN_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_intertechno_v3_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/intertechno_v3.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_INTERTECHNO_V3_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_clemsa_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/clemsa.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_CLEMSA_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_random_test) {
|
||||
mu_assert(subghz_decode_random_test(TEST_RANDOM_DIR_NAME), "Random test error\r\n");
|
||||
}
|
||||
@@ -552,6 +599,10 @@ MU_TEST_SUITE(subghz) {
|
||||
MU_RUN_TEST(subghz_decoder_doitrand_test);
|
||||
MU_RUN_TEST(subghz_decoder_phoenix_v2_test);
|
||||
MU_RUN_TEST(subghz_decoder_honeywell_wdb_test);
|
||||
MU_RUN_TEST(subghz_decoder_magellen_test);
|
||||
MU_RUN_TEST(subghz_decoder_intertechno_v3_test);
|
||||
MU_RUN_TEST(subghz_decoder_clemsa_test);
|
||||
MU_RUN_TEST(subghz_decoder_oregon2_test);
|
||||
|
||||
MU_RUN_TEST(subghz_encoder_princeton_test);
|
||||
MU_RUN_TEST(subghz_encoder_came_test);
|
||||
@@ -570,6 +621,9 @@ MU_TEST_SUITE(subghz) {
|
||||
MU_RUN_TEST(subghz_encoder_doitrand_test);
|
||||
MU_RUN_TEST(subghz_encoder_phoenix_v2_test);
|
||||
MU_RUN_TEST(subghz_encoder_honeywell_wdb_test);
|
||||
MU_RUN_TEST(subghz_encoder_magellen_test);
|
||||
MU_RUN_TEST(subghz_encoder_intertechno_v3_test);
|
||||
MU_RUN_TEST(subghz_encoder_clemsa_test);
|
||||
|
||||
MU_RUN_TEST(subghz_random_test);
|
||||
subghz_test_deinit();
|
||||
@@ -19,7 +19,10 @@ int run_minunit_test_stream();
|
||||
int run_minunit_test_storage();
|
||||
int run_minunit_test_subghz();
|
||||
int run_minunit_test_dirwalk();
|
||||
int run_minunit_test_protocol_dict();
|
||||
int run_minunit_test_lfrfid_protocols();
|
||||
int run_minunit_test_nfc();
|
||||
int run_minunit_test_bit_lib();
|
||||
|
||||
typedef int (*UnitTestEntry)();
|
||||
|
||||
@@ -39,6 +42,9 @@ const UnitTest unit_tests[] = {
|
||||
{.name = "subghz", .entry = run_minunit_test_subghz},
|
||||
{.name = "infrared", .entry = run_minunit_test_infrared},
|
||||
{.name = "nfc", .entry = run_minunit_test_nfc},
|
||||
{.name = "protocol_dict", .entry = run_minunit_test_protocol_dict},
|
||||
{.name = "lfrfid", .entry = run_minunit_test_lfrfid_protocols},
|
||||
{.name = "bit_lib", .entry = run_minunit_test_bit_lib},
|
||||
};
|
||||
|
||||
void minunit_print_progress() {
|
||||
88
applications/debug/unit_tests/varint/varint_test.c
Normal file
88
applications/debug/unit_tests/varint/varint_test.c
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include "../minunit.h"
|
||||
#include <toolbox/varint.h>
|
||||
#include <toolbox/profiler.h>
|
||||
|
||||
MU_TEST(test_varint_basic_u) {
|
||||
mu_assert_int_eq(1, varint_uint32_length(0));
|
||||
mu_assert_int_eq(5, varint_uint32_length(UINT32_MAX));
|
||||
|
||||
uint8_t data[8] = {};
|
||||
uint32_t out_value;
|
||||
|
||||
mu_assert_int_eq(1, varint_uint32_pack(0, data));
|
||||
mu_assert_int_eq(1, varint_uint32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(0, out_value);
|
||||
|
||||
mu_assert_int_eq(5, varint_uint32_pack(UINT32_MAX, data));
|
||||
mu_assert_int_eq(5, varint_uint32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(UINT32_MAX, out_value);
|
||||
}
|
||||
|
||||
MU_TEST(test_varint_basic_i) {
|
||||
mu_assert_int_eq(5, varint_int32_length(INT32_MIN / 2));
|
||||
mu_assert_int_eq(1, varint_int32_length(0));
|
||||
mu_assert_int_eq(5, varint_int32_length(INT32_MAX / 2));
|
||||
|
||||
mu_assert_int_eq(2, varint_int32_length(127));
|
||||
mu_assert_int_eq(2, varint_int32_length(-127));
|
||||
|
||||
uint8_t data[8] = {};
|
||||
int32_t out_value;
|
||||
mu_assert_int_eq(1, varint_int32_pack(0, data));
|
||||
mu_assert_int_eq(1, varint_int32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(0, out_value);
|
||||
|
||||
mu_assert_int_eq(2, varint_int32_pack(127, data));
|
||||
mu_assert_int_eq(2, varint_int32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(127, out_value);
|
||||
|
||||
mu_assert_int_eq(2, varint_int32_pack(-127, data));
|
||||
mu_assert_int_eq(2, varint_int32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(-127, out_value);
|
||||
|
||||
mu_assert_int_eq(5, varint_int32_pack(INT32_MAX, data));
|
||||
mu_assert_int_eq(5, varint_int32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(INT32_MAX, out_value);
|
||||
|
||||
mu_assert_int_eq(5, varint_int32_pack(INT32_MIN / 2 + 1, data));
|
||||
mu_assert_int_eq(5, varint_int32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(INT32_MIN / 2 + 1, out_value);
|
||||
}
|
||||
|
||||
MU_TEST(test_varint_rand_u) {
|
||||
uint8_t data[8] = {};
|
||||
uint32_t out_value;
|
||||
|
||||
for(size_t i = 0; i < 200000; i++) {
|
||||
uint32_t rand_value = rand();
|
||||
mu_assert_int_eq(
|
||||
varint_uint32_pack(rand_value, data), varint_uint32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(rand_value, out_value);
|
||||
}
|
||||
}
|
||||
|
||||
MU_TEST(test_varint_rand_i) {
|
||||
uint8_t data[8] = {};
|
||||
int32_t out_value;
|
||||
|
||||
for(size_t i = 0; i < 200000; i++) {
|
||||
int32_t rand_value = rand() + (INT32_MIN / 2 + 1);
|
||||
mu_assert_int_eq(
|
||||
varint_int32_pack(rand_value, data), varint_int32_unpack(&out_value, data, 8));
|
||||
mu_assert_int_eq(rand_value, out_value);
|
||||
}
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_varint_suite) {
|
||||
MU_RUN_TEST(test_varint_basic_u);
|
||||
MU_RUN_TEST(test_varint_basic_i);
|
||||
MU_RUN_TEST(test_varint_rand_u);
|
||||
MU_RUN_TEST(test_varint_rand_i);
|
||||
}
|
||||
|
||||
int run_minunit_test_varint() {
|
||||
MU_RUN_SUITE(test_varint_suite);
|
||||
return MU_EXIT_CODE;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user