Skip to content

Commit 34e682c

Browse files
committed
clang-format of some files
1 parent 82615a3 commit 34e682c

File tree

8 files changed

+251
-224
lines changed

8 files changed

+251
-224
lines changed

.clang-format

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
BasedOnStyle: WebKit
3+
AlignAfterOpenBracket: AlwaysBreak
4+
BinPackArguments: true
5+
BinPackParameters: false
6+
PenaltyBreakBeforeFirstCallParameter: 1
7+
AllowShortFunctionsOnASingleLine: None
8+
AllowShortIfStatementsOnASingleLine: false
9+
AllowShortLoopsOnASingleLine: false
10+
AlignEscapedNewlines: Left
11+
AlignArrayOfStructures: None
12+
PointerAlignment: Right
13+
InsertBraces: true
14+
BreakBeforeBraces: Linux
15+
BreakBeforeBinaryOperators: None
16+
KeepEmptyLinesAtTheStartOfBlocks: false
17+
IndentCaseLabels: true
18+
IndentWidth: 4
19+
UseTab: Never
20+
SortIncludes: false
21+
ColumnLimit: 80
22+
# Const always to left side.
23+
QualifierAlignment: Left
24+
---
25+
Language: JavaScript
26+
DisableFormat: true
27+
...

zephyr/subsys/bacnet_basic/bacnet_basic.c

Lines changed: 70 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -126,60 +126,59 @@ void bacnet_basic_task_object_timer_set(unsigned long milliseconds)
126126
#if defined(CONFIG_BACNETSTACK_BACNET_SETTINGS)
127127
void bacnet_basic_settings_restore(void)
128128
{
129-
/* use MAX_INSTANCE for our internal device data location */
130-
const uint32_t object_instance = BACNET_MAX_INSTANCE;
131-
const BACNET_OBJECT_TYPE object_type = OBJECT_DEVICE;
132-
BACNET_CHARACTER_STRING char_string = { 0 };
133-
char name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
134-
BACNET_UNSIGNED_INTEGER value_unsigned = 0;
135-
BACNET_UNSIGNED_INTEGER default_unsigned = 0;
136-
const char *default_name;
137-
const char *default_reinit_password = "";
138-
uint32_t array_index = BACNET_ARRAY_ALL;
139-
int rc;
129+
/* use MAX_INSTANCE for our internal device data location */
130+
const uint32_t object_instance = BACNET_MAX_INSTANCE;
131+
const BACNET_OBJECT_TYPE object_type = OBJECT_DEVICE;
132+
BACNET_CHARACTER_STRING char_string = { 0 };
133+
char name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
134+
BACNET_UNSIGNED_INTEGER value_unsigned = 0;
135+
BACNET_UNSIGNED_INTEGER default_unsigned = 0;
136+
const char *default_name;
137+
const char *default_reinit_password = "";
138+
uint32_t array_index = BACNET_ARRAY_ALL;
139+
int rc;
140140

141-
/* Set the device object name from non-volatile or default */
142-
default_name = Device_Object_Name_ANSI();
143-
rc = bacnet_settings_characterstring_get(object_type, object_instance,
144-
PROP_OBJECT_NAME, array_index,
145-
default_name, &char_string);
146-
if (rc < 1) {
147-
LOG_INF("The Device object-name was not stored."
148-
" Using default \"%s\"",
149-
default_name);
150-
}
151-
Device_Set_Object_Name(&char_string);
152-
/* Set the device reinitialize password from non-volatile or default */
153-
/* Note: doesn't have a standard property enumeration, use vendor range */
154-
rc = bacnet_settings_string_get(object_type, object_instance, 512,
155-
array_index, default_reinit_password, name,
156-
sizeof(name));
157-
if (rc < 0) {
158-
LOG_INF("The ReinitializeDevice Password was not stored."
159-
" Using default \"%s\"",
160-
name);
161-
}
162-
Device_Reinitialize_Password_Set(name);
163-
/* Set the device object instance from non-volatile or use a default */
164-
rc = bacnet_settings_unsigned_get(object_type, object_instance,
165-
PROP_OBJECT_IDENTIFIER, array_index,
166-
BACNET_MAX_INSTANCE, &value_unsigned);
167-
if (rc < 0) {
168-
LOG_INF("The device instance was not stored. Using default %lu.",
169-
(unsigned long)value_unsigned);
170-
}
171-
Device_Set_Object_Instance_Number(value_unsigned);
172-
/* Set the device object instance from non-volatile or use a default */
173-
default_unsigned = Device_Database_Revision();
174-
rc = bacnet_settings_unsigned_get(object_type, object_instance,
175-
PROP_DATABASE_REVISION, array_index, 0UL,
176-
&value_unsigned);
177-
if (rc < 0) {
178-
LOG_INF(
179-
"The device database-revision is not readable. Using default %lu.",
180-
(unsigned long)value_unsigned);
181-
}
182-
Device_Set_Database_Revision(value_unsigned);
141+
/* Set the device object name from non-volatile or default */
142+
default_name = Device_Object_Name_ANSI();
143+
rc = bacnet_settings_characterstring_get(object_type, object_instance,
144+
PROP_OBJECT_NAME, array_index,
145+
default_name, &char_string);
146+
if (rc < 1) {
147+
LOG_INF("The Device object-name was not stored."
148+
" Using default \"%s\"",
149+
default_name);
150+
}
151+
Device_Set_Object_Name(&char_string);
152+
/* Set the device reinitialize password from non-volatile or default */
153+
/* Note: doesn't have a standard property enumeration, use vendor range */
154+
rc = bacnet_settings_string_get(object_type, object_instance, 512,
155+
array_index, default_reinit_password,
156+
name, sizeof(name));
157+
if (rc < 0) {
158+
LOG_INF("The ReinitializeDevice Password was not stored."
159+
" Using default \"%s\"",
160+
name);
161+
}
162+
Device_Reinitialize_Password_Set(name);
163+
/* Set the device object instance from non-volatile or use a default */
164+
rc = bacnet_settings_unsigned_get(object_type, object_instance,
165+
PROP_OBJECT_IDENTIFIER, array_index,
166+
BACNET_MAX_INSTANCE, &value_unsigned);
167+
if (rc < 0) {
168+
LOG_INF("The device instance was not stored. Using default %lu.",
169+
(unsigned long)value_unsigned);
170+
}
171+
Device_Set_Object_Instance_Number(value_unsigned);
172+
/* Set the device object instance from non-volatile or use a default */
173+
default_unsigned = Device_Database_Revision();
174+
rc = bacnet_settings_unsigned_get(object_type, object_instance,
175+
PROP_DATABASE_REVISION, array_index,
176+
0UL, &value_unsigned);
177+
if (rc < 0) {
178+
LOG_INF("The device database-revision is not readable. Using default %lu.",
179+
(unsigned long)value_unsigned);
180+
}
181+
Device_Set_Database_Revision(value_unsigned);
183182
}
184183
#endif
185184

