Strip tabs and trailing white spaces, and fix end of files (#748)
* format: Strip trailing whitespaces
We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.
Commit was generated with:
pre-commit run --all-files trailing-whitespace
* format: Files should have exactly one new line end of them
It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.
Commit was generated with:
pre-commit run --all-files end-of-file-fixer
* format: Convert tabs to spaces
Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.
Commit was generated with:
pre-commit run --all-files remove-tabs
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -532,4 +532,3 @@ zephyr_compile_definitions(
|
||||
$<$<BOOL:${CONFIG_BACAPP_SCALE}>:BACAPP_SCALE>
|
||||
$<$<BOOL:${CONFIG_BACAPP_SHED_LEVEL}>:BACAPP_SHED_LEVEL>
|
||||
)
|
||||
|
||||
+408
-408
File diff suppressed because it is too large
Load Diff
@@ -17,11 +17,11 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void bacnet_basic_init(void);
|
||||
void bacnet_basic_init_callback_set(bacnet_basic_callback callback,
|
||||
void bacnet_basic_init_callback_set(bacnet_basic_callback callback,
|
||||
void *context);
|
||||
|
||||
void bacnet_basic_task(void);
|
||||
void bacnet_basic_task_callback_set(bacnet_basic_callback callback,
|
||||
void bacnet_basic_task_callback_set(bacnet_basic_callback callback,
|
||||
void *context);
|
||||
|
||||
unsigned long bacnet_basic_uptime_seconds(void);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief The BACnet datalink tasks for handling the device specific
|
||||
* @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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief API for the BACnet datalink tasks for handling the device specific
|
||||
* @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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief The BACnet/IPv6 datalink tasks for handling the device specific
|
||||
* @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
|
||||
|
||||
@@ -21,56 +21,56 @@ 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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
const char *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#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;
|
||||
uint16_t object_type;
|
||||
uint32_t object_instance;
|
||||
uint32_t property_id;
|
||||
uint32_t array_index;
|
||||
} BACNET_STORAGE_KEY;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -31,12 +31,12 @@ extern "C" {
|
||||
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);
|
||||
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);
|
||||
BACNET_STORAGE_KEY *key);
|
||||
int bacnet_storage_set(BACNET_STORAGE_KEY *key, const void *data,
|
||||
size_t data_size);
|
||||
size_t data_size);
|
||||
int bacnet_storage_get(BACNET_STORAGE_KEY *key, void *data, size_t data_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -26,7 +26,7 @@ The sample can be built for several platforms.
|
||||
QEMU testing
|
||||
************
|
||||
|
||||
The main logic of work can be found at the link
|
||||
The main logic of work can be found at the link
|
||||
https://docs.zephyrproject.org/3.0.0/guides/networking/qemu_setup.html
|
||||
|
||||
Steps to testing
|
||||
@@ -38,7 +38,7 @@ Steps to testing
|
||||
first: cd ~/net-tools && ./loop-socat.sh
|
||||
second: cd ~/net-tools && sudo ./loop-slip-tap.sh
|
||||
3 Configure prj.conf
|
||||
The net-tools creates and uses network 192.0.2.0/24 as `tap0` interface.
|
||||
The net-tools creates and uses network 192.0.2.0/24 as `tap0` interface.
|
||||
Need change prj.conf:
|
||||
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
|
||||
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
|
||||
|
||||
@@ -47,7 +47,7 @@ static void BACnet_Smart_Sensor_Init_Handler(void *context)
|
||||
Analog_Input_Create(Sensor_Instance);
|
||||
Analog_Input_Name_Set(Sensor_Instance, "Sensor");
|
||||
Analog_Input_Present_Value_Set(Sensor_Instance, 25.0f);
|
||||
LOG_INF("BACnet Device ID: %u", Device_Object_Instance_Number());
|
||||
LOG_INF("BACnet Device ID: %u", Device_Object_Instance_Number());
|
||||
/* start the seconds cyclic timer */
|
||||
mstimer_set(&Sensor_Update_Timer, 1000);
|
||||
srand(sys_rand32_get());
|
||||
@@ -78,9 +78,9 @@ static void BACnet_Smart_Sensor_Task_Handler(void *context)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
LOG_INF("\n*** BACnet Profile B-SS Sample ***\n");
|
||||
LOG_INF("BACnet Stack Version " BACNET_VERSION_TEXT);
|
||||
LOG_INF("BACnet Stack Max APDU: %d", MAX_APDU);
|
||||
LOG_INF("\n*** BACnet Profile B-SS Sample ***\n");
|
||||
LOG_INF("BACnet Stack Version " BACNET_VERSION_TEXT);
|
||||
LOG_INF("BACnet Stack Max APDU: %d", MAX_APDU);
|
||||
bacnet_basic_init_callback_set(BACnet_Smart_Sensor_Init_Handler, NULL);
|
||||
bacnet_basic_task_callback_set(BACnet_Smart_Sensor_Task_Handler, NULL);
|
||||
/* work happens in server module */
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
# @copyright SPDX-License-Identifier: MIT
|
||||
menuconfig BACNETSTACK_BACNET_BASIC
|
||||
bool "BACNETSTACK_BACNET_BASIC"
|
||||
default n
|
||||
help
|
||||
default n
|
||||
help
|
||||
This option enables a basic BACnet Device object and tasking
|
||||
|
||||
if BACNETSTACK_BACNET_BASIC
|
||||
@@ -14,33 +14,33 @@ if BACNETSTACK_BACNET_BASIC
|
||||
module = BACNETSTACK_BACNET_BASIC
|
||||
module-str = bacnet_basic
|
||||
|
||||
config BACNET_BASIC_DEVICE_OBJECT_NAME
|
||||
string "BACnet device object default name"
|
||||
default "Basic Server"
|
||||
help
|
||||
BACnet device object default name
|
||||
config BACNET_BASIC_DEVICE_OBJECT_NAME
|
||||
string "BACnet device object default name"
|
||||
default "Basic Server"
|
||||
help
|
||||
BACnet device object default name
|
||||
|
||||
config BACNET_BASIC_DEVICE_OBJECT_VERSION
|
||||
string "BACnet device object default application version string"
|
||||
default "1.0.0"
|
||||
help
|
||||
BACnet device object default application version string
|
||||
config BACNET_BASIC_DEVICE_OBJECT_VERSION
|
||||
string "BACnet device object default application version string"
|
||||
default "1.0.0"
|
||||
help
|
||||
BACnet device object default application version string
|
||||
|
||||
config BACNET_BASIC_DEVICE_DESCRIPTION
|
||||
string "BACnet device object default description string"
|
||||
default "BACnet Basic Server"
|
||||
help
|
||||
BACnet device object default description string
|
||||
config BACNET_BASIC_DEVICE_DESCRIPTION
|
||||
string "BACnet device object default description string"
|
||||
default "BACnet Basic Server"
|
||||
help
|
||||
BACnet device object default description string
|
||||
|
||||
config BACNET_BASIC_DEVICE_MODEL_NAME
|
||||
string "BACnet device object default model name string"
|
||||
default "Basic Server"
|
||||
help
|
||||
BACnet device object default model name string
|
||||
config BACNET_BASIC_DEVICE_MODEL_NAME
|
||||
string "BACnet device object default model name string"
|
||||
default "Basic Server"
|
||||
help
|
||||
BACnet device object default model name string
|
||||
|
||||
config BACNET_BASIC_DEVICE_SHELL
|
||||
bool "BACnet Basic Device subsystem shell"
|
||||
depends on BACNETSTACK
|
||||
default y if SHELL
|
||||
config BACNET_BASIC_DEVICE_SHELL
|
||||
bool "BACnet Basic Device subsystem shell"
|
||||
depends on BACNETSTACK
|
||||
default y if SHELL
|
||||
|
||||
endif # BACNETSTACK_BACNET_SETTINGS
|
||||
|
||||
@@ -49,7 +49,7 @@ static void *BACnet_Task_Context;
|
||||
* @param callback [in] The callback function called after initialization
|
||||
* @param context [in] The context to pass to the callback function
|
||||
*/
|
||||
void bacnet_basic_init_callback_set(bacnet_basic_callback callback,
|
||||
void bacnet_basic_init_callback_set(bacnet_basic_callback callback,
|
||||
void *context)
|
||||
{
|
||||
BACnet_Init_Callback = callback;
|
||||
@@ -71,7 +71,7 @@ static void bacnet_init_callback_handler(void)
|
||||
* @param callback [in] The callback function to call during the task
|
||||
* @param context [in] The context to pass to the callback function
|
||||
*/
|
||||
void bacnet_basic_task_callback_set(bacnet_basic_callback callback,
|
||||
void bacnet_basic_task_callback_set(bacnet_basic_callback callback,
|
||||
void *context)
|
||||
{
|
||||
BACnet_Task_Callback = callback;
|
||||
@@ -106,7 +106,7 @@ unsigned long bacnet_basic_packet_count(void)
|
||||
return BACnet_Packet_Count;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Initialize the BACnet device object, the service handlers, and timers
|
||||
*/
|
||||
void bacnet_basic_init(void)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief The BACnet/IPv4 datalink tasks for handling the device specific
|
||||
* @brief The BACnet/IPv4 datalink tasks for handling the device specific
|
||||
* data link layer
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief The BACnet/IPv4 datalink tasks for handling the device specific
|
||||
* @brief The BACnet/IPv4 datalink tasks for handling the device specific
|
||||
* data link layer
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief The BACnet datalink tasks for handling the device specific
|
||||
* @brief The BACnet datalink tasks for handling the device specific
|
||||
* data link layer
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date April 2024
|
||||
@@ -76,7 +76,7 @@ bool bacnet_port_ipv6_init(void)
|
||||
|
||||
if (!bip6_init(NULL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Network_Port_Object_Instance_Number_Set(0, instance);
|
||||
Network_Port_Name_Set(instance, "BACnet/IPv6 Port");
|
||||
Network_Port_Type_Set(instance, PORT_TYPE_BIP6);
|
||||
|
||||
@@ -28,30 +28,30 @@
|
||||
*/
|
||||
static int cmd_objects(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
int count;
|
||||
BACNET_OBJECT_TYPE object_type;
|
||||
uint32_t instance;
|
||||
uint32_t array_index;
|
||||
bool found;
|
||||
int count;
|
||||
BACNET_OBJECT_TYPE object_type;
|
||||
uint32_t instance;
|
||||
uint32_t array_index;
|
||||
bool found;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
shell_print(sh, "List of BACnet Objects: [{");
|
||||
count = Device_Object_List_Count();
|
||||
for (array_index = 1; array_index <= count; array_index++) {
|
||||
found = Device_Object_List_Identifier(array_index, &object_type,
|
||||
&instance);
|
||||
if (found) {
|
||||
shell_print(sh, " \"%s-%u\"%c",
|
||||
bactext_object_type_name(object_type),
|
||||
instance,
|
||||
(array_index == count) ? ' ' : ',');
|
||||
}
|
||||
}
|
||||
shell_print(sh, "}] -- %d objects found", count);
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
shell_print(sh, "List of BACnet Objects: [{");
|
||||
count = Device_Object_List_Count();
|
||||
for (array_index = 1; array_index <= count; array_index++) {
|
||||
found = Device_Object_List_Identifier(array_index, &object_type,
|
||||
&instance);
|
||||
if (found) {
|
||||
shell_print(sh, " \"%s-%u\"%c",
|
||||
bactext_object_type_name(object_type),
|
||||
instance,
|
||||
(array_index == count) ? ' ' : ',');
|
||||
}
|
||||
}
|
||||
shell_print(sh, "}] -- %d objects found", count);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHELL_SUBCMD_ADD((bacnet), objects, NULL, "list of BACnet objects", cmd_objects,
|
||||
1, 0);
|
||||
1, 0);
|
||||
|
||||
@@ -35,4 +35,4 @@ static int cmd_packets(const struct shell *sh, size_t argc, char **argv)
|
||||
}
|
||||
|
||||
SHELL_SUBCMD_ADD((bacnet), packets, NULL, "BACnet task packet stats", cmd_packets,
|
||||
1, 0);
|
||||
1, 0);
|
||||
|
||||
@@ -35,4 +35,4 @@ static int cmd_uptime(const struct shell *sh, size_t argc, char **argv)
|
||||
}
|
||||
|
||||
SHELL_SUBCMD_ADD((bacnet), uptime, NULL, "BACnet task uptime", cmd_uptime,
|
||||
1, 0);
|
||||
1, 0);
|
||||
|
||||
@@ -93,12 +93,12 @@
|
||||
#define BACNET_DEVICE_MODEL_NAME "GNU Basic Server Model 42"
|
||||
#endif
|
||||
|
||||
static object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{ OBJECT_DEVICE, NULL, /* don't init - recursive! */
|
||||
Device_Count, Device_Index_To_Instance,
|
||||
Device_Valid_Object_Instance_Number,
|
||||
Device_Object_Name, Device_Read_Property_Local,
|
||||
Device_Write_Property_Local, Device_Property_Lists,
|
||||
Device_Write_Property_Local, Device_Property_Lists,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */,
|
||||
NULL /* Intrinsic Reporting */, NULL /* Add_List_Element */,
|
||||
@@ -120,7 +120,7 @@ static object_functions_t Object_Table[] = {
|
||||
Analog_Output_Index_To_Instance, Analog_Output_Valid_Instance,
|
||||
Analog_Output_Object_Name, Analog_Output_Read_Property,
|
||||
Analog_Output_Write_Property, Analog_Output_Property_Lists,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
Analog_Output_Encode_Value_List, Analog_Output_Change_Of_Value,
|
||||
Analog_Output_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
|
||||
NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
|
||||
@@ -153,7 +153,7 @@ static object_functions_t Object_Table[] = {
|
||||
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
|
||||
Binary_Output_Object_Name, Binary_Output_Read_Property,
|
||||
Binary_Output_Write_Property, Binary_Output_Property_Lists,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
Binary_Output_Encode_Value_List, Binary_Output_Change_Of_Value,
|
||||
Binary_Output_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
|
||||
NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
|
||||
@@ -164,9 +164,9 @@ static object_functions_t Object_Table[] = {
|
||||
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
|
||||
Binary_Value_Object_Name, Binary_Value_Read_Property,
|
||||
Binary_Value_Write_Property, Binary_Value_Property_Lists,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
Binary_Value_Encode_Value_List, Binary_Value_Change_Of_Value,
|
||||
Binary_Value_Change_Of_Value_Clear,
|
||||
Binary_Value_Change_Of_Value_Clear,
|
||||
NULL /* Intrinsic Reporting */,
|
||||
NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
|
||||
Binary_Value_Create, Binary_Value_Delete, NULL /* Timer */ },
|
||||
@@ -176,7 +176,7 @@ static object_functions_t Object_Table[] = {
|
||||
Multistate_Input_Index_To_Instance, Multistate_Input_Valid_Instance,
|
||||
Multistate_Input_Object_Name, Multistate_Input_Read_Property,
|
||||
Multistate_Input_Write_Property, Multistate_Input_Property_Lists,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
Multistate_Input_Encode_Value_List, Multistate_Input_Change_Of_Value,
|
||||
Multistate_Input_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
|
||||
NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
|
||||
@@ -188,7 +188,7 @@ static object_functions_t Object_Table[] = {
|
||||
Multistate_Output_Valid_Instance, Multistate_Output_Object_Name,
|
||||
Multistate_Output_Read_Property, Multistate_Output_Write_Property,
|
||||
Multistate_Output_Property_Lists, NULL /* ReadRangeInfo */,
|
||||
NULL /* Iterator */,
|
||||
NULL /* Iterator */,
|
||||
Multistate_Output_Encode_Value_List, Multistate_Output_Change_Of_Value,
|
||||
Multistate_Output_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
|
||||
NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
|
||||
@@ -374,9 +374,9 @@ static const int Device_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_DATABASE_REVISION, -1 };
|
||||
|
||||
static const int Device_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_LOCATION,
|
||||
PROP_LOCATION,
|
||||
#if defined(BACDL_MSTP)
|
||||
PROP_MAX_MASTER, PROP_MAX_INFO_FRAMES,
|
||||
PROP_MAX_MASTER, PROP_MAX_INFO_FRAMES,
|
||||
#endif
|
||||
-1 };
|
||||
|
||||
@@ -958,7 +958,7 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_APPLICATION_SOFTWARE_VERSION:
|
||||
characterstring_init_ansi(&char_string,
|
||||
characterstring_init_ansi(&char_string,
|
||||
Application_Software_Version);
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
# @copyright SPDX-License-Identifier: MIT
|
||||
menuconfig BACNETSTACK_BACNET_SETTINGS
|
||||
bool "BACNETSTACK_BACNET_SETTINGS"
|
||||
default y if BACNETSTACK && SETTINGS
|
||||
help
|
||||
default y if BACNETSTACK && SETTINGS
|
||||
help
|
||||
This option enables BACnet Settings services
|
||||
|
||||
if BACNETSTACK_BACNET_SETTINGS
|
||||
@@ -14,15 +14,15 @@ if BACNETSTACK_BACNET_SETTINGS
|
||||
module = BACNETSTACK_BACNET_SETTINGS
|
||||
module-str = bac_settings
|
||||
|
||||
config BACNET_SETTINGS_BASE_NAME
|
||||
string "BACnet object path base name for every setting"
|
||||
default ".bacnet"
|
||||
help
|
||||
BACnet object path base name for every setting"
|
||||
config BACNET_SETTINGS_BASE_NAME
|
||||
string "BACnet object path base name for every setting"
|
||||
default ".bacnet"
|
||||
help
|
||||
BACnet object path base name for every setting"
|
||||
|
||||
config BACNET_SETTINGS_SHELL
|
||||
bool "BACnet settings subsystem shell"
|
||||
depends on BACNETSTACK
|
||||
default y if SHELL && SETTINGS
|
||||
config BACNET_SETTINGS_SHELL
|
||||
bool "BACnet settings subsystem shell"
|
||||
depends on BACNETSTACK
|
||||
default y if SHELL && SETTINGS
|
||||
|
||||
endif # BACNETSTACK_BACNET_SETTINGS
|
||||
|
||||
@@ -27,26 +27,26 @@
|
||||
* @return stored data length on success 0..N, negative on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacapp_decode_application_data(name, stored_len, value);
|
||||
if (len <= 0) {
|
||||
if (value) {
|
||||
value->tag = MAX_BACNET_APPLICATION_TAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacapp_decode_application_data(name, stored_len, value);
|
||||
if (len <= 0) {
|
||||
if (value) {
|
||||
value->tag = MAX_BACNET_APPLICATION_TAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stored_len;
|
||||
return stored_len;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,25 +59,25 @@ int bacnet_settings_value_get(uint16_t object_type, uint32_t object_instance,
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int rc, len;
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int rc, len;
|
||||
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
len = bacapp_encode_application_data(NULL, value);
|
||||
if (len <= 0) {
|
||||
return false;
|
||||
} else if (len > sizeof(name)) {
|
||||
return false;
|
||||
}
|
||||
len = bacapp_encode_application_data(name, value);
|
||||
rc = bacnet_storage_set(&key, name, len);
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
len = bacapp_encode_application_data(NULL, value);
|
||||
if (len <= 0) {
|
||||
return false;
|
||||
} else if (len > sizeof(name)) {
|
||||
return false;
|
||||
}
|
||||
len = bacapp_encode_application_data(name, value);
|
||||
rc = bacnet_storage_set(&key, name, len);
|
||||
|
||||
return rc == 0;
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,26 +90,26 @@ bool bacnet_settings_value_set(uint16_t object_type, uint32_t object_instance,
|
||||
* @return stored data length on success 0..N, negative on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
float default_value, float *value)
|
||||
{
|
||||
int stored_len;
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
int stored_len;
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
|
||||
stored_len =
|
||||
bacnet_settings_value_get(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
if ((stored_len >= 0) && (bvalue.tag == BACNET_APPLICATION_TAG_REAL)) {
|
||||
if (value) {
|
||||
*value = bvalue.type.Real;
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
stored_len =
|
||||
bacnet_settings_value_get(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
if ((stored_len >= 0) && (bvalue.tag == BACNET_APPLICATION_TAG_REAL)) {
|
||||
if (value) {
|
||||
*value = bvalue.type.Real;
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
|
||||
return stored_len;
|
||||
return stored_len;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,17 +122,17 @@ int bacnet_settings_real_get(uint16_t object_type, uint32_t object_instance,
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
bool bacnet_settings_real_set(uint16_t object_type, uint32_t object_instance,
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
float value)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
float value)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_REAL;
|
||||
bvalue.type.Real = value;
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_REAL;
|
||||
bvalue.type.Real = value;
|
||||
|
||||
return bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
return bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,32 +144,32 @@ bool bacnet_settings_real_set(uint16_t object_type, uint32_t object_instance,
|
||||
* @return stored data length on success 0..N, negative on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
BACNET_UNSIGNED_INTEGER default_value,
|
||||
BACNET_UNSIGNED_INTEGER *value)
|
||||
{
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacnet_unsigned_application_decode(name, stored_len,
|
||||
value);
|
||||
if (len <= 0) {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacnet_unsigned_application_decode(name, stored_len,
|
||||
value);
|
||||
if (len <= 0) {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
|
||||
return stored_len;
|
||||
return stored_len;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,18 +181,18 @@ int bacnet_settings_unsigned_get(uint16_t object_type, uint32_t object_instance,
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t object_instance,
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
BACNET_UNSIGNED_INTEGER value)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
|
||||
bvalue.type.Unsigned_Int = value;
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
|
||||
bvalue.type.Unsigned_Int = value;
|
||||
|
||||
return bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
return bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,30 +205,30 @@ bool bacnet_settings_unsigned_set(uint16_t object_type,
|
||||
* @return stored data length on success 0..N, negative on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
int32_t default_value, int32_t *value)
|
||||
{
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacnet_signed_application_decode(name, stored_len, value);
|
||||
if (len <= 0) {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacnet_signed_application_decode(name, stored_len, value);
|
||||
if (len <= 0) {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
*value = default_value;
|
||||
}
|
||||
}
|
||||
|
||||
return stored_len;
|
||||
return stored_len;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,17 +241,17 @@ int bacnet_settings_signed_get(uint16_t object_type, uint32_t object_instance,
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
bool bacnet_settings_signed_set(uint16_t object_type, uint32_t object_instance,
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
int32_t value)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
int32_t value)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_SIGNED_INT;
|
||||
bvalue.type.Signed_Int = value;
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_SIGNED_INT;
|
||||
bvalue.type.Signed_Int = value;
|
||||
|
||||
return bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
return bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index, &bvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,30 +264,30 @@ bool bacnet_settings_signed_set(uint16_t object_type, uint32_t object_instance,
|
||||
* @return stored data length on success 0..N, negative on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t object_instance,
|
||||
uint32_t property_id,
|
||||
uint32_t array_index,
|
||||
const char *default_value,
|
||||
BACNET_CHARACTER_STRING *value)
|
||||
{
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
uint8_t name[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int stored_len, len;
|
||||
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacnet_character_string_application_decode(
|
||||
name, stored_len, value);
|
||||
if (len <= 0) {
|
||||
characterstring_init_ansi(value, default_value);
|
||||
}
|
||||
} else {
|
||||
characterstring_init_ansi(value, default_value);
|
||||
}
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
stored_len = bacnet_storage_get(&key, name, sizeof(name));
|
||||
if (stored_len > 0) {
|
||||
len = bacnet_character_string_application_decode(
|
||||
name, stored_len, value);
|
||||
if (len <= 0) {
|
||||
characterstring_init_ansi(value, default_value);
|
||||
}
|
||||
} else {
|
||||
characterstring_init_ansi(value, default_value);
|
||||
}
|
||||
|
||||
return stored_len;
|
||||
return stored_len;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,25 +300,25 @@ int bacnet_settings_characterstring_get(uint16_t object_type,
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t object_instance,
|
||||
uint32_t property_id,
|
||||
uint32_t array_index,
|
||||
const char *cstring)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
bool status;
|
||||
BACNET_APPLICATION_DATA_VALUE bvalue = { 0 };
|
||||
bool status;
|
||||
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_CHARACTER_STRING;
|
||||
status = characterstring_init_ansi(&bvalue.type.Character_String,
|
||||
cstring);
|
||||
if (!status) {
|
||||
status = bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index,
|
||||
&bvalue);
|
||||
}
|
||||
bvalue.context_specific = false;
|
||||
bvalue.tag = BACNET_APPLICATION_TAG_CHARACTER_STRING;
|
||||
status = characterstring_init_ansi(&bvalue.type.Character_String,
|
||||
cstring);
|
||||
if (!status) {
|
||||
status = bacnet_settings_value_set(object_type, object_instance,
|
||||
property_id, array_index,
|
||||
&bvalue);
|
||||
}
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,24 +332,24 @@ bool bacnet_settings_characterstring_ansi_set(uint16_t object_type,
|
||||
* @return stored data length on success 0..N, negative on failure.
|
||||
*/
|
||||
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)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
const char *default_value, char *value,
|
||||
size_t value_size)
|
||||
{
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int rc;
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int rc;
|
||||
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
rc = bacnet_storage_get(&key, value, value_size);
|
||||
if (rc <= 0) {
|
||||
if (default_value) {
|
||||
strncpy(value, default_value, value_size);
|
||||
rc = strlen(default_value);
|
||||
}
|
||||
}
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
rc = bacnet_storage_get(&key, value, value_size);
|
||||
if (rc <= 0) {
|
||||
if (default_value) {
|
||||
strncpy(value, default_value, value_size);
|
||||
rc = strlen(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,18 +362,18 @@ int bacnet_settings_string_get(uint16_t object_type, uint32_t object_instance,
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
bool bacnet_settings_string_set(uint16_t object_type, uint32_t object_instance,
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
const char *value)
|
||||
uint32_t property_id, uint32_t array_index,
|
||||
const char *value)
|
||||
{
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int rc;
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
int rc;
|
||||
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
rc = bacnet_storage_set(&key, (const char *)value, strlen(value) + 1);
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
bacnet_storage_key_init(&key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
rc = bacnet_storage_set(&key, (const char *)value, strlen(value) + 1);
|
||||
|
||||
return rc == 0;
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
@@ -19,48 +19,48 @@
|
||||
* @return 0 on success, negative on failure
|
||||
*/
|
||||
static int cmd_key(BACNET_STORAGE_KEY *key, const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
char **argv)
|
||||
{
|
||||
uint16_t object_type;
|
||||
uint32_t object_instance;
|
||||
uint32_t property_id = 77;
|
||||
uint32_t array_index = BACNET_STORAGE_ARRAY_INDEX_NONE;
|
||||
long value = 0;
|
||||
uint16_t object_type;
|
||||
uint32_t object_instance;
|
||||
uint32_t property_id = 77;
|
||||
uint32_t array_index = BACNET_STORAGE_ARRAY_INDEX_NONE;
|
||||
long value = 0;
|
||||
|
||||
if (argc < 3) {
|
||||
shell_error(
|
||||
sh,
|
||||
"Usage: %s <object-type> <instance> <property> [value]",
|
||||
argv[0]);
|
||||
return -EINVAL;
|
||||
}
|
||||
value = strtoul(argv[1], NULL, 0);
|
||||
if ((value < 0) || (value >= UINT16_MAX)) {
|
||||
shell_error(sh, "Invalid object-type: %s. Must be 0-65535.",
|
||||
argv[1]);
|
||||
return -EINVAL;
|
||||
}
|
||||
object_type = (uint16_t)value;
|
||||
value = strtoul(argv[2], NULL, 0);
|
||||
if (value > 4194303) {
|
||||
shell_error(sh,
|
||||
"Invalid object-instance: %s. Must be 0-4194303.",
|
||||
argv[2]);
|
||||
return -EINVAL;
|
||||
}
|
||||
object_instance = (uint32_t)value;
|
||||
value = strtoul(argv[3], NULL, 0);
|
||||
if (value > UINT32_MAX) {
|
||||
shell_error(sh, "Invalid property: %s. Must be 0-4294967295.",
|
||||
argv[3]);
|
||||
return -EINVAL;
|
||||
}
|
||||
property_id = (uint32_t)value;
|
||||
/* setup the storage key */
|
||||
bacnet_storage_key_init(key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
if (argc < 3) {
|
||||
shell_error(
|
||||
sh,
|
||||
"Usage: %s <object-type> <instance> <property> [value]",
|
||||
argv[0]);
|
||||
return -EINVAL;
|
||||
}
|
||||
value = strtoul(argv[1], NULL, 0);
|
||||
if ((value < 0) || (value >= UINT16_MAX)) {
|
||||
shell_error(sh, "Invalid object-type: %s. Must be 0-65535.",
|
||||
argv[1]);
|
||||
return -EINVAL;
|
||||
}
|
||||
object_type = (uint16_t)value;
|
||||
value = strtoul(argv[2], NULL, 0);
|
||||
if (value > 4194303) {
|
||||
shell_error(sh,
|
||||
"Invalid object-instance: %s. Must be 0-4194303.",
|
||||
argv[2]);
|
||||
return -EINVAL;
|
||||
}
|
||||
object_instance = (uint32_t)value;
|
||||
value = strtoul(argv[3], NULL, 0);
|
||||
if (value > UINT32_MAX) {
|
||||
shell_error(sh, "Invalid property: %s. Must be 0-4294967295.",
|
||||
argv[3]);
|
||||
return -EINVAL;
|
||||
}
|
||||
property_id = (uint32_t)value;
|
||||
/* setup the storage key */
|
||||
bacnet_storage_key_init(key, object_type, object_instance, property_id,
|
||||
array_index);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,45 +72,45 @@ static int cmd_key(BACNET_STORAGE_KEY *key, const struct shell *sh, size_t argc,
|
||||
*/
|
||||
static int cmd_string(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
char key_name[BACNET_STORAGE_KEY_SIZE_MAX + 1] = { 0 };
|
||||
uint8_t data[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
size_t arg_len = 0;
|
||||
int rc;
|
||||
char key_name[BACNET_STORAGE_KEY_SIZE_MAX + 1] = { 0 };
|
||||
uint8_t data[BACNET_STORAGE_VALUE_SIZE_MAX + 1] = { 0 };
|
||||
BACNET_STORAGE_KEY key = { 0 };
|
||||
size_t arg_len = 0;
|
||||
int rc;
|
||||
|
||||
rc = cmd_key(&key, sh, argc, argv);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
/* convert the key to a string for the shell */
|
||||
(void)bacnet_storage_key_encode(key_name, sizeof(key_name), &key);
|
||||
if (argc > 4) {
|
||||
arg_len = strlen(argv[4]);
|
||||
rc = bacnet_storage_set(&key, argv[4], arg_len);
|
||||
if (rc == 0) {
|
||||
shell_print(sh, "Set %s = %s", key_name, argv[4]);
|
||||
} else {
|
||||
shell_error(sh, "Unable to set %s = %s", key_name,
|
||||
argv[4]);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
rc = bacnet_storage_get(&key, data, sizeof(data));
|
||||
if (rc < 0) {
|
||||
shell_error(sh, "Unable to get %s", key_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
shell_print(sh, "Get %s = %s", key_name, data);
|
||||
}
|
||||
rc = cmd_key(&key, sh, argc, argv);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
/* convert the key to a string for the shell */
|
||||
(void)bacnet_storage_key_encode(key_name, sizeof(key_name), &key);
|
||||
if (argc > 4) {
|
||||
arg_len = strlen(argv[4]);
|
||||
rc = bacnet_storage_set(&key, argv[4], arg_len);
|
||||
if (rc == 0) {
|
||||
shell_print(sh, "Set %s = %s", key_name, argv[4]);
|
||||
} else {
|
||||
shell_error(sh, "Unable to set %s = %s", key_name,
|
||||
argv[4]);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
rc = bacnet_storage_get(&key, data, sizeof(data));
|
||||
if (rc < 0) {
|
||||
shell_error(sh, "Unable to get %s", key_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
shell_print(sh, "Get %s = %s", key_name, data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(sub_bacnet_settings_cmds,
|
||||
SHELL_CMD(string, NULL,
|
||||
"get or set BACnet storage string",
|
||||
cmd_string),
|
||||
SHELL_SUBCMD_SET_END);
|
||||
SHELL_CMD(string, NULL,
|
||||
"get or set BACnet storage string",
|
||||
cmd_string),
|
||||
SHELL_SUBCMD_SET_END);
|
||||
|
||||
SHELL_SUBCMD_ADD((bacnet), settings, &sub_bacnet_settings_cmds,
|
||||
"BACnet settings commands", NULL, 1, 0);
|
||||
"BACnet settings commands", NULL, 1, 0);
|
||||
|
||||
@@ -41,38 +41,38 @@ LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
|
||||
*/
|
||||
void bacnet_storage_init(void)
|
||||
{
|
||||
int rc;
|
||||
int rc;
|
||||
|
||||
#if defined(CONFIG_SETTINGS_FILE) && defined(CONFIG_FILE_SYSTEM_LITTLEFS)
|
||||
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
||||
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
||||
|
||||
/* mounting info */
|
||||
static struct fs_mount_t littlefs_mnt = {
|
||||
.type = FS_LITTLEFS,
|
||||
.fs_data = &cstorage,
|
||||
.storage_dev = (void *)STORAGE_PARTITION_ID,
|
||||
.mnt_point = "/ff"
|
||||
};
|
||||
/* mounting info */
|
||||
static struct fs_mount_t littlefs_mnt = {
|
||||
.type = FS_LITTLEFS,
|
||||
.fs_data = &cstorage,
|
||||
.storage_dev = (void *)STORAGE_PARTITION_ID,
|
||||
.mnt_point = "/ff"
|
||||
};
|
||||
|
||||
rc = fs_mount(&littlefs_mnt);
|
||||
if (rc != 0) {
|
||||
LOG_INF("mounting littlefs error: [%d]", rc);
|
||||
} else {
|
||||
rc = fs_unlink(CONFIG_SETTINGS_FILE_PATH);
|
||||
if ((rc != 0) && (rc != -ENOENT)) {
|
||||
H("can't delete config file%d", rc);
|
||||
} else {
|
||||
LOG_INF("FS initialized: OK");
|
||||
}
|
||||
}
|
||||
rc = fs_mount(&littlefs_mnt);
|
||||
if (rc != 0) {
|
||||
LOG_INF("mounting littlefs error: [%d]", rc);
|
||||
} else {
|
||||
rc = fs_unlink(CONFIG_SETTINGS_FILE_PATH);
|
||||
if ((rc != 0) && (rc != -ENOENT)) {
|
||||
H("can't delete config file%d", rc);
|
||||
} else {
|
||||
LOG_INF("FS initialized: OK");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
rc = settings_subsys_init();
|
||||
if (rc) {
|
||||
LOG_INF("settings subsys initialization: fail (err %d)", rc);
|
||||
return;
|
||||
}
|
||||
rc = settings_subsys_init();
|
||||
if (rc) {
|
||||
LOG_INF("settings subsys initialization: fail (err %d)", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INF("settings subsys initialization: OK.");
|
||||
LOG_INF("settings subsys initialization: OK.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,15 +84,15 @@ void bacnet_storage_init(void)
|
||||
* @param array_index BACnet array index
|
||||
*/
|
||||
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)
|
||||
uint32_t object_instance, uint32_t property_id,
|
||||
uint32_t array_index)
|
||||
{
|
||||
if (key) {
|
||||
key->object_type = object_type;
|
||||
key->object_instance = object_instance;
|
||||
key->property_id = property_id;
|
||||
key->array_index = array_index;
|
||||
}
|
||||
if (key) {
|
||||
key->object_type = object_type;
|
||||
key->object_instance = object_instance;
|
||||
key->property_id = property_id;
|
||||
key->array_index = array_index;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,35 +103,35 @@ void bacnet_storage_key_init(BACNET_STORAGE_KEY *key, uint16_t object_type,
|
||||
* @return length of the string
|
||||
*/
|
||||
int bacnet_storage_key_encode(char *buffer, size_t buffer_size,
|
||||
BACNET_STORAGE_KEY *key)
|
||||
BACNET_STORAGE_KEY *key)
|
||||
{
|
||||
int rc = 0;
|
||||
const char base_name[] = CONFIG_BACNET_STORAGE_BASE_NAME;
|
||||
int rc = 0;
|
||||
const char base_name[] = CONFIG_BACNET_STORAGE_BASE_NAME;
|
||||
|
||||
if (buffer) {
|
||||
memset(buffer, 0, buffer_size);
|
||||
}
|
||||
if (key->array_index == BACNET_STORAGE_ARRAY_INDEX_NONE) {
|
||||
rc = snprintf(buffer, buffer_size, "%s%c%u%c%lu%c%lu",
|
||||
base_name, SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned short)key->object_type,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->object_instance,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->property_id);
|
||||
} else {
|
||||
rc = snprintf(buffer, buffer_size, "%s%c%u%c%lu%c%lu%c%lu",
|
||||
base_name, SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned short)key->object_type,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->object_instance,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->property_id,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->array_index);
|
||||
}
|
||||
if (buffer) {
|
||||
memset(buffer, 0, buffer_size);
|
||||
}
|
||||
if (key->array_index == BACNET_STORAGE_ARRAY_INDEX_NONE) {
|
||||
rc = snprintf(buffer, buffer_size, "%s%c%u%c%lu%c%lu",
|
||||
base_name, SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned short)key->object_type,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->object_instance,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->property_id);
|
||||
} else {
|
||||
rc = snprintf(buffer, buffer_size, "%s%c%u%c%lu%c%lu%c%lu",
|
||||
base_name, SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned short)key->object_type,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->object_instance,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->property_id,
|
||||
SETTINGS_NAME_SEPARATOR,
|
||||
(unsigned long)key->array_index);
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,31 +142,31 @@ int bacnet_storage_key_encode(char *buffer, size_t buffer_size,
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int bacnet_storage_set(BACNET_STORAGE_KEY *key, const void *data,
|
||||
size_t data_len)
|
||||
size_t data_len)
|
||||
{
|
||||
char name[SETTINGS_MAX_NAME_LEN + 1] = { 0 };
|
||||
int rc;
|
||||
char name[SETTINGS_MAX_NAME_LEN + 1] = { 0 };
|
||||
int rc;
|
||||
|
||||
rc = bacnet_storage_key_encode(name, sizeof(name), key);
|
||||
LOG_INF("Set a key-value pair. Key=%s", name);
|
||||
rc = settings_save_one(name, data, data_len);
|
||||
if (rc) {
|
||||
LOG_INF(FAIL_MSG, rc);
|
||||
} else {
|
||||
LOG_HEXDUMP_INF(data, data_len, "value");
|
||||
}
|
||||
rc = bacnet_storage_key_encode(name, sizeof(name), key);
|
||||
LOG_INF("Set a key-value pair. Key=%s", name);
|
||||
rc = settings_save_one(name, data, data_len);
|
||||
if (rc) {
|
||||
LOG_INF(FAIL_MSG, rc);
|
||||
} else {
|
||||
LOG_HEXDUMP_INF(data, data_len, "value");
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Structure to hold immediate values
|
||||
*/
|
||||
struct direct_immediate_value {
|
||||
size_t value_size;
|
||||
size_t value_len;
|
||||
void *value;
|
||||
bool fetched;
|
||||
size_t value_size;
|
||||
size_t value_len;
|
||||
void *value;
|
||||
bool fetched;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -179,33 +179,33 @@ struct direct_immediate_value {
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
static int direct_loader_immediate_value(const char *name, size_t len,
|
||||
settings_read_cb read_cb, void *cb_arg,
|
||||
void *param)
|
||||
settings_read_cb read_cb, void *cb_arg,
|
||||
void *param)
|
||||
{
|
||||
const char *next;
|
||||
size_t name_len;
|
||||
int rc;
|
||||
struct direct_immediate_value *context =
|
||||
(struct direct_immediate_value *)param;
|
||||
const char *next;
|
||||
size_t name_len;
|
||||
int rc;
|
||||
struct direct_immediate_value *context =
|
||||
(struct direct_immediate_value *)param;
|
||||
|
||||
/* only the exact match and ignore descendants of the searched name */
|
||||
name_len = settings_name_next(name, &next);
|
||||
if (name_len == 0) {
|
||||
rc = read_cb(cb_arg, context->value, len);
|
||||
if ((rc >= 0) && (rc <= context->value_size)) {
|
||||
context->fetched = true;
|
||||
context->value_len = rc;
|
||||
LOG_INF("immediate load: OK.");
|
||||
return 0;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
/* only the exact match and ignore descendants of the searched name */
|
||||
name_len = settings_name_next(name, &next);
|
||||
if (name_len == 0) {
|
||||
rc = read_cb(cb_arg, context->value, len);
|
||||
if ((rc >= 0) && (rc <= context->value_size)) {
|
||||
context->fetched = true;
|
||||
context->value_len = rc;
|
||||
LOG_INF("immediate load: OK.");
|
||||
return 0;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* other keys aren't served by the callback
|
||||
* Return success in order to skip them
|
||||
* and keep storage processing.
|
||||
*/
|
||||
return 0;
|
||||
/* other keys aren't served by the callback
|
||||
* Return success in order to skip them
|
||||
* and keep storage processing.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,25 +216,25 @@ static int direct_loader_immediate_value(const char *name, size_t len,
|
||||
* @return value length in bytes on success 0..N, negative on failure.
|
||||
*/
|
||||
static int load_immediate_value(const char *name, void *value,
|
||||
size_t value_size)
|
||||
size_t value_size)
|
||||
{
|
||||
int rc;
|
||||
struct direct_immediate_value context;
|
||||
int rc;
|
||||
struct direct_immediate_value context;
|
||||
|
||||
context.fetched = false;
|
||||
context.value_size = value_size;
|
||||
context.value_len = 0;
|
||||
context.value = value;
|
||||
context.fetched = false;
|
||||
context.value_size = value_size;
|
||||
context.value_len = 0;
|
||||
context.value = value;
|
||||
|
||||
rc = settings_load_subtree_direct(name, direct_loader_immediate_value,
|
||||
(void *)&context);
|
||||
if (rc == 0) {
|
||||
if (!context.fetched) {
|
||||
rc = -ENOENT;
|
||||
}
|
||||
}
|
||||
rc = settings_load_subtree_direct(name, direct_loader_immediate_value,
|
||||
(void *)&context);
|
||||
if (rc == 0) {
|
||||
if (!context.fetched) {
|
||||
rc = -ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
return context.value_len;
|
||||
return context.value_len;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,21 +246,21 @@ static int load_immediate_value(const char *name, void *value,
|
||||
*/
|
||||
int bacnet_storage_get(BACNET_STORAGE_KEY *key, void *data, size_t data_size)
|
||||
{
|
||||
char name[SETTINGS_MAX_NAME_LEN + 1] = { 0 };
|
||||
int rc;
|
||||
char name[SETTINGS_MAX_NAME_LEN + 1] = { 0 };
|
||||
int rc;
|
||||
|
||||
rc = bacnet_storage_key_encode(name, sizeof(name), key);
|
||||
LOG_INF("Get a key-value pair. Key=<%s>", name);
|
||||
rc = load_immediate_value(name, data, data_size);
|
||||
if (rc == 0) {
|
||||
LOG_INF("empty entry");
|
||||
} else if (rc > 0) {
|
||||
LOG_HEXDUMP_INF(data, rc, "value");
|
||||
} else if (rc == -ENOENT) {
|
||||
LOG_INF("no entry");
|
||||
} else {
|
||||
LOG_INF("unexpected" FAIL_MSG, rc);
|
||||
}
|
||||
rc = bacnet_storage_key_encode(name, sizeof(name), key);
|
||||
LOG_INF("Get a key-value pair. Key=<%s>", name);
|
||||
rc = load_immediate_value(name, data, data_size);
|
||||
if (rc == 0) {
|
||||
LOG_INF("empty entry");
|
||||
} else if (rc > 0) {
|
||||
LOG_HEXDUMP_INF(data, rc, "value");
|
||||
} else if (rc == -ENOENT) {
|
||||
LOG_INF("no entry");
|
||||
} else {
|
||||
LOG_INF("unexpected" FAIL_MSG, rc);
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
if BACNETSTACK
|
||||
|
||||
config BACNET_USE_DYNAMIC_DESCRIPTION
|
||||
bool "Use dynalic allocate for objects descriptions"
|
||||
default false
|
||||
help
|
||||
Use dynalic allocate for objects descriptions
|
||||
bool "Use dynalic allocate for objects descriptions"
|
||||
default false
|
||||
help
|
||||
Use dynalic allocate for objects descriptions
|
||||
|
||||
endif # BACNETSTACK
|
||||
|
||||
@@ -15,7 +15,7 @@ void Analog_Input_Init(void)
|
||||
{
|
||||
if (!Object_List) {
|
||||
Object_List = Keylist_Create();
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
/* Set handler for GetEventInformation function */
|
||||
handler_get_event_information_set(
|
||||
|
||||
@@ -15,7 +15,7 @@ void Analog_Value_Init(void)
|
||||
{
|
||||
if (!Object_List) {
|
||||
Object_List = Keylist_Create();
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
/* Set handler for GetEventInformation function */
|
||||
handler_get_event_information_set(
|
||||
|
||||
@@ -8,4 +8,3 @@
|
||||
#include "bacnet/basic/object/bacfile.h"
|
||||
|
||||
OBJECT_FUNCTIONS(Bacfile, BACNET_FILE_LISTING);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ static object_functions Routing_object = {
|
||||
};
|
||||
static bool routing_Device = false;
|
||||
|
||||
/* In Zephyr port the object_functions table is saved in ROM and
|
||||
/* In Zephyr port the object_functions table is saved in ROM and
|
||||
can't change fields value.
|
||||
Instead this Device_Objects_Get_First(Next)_Object() returns the "Routing"
|
||||
object when asked "Device" object, see static filter functions. */
|
||||
@@ -86,7 +86,7 @@ struct object_functions *Device_Objects_Get_Next_Object(
|
||||
{
|
||||
if (object == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
object = Device_Object_Filter_In(object);
|
||||
++object;
|
||||
|
||||
|
||||
@@ -10,4 +10,3 @@
|
||||
#include "bacnet/basic/object/mso.h"
|
||||
|
||||
OBJECT_FUNCTIONS(Multistate_Output, MULTISTATE_OUTPUT_DESCR);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
menuconfig BACNETSTACK_BACNET_SERVER
|
||||
bool "BACNETSTACK_BACNET_SERVER"
|
||||
help
|
||||
help
|
||||
This option enables BACnet Server services
|
||||
|
||||
if BACNETSTACK_BACNET_SERVER
|
||||
@@ -17,19 +17,19 @@ if BACNETSTACK_BACNET_SERVER
|
||||
config BACNETSTACK_BACNET_SERVER_APP_PRIORITY
|
||||
int "App init priority"
|
||||
default 0
|
||||
help
|
||||
help
|
||||
This sets the starting priority of the thread.
|
||||
|
||||
config BACNETSTACK_BACNET_SERVER_PRIO
|
||||
int "BACnet server thread priority"
|
||||
default 50
|
||||
help
|
||||
help
|
||||
This sets the execution priority of the thread.
|
||||
|
||||
config BACNETSTACK_BACNET_SERVER_STACK_SIZE
|
||||
int "BACnet server stack size"
|
||||
default 4096
|
||||
help
|
||||
help
|
||||
This sets the stack size of the thread.
|
||||
|
||||
endif # BACNETSTACK_BACNET_SERVER
|
||||
|
||||
+123
-123
@@ -40,26 +40,26 @@
|
||||
LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
|
||||
|
||||
enum bacnet_server_msg_type {
|
||||
SERVER_MSG_TYPE_INVALID = 0,
|
||||
SERVER_MSG_TYPE_IPV4_EVENT,
|
||||
SERVER_MSG_TYPE_INVALID = 0,
|
||||
SERVER_MSG_TYPE_IPV4_EVENT,
|
||||
};
|
||||
|
||||
struct bacnet_server_msg {
|
||||
uint8_t type;
|
||||
uint8_t dummy[3];
|
||||
uint32_t parm_u32;
|
||||
void *parm_ptr;
|
||||
uint8_t type;
|
||||
uint8_t dummy[3];
|
||||
uint32_t parm_u32;
|
||||
void *parm_ptr;
|
||||
};
|
||||
|
||||
K_MSGQ_DEFINE(bacnet_server_msgq, sizeof(struct bacnet_server_msg), 8,
|
||||
alignof(struct bacnet_server_msg));
|
||||
alignof(struct bacnet_server_msg));
|
||||
|
||||
#define SERVER_IPV4_EVENTS_MASK \
|
||||
(NET_EVENT_IPV4_ADDR_ADD | NET_EVENT_IPV4_ADDR_DEL)
|
||||
(NET_EVENT_IPV4_ADDR_ADD | NET_EVENT_IPV4_ADDR_DEL)
|
||||
|
||||
static struct k_thread server_thread_data;
|
||||
static K_THREAD_STACK_DEFINE(server_thread_stack,
|
||||
CONFIG_BACNETSTACK_BACNET_SERVER_STACK_SIZE);
|
||||
CONFIG_BACNETSTACK_BACNET_SERVER_STACK_SIZE);
|
||||
|
||||
/* Keep a reference to the Ethernet interface */
|
||||
static struct net_mgmt_event_callback mgmt_cb;
|
||||
@@ -74,61 +74,61 @@ static uint8_t BIP_Rx_Buffer[MAX_MPDU];
|
||||
*/
|
||||
static void service_handlers_init(void)
|
||||
{
|
||||
Device_Init(NULL);
|
||||
/* we need to handle who-is to support dynamic device binding */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
|
||||
handler_who_is);
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
|
||||
handler_who_has);
|
||||
/* set the handler for all the services we don't implement */
|
||||
/* It is required to send the proper reject message... */
|
||||
apdu_set_unrecognized_service_handler_handler(
|
||||
handler_unrecognized_service);
|
||||
/* Set the handlers for any confirmed services that we support. */
|
||||
/* We must implement read property - it's required! */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
handler_read_property);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
||||
handler_read_property_multiple);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||
handler_write_property);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE,
|
||||
handler_write_property_multiple);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
||||
handler_reinitialize_device);
|
||||
/* handle communication so we can shutup when asked */
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
handler_device_communication_control);
|
||||
Device_Init(NULL);
|
||||
/* we need to handle who-is to support dynamic device binding */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
|
||||
handler_who_is);
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
|
||||
handler_who_has);
|
||||
/* set the handler for all the services we don't implement */
|
||||
/* It is required to send the proper reject message... */
|
||||
apdu_set_unrecognized_service_handler_handler(
|
||||
handler_unrecognized_service);
|
||||
/* Set the handlers for any confirmed services that we support. */
|
||||
/* We must implement read property - it's required! */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
handler_read_property);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
||||
handler_read_property_multiple);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||
handler_write_property);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE,
|
||||
handler_write_property_multiple);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
||||
handler_reinitialize_device);
|
||||
/* handle communication so we can shutup when asked */
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
handler_device_communication_control);
|
||||
}
|
||||
|
||||
/* TODO: Update copyright as this code pattern copied from
|
||||
* conn_mgr_ipv4_events_handler()
|
||||
*/
|
||||
static void ipv4_events_handler(struct net_mgmt_event_callback *cb,
|
||||
u32_t mgmt_event, struct net_if *iface)
|
||||
u32_t mgmt_event, struct net_if *iface)
|
||||
{
|
||||
static int counter = 0;
|
||||
printk("\n*** Handler[%d]: IPv4 event %08x received on iface %p ***\n",
|
||||
++counter, mgmt_event, iface);
|
||||
static int counter = 0;
|
||||
printk("\n*** Handler[%d]: IPv4 event %08x received on iface %p ***\n",
|
||||
++counter, mgmt_event, iface);
|
||||
|
||||
if ((mgmt_event & SERVER_IPV4_EVENTS_MASK) != mgmt_event) {
|
||||
printk("\n*** Handler[%d]: ignoring event %08x on iface %p ***\n",
|
||||
counter, mgmt_event, iface);
|
||||
return;
|
||||
}
|
||||
if ((mgmt_event & SERVER_IPV4_EVENTS_MASK) != mgmt_event) {
|
||||
printk("\n*** Handler[%d]: ignoring event %08x on iface %p ***\n",
|
||||
counter, mgmt_event, iface);
|
||||
return;
|
||||
}
|
||||
|
||||
struct bacnet_server_msg msg = {
|
||||
.type = SERVER_MSG_TYPE_IPV4_EVENT,
|
||||
.parm_u32 = mgmt_event,
|
||||
.parm_ptr = iface,
|
||||
};
|
||||
struct bacnet_server_msg msg = {
|
||||
.type = SERVER_MSG_TYPE_IPV4_EVENT,
|
||||
.parm_u32 = mgmt_event,
|
||||
.parm_ptr = iface,
|
||||
};
|
||||
|
||||
int ret = k_msgq_put(&bacnet_server_msgq, &msg, K_NO_WAIT);
|
||||
if (ret != 0) {
|
||||
printk("\n*** Handler[%d]: queue full, type %u event 0x%08x on iface %p dropped! ***\n",
|
||||
counter, msg.type, msg.parm_u32, msg.parm_ptr);
|
||||
}
|
||||
int ret = k_msgq_put(&bacnet_server_msgq, &msg, K_NO_WAIT);
|
||||
if (ret != 0) {
|
||||
printk("\n*** Handler[%d]: queue full, type %u event 0x%08x on iface %p dropped! ***\n",
|
||||
counter, msg.type, msg.parm_u32, msg.parm_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,59 +136,59 @@ static void ipv4_events_handler(struct net_mgmt_event_callback *cb,
|
||||
*/
|
||||
static void server_thread(void)
|
||||
{
|
||||
LOG_INF("Server: started");
|
||||
service_handlers_init();
|
||||
LOG_INF("Server: started");
|
||||
service_handlers_init();
|
||||
|
||||
bip_init("Server: from init");
|
||||
BIP_Net = 1;
|
||||
bip_init("Server: from init");
|
||||
BIP_Net = 1;
|
||||
|
||||
net_mgmt_init_event_callback(&mgmt_cb, ipv4_events_handler,
|
||||
SERVER_IPV4_EVENTS_MASK);
|
||||
net_mgmt_add_event_callback(&mgmt_cb);
|
||||
net_mgmt_init_event_callback(&mgmt_cb, ipv4_events_handler,
|
||||
SERVER_IPV4_EVENTS_MASK);
|
||||
net_mgmt_add_event_callback(&mgmt_cb);
|
||||
|
||||
while (1) {
|
||||
const s32_t sleep_ms = K_FOREVER;
|
||||
while (1) {
|
||||
const s32_t sleep_ms = K_FOREVER;
|
||||
|
||||
struct bacnet_server_msg msg = {
|
||||
.type = SERVER_MSG_TYPE_INVALID,
|
||||
};
|
||||
int ret = k_msgq_get(&bacnet_server_msgq, &msg, sleep_ms);
|
||||
struct bacnet_server_msg msg = {
|
||||
.type = SERVER_MSG_TYPE_INVALID,
|
||||
};
|
||||
int ret = k_msgq_get(&bacnet_server_msgq, &msg, sleep_ms);
|
||||
|
||||
/* Waiting period timed out */
|
||||
if (-EAGAIN == ret) {
|
||||
BACNET_ADDRESS src = {
|
||||
0
|
||||
}; /* address where message came from */
|
||||
/* input */
|
||||
/* returns 0 bytes on timeout */
|
||||
uint16_t pdu_len = bip_receive(&src, &BIP_Rx_Buffer[0],
|
||||
MAX_MPDU, 5);
|
||||
/* Waiting period timed out */
|
||||
if (-EAGAIN == ret) {
|
||||
BACNET_ADDRESS src = {
|
||||
0
|
||||
}; /* address where message came from */
|
||||
/* input */
|
||||
/* returns 0 bytes on timeout */
|
||||
uint16_t pdu_len = bip_receive(&src, &BIP_Rx_Buffer[0],
|
||||
MAX_MPDU, 5);
|
||||
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
LOG_INF("Server: BIP received %u bytes.",
|
||||
(unsigned)pdu_len);
|
||||
}
|
||||
}
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
LOG_INF("Server: BIP received %u bytes.",
|
||||
(unsigned)pdu_len);
|
||||
}
|
||||
}
|
||||
|
||||
/* Message received */
|
||||
else if (0 == ret) {
|
||||
switch (msg.type) {
|
||||
/* Message received */
|
||||
else if (0 == ret) {
|
||||
switch (msg.type) {
|
||||
#if defined(CONFIG_NET_IPV4)
|
||||
case SERVER_MSG_TYPE_IPV4_EVENT: {
|
||||
LOG_INF("Server: MSG_TYPE_IPV4_EVENT u32: %08x ptr: %p",
|
||||
msg.parm_u32, msg.parm_ptr);
|
||||
const u32_t mgmt_event = msg.parm_u32;
|
||||
//TODO: const struct net_if *iface = msg.parm_ptr;
|
||||
case SERVER_MSG_TYPE_IPV4_EVENT: {
|
||||
LOG_INF("Server: MSG_TYPE_IPV4_EVENT u32: %08x ptr: %p",
|
||||
msg.parm_u32, msg.parm_ptr);
|
||||
const u32_t mgmt_event = msg.parm_u32;
|
||||
//TODO: const struct net_if *iface = msg.parm_ptr;
|
||||
|
||||
/* Handle events */
|
||||
if ((mgmt_event & SERVER_IPV4_EVENTS_MASK) !=
|
||||
mgmt_event) {
|
||||
LOG_INF("Server: thread ignoring event");
|
||||
break;
|
||||
}
|
||||
/* Handle events */
|
||||
if ((mgmt_event & SERVER_IPV4_EVENTS_MASK) !=
|
||||
mgmt_event) {
|
||||
LOG_INF("Server: thread ignoring event");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (NET_MGMT_GET_COMMAND(mgmt_event)) {
|
||||
switch (NET_MGMT_GET_COMMAND(mgmt_event)) {
|
||||
#if 0
|
||||
case NET_EVENT_IPV4_CMD_ADDR_ADD:
|
||||
LOG_INF("Server: IPv4 addr activated");
|
||||
@@ -201,42 +201,42 @@ static void server_thread(void)
|
||||
BIP_Net = 0;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
LOG_INF("Server: Unsupported event %u",
|
||||
mgmt_event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_INF("Server: Unsupported event %u",
|
||||
mgmt_event);
|
||||
break;
|
||||
}
|
||||
|
||||
} break;
|
||||
} break;
|
||||
#endif /* defined(CONFIG_NET_IPV4) */
|
||||
|
||||
default:
|
||||
LOG_WRN("Server: Dropping unsupported type %u",
|
||||
msg.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
LOG_WRN("Server: Dropping unsupported type %u",
|
||||
msg.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returned without waiting and without message - why? */
|
||||
else {
|
||||
LOG_WRN("Server: Msgq returned w/o timeout or msg! req = %d",
|
||||
ret);
|
||||
}
|
||||
}
|
||||
/* Returned without waiting and without message - why? */
|
||||
else {
|
||||
LOG_WRN("Server: Msgq returned w/o timeout or msg! req = %d",
|
||||
ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int server_init(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
k_thread_create(&server_thread_data, server_thread_stack,
|
||||
K_THREAD_STACK_SIZEOF(server_thread_stack),
|
||||
(k_thread_entry_t)server_thread, NULL, NULL, NULL,
|
||||
K_PRIO_PREEMPT(CONFIG_BACNETSTACK_BACNET_SERVER_PRIO), 0,
|
||||
K_NO_WAIT);
|
||||
k_thread_name_set(&server_thread_data, "BACserver");
|
||||
k_thread_create(&server_thread_data, server_thread_stack,
|
||||
K_THREAD_STACK_SIZEOF(server_thread_stack),
|
||||
(k_thread_entry_t)server_thread, NULL, NULL, NULL,
|
||||
K_PRIO_PREEMPT(CONFIG_BACNETSTACK_BACNET_SERVER_PRIO), 0,
|
||||
K_NO_WAIT);
|
||||
k_thread_name_set(&server_thread_data, "BACserver");
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(server_init, APPLICATION, CONFIG_BACNETSTACK_BACNET_SERVER_APP_PRIORITY);
|
||||
|
||||
@@ -75,7 +75,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -73,7 +73,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -74,7 +74,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -73,7 +73,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -73,7 +73,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -73,7 +73,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -70,7 +70,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -72,8 +72,8 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
${BACNET_TEST_PATH}/src/main.c
|
||||
|
||||
@@ -73,7 +73,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -73,7 +73,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -72,7 +72,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -71,7 +71,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -74,7 +74,7 @@ else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(${BACNET_NAME})
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
target_include_directories(app PRIVATE
|
||||
${BACNET_INCLUDE}
|
||||
${TEST_OBJECT_INCLUDE})
|
||||
target_sources(app PRIVATE
|
||||
|
||||
@@ -34,8 +34,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/bacstr.c
|
||||
${BACNET_SRC}/bacint.c
|
||||
${BACNET_SRC}/bacreal.c
|
||||
${BACNET_SRC}/bactext.c
|
||||
${BACNET_SRC}/indtext.c
|
||||
${BACNET_SRC}/bactext.c
|
||||
${BACNET_SRC}/indtext.c
|
||||
${BACNET_SRC}/datetime.c
|
||||
${BACNET_SRC}/timestamp.c
|
||||
${BACNET_SRC}/basic/sys/days.c
|
||||
|
||||
@@ -29,4 +29,3 @@ target_include_directories(testbinary PRIVATE
|
||||
CONFIG_ZTEST_NEW_API
|
||||
BACNET_STACK_DEPRECATED_DISABLE
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user