Added Zephyr settings and basic device in subsys. (#697)

* Added Zephyr settings subsys to enable storing of BACnet values according to BACnet object property value path.

* Added BACnet Basic features to enable basic samples. Refactored the zephyr BACnet profile B-SS sample to use BACnet basic subsys.
This commit is contained in:
Steve Karg
2024-07-19 17:12:20 -05:00
committed by GitHub
parent 90714c094c
commit 1e889b633c
33 changed files with 3400 additions and 213 deletions
@@ -0,0 +1,25 @@
/**
* @file
* @brief BACnet Basic Stack initialization and basic task handler
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_BASIC_H
#define BACNET_BASIC_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void bacnet_basic_init(void);
void bacnet_basic_task(void);
unsigned long bacnet_basic_uptime_seconds(void);
unsigned long bacnet_basic_packet_count(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+27
View File
@@ -0,0 +1,27 @@
/**
* @file
* @brief The BACnet datalink tasks for handling the device specific
* data link network port layer
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_PORT_H
#define BACNET_PORT_H
#include <stdint.h>
#include <stdint.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
bool bacnet_port_init(void);
void bacnet_port_task(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
@@ -0,0 +1,31 @@
/**
* @file
* @brief API for the BACnet datalink tasks for handling the device specific
* data link network port layer
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_PORT_IPV4_H
#define BACNET_PORT_IPV4_H
#include <stdbool.h>
#include <stdint.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
#include "bacnet/datalink/bvlc.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void bacnet_port_ipv4_foreign_device_init(
const uint16_t ttl_seconds,
const BACNET_IP_ADDRESS *bbmd_address);
void bacnet_port_ipv4_task(uint16_t elapsed_seconds);
bool bacnet_port_ipv4_init(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
@@ -0,0 +1,30 @@
/**
* @file
* @brief The BACnet/IPv6 datalink tasks for handling the device specific
* data link network port layer
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_PORT_IPV6_H
#define BACNET_PORT_IPV6_H
#include <stdbool.h>
#include <stdint.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
#include "bacnet/datalink/bvlc6.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void bacnet_port_ipv6_foreign_device_init(
const uint16_t ttl_seconds, const BACNET_IP6_ADDRESS *bbmd_address);
void bacnet_port_ipv6_task(uint16_t elapsed_seconds);
bool bacnet_port_ipv6_init(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
@@ -0,0 +1,78 @@
/**
* @file
* @brief API for Get/Set of BACnet application encoded settings handlers
* @author Steve Karg <skarg@users.sourceforge.net>
* @date May 2024
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_SETTINGS_H
#define BACNET_SETTINGS_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "bacnet/bacdef.h"
#include "bacnet/bacapp.h"
#include "bacnet/bacstr.h"
#include "bacnet/bacint.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
int bacnet_settings_value_get(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
BACNET_APPLICATION_DATA_VALUE *value);
bool bacnet_settings_value_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
BACNET_APPLICATION_DATA_VALUE *value);
int bacnet_settings_real_get(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
float default_value, float *value);
bool bacnet_settings_real_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
float value);
int bacnet_settings_unsigned_get(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
BACNET_UNSIGNED_INTEGER default_value,
BACNET_UNSIGNED_INTEGER *value);
bool bacnet_settings_unsigned_set(uint16_t object_type,
uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
BACNET_UNSIGNED_INTEGER value);
int bacnet_settings_signed_get(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
int32_t default_value, int32_t *value);
bool bacnet_settings_signed_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
int32_t value);
int bacnet_settings_characterstring_get(uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
const char *default_value,
BACNET_CHARACTER_STRING *value);
bool bacnet_settings_characterstring_ansi_set(uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
const char *cstring);
int bacnet_settings_string_get(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
const char *default_value, char *value,
size_t value_size);
bool bacnet_settings_string_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
const char *value);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
@@ -0,0 +1,45 @@
/**
* @file
* @brief API for the BACnet storage tasks for handling the device specific
* non-volatile object data
* @author Steve Karg <skarg@users.sourceforge.net>
* @date May 2024
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_STORAGE_H
#define BACNET_STORAGE_H
#include <stddef.h>
#include <stdint.h>
#include <zephyr/settings/settings.h>
#define BACNET_STORAGE_VALUE_SIZE_MAX SETTINGS_MAX_VAL_LEN
#define BACNET_STORAGE_KEY_SIZE_MAX SETTINGS_MAX_NAME_LEN
#define BACNET_STORAGE_ARRAY_INDEX_NONE UINT32_MAX
typedef struct bacnet_storage_key_t {
uint16_t object_type;
uint32_t object_instance;
uint32_t property_id;
uint32_t array_index;
} BACNET_STORAGE_KEY;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void bacnet_storage_init(void);
void bacnet_storage_key_init(BACNET_STORAGE_KEY *key, uint16_t object_type,
uint32_t object_instance, uint32_t property_id,
uint32_t array_index);
int bacnet_storage_key_encode(char *buffer, size_t buffer_size,
BACNET_STORAGE_KEY *key);
int bacnet_storage_set(BACNET_STORAGE_KEY *key, const void *data,
size_t data_size);
int bacnet_storage_get(BACNET_STORAGE_KEY *key, void *data, size_t data_size);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif