Skip to content

Commit 6aec7a0

Browse files
authored
Merge pull request #22 from bacnet-stack/feature/bacnet-basic-storage
2 parents 25d1814 + cb16730 commit 6aec7a0

28 files changed

+2035
-2109
lines changed

zephyr/.clang-format

Lines changed: 59 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,44 @@
1-
# SPDX-License-Identifier: GPL-2.0
1+
# SPDX-License-Identifier: Apache-2.0
22
#
3-
# clang-format configuration file. Intended for clang-format >= 4.
3+
# Note: The list of ForEachMacros can be obtained using:
44
#
5-
# For more information, see:
6-
#
7-
# Documentation/process/clang-format.rst
8-
# https://clang.llvm.org/docs/ClangFormat.html
9-
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
5+
# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
6+
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
7+
# | sort | uniq
108
#
9+
# References:
10+
# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
11+
1112
---
12-
AccessModifierOffset: -4
13-
AlignAfterOpenBracket: Align
14-
AlignConsecutiveAssignments: false
15-
AlignConsecutiveDeclarations: false
16-
#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
17-
AlignOperands: true
18-
AlignTrailingComments: false
19-
AllowAllParametersOfDeclarationOnNextLine: false
20-
AllowShortBlocksOnASingleLine: false
13+
BasedOnStyle: LLVM
14+
AlignConsecutiveMacros: AcrossComments
15+
AllowShortBlocksOnASingleLine: Never
2116
AllowShortCaseLabelsOnASingleLine: false
17+
AllowShortEnumsOnASingleLine: false
2218
AllowShortFunctionsOnASingleLine: None
2319
AllowShortIfStatementsOnASingleLine: false
2420
AllowShortLoopsOnASingleLine: false
25-
AlwaysBreakAfterDefinitionReturnType: None
26-
AlwaysBreakAfterReturnType: None
27-
AlwaysBreakBeforeMultilineStrings: false
28-
AlwaysBreakTemplateDeclarations: false
29-
BinPackArguments: true
30-
BinPackParameters: true
31-
BraceWrapping:
32-
AfterClass: false
33-
AfterControlStatement: false
34-
AfterEnum: false
35-
AfterFunction: true
36-
AfterNamespace: true
37-
AfterObjCDeclaration: false
38-
AfterStruct: false
39-
AfterUnion: false
40-
#AfterExternBlock: false # Unknown to clang-format-5.0
41-
BeforeCatch: false
42-
BeforeElse: false
43-
IndentBraces: false
44-
#SplitEmptyFunction: true # Unknown to clang-format-4.0
45-
#SplitEmptyRecord: true # Unknown to clang-format-4.0
46-
#SplitEmptyNamespace: true # Unknown to clang-format-4.0
47-
BreakBeforeBinaryOperators: None
48-
BreakBeforeBraces: Custom
49-
#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
50-
BreakBeforeTernaryOperators: false
51-
BreakConstructorInitializersBeforeComma: false
52-
#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
53-
BreakAfterJavaFieldAnnotations: false
54-
BreakStringLiterals: false
55-
ColumnLimit: 80
56-
CommentPragmas: '^ IWYU pragma:'
57-
#CompactNamespaces: false # Unknown to clang-format-4.0
58-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
21+
AttributeMacros:
22+
- __aligned
23+
- __deprecated
24+
- __packed
25+
- __printf_like
26+
- __syscall
27+
- __syscall_always_inline
28+
- __subsystem
29+
BitFieldColonSpacing: After
30+
BreakBeforeBraces: Linux
31+
ColumnLimit: 100
5932
ConstructorInitializerIndentWidth: 8
6033
ContinuationIndentWidth: 8
61-
Cpp11BracedListStyle: false
62-
DerivePointerAlignment: false
63-
DisableFormat: false
64-
ExperimentalAutoDetectBinPacking: false
65-
#FixNamespaceComments: false # Unknown to clang-format-4.0
66-
67-
# Taken from:
68-
# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
69-
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
70-
# | sort | uniq
7134
ForEachMacros:
35+
- 'ARRAY_FOR_EACH'
36+
- 'ARRAY_FOR_EACH_PTR'
7237
- 'FOR_EACH'
7338
- 'FOR_EACH_FIXED_ARG'
39+
- 'FOR_EACH_IDX'
40+
- 'FOR_EACH_IDX_FIXED_ARG'
41+
- 'FOR_EACH_NONEMPTY_TERM'
7442
- 'RB_FOR_EACH'
7543
- 'RB_FOR_EACH_CONTAINER'
7644
- 'SYS_DLIST_FOR_EACH_CONTAINER'
@@ -85,61 +53,42 @@ ForEachMacros:
8553
- 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE'
8654
- 'SYS_SLIST_FOR_EACH_NODE'
8755
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
56+
- '_WAIT_Q_FOR_EACH'
57+
- 'Z_FOR_EACH'
58+
- 'Z_FOR_EACH_ENGINE'
59+
- 'Z_FOR_EACH_EXEC'
60+
- 'Z_FOR_EACH_FIXED_ARG'
61+
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
62+
- 'Z_FOR_EACH_IDX'
63+
- 'Z_FOR_EACH_IDX_EXEC'
64+
- 'Z_FOR_EACH_IDX_FIXED_ARG'
65+
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
8866
- 'Z_GENLIST_FOR_EACH_CONTAINER'
8967
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
9068
- 'Z_GENLIST_FOR_EACH_NODE'
9169
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
92-
- '_WAIT_Q_FOR_EACH'
93-
94-
#IncludeBlocks: Preserve # Unknown to clang-format-5.0
70+
- 'STRUCT_SECTION_FOREACH'
71+
- 'TYPE_SECTION_FOREACH'
72+
- 'K_SPINLOCK'
73+
IfMacros:
74+
- 'CHECKIF'
75+
# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520
76+
#IncludeBlocks: Regroup
9577
IncludeCategories:
96-
- Regex: '.*'
78+
- Regex: '^".*\.h"$'
79+
Priority: 0
80+
- Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$'
9781
Priority: 1
98-
IncludeIsMainRegex: '(Test)?$'
82+
- Regex: '^\<zephyr/.*\.h\>$'
83+
Priority: 2
84+
- Regex: '.*'
85+
Priority: 3
9986
IndentCaseLabels: false
100-
#IndentPPDirectives: None # Unknown to clang-format-5.0
10187
IndentWidth: 8
102-
IndentWrappedFunctionNames: false
103-
JavaScriptQuotes: Leave
104-
JavaScriptWrapImports: true
105-
KeepEmptyLinesAtTheStartOfBlocks: false
106-
MacroBlockBegin: ''
107-
MacroBlockEnd: ''
108-
MaxEmptyLinesToKeep: 1
109-
NamespaceIndentation: Inner
110-
#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
111-
ObjCBlockIndentWidth: 8
112-
ObjCSpaceAfterProperty: true
113-
ObjCSpaceBeforeProtocolList: true
114-
115-
# Taken from git's rules
116-
#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
117-
PenaltyBreakBeforeFirstCallParameter: 30
118-
PenaltyBreakComment: 10
119-
PenaltyBreakFirstLessLess: 0
120-
PenaltyBreakString: 10
121-
PenaltyExcessCharacter: 100
122-
PenaltyReturnTypeOnItsOwnLine: 60
123-
124-
PointerAlignment: Right
125-
ReflowComments: false
126-
SortIncludes: false
127-
#SortUsingDeclarations: false # Unknown to clang-format-4.0
128-
SpaceAfterCStyleCast: false
129-
SpaceAfterTemplateKeyword: true
130-
SpaceBeforeAssignmentOperators: true
131-
#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
132-
#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
133-
SpaceBeforeParens: ControlStatements
134-
#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
135-
SpaceInEmptyParentheses: false
136-
SpacesBeforeTrailingComments: 1
137-
SpacesInAngles: false
138-
SpacesInContainerLiterals: false
139-
SpacesInCStyleCastParentheses: false
140-
SpacesInParentheses: false
141-
SpacesInSquareBrackets: false
142-
Standard: Cpp03
143-
TabWidth: 8
144-
UseTab: Always
145-
...
88+
InsertBraces: true
89+
SpaceBeforeParens: ControlStatementsExceptControlMacros
90+
SortIncludes: Never
91+
UseTab: ForContinuationAndIndentation
92+
WhitespaceSensitiveMacros:
93+
- STRINGIFY
94+
- Z_STRINGIFY
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2022 STMicroelectronics
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/delete-node/ &storage_partition;
8+
9+
&flash0 {
10+
partitions {
11+
/* Set 48KB of storage at the beginning of bank2 in order to have 3 sectors smaller than 32K
12+
* (nvs.h: uint16_t sector_size)
13+
*/
14+
storage_partition: partition@100000 {
15+
label = "storage";
16+
reg = <0x000100000 DT_SIZE_K(48)>;
17+
};
18+
};
19+
};

