Skip to content

Commit cc0c618

Browse files
authored
Merge pull request #17 from leedave/feature/linting
Feature/linting
2 parents 908eb0b + f179b0d commit cc0c618

25 files changed

+501
-354
lines changed

.clang-format

+191
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: AlwaysBreak
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveMacros: None
7+
AlignConsecutiveAssignments: None
8+
AlignConsecutiveBitFields: None
9+
AlignConsecutiveDeclarations: None
10+
AlignEscapedNewlines: Left
11+
AlignOperands: Align
12+
AlignTrailingComments: false
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllParametersOfDeclarationOnNextLine: false
15+
AllowShortEnumsOnASingleLine: true
16+
AllowShortBlocksOnASingleLine: Never
17+
AllowShortCaseLabelsOnASingleLine: false
18+
AllowShortFunctionsOnASingleLine: None
19+
AllowShortLambdasOnASingleLine: All
20+
AllowShortIfStatementsOnASingleLine: WithoutElse
21+
AllowShortLoopsOnASingleLine: true
22+
AlwaysBreakAfterDefinitionReturnType: None
23+
AlwaysBreakAfterReturnType: None
24+
AlwaysBreakBeforeMultilineStrings: false
25+
AlwaysBreakTemplateDeclarations: Yes
26+
AttributeMacros:
27+
- __capability
28+
BinPackArguments: false
29+
BinPackParameters: false
30+
BraceWrapping:
31+
AfterCaseLabel: false
32+
AfterClass: false
33+
AfterControlStatement: Never
34+
AfterEnum: false
35+
AfterFunction: false
36+
AfterNamespace: false
37+
AfterObjCDeclaration: false
38+
AfterStruct: false
39+
AfterUnion: false
40+
AfterExternBlock: false
41+
BeforeCatch: false
42+
BeforeElse: false
43+
BeforeLambdaBody: false
44+
BeforeWhile: false
45+
IndentBraces: false
46+
SplitEmptyFunction: true
47+
SplitEmptyRecord: true
48+
SplitEmptyNamespace: true
49+
BreakBeforeBinaryOperators: None
50+
BreakBeforeConceptDeclarations: true
51+
BreakBeforeBraces: Attach
52+
BreakBeforeInheritanceComma: false
53+
BreakInheritanceList: BeforeColon
54+
BreakBeforeTernaryOperators: false
55+
BreakConstructorInitializersBeforeComma: false
56+
BreakConstructorInitializers: BeforeComma
57+
BreakAfterJavaFieldAnnotations: false
58+
BreakStringLiterals: false
59+
ColumnLimit: 99
60+
CommentPragmas: '^ IWYU pragma:'
61+
QualifierAlignment: Leave
62+
CompactNamespaces: false
63+
ConstructorInitializerIndentWidth: 4
64+
ContinuationIndentWidth: 4
65+
Cpp11BracedListStyle: true
66+
DeriveLineEnding: true
67+
DerivePointerAlignment: false
68+
DisableFormat: false
69+
EmptyLineAfterAccessModifier: Never
70+
EmptyLineBeforeAccessModifier: LogicalBlock
71+
ExperimentalAutoDetectBinPacking: false
72+
PackConstructorInitializers: BinPack
73+
BasedOnStyle: ''
74+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
75+
AllowAllConstructorInitializersOnNextLine: true
76+
FixNamespaceComments: false
77+
ForEachMacros:
78+
- foreach
79+
- Q_FOREACH
80+
- BOOST_FOREACH
81+
IfMacros:
82+
- KJ_IF_MAYBE
83+
IncludeBlocks: Preserve
84+
IncludeCategories:
85+
- Regex: '.*'
86+
Priority: 1
87+
SortPriority: 0
88+
CaseSensitive: false
89+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
90+
Priority: 3
91+
SortPriority: 0
92+
CaseSensitive: false
93+
- Regex: '.*'
94+
Priority: 1
95+
SortPriority: 0
96+
CaseSensitive: false
97+
IncludeIsMainRegex: '(Test)?$'
98+
IncludeIsMainSourceRegex: ''
99+
IndentAccessModifiers: false
100+
IndentCaseLabels: false
101+
IndentCaseBlocks: false
102+
IndentGotoLabels: true
103+
IndentPPDirectives: None
104+
IndentExternBlock: AfterExternBlock
105+
IndentRequires: false
106+
IndentWidth: 4
107+
IndentWrappedFunctionNames: true
108+
InsertTrailingCommas: None
109+
JavaScriptQuotes: Leave
110+
JavaScriptWrapImports: true
111+
KeepEmptyLinesAtTheStartOfBlocks: false
112+
LambdaBodyIndentation: Signature
113+
MacroBlockBegin: ''
114+
MacroBlockEnd: ''
115+
MaxEmptyLinesToKeep: 1
116+
NamespaceIndentation: None
117+
ObjCBinPackProtocolList: Auto
118+
ObjCBlockIndentWidth: 4
119+
ObjCBreakBeforeNestedBlockParam: true
120+
ObjCSpaceAfterProperty: true
121+
ObjCSpaceBeforeProtocolList: true
122+
PenaltyBreakAssignment: 10
123+
PenaltyBreakBeforeFirstCallParameter: 30
124+
PenaltyBreakComment: 10
125+
PenaltyBreakFirstLessLess: 0
126+
PenaltyBreakOpenParenthesis: 0
127+
PenaltyBreakString: 10
128+
PenaltyBreakTemplateDeclaration: 10
129+
PenaltyExcessCharacter: 100
130+
PenaltyReturnTypeOnItsOwnLine: 60
131+
PenaltyIndentedWhitespace: 0
132+
PointerAlignment: Left
133+
PPIndentWidth: -1
134+
ReferenceAlignment: Pointer
135+
ReflowComments: false
136+
RemoveBracesLLVM: false
137+
SeparateDefinitionBlocks: Leave
138+
ShortNamespaceLines: 1
139+
SortIncludes: Never
140+
SortJavaStaticImport: Before
141+
SortUsingDeclarations: false
142+
SpaceAfterCStyleCast: false
143+
SpaceAfterLogicalNot: false
144+
SpaceAfterTemplateKeyword: true
145+
SpaceBeforeAssignmentOperators: true
146+
SpaceBeforeCaseColon: false
147+
SpaceBeforeCpp11BracedList: false
148+
SpaceBeforeCtorInitializerColon: true
149+
SpaceBeforeInheritanceColon: true
150+
SpaceBeforeParens: Never
151+
SpaceBeforeParensOptions:
152+
AfterControlStatements: false
153+
AfterForeachMacros: false
154+
AfterFunctionDefinitionName: false
155+
AfterFunctionDeclarationName: false
156+
AfterIfMacros: false
157+
AfterOverloadedOperator: false
158+
BeforeNonEmptyParentheses: false
159+
SpaceAroundPointerQualifiers: Default
160+
SpaceBeforeRangeBasedForLoopColon: true
161+
SpaceInEmptyBlock: false
162+
SpaceInEmptyParentheses: false
163+
SpacesBeforeTrailingComments: 1
164+
SpacesInAngles: Never
165+
SpacesInConditionalStatement: false
166+
SpacesInContainerLiterals: false
167+
SpacesInCStyleCastParentheses: false
168+
SpacesInLineCommentPrefix:
169+
Minimum: 1
170+
Maximum: -1
171+
SpacesInParentheses: false
172+
SpacesInSquareBrackets: false
173+
SpaceBeforeSquareBrackets: false
174+
BitFieldColonSpacing: Both
175+
Standard: c++03
176+
StatementAttributeLikeMacros:
177+
- Q_EMIT
178+
StatementMacros:
179+
- Q_UNUSED
180+
- QT_REQUIRE_VERSION
181+
TabWidth: 4
182+
UseCRLF: false
183+
UseTab: Never
184+
WhitespaceSensitiveMacros:
185+
- STRINGIZE
186+
- PP_STRINGIZE
187+
- BOOST_PP_STRINGIZE
188+
- NS_SWIFT_NAME
189+
- CF_SWIFT_NAME
190+
...
191+