@@ -193,19 +192,21 @@ void bacnet_basic_settings_restore(void)
193192
* @param application_data - pointer to the data
194193
* @param application_data_len - length of the data
195194
*/
196-
void bacnet_basic_settings_store(BACNET_OBJECT_TYPE object_type, uint32_t object_instance,
197-
BACNET_PROPERTY_ID object_property,
198-
BACNET_ARRAY_INDEX array_index,
199-
uint8_t *application_data, int application_data_len)
195+
void bacnet_basic_settings_store(BACNET_OBJECT_TYPE object_type,
196+
uint32_t object_instance,
197+
BACNET_PROPERTY_ID object_property,
198+
BACNET_ARRAY_INDEX array_index,
199+
uint8_t *application_data,
200+
int application_data_len)
200201
{
201-
BACNET_STORAGE_KEY key = { 0 };
202+
BACNET_STORAGE_KEY key = { 0 };
202203

203-
LOG_INF("WriteProperty data store");
204-
/* create the key */
205-
bacnet_storage_key_init(&key, object_type, object_instance, object_property,
206-
array_index);
207-
/* store the data */
208-
(void)bacnet_storage_set(&key, application_data, application_data_len);
204+
LOG_INF("WriteProperty data store");
205+
/* create the key */
206+
bacnet_storage_key_init(&key, object_type, object_instance,
207+
object_property, array_index);
208+
/* store the data */
209+
(void)bacnet_storage_set(&key, application_data, application_data_len);
209210
}
210211
#endif
211212

@@ -233,10 +234,11 @@ bool bacnet_basic_write_property_store(BACNET_WRITE_PROPERTY_DATA *wp_data)
233234
} else {
234235
array_index = wp_data->array_index;
235236
}
236-
bacnet_basic_settings_store(wp_data->object_type, wp_data->object_instance,
237-
wp_data->object_property, array_index,
238-
wp_data->application_data,
239-
wp_data->application_data_len);
237+
bacnet_basic_settings_store(wp_data->object_type,
238+
wp_data->object_instance,
239+
wp_data->object_property, array_index,
240+
wp_data->application_data,
241+
wp_data->application_data_len);
240242