zephyr/samples/profiles/b-ld/prj.conf

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ CONFIG_INIT_STACKS=y
2424
CONFIG_BACNETSTACK=y
2525
CONFIG_BACNETSTACK_LOG_LEVEL=3
2626
CONFIG_BACNETSTACK_BACNET_BASIC=y
27+
# BACnet settings subsystem
28+
CONFIG_BACNETSTACK_BACNET_SETTINGS=y
29+
CONFIG_BACNET_SETTINGS_SHELL=y
2730
# BACnet Library - options
2831
CONFIG_BACNET_MAX_CHARACTER_STRING_BYTES=128
2932
CONFIG_BACAPP_MINIMAL=y
@@ -34,10 +37,6 @@ CONFIG_BACNET_BASIC_OBJECT_LIGHTING_OUTPUT=y
3437
CONFIG_BACAPP_LIGHTING_COMMAND=y
3538
# BACnet Library - shell
3639
CONFIG_BACNET_BASIC_DEVICE_SHELL=y
37-
# BACnet settings subsystem
38-
#CONFIG_BACNETSTACK_BACNET_SETTINGS=y
39-
#CONFIG_BACNET_SETTINGS=y
40-
#CONFIG_BACNET_SETTINGS_SHELL=y
4140

4241
# BACnet Datalink Options
4342
CONFIG_BACDL_BIP=y
@@ -120,19 +119,19 @@ CONFIG_STATS_SHELL=y
120119
#
121120
# Storage
122121
#
123-
#CONFIG_FLASH=y
124-
#CONFIG_FLASH_MAP=y
122+
CONFIG_FLASH=y
123+
CONFIG_FLASH_MAP=y
125124
#CONFIG_FLASH_PAGE_LAYOUT=y
126125
# native_posix uses a simulated flash
127126
#CONFIG_FLASH_SIMULATOR=y
128127
#CONFIG_DISK_ACCESS=y.
129128
#CONFIG_FILE_SYSTEM=y
130129
#CONFIG_FILE_SYSTEM_LITTLEFS=y
131130
#CONFIG_FILE_SYSTEM_SHELL=y
132-
#CONFIG_NVS=y
133-
#CONFIG_SETTINGS=y
134-
#CONFIG_SETTINGS_NVS=y
135-
#CONFIG_SETTINGS_RUNTIME=y
131+
CONFIG_NVS=y
132+
CONFIG_SETTINGS=y
133+
CONFIG_SETTINGS_NVS=y
134+
CONFIG_SETTINGS_RUNTIME=y
136135
#CONFIG_SETTINGS_FILE=y
137136
#CONFIG_SETTINGS_SHELL=y
138137

