Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -108,7 +108,8 @@ static void bacnet_data_object_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void bacnet_data_object_store(int index,
|
||||
static void bacnet_data_object_store(
|
||||
int index,
|
||||
const BACNET_READ_PROPERTY_DATA *rp_data,
|
||||
const BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
@@ -149,7 +150,8 @@ static void bacnet_data_object_store(int index,
|
||||
* @param value [in] pointer to the BACNET_APPLICATION_DATA_VALUE structure
|
||||
* which is packed with the decoded value from the ReadProperty request.
|
||||
*/
|
||||
void bacnet_data_value_save(uint32_t device_instance,
|
||||
void bacnet_data_value_save(
|
||||
uint32_t device_instance,
|
||||
BACNET_READ_PROPERTY_DATA *rp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
@@ -172,8 +174,9 @@ void bacnet_data_value_save(uint32_t device_instance,
|
||||
case OBJECT_MULTI_STATE_INPUT:
|
||||
case OBJECT_MULTI_STATE_OUTPUT:
|
||||
case OBJECT_MULTI_STATE_VALUE:
|
||||
index = bacnet_data_object_index_find(device_instance,
|
||||
rp_data->object_type, rp_data->object_instance);
|
||||
index = bacnet_data_object_index_find(
|
||||
device_instance, rp_data->object_type,
|
||||
rp_data->object_instance);
|
||||
if (index != BACNET_STATUS_ERROR) {
|
||||
bacnet_data_object_store(index, rp_data, value);
|
||||
}
|
||||
@@ -193,9 +196,9 @@ static void bacnet_data_object_process(const BACNET_DATA_OBJECT *object)
|
||||
{
|
||||
if (object && (object->Device_ID < BACNET_MAX_INSTANCE) &&
|
||||
(object->Object_ID < BACNET_MAX_INSTANCE)) {
|
||||
bacnet_read_property_queue(object->Device_ID,
|
||||
(BACNET_OBJECT_TYPE)object->Object_Type, object->Object_ID,
|
||||
PROP_PRESENT_VALUE, BACNET_ARRAY_ALL);
|
||||
bacnet_read_property_queue(
|
||||
object->Device_ID, (BACNET_OBJECT_TYPE)object->Object_Type,
|
||||
object->Object_ID, PROP_PRESENT_VALUE, BACNET_ARRAY_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +209,8 @@ static void bacnet_data_object_process(const BACNET_DATA_OBJECT *object)
|
||||
* @param object_instance - Instance # of the object to be read.
|
||||
* @return true if added or existing, false if not added or existing
|
||||
*/
|
||||
bool bacnet_data_object_add(uint32_t device_id,
|
||||
bool bacnet_data_object_add(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance)
|
||||
{
|
||||
@@ -258,7 +262,8 @@ bool bacnet_data_object_add(uint32_t device_id,
|
||||
* @param float_value [out] property value stored if available
|
||||
* @return true if found and value loaded
|
||||
*/
|
||||
bool bacnet_data_analog_present_value(uint32_t device_id,
|
||||
bool bacnet_data_analog_present_value(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
float *float_value)
|
||||
@@ -291,7 +296,8 @@ bool bacnet_data_analog_present_value(uint32_t device_id,
|
||||
* @param bool_value [out] property value stored if available
|
||||
* @return true if found and value loaded
|
||||
*/
|
||||
bool bacnet_data_binary_present_value(uint32_t device_id,
|
||||
bool bacnet_data_binary_present_value(
|
||||
uint32_t device_id,
|
||||
uint16_t object_type,
|
||||
uint32_t object_instance,
|
||||
bool *bool_value)
|
||||
@@ -329,7 +335,8 @@ bool bacnet_data_binary_present_value(uint32_t device_id,
|
||||
* @param bool_value [out] property value stored if available
|
||||
* @return true if found and value loaded
|
||||
*/
|
||||
bool bacnet_data_multistate_present_value(uint32_t device_id,
|
||||
bool bacnet_data_multistate_present_value(
|
||||
uint32_t device_id,
|
||||
uint16_t object_type,
|
||||
uint32_t object_instance,
|
||||
uint32_t *unsigned_value)
|
||||
|
||||
@@ -35,25 +35,30 @@ void bacnet_data_poll_seconds_set(unsigned int seconds);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned int bacnet_data_poll_seconds(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void bacnet_data_value_save(uint32_t device_instance,
|
||||
void bacnet_data_value_save(
|
||||
uint32_t device_instance,
|
||||
BACNET_READ_PROPERTY_DATA *rp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_data_object_add(uint32_t device_id,
|
||||
bool bacnet_data_object_add(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_data_analog_present_value(uint32_t device_id,
|
||||
bool bacnet_data_analog_present_value(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
float *float_value);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_data_multistate_present_value(uint32_t device_id,
|
||||
bool bacnet_data_multistate_present_value(
|
||||
uint32_t device_id,
|
||||
uint16_t object_type,
|
||||
uint32_t object_instance,
|
||||
uint32_t *unsigned_value);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_data_binary_present_value(uint32_t device_id,
|
||||
bool bacnet_data_binary_present_value(
|
||||
uint32_t device_id,
|
||||
uint16_t object_type,
|
||||
uint32_t object_instance,
|
||||
bool *bool_value);
|
||||
|
||||
@@ -224,8 +224,8 @@ static BACNET_DEVICE_DATA *bacnet_device_data_add(uint32_t device_instance)
|
||||
* @param device_id - BACnet device instance
|
||||
* @return Pointer to the device data structure
|
||||
*/
|
||||
static BACNET_DEVICE_DATA *bacnet_device_data(
|
||||
OS_Keylist list, uint32_t device_id)
|
||||
static BACNET_DEVICE_DATA *
|
||||
bacnet_device_data(OS_Keylist list, uint32_t device_id)
|
||||
{
|
||||
KEY key = device_id;
|
||||
BACNET_DEVICE_DATA *device_data;
|
||||
@@ -395,7 +395,8 @@ unsigned long bacnet_discover_device_elapsed_milliseconds(uint32_t device_id)
|
||||
* @param value property value stored if available (see tag for type)
|
||||
* @return true if found and value loaded
|
||||
*/
|
||||
bool bacnet_discover_property_value(uint32_t device_id,
|
||||
bool bacnet_discover_property_value(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -420,10 +421,10 @@ bool bacnet_discover_property_value(uint32_t device_id,
|
||||
property = Keylist_Data(object->Property_List, key);
|
||||
if (property) {
|
||||
if (property->application_data_len > 0) {
|
||||
len =
|
||||
bacapp_decode_known_property(property->application_data,
|
||||
property->application_data_len, value, object_type,
|
||||
object_property);
|
||||
len = bacapp_decode_known_property(
|
||||
property->application_data,
|
||||
property->application_data_len, value, object_type,
|
||||
object_property);
|
||||
if (len > 0) {
|
||||
status = true;
|
||||
}
|
||||
@@ -449,7 +450,8 @@ bool bacnet_discover_property_value(uint32_t device_id,
|
||||
* @param default_string [in] String to use if the property is not found.
|
||||
* @return true if found and value copied, else false and default_string copied.
|
||||
*/
|
||||
bool bacnet_discover_property_name(uint32_t device_id,
|
||||
bool bacnet_discover_property_name(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -465,8 +467,8 @@ bool bacnet_discover_property_name(uint32_t device_id,
|
||||
device_id, object_type, object_instance, object_property, &value);
|
||||
if (status && value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||
if (characterstring_valid(&value.type.Character_String)) {
|
||||
strncpy(buffer,
|
||||
characterstring_value(&value.type.Character_String),
|
||||
strncpy(
|
||||
buffer, characterstring_value(&value.type.Character_String),
|
||||
buffer_len - 1);
|
||||
} else {
|
||||
status = false;
|
||||
@@ -487,7 +489,8 @@ bool bacnet_discover_property_name(uint32_t device_id,
|
||||
* @param object_instance - Instance number of the object to be read.
|
||||
* @return number of object properties
|
||||
*/
|
||||
unsigned int bacnet_discover_object_property_count(uint32_t device_id,
|
||||
unsigned int bacnet_discover_object_property_count(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance)
|
||||
{
|
||||
@@ -517,7 +520,8 @@ unsigned int bacnet_discover_object_property_count(uint32_t device_id,
|
||||
* @param property_id - property identifier if object exists
|
||||
* @return true if an object property ID was found at this index
|
||||
*/
|
||||
bool bacnet_discover_object_property_identifier(uint32_t device_id,
|
||||
bool bacnet_discover_object_property_identifier(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
unsigned index,
|
||||
@@ -554,7 +558,8 @@ bool bacnet_discover_object_property_identifier(uint32_t device_id,
|
||||
* which is packed with the decoded value from the ReadProperty request.
|
||||
* @param device_data [in] Pointer to the device data structure
|
||||
*/
|
||||
static void bacnet_device_object_property_add(uint32_t device_id,
|
||||
static void bacnet_device_object_property_add(
|
||||
uint32_t device_id,
|
||||
const BACNET_READ_PROPERTY_DATA *rp_data,
|
||||
const BACNET_APPLICATION_DATA_VALUE *value,
|
||||
BACNET_DEVICE_DATA *device_data)
|
||||
@@ -578,9 +583,11 @@ static void bacnet_device_object_property_add(uint32_t device_id,
|
||||
}
|
||||
} else if (value->tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
if (rp_data->array_index <= device_data->Object_List_Size) {
|
||||
object_data = bacnet_object_data_add(device_data->Object_List,
|
||||
value->type.Object_Id.type, value->type.Object_Id.instance);
|
||||
debug_printf("add %u object-list[%u] %s-%lu %s.\n", device_id,
|
||||
object_data = bacnet_object_data_add(
|
||||
device_data->Object_List, value->type.Object_Id.type,
|
||||
value->type.Object_Id.instance);
|
||||
debug_printf(
|
||||
"add %u object-list[%u] %s-%lu %s.\n", device_id,
|
||||
device_data->Object_List_Index,
|
||||
bactext_object_type_name(value->type.Object_Id.type),
|
||||
(unsigned long)value->type.Object_Id.instance,
|
||||
@@ -599,10 +606,12 @@ static void bacnet_device_object_property_add(uint32_t device_id,
|
||||
device_data->Discovery_State =
|
||||
BACNET_DISCOVER_STATE_OBJECT_GET_PROPERTY_RESPONSE;
|
||||
}
|
||||
object_data = bacnet_object_data_add(device_data->Object_List,
|
||||
rp_data->object_type, rp_data->object_instance);
|
||||
object_data = bacnet_object_data_add(
|
||||
device_data->Object_List, rp_data->object_type,
|
||||
rp_data->object_instance);
|
||||
if (!object_data) {
|
||||
debug_perror("%s-%u object fail to add!\n",
|
||||
debug_perror(
|
||||
"%s-%u object fail to add!\n",
|
||||
bactext_object_type_name(rp_data->object_type),
|
||||
rp_data->object_instance);
|
||||
return;
|
||||
@@ -610,7 +619,8 @@ static void bacnet_device_object_property_add(uint32_t device_id,
|
||||
property_data = bacnet_property_data_add(
|
||||
object_data->Property_List, rp_data->object_property);
|
||||
if (!property_data) {
|
||||
debug_perror("%s-%u %s property fail to add!\n",
|
||||
debug_perror(
|
||||
"%s-%u %s property fail to add!\n",
|
||||
bactext_object_type_name(rp_data->object_type),
|
||||
rp_data->object_instance,
|
||||
bactext_property_name(rp_data->object_property));
|
||||
@@ -626,10 +636,12 @@ static void bacnet_device_object_property_add(uint32_t device_id,
|
||||
if (property_data->application_data) {
|
||||
property_data->application_data_len =
|
||||
rp_data->application_data_len;
|
||||
memcpy(property_data->application_data,
|
||||
rp_data->application_data, rp_data->application_data_len);
|
||||
memcpy(
|
||||
property_data->application_data, rp_data->application_data,
|
||||
rp_data->application_data_len);
|
||||
} else {
|
||||
debug_perror("%s-%u %s property fail to allocate!\n",
|
||||
debug_perror(
|
||||
"%s-%u %s property fail to allocate!\n",
|
||||
bactext_object_type_name(rp_data->object_type),
|
||||
rp_data->object_instance,
|
||||
bactext_property_name(rp_data->object_property));
|
||||
@@ -640,17 +652,20 @@ static void bacnet_device_object_property_add(uint32_t device_id,
|
||||
property_data->application_data_len = 0;
|
||||
}
|
||||
if (rp_data->array_index == BACNET_ARRAY_ALL) {
|
||||
debug_printf("%u object-list[%d] %s-%lu %s added.\n", device_id,
|
||||
bacnet_object_list_index(device_data->Object_List,
|
||||
rp_data->object_type, rp_data->object_instance),
|
||||
debug_printf(
|
||||
"%u object-list[%d] %s-%lu %s added.\n", device_id,
|
||||
bacnet_object_list_index(
|
||||
device_data->Object_List, rp_data->object_type,
|
||||
rp_data->object_instance),
|
||||
bactext_object_type_name(rp_data->object_type),
|
||||
(unsigned long)rp_data->object_instance,
|
||||
bactext_property_name(rp_data->object_property));
|
||||
} else {
|
||||
debug_printf("%u object-list[%d] %s-%lu %s[%lu] added.\n",
|
||||
device_id,
|
||||
bacnet_object_list_index(device_data->Object_List,
|
||||
rp_data->object_type, rp_data->object_instance),
|
||||
debug_printf(
|
||||
"%u object-list[%d] %s-%lu %s[%lu] added.\n", device_id,
|
||||
bacnet_object_list_index(
|
||||
device_data->Object_List, rp_data->object_type,
|
||||
rp_data->object_instance),
|
||||
bactext_object_type_name(rp_data->object_type),
|
||||
(unsigned long)rp_data->object_instance,
|
||||
bactext_property_name(rp_data->object_property),
|
||||
@@ -664,7 +679,8 @@ static void bacnet_device_object_property_add(uint32_t device_id,
|
||||
* @param device_id - device instance number where data originated
|
||||
* @param error_code - BACnet Error code
|
||||
*/
|
||||
static void Device_Error_Handler(uint32_t device_id,
|
||||
static void Device_Error_Handler(
|
||||
uint32_t device_id,
|
||||
BACNET_ERROR_CODE error_code,
|
||||
BACNET_DEVICE_DATA *device_data)
|
||||
{
|
||||
@@ -702,7 +718,8 @@ static void Device_Error_Handler(uint32_t device_id,
|
||||
* @param value [in] pointer to the BACNET_APPLICATION_DATA_VALUE structure
|
||||
* which is packed with the decoded value from the ReadProperty request.
|
||||
*/
|
||||
static void bacnet_read_property_reply(uint32_t device_id,
|
||||
static void bacnet_read_property_reply(
|
||||
uint32_t device_id,
|
||||
BACNET_READ_PROPERTY_DATA *rp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
@@ -728,8 +745,8 @@ static void bacnet_read_property_reply(uint32_t device_id,
|
||||
* @param device_id - Device ID from discovered device
|
||||
* @param device_data - Pointer to the device data structure
|
||||
*/
|
||||
static void bacnet_discover_device_fsm(
|
||||
uint32_t device_id, BACNET_DEVICE_DATA *device_data)
|
||||
static void
|
||||
bacnet_discover_device_fsm(uint32_t device_id, BACNET_DEVICE_DATA *device_data)
|
||||
{
|
||||
KEY key = 0;
|
||||
BACNET_OBJECT_TYPE object_type = 0;
|
||||
@@ -765,19 +782,21 @@ static void bacnet_discover_device_fsm(
|
||||
device_data->Object_List_Index++;
|
||||
if (device_data->Object_List_Index <=
|
||||
device_data->Object_List_Size) {
|
||||
debug_printf("%u object-list[%u] size=%u.\n", device_id,
|
||||
debug_printf(
|
||||
"%u object-list[%u] size=%u.\n", device_id,
|
||||
device_data->Object_List_Index,
|
||||
device_data->Object_List_Size);
|
||||
status = bacnet_read_property_queue(device_id, OBJECT_DEVICE,
|
||||
device_id, PROP_OBJECT_LIST,
|
||||
status = bacnet_read_property_queue(
|
||||
device_id, OBJECT_DEVICE, device_id, PROP_OBJECT_LIST,
|
||||
device_data->Object_List_Index);
|
||||
if (status) {
|
||||
device_data->Discovery_State =
|
||||
BACNET_DISCOVER_STATE_OBJECT_LIST_REQUEST;
|
||||
return;
|
||||
} else {
|
||||
debug_perror("%u object-list[%u] %s-%u fail to queue!\n",
|
||||
device_id, device_data->Object_List_Index,
|
||||
debug_perror(
|
||||
"%u object-list[%u] %s-%u fail to queue!\n", device_id,
|
||||
device_data->Object_List_Index,
|
||||
bactext_object_type_name(object_type),
|
||||
(unsigned)object_instance);
|
||||
device_data->Object_List_Index--;
|
||||
@@ -794,24 +813,28 @@ static void bacnet_discover_device_fsm(
|
||||
case BACNET_DISCOVER_STATE_OBJECT_GET_PROPERTY_RESPONSE:
|
||||
if (device_data->Object_List_Index <
|
||||
device_data->Object_List_Size) {
|
||||
if (Keylist_Index_Key(device_data->Object_List,
|
||||
if (Keylist_Index_Key(
|
||||
device_data->Object_List,
|
||||
device_data->Object_List_Index, &key)) {
|
||||
object_type = KEY_DECODE_TYPE(key);
|
||||
object_instance = KEY_DECODE_ID(key);
|
||||
debug_printf("%u object-list[%u] %s-%u read ALL.\n",
|
||||
device_id, device_data->Object_List_Index,
|
||||
debug_printf(
|
||||
"%u object-list[%u] %s-%u read ALL.\n", device_id,
|
||||
device_data->Object_List_Index,
|
||||
bactext_object_type_name(object_type),
|
||||
(unsigned)object_instance);
|
||||
status = bacnet_read_property_queue(device_id, object_type,
|
||||
object_instance, PROP_ALL, BACNET_ARRAY_ALL);
|
||||
status = bacnet_read_property_queue(
|
||||
device_id, object_type, object_instance, PROP_ALL,
|
||||
BACNET_ARRAY_ALL);
|
||||
}
|
||||
if (status) {
|
||||
device_data->Discovery_State =
|
||||
BACNET_DISCOVER_STATE_OBJECT_GET_PROPERTY_REQUEST;
|
||||
device_data->Object_List_Index++;
|
||||
} else {
|
||||
debug_perror("%u object-list[%u] %s-%u fail to queue!\n",
|
||||
device_id, device_data->Object_List_Index,
|
||||
debug_perror(
|
||||
"%u object-list[%u] %s-%u fail to queue!\n", device_id,
|
||||
device_data->Object_List_Index,
|
||||
bactext_object_type_name(object_type),
|
||||
(unsigned)object_instance);
|
||||
}
|
||||
@@ -833,7 +856,8 @@ static void bacnet_discover_device_fsm(
|
||||
}
|
||||
break;
|
||||
default:
|
||||
debug_perror("%u unknown state %u!\n", device_id,
|
||||
debug_perror(
|
||||
"%u unknown state %u!\n", device_id,
|
||||
device_data->Discovery_State);
|
||||
break;
|
||||
}
|
||||
@@ -873,7 +897,8 @@ static void bacnet_discover_devices_task(void)
|
||||
* @param context - pointer to user data
|
||||
* @return true if the iteration completed, false if it stopped early
|
||||
*/
|
||||
bool bacnet_discover_device_object_property_iterate(uint32_t device_id,
|
||||
bool bacnet_discover_device_object_property_iterate(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
bacnet_discover_device_callback callback,
|
||||
@@ -918,8 +943,9 @@ bool bacnet_discover_device_object_property_iterate(uint32_t device_id,
|
||||
rp_data.error_code = ERROR_CODE_SUCCESS;
|
||||
rp_data.application_data = property->application_data;
|
||||
rp_data.application_data_len = property->application_data_len;
|
||||
status = callback(device_id, device_index, object_index,
|
||||
property_index, &rp_data, context);
|
||||
status = callback(
|
||||
device_id, device_index, object_index, property_index, &rp_data,
|
||||
context);
|
||||
/* callback returns true if the iteration
|
||||
should continue, false if it should stop */
|
||||
if (!status) {
|
||||
@@ -930,8 +956,9 @@ bool bacnet_discover_device_object_property_iterate(uint32_t device_id,
|
||||
rp_data.application_data_len = 0;
|
||||
rp_data.error_class = ERROR_CLASS_PROPERTY;
|
||||
rp_data.error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||
status = callback(device_id, device_index, object_index,
|
||||
property_index, &rp_data, context);
|
||||
status = callback(
|
||||
device_id, device_index, object_index, property_index, &rp_data,
|
||||
context);
|
||||
/* callback returns true if the iteration
|
||||
should continue, false if it should stop */
|
||||
if (!status) {
|
||||
@@ -1118,7 +1145,8 @@ unsigned long bacnet_discover_read_process_milliseconds(void)
|
||||
* @param segmentation [in] segmentation flag
|
||||
* @param vendor_id [in] vendor identifier
|
||||
*/
|
||||
void bacnet_discover_device_add(uint32_t device_instance,
|
||||
void bacnet_discover_device_add(
|
||||
uint32_t device_instance,
|
||||
unsigned max_apdu,
|
||||
int segmentation,
|
||||
uint16_t vendor_id)
|
||||
@@ -1128,7 +1156,8 @@ void bacnet_discover_device_add(uint32_t device_instance,
|
||||
(void)max_apdu;
|
||||
(void)segmentation;
|
||||
device_data = bacnet_device_data_add(device_instance);
|
||||
debug_printf("device[%d] %lu - vendor=%u %s.\n",
|
||||
debug_printf(
|
||||
"device[%d] %lu - vendor=%u %s.\n",
|
||||
Keylist_Index(Device_List, device_instance), device_instance, vendor_id,
|
||||
device_data ? "success" : "fail");
|
||||
}
|
||||
|
||||
@@ -18,19 +18,22 @@
|
||||
/**
|
||||
* @brief Callback function for iterating the results of the device discovery.
|
||||
* @param device_id [in] The device ID of the data
|
||||
* @param device_index [in] The index of the device in the list of discovered devices
|
||||
* @param object_index [in] The index of the object in the list of discovered objects in the device
|
||||
* @param property_index [in] The index of the property in the list of discovered properties in the object in the device
|
||||
* @param device_index [in] The index of the device in the list of discovered
|
||||
* devices
|
||||
* @param object_index [in] The index of the object in the list of discovered
|
||||
* objects in the device
|
||||
* @param property_index [in] The index of the property in the list of
|
||||
* discovered properties in the object in the device
|
||||
* @param rp_data [in] The contents of the device object property
|
||||
* @param context_data [in] The context data passed to the discover function
|
||||
* @return true if the iteration should continue, false if it should stop
|
||||
*/
|
||||
typedef bool (*bacnet_discover_device_callback) (
|
||||
*/
|
||||
typedef bool (*bacnet_discover_device_callback)(
|
||||
uint32_t device_id,
|
||||
unsigned device_index,
|
||||
unsigned object_index,
|
||||
unsigned property_index,
|
||||
BACNET_READ_PROPERTY_DATA * rp_data,
|
||||
BACNET_READ_PROPERTY_DATA *rp_data,
|
||||
void *context_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -47,14 +50,12 @@ uint32_t bacnet_discover_device_instance(unsigned index);
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_discover_device_object_count(uint32_t device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_discover_device_object_identifier(uint32_t device_id,
|
||||
unsigned index, BACNET_OBJECT_ID *object_id);
|
||||
bool bacnet_discover_device_object_identifier(
|
||||
uint32_t device_id, unsigned index, BACNET_OBJECT_ID *object_id);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned long bacnet_discover_device_elapsed_milliseconds(
|
||||
uint32_t device_id);
|
||||
unsigned long bacnet_discover_device_elapsed_milliseconds(uint32_t device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
size_t bacnet_discover_device_memory(
|
||||
uint32_t device_id);
|
||||
size_t bacnet_discover_device_memory(uint32_t device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned int bacnet_discover_object_property_count(
|
||||
uint32_t device_id,
|
||||
@@ -68,13 +69,15 @@ bool bacnet_discover_object_property_identifier(
|
||||
unsigned index,
|
||||
uint32_t *property_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_discover_property_value(uint32_t device_id,
|
||||
bool bacnet_discover_property_value(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
BACNET_APPLICATION_DATA_VALUE *value);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_discover_property_name(uint32_t device_id,
|
||||
bool bacnet_discover_property_name(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -87,11 +90,13 @@ bool bacnet_discover_device_object_property_iterate(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
bacnet_discover_device_callback callback, void *context);
|
||||
bacnet_discover_device_callback callback,
|
||||
void *context);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_discover_device_object_iterate(
|
||||
uint32_t device_id,
|
||||
bacnet_discover_device_callback callback, void *context);
|
||||
bacnet_discover_device_callback callback,
|
||||
void *context);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_discover_device_iterate(
|
||||
bacnet_discover_device_callback callback, void *context);
|
||||
|
||||
@@ -89,7 +89,8 @@ static BACNET_CLIENT_STATE RW_State = BACNET_CLIENT_IDLE;
|
||||
* @param error_class [in] the error class
|
||||
* @param error_code [in] the error code
|
||||
*/
|
||||
static void MyErrorHandler(BACNET_ADDRESS *src,
|
||||
static void MyErrorHandler(
|
||||
BACNET_ADDRESS *src,
|
||||
uint8_t invoke_id,
|
||||
BACNET_ERROR_CLASS error_class,
|
||||
BACNET_ERROR_CODE error_code)
|
||||
@@ -127,8 +128,8 @@ static void MyAbortHandler(
|
||||
* @param invoke_id [in] the invokeID from the rejected message
|
||||
* @param reject_reason [in] the reason for the rejection
|
||||
*/
|
||||
static void MyRejectHandler(
|
||||
BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
|
||||
static void
|
||||
MyRejectHandler(BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
@@ -187,8 +188,8 @@ static void My_I_Am_Bind(
|
||||
* @param src [in] BACNET_ADDRESS of the source of the message
|
||||
* @param invoke_id [in] the invokeID from the rejected message
|
||||
*/
|
||||
static void MyWritePropertySimpleAckHandler(
|
||||
BACNET_ADDRESS *src, uint8_t invoke_id)
|
||||
static void
|
||||
MyWritePropertySimpleAckHandler(BACNET_ADDRESS *src, uint8_t invoke_id)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
@@ -219,8 +220,9 @@ static void bacnet_read_property_ack_process(
|
||||
apdu_len = rp_data->application_data_len;
|
||||
while (apdu_len) {
|
||||
value = &Target_Decoded_Property_Value;
|
||||
len = bacapp_decode_known_property(apdu, (unsigned)apdu_len, value,
|
||||
rp_data->object_type, rp_data->object_property);
|
||||
len = bacapp_decode_known_property(
|
||||
apdu, (unsigned)apdu_len, value, rp_data->object_type,
|
||||
rp_data->object_property);
|
||||
if (len > 0) {
|
||||
if ((len < apdu_len) &&
|
||||
(rp_data->array_index == BACNET_ARRAY_ALL)) {
|
||||
@@ -268,7 +270,8 @@ static void bacnet_read_property_ack_process(
|
||||
* @param service_data [in] The BACNET_CONFIRMED_SERVICE_DATA information
|
||||
* decoded from the APDU header of this message.
|
||||
*/
|
||||
static void My_Read_Property_Ack_Handler(uint8_t *service_request,
|
||||
static void My_Read_Property_Ack_Handler(
|
||||
uint8_t *service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
|
||||
@@ -303,7 +306,8 @@ static void My_Read_Property_Ack_Handler(uint8_t *service_request,
|
||||
* @param service_data [in] The BACNET_CONFIRMED_SERVICE_DATA information
|
||||
* decoded from the APDU header of this message.
|
||||
*/
|
||||
static void My_Read_Property_Multiple_Ack_Handler(uint8_t *apdu,
|
||||
static void My_Read_Property_Multiple_Ack_Handler(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
|
||||
@@ -315,8 +319,8 @@ static void My_Read_Property_Multiple_Ack_Handler(uint8_t *apdu,
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(service_data->invoke_id == Request_Invoke_ID)) {
|
||||
rp_data.error_code = ERROR_CODE_SUCCESS;
|
||||
rpm_ack_object_property_process(apdu, apdu_len,
|
||||
device_id, &rp_data,
|
||||
rpm_ack_object_property_process(
|
||||
apdu, apdu_len, device_id, &rp_data,
|
||||
bacnet_read_property_ack_process);
|
||||
}
|
||||
}
|
||||
@@ -328,7 +332,8 @@ static void My_Read_Property_Multiple_Ack_Handler(uint8_t *apdu,
|
||||
* @param object_instance [in] The contents of the service request.
|
||||
* @return invoke_id of request
|
||||
*/
|
||||
static uint8_t Send_RPM_All_Request(uint32_t device_id,
|
||||
static uint8_t Send_RPM_All_Request(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance)
|
||||
{
|
||||
@@ -450,13 +455,14 @@ static bool bacnet_read_write_process(const TARGET_DATA *target)
|
||||
}
|
||||
} else {
|
||||
if (target->object_property == PROP_ALL) {
|
||||
Request_Invoke_ID = Send_RPM_All_Request(target->device_id,
|
||||
target->object_type, target->object_instance);
|
||||
Request_Invoke_ID = Send_RPM_All_Request(
|
||||
target->device_id, target->object_type,
|
||||
target->object_instance);
|
||||
} else {
|
||||
Request_Invoke_ID =
|
||||
Send_Read_Property_Request(target->device_id,
|
||||
target->object_type, target->object_instance,
|
||||
target->object_property, target->array_index);
|
||||
Request_Invoke_ID = Send_Read_Property_Request(
|
||||
target->device_id, target->object_type,
|
||||
target->object_instance, target->object_property,
|
||||
target->array_index);
|
||||
}
|
||||
}
|
||||
if (Request_Invoke_ID == 0) {
|
||||
@@ -564,7 +570,8 @@ void bacnet_read_write_task(void)
|
||||
* - BACNET_ARRAY_ALL (~0) for the full array to be read.
|
||||
* @return true if added, false if not added
|
||||
*/
|
||||
bool bacnet_read_property_queue(uint32_t device_id,
|
||||
bool bacnet_read_property_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -599,7 +606,8 @@ bool bacnet_read_property_queue(uint32_t device_id,
|
||||
* - BACNET_ARRAY_ALL (~0) for the full array to be read.
|
||||
* @return true if added, false if not added
|
||||
*/
|
||||
bool bacnet_write_property_real_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_real_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -639,7 +647,8 @@ bool bacnet_write_property_real_queue(uint32_t device_id,
|
||||
* - BACNET_ARRAY_ALL (~0) for the full array to be read.
|
||||
* @return true if added, false if not added
|
||||
*/
|
||||
bool bacnet_write_property_null_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_null_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -677,7 +686,8 @@ bool bacnet_write_property_null_queue(uint32_t device_id,
|
||||
* - BACNET_ARRAY_ALL (~0) for the full array to be read.
|
||||
* @return true if added, false if not added
|
||||
*/
|
||||
bool bacnet_write_property_enumerated_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_enumerated_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -717,7 +727,8 @@ bool bacnet_write_property_enumerated_queue(uint32_t device_id,
|
||||
* - BACNET_ARRAY_ALL (~0) for the full array to be read.
|
||||
* @return true if added, false if not added
|
||||
*/
|
||||
bool bacnet_write_property_unsigned_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_unsigned_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -757,7 +768,8 @@ bool bacnet_write_property_unsigned_queue(uint32_t device_id,
|
||||
* - BACNET_ARRAY_ALL (~0) for the full array to be read.
|
||||
* @return true if added, false if not added
|
||||
*/
|
||||
bool bacnet_write_property_signed_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_signed_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -797,7 +809,8 @@ bool bacnet_write_property_signed_queue(uint32_t device_id,
|
||||
* - BACNET_ARRAY_ALL (~0) for the full array to be read.
|
||||
* @return true if added, false if not added
|
||||
*/
|
||||
bool bacnet_write_property_boolean_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_boolean_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -865,14 +878,16 @@ uint16_t bacnet_read_write_vendor_id_filter(void)
|
||||
*/
|
||||
void bacnet_read_write_init(void)
|
||||
{
|
||||
Ringbuf_Init(&Target_Data_Queue, (uint8_t *)&Target_Data_Buffer,
|
||||
Ringbuf_Init(
|
||||
&Target_Data_Queue, (uint8_t *)&Target_Data_Buffer,
|
||||
TARGET_DATA_QUEUE_SIZE, TARGET_DATA_QUEUE_COUNT);
|
||||
/* handle i-am to support binding to other devices */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, My_I_Am_Bind);
|
||||
/* handle the data coming back from confirmed requests */
|
||||
apdu_set_confirmed_ack_handler(
|
||||
SERVICE_CONFIRMED_READ_PROPERTY, My_Read_Property_Ack_Handler);
|
||||
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
||||
apdu_set_confirmed_ack_handler(
|
||||
SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
||||
My_Read_Property_Multiple_Ack_Handler);
|
||||
/* handle the Simple ACK coming back */
|
||||
apdu_set_confirmed_simple_ack_handler(
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
* @param value [in] pointer to the BACNET_APPLICATION_DATA_VALUE structure
|
||||
* which is packed with the decoded value from the ReadProperty request.
|
||||
*/
|
||||
typedef void (*bacnet_read_write_value_callback_t)(uint32_t device_instance,
|
||||
typedef void (*bacnet_read_write_value_callback_t)(
|
||||
uint32_t device_instance,
|
||||
BACNET_READ_PROPERTY_DATA *rp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value);
|
||||
|
||||
@@ -35,7 +36,8 @@ typedef void (*bacnet_read_write_value_callback_t)(uint32_t device_instance,
|
||||
* @param segmentation [in] segmentation flag
|
||||
* @param vendor_id [in] vendor identifier
|
||||
*/
|
||||
typedef void (*bacnet_read_write_device_callback_t)(uint32_t device_instance,
|
||||
typedef void (*bacnet_read_write_device_callback_t)(
|
||||
uint32_t device_instance,
|
||||
unsigned max_apdu,
|
||||
int segmentation,
|
||||
uint16_t vendor_id);
|
||||
@@ -53,13 +55,15 @@ bool bacnet_read_write_idle(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_read_write_busy(void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_read_property_queue(uint32_t device_id,
|
||||
bool bacnet_read_property_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
uint32_t array_index);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_write_property_real_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_real_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -67,14 +71,16 @@ bool bacnet_write_property_real_queue(uint32_t device_id,
|
||||
uint8_t priority,
|
||||
uint32_t array_index);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_write_property_null_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_null_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
uint8_t priority,
|
||||
uint32_t array_index);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_write_property_enumerated_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_enumerated_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -82,7 +88,8 @@ bool bacnet_write_property_enumerated_queue(uint32_t device_id,
|
||||
uint8_t priority,
|
||||
uint32_t array_index);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_write_property_unsigned_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_unsigned_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -90,7 +97,8 @@ bool bacnet_write_property_unsigned_queue(uint32_t device_id,
|
||||
uint8_t priority,
|
||||
uint32_t array_index);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_write_property_signed_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_signed_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -98,7 +106,8 @@ bool bacnet_write_property_signed_queue(uint32_t device_id,
|
||||
uint8_t priority,
|
||||
uint32_t array_index);
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_write_property_boolean_queue(uint32_t device_id,
|
||||
bool bacnet_write_property_boolean_queue(
|
||||
uint32_t device_id,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
|
||||
@@ -100,7 +100,8 @@ void bacnet_task_init(void)
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_READ_PROP_MULTIPLE, handler_read_property_multiple);
|
||||
/* handle communication so we can shutup when asked */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
handler_device_communication_control);
|
||||
bacnet_data_init();
|
||||
mstimer_set(&BACnet_Task_Timer, 1000);
|
||||
|
||||
Reference in New Issue
Block a user