241243
return true;
242244
}
@@ -298,7 +300,6 @@ void bacnet_basic_init(void)
298300
#if defined(CONFIG_BACNETSTACK_BACNET_SETTINGS)
299301
bacnet_basic_settings_restore();
300302
#endif
301-
302303
}
303304

304305
/* local buffer for incoming PDUs to process */

zephyr/subsys/bacnet_basic/bacnet_port.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,35 @@ static struct mstimer BACnet_Task_Timer;
3232
*/
3333
void bacnet_port_task(void)
3434
{
35-
uint32_t elapsed_milliseconds = 0;
36-
uint32_t elapsed_seconds = 0;
35+
uint32_t elapsed_milliseconds = 0;
36+
uint32_t elapsed_seconds = 0;
3737

38-
if (mstimer_expired(&BACnet_Task_Timer)) {
39-
/* 1 second tasks */
40-
mstimer_reset(&BACnet_Task_Timer);
41-
/* presume that the elapsed time is the interval time */
42-
elapsed_milliseconds = mstimer_interval(&BACnet_Task_Timer);
43-
elapsed_seconds = elapsed_milliseconds / 1000;
38+
if (mstimer_expired(&BACnet_Task_Timer)) {
39+
/* 1 second tasks */
40+
mstimer_reset(&BACnet_Task_Timer);
41+
/* presume that the elapsed time is the interval time */
42+
elapsed_milliseconds = mstimer_interval(&BACnet_Task_Timer);
43+
elapsed_seconds = elapsed_milliseconds / 1000;
4444
#if defined(BACDL_BIP)
45-
bacnet_port_ipv4_task(elapsed_seconds);
45+
bacnet_port_ipv4_task(elapsed_seconds);
4646
#elif defined(BACDL_BIP6)
47-
bacnet_port_ipv6_task(elapsed_seconds);
47+
bacnet_port_ipv6_task(elapsed_seconds);
4848
#endif
49-
}
49+
}
5050
}
5151

5252
/**
5353
* @brief Initialize the datalink network port
5454
*/
5555
bool bacnet_port_init(void)
5656
{
57-
bool status = false;
58-
/* start the 1 second timer for non-critical cyclic tasks */
59-
mstimer_set(&BACnet_Task_Timer, 1000L);
57+
bool status = false;
58+
/* start the 1 second timer for non-critical cyclic tasks */
59+
mstimer_set(&BACnet_Task_Timer, 1000L);
6060
#if defined(BACDL_BIP)
61-
status = bacnet_port_ipv4_init();
61+
status = bacnet_port_ipv4_init();
6262
#elif defined(BACDL_BIP6)
63-
status = bacnet_port_ipv6_init();
63+
status = bacnet_port_ipv6_init();
6464
#endif
65-
return status;
65+
return status;
6666
}

zephyr/subsys/bacnet_basic/bacnet_port_ipv4.c

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,69 +33,68 @@ static BACNET_IP_ADDRESS BBMD_Address;
3333
* @param ttl_seconds [in] The time-to-live in seconds for the Foreign Device Registration
3434
* @param bbmd_address [in] The address of the BBMD
3535
*/
36-
void bacnet_port_ipv4_foreign_device_init(
37-
const uint16_t ttl_seconds,
38-
const BACNET_IP_ADDRESS *bbmd_address)
36+
void bacnet_port_ipv4_foreign_device_init(const uint16_t ttl_seconds,
37+
const BACNET_IP_ADDRESS *bbmd_address)
3938
{
40-
BBMD_TTL_Seconds = ttl_seconds;
41-
if (bbmd_address) {
42-
memcpy(&BBMD_Address, bbmd_address, sizeof(BACNET_IP_ADDRESS));
43-
}
39+
BBMD_TTL_Seconds = ttl_seconds;
40+
if (bbmd_address) {
41+
memcpy(&BBMD_Address, bbmd_address, sizeof(BACNET_IP_ADDRESS));
42+
}
4443
}
4544

4645
/**
4746
* @brief Renew the Foreign Device Registration
4847
*/
4948
void bacnet_port_ipv4_task(uint16_t elapsed_seconds)
5049
{
51-
if (BBMD_Timer_Seconds) {
52-
if (BBMD_Timer_Seconds <= elapsed_seconds) {
53-
BBMD_Timer_Seconds = 0;
54-
} else {
55-
BBMD_Timer_Seconds -= elapsed_seconds;
56-
}
57-
if (BBMD_Timer_Seconds == 0) {
58-
if (BBMD_Address.port > 0) {
59-
(void)bvlc_register_with_bbmd(&BBMD_Address,
60-
BBMD_TTL_Seconds);
61-
}
62-
BBMD_Timer_Seconds = (uint16_t)BBMD_TTL_Seconds;
63-
}
64-
}
50+
if (BBMD_Timer_Seconds) {
51+
if (BBMD_Timer_Seconds <= elapsed_seconds) {
52+
BBMD_Timer_Seconds = 0;
53+
} else {
54+
BBMD_Timer_Seconds -= elapsed_seconds;
55+
}
56+
if (BBMD_Timer_Seconds == 0) {
57+
if (BBMD_Address.port > 0) {
58+
(void)bvlc_register_with_bbmd(&BBMD_Address,
59+
BBMD_TTL_Seconds);
60+
}
61+
BBMD_Timer_Seconds = (uint16_t)BBMD_TTL_Seconds;
62+
}
63+
}
6564
}
6665

6766
/**
6867
* Initialize the network port object.
6968
*/
7069
bool bacnet_port_ipv4_init(void)
7170
{
72-
const uint32_t instance = 1;
73-
BACNET_IP_ADDRESS addr = { 0 };
74-
uint8_t prefix = 0;
71+
const uint32_t instance = 1;
72+
BACNET_IP_ADDRESS addr = { 0 };
73+
uint8_t prefix = 0;
7574

76-
if (!bip_init(NULL)) {
77-
return false;
78-
}
79-
Network_Port_Object_Instance_Number_Set(0, instance);
80-
Network_Port_Name_Set(instance, "BACnet/IP Port");
81-
Network_Port_Type_Set(instance, PORT_TYPE_BIP);
82-
bip_get_addr(&addr);
83-
prefix = bip_get_subnet_prefix();
84-
Network_Port_BIP_Port_Set(instance, addr.port);
85-
Network_Port_IP_Address_Set(instance, addr.address[0], addr.address[1],
86-
addr.address[2], addr.address[3]);
87-
Network_Port_IP_Subnet_Prefix_Set(instance, prefix);
88-
Network_Port_Link_Speed_Set(instance, 0.0);
89-
/* common NP data */
90-
Network_Port_Reliability_Set(instance, RELIABILITY_NO_FAULT_DETECTED);
91-
Network_Port_Out_Of_Service_Set(instance, false);
92-
Network_Port_Quality_Set(instance, PORT_QUALITY_UNKNOWN);
93-
Network_Port_APDU_Length_Set(instance, MAX_APDU);
94-
Network_Port_Network_Number_Set(instance, 0);
95-
/* last thing - clear pending changes - we don't want to set these
75+
if (!bip_init(NULL)) {
76+
return false;
77+
}
78+
Network_Port_Object_Instance_Number_Set(0, instance);
79+
Network_Port_Name_Set(instance, "BACnet/IP Port");
80+
Network_Port_Type_Set(instance, PORT_TYPE_BIP);
81+
bip_get_addr(&addr);
82+
prefix = bip_get_subnet_prefix();
83+
Network_Port_BIP_Port_Set(instance, addr.port);
84+
Network_Port_IP_Address_Set(instance, addr.address[0], addr.address[1],
85+
addr.address[2], addr.address[3]);
86+
Network_Port_IP_Subnet_Prefix_Set(instance, prefix);
87+
Network_Port_Link_Speed_Set(instance, 0.0);
88+
/* common NP data */
89+
Network_Port_Reliability_Set(instance, RELIABILITY_NO_FAULT_DETECTED);
90+
Network_Port_Out_Of_Service_Set(instance, false);
91+
Network_Port_Quality_Set(instance, PORT_QUALITY_UNKNOWN);
92+
Network_Port_APDU_Length_Set(instance, MAX_APDU);
93+
Network_Port_Network_Number_Set(instance, 0);
94+
/* last thing - clear pending changes - we don't want to set these
9695
since they are already set */
97-
Network_Port_Changes_Pending_Set(instance, false);
96+
Network_Port_Changes_Pending_Set(instance, false);
9897

99-
return true;
98+
return true;
10099
}
101100
#endif

0 commit comments

Comments
 (0)