zephyr/samples/profiles/b-ld/src/main.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
3030

3131
/* FIXME: get the device instance and name from settings! */
32-
static const uint32_t Device_Instance = 260125;
3332
static const char *Device_Name = "BACnet Lighting Device (B-LD)";
3433
/* object instances */
3534
static const uint32_t Lighting_Instance = 1;
@@ -39,8 +38,8 @@ static const uint32_t Lighting_Instance = 1;
3938
* @param object-instance [in] The object-instance number of the object
4039
* @param old_value [in] The value to track
4140
*/
42-
void BACnet_Lighting_Output_Tracking_Value_Handler(uint32_t object_instance,
43-
float old_value, float value)
41+
void BACnet_Lighting_Output_Tracking_Value_Handler(uint32_t object_instance, float old_value,
42+
float value)
4443
{
4544
uint16_t steps = 0;
4645

@@ -56,9 +55,8 @@ void BACnet_Lighting_Output_Tracking_Value_Handler(uint32_t object_instance,
5655
} else {
5756
steps = 0;
5857
}
59-
LOG_INF("Lighting Output[%lu]: value=%f step=%u/%u",
60-
(unsigned long)object_instance, (double)value, (unsigned)steps,
61-
(unsigned)UINT16_MAX);
58+
LOG_INF("Lighting Output[%lu]: value=%f step=%u/%u", (unsigned long)object_instance,
59+
(double)value, (unsigned)steps, (unsigned)UINT16_MAX);
6260
}
6361