application.fam

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@ App(
33
name="Restaurant Pager Trigger",
44
apptype=FlipperAppType.EXTERNAL,
55
entry_point="meal_pager_app",
6-
cdefines=["APP_MEAL_PAGER"],
7-
requires=[
8-
"gui",
9-
"storage",
10-
],
116
stack_size=2 * 1024,
12-
order=10,
13-
fap_libs=["assets"],
147
fap_icon="icons/meal_pager_10px.png",
158
fap_icon_assets="icons",
169
fap_category="Sub-Ghz",
17-
fap_version="0.1",
10+
fap_version="0.7",
11+
fap_author="leedave",
12+
fap_weburl="https://github.com/leedave/flipper-zero-meal-pager",
13+
fap_description="This app triggers restaurant pagers in a brute force manner, useful to test if devices are still functional.",
1814
)

helpers/meal_pager_calc.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
void customConcat(char* dest, const char* src) {
44
// Find the end of the destination string
5-
while (*dest != '\0') {
5+
while(*dest != '\0') {
66
dest++;
77
}
88

99
// Copy characters from src to dest
10-
while (*src != '\0') {
10+
while(*src != '\0') {
1111
*dest = *src;
1212
dest++;
1313
src++;
@@ -22,18 +22,18 @@ char* encManchester(const char* bits, int mode) {
2222
char* res = (char*)malloc((strlen(bits) * 2 + 1) * sizeof(char));
2323

2424
int index = 0;
25-
for (int i = 0; bits[i] != '\0'; i++) {
25+
for(int i = 0; bits[i] != '\0'; i++) {
2626
char c = bits[i];
27-
if (c == '0') {
28-
if (mode) {
27+
if(c == '0') {
28+
if(mode) {
2929
res[index++] = '1';
3030
res[index++] = '0';
3131
} else {
3232
res[index++] = '0';
3333
res[index++] = '1';
3434
}
35-
} else if (c == '1') {
36-
if (mode) {
35+
} else if(c == '1') {
36+
if(mode) {
3737
res[index++] = '0';
3838
res[index++] = '1';
3939
} else {
@@ -56,21 +56,21 @@ char* encManchester(const char* bits, int mode) {
5656
void uint32ToBinaray(uint32_t number, char* str, int8_t length) {
5757
int i = 0;
5858
length--; // count length without 0
59-
for (i = length; i >= 0; i--) {
59+
for(i = length; i >= 0; i--) {
6060
// Bitwise AND extration of the i-th bit
6161
int bit = (number >> i) & 1;
6262
// convert the bit to a character of 1 or 0
6363
str[length - i] = bit + '0';
6464
}
6565
// Terminate the string
66-
str[length+1] = '\0';
66+
str[length + 1] = '\0';
6767
}
6868

6969
void reverse(char* str) {
7070
int length = strlen(str);
7171
int start = 0;
7272
int end = length - 1;
73-
while (start < end) {
73+
while(start < end) {
7474
char temp = str[start];
7575
str[start] = str[end];
7676
str[end] = temp;

helpers/meal_pager_custom_event.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ static inline uint32_t meal_pager_custom_menu_event_pack(uint16_t type, int16_t
4545
Meal_PagerCustomEventMenu event = {.content = {.type = type, .value = value}};
4646
return event.packed_value;
4747
}
48-
static inline void meal_pager_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) {
48+
static inline void
49+
meal_pager_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) {
4950
Meal_PagerCustomEventMenu event = {.packed_value = packed_value};
5051
if(type) *type = event.content.type;
5152
if(value) *value = event.content.value;

helpers/meal_pager_haptic.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
void meal_pager_play_happy_bump(void* context) {
44
Meal_Pager* app = context;
5-
if (app->haptic != 1) {
5+
if(app->haptic != 1) {
66
return;
77
}
88
notification_message(app->notification, &sequence_set_vibro_on);
@@ -12,7 +12,7 @@ void meal_pager_play_happy_bump(void* context) {
1212

1313
void meal_pager_play_bad_bump(void* context) {
1414
Meal_Pager* app = context;
15-
if (app->haptic != 1) {
15+
if(app->haptic != 1) {
1616
return;
1717
}
1818
notification_message(app->notification, &sequence_set_vibro_on);
@@ -22,10 +22,10 @@ void meal_pager_play_bad_bump(void* context) {
2222

2323
void meal_pager_play_long_bump(void* context) {
2424
Meal_Pager* app = context;
25-
if (app->haptic != 1) {
25+
if(app->haptic != 1) {
2626
return;
2727
}
28-
for (int i = 0; i < 4; i++) {
28+
for(int i = 0; i < 4; i++) {
2929
notification_message(app->notification, &sequence_set_vibro_on);
3030
furi_thread_flags_wait(0, FuriFlagWaitAny, 50);
3131
notification_message(app->notification, &sequence_reset_vibro);

helpers/meal_pager_haptic.h

-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ void meal_pager_play_happy_bump(void* context);
88
void meal_pager_play_bad_bump(void* context);
99

1010
void meal_pager_play_long_bump(void* context);
11-

helpers/meal_pager_led.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void meal_pager_blink_stop(Meal_Pager* app) {
1919

2020
void meal_pager_led_set_rgb(void* context, int red, int green, int blue) {
2121
Meal_Pager* app = context;
22-
if (app->led != 1) {
22+
if(app->led != 1) {
2323
return;
2424
}
2525
NotificationMessage notification_led_message_1;
@@ -40,14 +40,16 @@ void meal_pager_led_set_rgb(void* context, int red, int green, int blue) {
4040
NULL,
4141
};
4242
notification_message(app->notification, &notification_sequence);
43-
furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
43+
furi_thread_flags_wait(
44+
0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
4445
}
4546

4647
void meal_pager_led_reset(void* context) {
4748
Meal_Pager* app = context;
4849
notification_message(app->notification, &sequence_reset_red);
4950
notification_message(app->notification, &sequence_reset_green);
5051
notification_message(app->notification, &sequence_reset_blue);
51-
52-
furi_thread_flags_wait(0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set
52+
53+
furi_thread_flags_wait(
54+
0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set
5355
}

helpers/meal_pager_led.h

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ void meal_pager_blink_stop(Meal_Pager* app);
1111
void meal_pager_led_set_rgb(void* context, int red, int green, int blue);
1212

1313
void meal_pager_led_reset(void* context);
14-

helpers/meal_pager_speaker.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44

55
void meal_pager_play_input_sound(void* context) {
66
Meal_Pager* app = context;
7-
if (app->speaker != 1) {
7+
if(app->speaker != 1) {
88
return;
99
}
1010
float volume = 1.0f;
1111
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
1212
furi_hal_speaker_start(NOTE_INPUT, volume);
1313
}
14-
1514
}
1615

1716
void meal_pager_stop_all_sound(void* context) {
1817
Meal_Pager* app = context;
19-
if (app->speaker != 1) {
18+
if(app->speaker != 1) {
2019
return;
2120
}
2221
if(furi_hal_speaker_is_mine()) {

0 commit comments

Comments
 (0)