Skip to content

Commit e31e393

Browse files
committed
[WIP] configure NVS for storing BACnet settings
1 parent 25d1814 commit e31e393

File tree

12 files changed

+478
-117
lines changed

12 files changed

+478
-117
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @file
3+
* @brief The BACnet datalink initialization functions
4+
* @author Steve Karg <[email protected]>
5+
* @date January 2025
6+
* @copyright SPDX-License-Identifier: Apache-2.0
7+
*/
8+
#ifndef BACNET_DATALINK_MSTP_INIT_H
9+
#define BACNET_DATALINK_MSTP_INIT_H
10+
11+
#include <stdint.h>
12+
#include <stdint.h>
13+
/* BACnet Stack defines - first */
14+
#include "bacnet/bacdef.h"
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif /* __cplusplus */
19+
20+
void mstp_init_uuid(const uint8_t *new_uuid, size_t length);
21+
void mstp_init_mac(uint8_t mac);
22+
void mstp_init_baud(uint32_t baud);
23+
void mstp_init_max_master(uint8_t max_master);
24+
void mstp_init_port(uint8_t mac, uint32_t baud, uint8_t max_master);
25+
26+
#ifdef __cplusplus
27+
}
28+
#endif /* __cplusplus */
29+
#endif

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ static void BACnet_Lighting_Device_Init_Handler(void *context)
7171
(void)context;
7272
LOG_INF("BACnet Stack Initialized");
7373
/* initialize objects for this basic sample */
74-
Device_Init(NULL);
75-
Device_Set_Object_Instance_Number(Device_Instance);
7674
Device_Object_Name_ANSI_Init(Device_Name);
7775
Lighting_Output_Create(Lighting_Instance);
7876
Lighting_Output_Name_Set(Lighting_Instance, "Light-1");
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @file
3+
* @brief Override existing Nucleo F429ZI board for the BACnet sample.
4+
* @author Steve Karg <[email protected]>
5+
* @date January 2025
6+
* @copyright SPDX-License-Identifier: Apache-2.0
7+
*/
8+
/delete-node/ &storage_partition;
9+
&flash0 {
10+
partitions {
11+
/* Configure storage for NVS: rules from nvs.h: uint16_t sector_size
12+
a) shall be more than one sector
13+
b) each sector shall be the same size
14+
c) each sector shalle be smaller than 64KB
15+
*/
16+
storage_partition: partition@100000 {
17+
label = "storage";
18+
reg = <0x000100000 DT_SIZE_K(48)>;
19+
};
20+
};
21+
};

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ 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
30+
# the dependencies of the SETTINGS option.
31+
CONFIG_FLASH=y
32+
CONFIG_FLASH_MAP=y
33+
CONFIG_NVS=y
34+
CONFIG_SETTINGS=y
35+
CONFIG_SETTINGS_NVS=y
36+
CONFIG_SETTINGS_RUNTIME=y
2737
# BACnet Library - options
2838
CONFIG_BACNET_MAX_CHARACTER_STRING_BYTES=128
2939
CONFIG_BACAPP_MINIMAL=y
@@ -33,10 +43,6 @@ CONFIG_BACNET_BASIC_OBJECT_NETWORK_PORT=y
3343
CONFIG_BACNET_BASIC_OBJECT_ANALOG_INPUT=y
3444
# BACnet Library - shell
3545
CONFIG_BACNET_BASIC_DEVICE_SHELL=y
36-
# BACnet settings subsystem
37-
#CONFIG_BACNETSTACK_BACNET_SETTINGS=y
38-
#CONFIG_BACNET_SETTINGS=y
39-
#CONFIG_BACNET_SETTINGS_SHELL=y
4046

4147
# BACnet Datalink Options
4248
CONFIG_BACDL_BIP=y
@@ -116,9 +122,6 @@ CONFIG_STATS_SHELL=y
116122
#CONFIG_FILE_SYSTEM=y
117123
#CONFIG_FILE_SYSTEM_LITTLEFS=y
118124
#CONFIG_FILE_SYSTEM_SHELL=y
119-
#CONFIG_NVS=y
120-
#CONFIG_SETTINGS=y
121-
#CONFIG_SETTINGS_NVS=y
122125
#CONFIG_SETTINGS_RUNTIME=y
123126
#CONFIG_SETTINGS_FILE=y
124127
#CONFIG_SETTINGS_SHELL=y

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,12 @@
2828
#include "bacnet_osif/bacnet_log.h"
2929
LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
3030

31-
/* FIXME: get the device instance and name from settings! */
32-
static const uint32_t Device_Instance = 260123;
3331
static const char *Device_Name = "BACnet Smart Sensor (B-SS)";
3432
/* object instances */
3533
static const uint32_t Sensor_Instance = 1;
3634
/* timer for Sensor Update Interval */
3735
static struct mstimer Sensor_Update_Timer;
3836

39-
static void BACnet_Smart_Sensor_Datalink_Init(void)
40-
{
41-
42-
}
43-
4437
/**
4538
* @brief BACnet Project Initialization Handler
4639
* @param context [in] The context to pass to the callback function
@@ -50,10 +43,7 @@ static void BACnet_Smart_Sensor_Init_Handler(void *context)
5043
{
5144
(void)context;
5245
LOG_INF("BACnet Stack Initialized");
53-
BACnet_Smart_Sensor_Datalink_Init();
54-
/* initialize objects for this basic sample */
55-
Device_Init(NULL);
56-
Device_Set_Object_Instance_Number(Device_Instance);
46+
/* initialize child objects for this basic sample */
5747
Device_Object_Name_ANSI_Init(Device_Name);
5848
Analog_Input_Create(Sensor_Instance);
5949
Analog_Input_Name_Set(Sensor_Instance, "Sensor");

0 commit comments

Comments
 (0)