6462
/**
@@ -71,8 +69,6 @@ static void BACnet_Lighting_Device_Init_Handler(void *context)
7169
(void)context;
7270
LOG_INF("BACnet Stack Initialized");
7371
/* initialize objects for this basic sample */
74-
Device_Init(NULL);
75-
Device_Set_Object_Instance_Number(Device_Instance);
7672
Device_Object_Name_ANSI_Init(Device_Name);
7773
Lighting_Output_Create(Lighting_Instance);
7874
Lighting_Output_Name_Set(Lighting_Instance, "Light-1");
@@ -99,10 +95,8 @@ int main(void)
9995
LOG_INF("BACnet Device: %s", Device_Name);
10096
LOG_INF("BACnet Stack Version " BACNET_VERSION_TEXT);
10197
LOG_INF("BACnet Stack Max APDU: %d", MAX_APDU);
102-
bacnet_basic_init_callback_set(BACnet_Lighting_Device_Init_Handler,
103-
NULL);
104-
bacnet_basic_task_callback_set(BACnet_Lighting_Device_Task_Handler,
105-
NULL);
98+
bacnet_basic_init_callback_set(BACnet_Lighting_Device_Init_Handler, NULL);
99+
bacnet_basic_task_callback_set(BACnet_Lighting_Device_Task_Handler, NULL);
106100
/* work happens in server module */
107101
for (;;) {
108102
k_sleep(K_MSEC(1000));
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2022 STMicroelectronics
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/delete-node/ &storage_partition;
8+
9+
&flash0 {
10+
partitions {
11+
/* Set 48KB of storage at the beginning of bank2 in order to have 3 sectors smaller than 32K
12+
* (nvs.h: uint16_t sector_size)
13+
*/
14+
storage_partition: partition@100000 {
15+
label = "storage";
16+
reg = <0x000100000 DT_SIZE_K(48)>;
17+
};
18+
};
19+
};

zephyr/samples/profiles/b-ls/prj.conf

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ CONFIG_INIT_STACKS=y
2424
CONFIG_BACNETSTACK=y
2525
CONFIG_BACNETSTACK_LOG_LEVEL=3
2626
CONFIG_BACNETSTACK_BACNET_BASIC=y
27+
# BACnet settings subsystem
28+
CONFIG_BACNETSTACK_BACNET_SETTINGS=y
29+
CONFIG_BACNET_SETTINGS_SHELL=y
2730
# BACnet Library - options
2831
CONFIG_BACNET_MAX_CHARACTER_STRING_BYTES=128
2932
CONFIG_BACAPP_MINIMAL=y
@@ -40,10 +43,6 @@ CONFIG_BACAPP_DOUBLE=y
4043
CONFIG_BACAPP_COLOR_COMMAND=y
4144
# BACnet Library - shell
4245
CONFIG_BACNET_BASIC_DEVICE_SHELL=y
43-
# BACnet settings subsystem
44-
#CONFIG_BACNETSTACK_BACNET_SETTINGS=y
45-
#CONFIG_BACNET_SETTINGS=y
46-
#CONFIG_BACNET_SETTINGS_SHELL=y
4746

4847
# BACnet Datalink Options
4948
CONFIG_BACDL_BIP=y
@@ -125,21 +124,21 @@ CONFIG_STATS_SHELL=y
125124
#
126125
# Storage
127126
#
128-
#CONFIG_FLASH=y
129-
#CONFIG_FLASH_MAP=y
127+
CONFIG_FLASH=y
128+
CONFIG_FLASH_MAP=y
130129
#CONFIG_FLASH_PAGE_LAYOUT=y
130+
CONFIG_NVS=y
131+
CONFIG_SETTINGS=y
132+
CONFIG_SETTINGS_NVS=y
133+
CONFIG_SETTINGS_RUNTIME=y
134+
#CONFIG_SETTINGS_FILE=y
135+
#CONFIG_SETTINGS_SHELL=y
131136
# native_posix uses a simulated flash
132137
#CONFIG_FLASH_SIMULATOR=y
133138
#CONFIG_DISK_ACCESS=y.
134139
#CONFIG_FILE_SYSTEM=y
135140
#CONFIG_FILE_SYSTEM_LITTLEFS=y
136141
#CONFIG_FILE_SYSTEM_SHELL=y
137-
#CONFIG_NVS=y
138-
#CONFIG_SETTINGS=y
139-
#CONFIG_SETTINGS_NVS=y
140-
#CONFIG_SETTINGS_RUNTIME=y
141-
#CONFIG_SETTINGS_FILE=y
142-
#CONFIG_SETTINGS_SHELL=y
143142

144143
CONFIG_TEST_RANDOM_GENERATOR=y
145144
CONFIG_TIMER_RANDOM_GENERATOR=y

0 commit comments

Comments
 (0)