make pretty
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# Ignore formatting change commits when determining blame
|
||||
# git config --global blame.ignoreRevsFile .git-blame-ignore-revs
|
||||
# Mark any lines that have had a commit skipped using --ignore-rev with a `?`
|
||||
# git config --global blame.markIgnoredLines true
|
||||
# Mark any lines that were added in a skipped commit and can not be attributed with a `*`
|
||||
# git config --global blame.markUnblamableLines true
|
||||
|
||||
# make pretty - apps/ and src/
|
||||
|
||||
+9
-15
@@ -153,8 +153,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_confirmed_simple_ack_handler(
|
||||
SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM, MyWritePropertySimpleAckHandler);
|
||||
/* handle any errors coming back */
|
||||
apdu_set_error_handler(
|
||||
SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM, MyErrorHandler);
|
||||
apdu_set_error_handler(SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM, MyErrorHandler);
|
||||
apdu_set_abort_handler(MyAbortHandler);
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
@@ -294,8 +293,8 @@ int main(int argc, char *argv[])
|
||||
data.eventObjectIdentifier.type = object_type;
|
||||
target_args++;
|
||||
} else {
|
||||
fprintf(stderr, "event-object-type=%s invalid\n",
|
||||
argv[argi]);
|
||||
fprintf(
|
||||
stderr, "event-object-type=%s invalid\n", argv[argi]);
|
||||
return 1;
|
||||
}
|
||||
} else if (target_args == 3) {
|
||||
@@ -305,13 +304,11 @@ int main(int argc, char *argv[])
|
||||
target_args++;
|
||||
} else if (target_args == 4) {
|
||||
/* event-state-acked */
|
||||
if (bactext_event_state_strtol(argv[argi],
|
||||
&object_type)) {
|
||||
if (bactext_event_state_strtol(argv[argi], &object_type)) {
|
||||
data.eventStateAcked = object_type;
|
||||
target_args++;
|
||||
} else {
|
||||
fprintf(stderr, "event-state=%s invalid\n",
|
||||
argv[argi]);
|
||||
fprintf(stderr, "event-state=%s invalid\n", argv[argi]);
|
||||
return 1;
|
||||
}
|
||||
} else if (target_args == 5) {
|
||||
@@ -397,7 +394,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
@@ -405,12 +402,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (found) {
|
||||
if (Request_Invoke_ID == 0) {
|
||||
Request_Invoke_ID =
|
||||
Send_Alarm_Acknowledgement_Address(
|
||||
Handler_Transmit_Buffer,
|
||||
sizeof(Handler_Transmit_Buffer),
|
||||
&data,
|
||||
&Target_Address);
|
||||
Request_Invoke_ID = Send_Alarm_Acknowledgement_Address(
|
||||
Handler_Transmit_Buffer, sizeof(Handler_Transmit_Buffer),
|
||||
&data, &Target_Address);
|
||||
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||
break;
|
||||
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
|
||||
+26
-26
@@ -220,7 +220,7 @@ static void MyAbortHandler(
|
||||
(ERROR_CODE_ABORT_BUFFER_OVERFLOW - 1) + abort_reason;
|
||||
} else {
|
||||
Last_Error_Code = ERROR_CODE_ABORT_OTHER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ static void MyRejectHandler(
|
||||
(ERROR_CODE_REJECT_BUFFER_OVERFLOW - 1) + reject_reason;
|
||||
} else {
|
||||
Last_Error_Code = ERROR_CODE_REJECT_OTHER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ static void MyReadPropertyAckHandler(uint8_t *service_request,
|
||||
} else {
|
||||
if (len < 0) { /* Eg, failed due to no segmentation */
|
||||
Error_Detected = true;
|
||||
}
|
||||
}
|
||||
free(rp_data);
|
||||
}
|
||||
}
|
||||
@@ -428,7 +428,7 @@ static void CheckIsWritableProperty(BACNET_OBJECT_TYPE object_type,
|
||||
*/
|
||||
if (bIsWritable) {
|
||||
fprintf(stdout, " Writable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char *protocol_services_supported_text(size_t bit_index)
|
||||
@@ -506,7 +506,7 @@ static bool PrettyPrintPropertyValue(
|
||||
}
|
||||
} else { /* not supported */
|
||||
fprintf(stream, ",");
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stream, "\n ");
|
||||
}
|
||||
@@ -527,7 +527,7 @@ static bool PrettyPrintPropertyValue(
|
||||
status = bacapp_print_value(stdout, object_value);
|
||||
} else {
|
||||
fprintf(stream, "? \n");
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -586,7 +586,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
}
|
||||
if (object_type == OBJECT_DATETIME_VALUE) {
|
||||
break; /* A special case - no braces for this pair */
|
||||
}
|
||||
}
|
||||
/* Else, fall through to normal processing. */
|
||||
default:
|
||||
/* Normal array: open brace */
|
||||
@@ -598,7 +598,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
|
||||
if (!Using_Walked_List) {
|
||||
Walked_List_Index = Walked_List_Length = 0; /* In case we need this. */
|
||||
}
|
||||
}
|
||||
/* value(s) loop until there is no "next" ... */
|
||||
while (value != NULL) {
|
||||
object_value.object_property = rpm_property->propertyIdentifier;
|
||||
@@ -620,12 +620,12 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
if (rpm_property->propertyIdentifier ==
|
||||
PROP_OBJECT_LIST) {
|
||||
Object_List_Length = value->type.Unsigned_Int;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
assert(Walked_List_Index ==
|
||||
(uint32_t)rpm_property->propertyArrayIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Walked_List_Index++;
|
||||
/* If we got the whole Object List array in one RP call,
|
||||
@@ -633,7 +633,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
* through. */
|
||||
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
|
||||
Object_List_Length = ++Object_List_Index;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Walked_List_Index == 1) {
|
||||
/* If the array is empty (nothing for this first entry),
|
||||
@@ -651,7 +651,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
fprintf(stdout, "{ \n ");
|
||||
} else {
|
||||
fprintf(stdout, "\n ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
|
||||
@@ -701,11 +701,11 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
* braces */
|
||||
if (isSequence) {
|
||||
fprintf(stdout, "{");
|
||||
}
|
||||
}
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
if (isSequence) {
|
||||
fprintf(stdout, "}");
|
||||
}
|
||||
}
|
||||
|
||||
if ((Walked_List_Index < Walked_List_Length) ||
|
||||
(value->next != NULL)) {
|
||||
@@ -713,7 +713,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
fprintf(stdout, ", ");
|
||||
if (!(Walked_List_Index % 3)) {
|
||||
fprintf(stdout, "\n ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stdout, " } \n");
|
||||
}
|
||||
@@ -1091,10 +1091,10 @@ static int CheckCommandLineArgs(int argc, char *argv[])
|
||||
if (Target_Address.mac_len == 0) {
|
||||
fprintf(
|
||||
stderr, "Must provide a Target MAC before DNET \n");
|
||||
}
|
||||
}
|
||||
if (++i < argc) {
|
||||
Target_Address.net = (uint16_t)strtol(argv[i], NULL, 0);
|
||||
}
|
||||
}
|
||||
/* Used strtol so dest.net can be either 0x1234 or 4660 */
|
||||
break;
|
||||
case 't':
|
||||
@@ -1231,7 +1231,7 @@ static void PrintHeading(void)
|
||||
for (i = 0; i < len; i++) {
|
||||
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i)) {
|
||||
printf(" %s\n", protocol_services_supported_text(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf("-- use \'Initiate\' or \'Execute\' or both for services.\n");
|
||||
@@ -1279,7 +1279,7 @@ static void PrintHeading(void)
|
||||
for (i = 0; i < len; i++) {
|
||||
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i)) {
|
||||
printf(" %s\n", bactext_object_type_name(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf("-- possible objects in this device\n");
|
||||
@@ -1501,7 +1501,7 @@ int main(int argc, char *argv[])
|
||||
/* Update by adding the MAC address */
|
||||
if (max_apdu == 0) {
|
||||
max_apdu = MAX_APDU; /* Whatever set for this datalink. */
|
||||
}
|
||||
}
|
||||
address_add_binding(
|
||||
Target_Device_Object_Instance, max_apdu, &Target_Address);
|
||||
}
|
||||
@@ -1598,7 +1598,7 @@ int main(int argc, char *argv[])
|
||||
myState = GET_LIST_OF_ALL_RESPONSE;
|
||||
} else {
|
||||
myState = GET_ALL_RESPONSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1655,7 +1655,7 @@ int main(int argc, char *argv[])
|
||||
myState = GET_ALL_REQUEST; /* Let's try again */
|
||||
} else {
|
||||
myState = GET_PROPERTY_REQUEST;
|
||||
}
|
||||
}
|
||||
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
||||
fprintf(stderr, "\rError: TSM Timeout!\n");
|
||||
tsm_free_invoke_id(Request_Invoke_ID);
|
||||
@@ -1666,7 +1666,7 @@ int main(int argc, char *argv[])
|
||||
/* just press ahead without the data */
|
||||
} else {
|
||||
myState = GET_ALL_REQUEST; /* Let's try again */
|
||||
}
|
||||
}
|
||||
} else if (Error_Detected) {
|
||||
/* Don't think we'll ever actually reach this point. */
|
||||
elapsed_seconds = 0;
|
||||
@@ -1676,7 +1676,7 @@ int main(int argc, char *argv[])
|
||||
/* just press ahead without the data */
|
||||
} else {
|
||||
myState = NEXT_OBJECT;
|
||||
}/* Give up and move on to the
|
||||
} /* Give up and move on to the
|
||||
next. */
|
||||
Error_Count++;
|
||||
}
|
||||
@@ -1696,7 +1696,7 @@ int main(int argc, char *argv[])
|
||||
myState = NEXT_OBJECT; /* Move on to the next. */
|
||||
} else {
|
||||
myState = GET_PROPERTY_RESPONSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_PROPERTY_RESPONSE:
|
||||
@@ -1813,7 +1813,7 @@ int main(int argc, char *argv[])
|
||||
/* Don't re-list the Device Object among its objects */
|
||||
if (myObject.type == OBJECT_DEVICE) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* Closing brace for the previous Object */
|
||||
printf(" }, \n");
|
||||
/* Opening brace for the new Object */
|
||||
|
||||
+16
-13
@@ -481,7 +481,8 @@ int main(int argc, char *argv[])
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_OUT_OF_RANGE) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_CHANGE_OF_LIFE_SAFETY) {
|
||||
} else if (event_data.eventType ==
|
||||
EVENT_CHANGE_OF_LIFE_SAFETY) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_EXTENDED) {
|
||||
/* FIXME: add event type parameters */
|
||||
@@ -495,17 +496,22 @@ int main(int argc, char *argv[])
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_SIGNED_OUT_OF_RANGE) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_UNSIGNED_OUT_OF_RANGE) {
|
||||
} else if (event_data.eventType ==
|
||||
EVENT_UNSIGNED_OUT_OF_RANGE) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_CHANGE_OF_CHARACTERSTRING) {
|
||||
} else if (event_data.eventType ==
|
||||
EVENT_CHANGE_OF_CHARACTERSTRING) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_CHANGE_OF_STATUS_FLAGS) {
|
||||
} else if (event_data.eventType ==
|
||||
EVENT_CHANGE_OF_STATUS_FLAGS) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_CHANGE_OF_RELIABILITY) {
|
||||
} else if (event_data.eventType ==
|
||||
EVENT_CHANGE_OF_RELIABILITY) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_NONE) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_CHANGE_OF_DISCRETE_VALUE) {
|
||||
} else if (event_data.eventType ==
|
||||
EVENT_CHANGE_OF_DISCRETE_VALUE) {
|
||||
/* FIXME: add event type parameters */
|
||||
} else if (event_data.eventType == EVENT_CHANGE_OF_TIMER) {
|
||||
/* FIXME: add event type parameters */
|
||||
@@ -587,7 +593,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
@@ -595,12 +601,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (found) {
|
||||
if (Request_Invoke_ID == 0) {
|
||||
Request_Invoke_ID =
|
||||
Send_CEvent_Notify_Address(
|
||||
Handler_Transmit_Buffer,
|
||||
sizeof(Handler_Transmit_Buffer),
|
||||
&event_data,
|
||||
&Target_Address);
|
||||
Request_Invoke_ID = Send_CEvent_Notify_Address(
|
||||
Handler_Transmit_Buffer, sizeof(Handler_Transmit_Buffer),
|
||||
&event_data, &Target_Address);
|
||||
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||
break;
|
||||
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ static void Initialize_Device_Addresses(void)
|
||||
{
|
||||
int i = 0; /* First entry is Gateway Device */
|
||||
uint32_t virtual_mac = 0;
|
||||
BACNET_ADDRESS virtual_address = {0};
|
||||
BACNET_ADDRESS virtual_address = { 0 };
|
||||
DEVICE_OBJECT_DATA *pDev = NULL;
|
||||
/* Setup info for the main gateway device first */
|
||||
pDev = Get_Routed_Device_Object(i);
|
||||
|
||||
@@ -127,7 +127,7 @@ static void My_Get_Event_Ack_Handler(uint8_t *service_request,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA data[MAX_OBJ_IDS_IN_GE_ACK];
|
||||
for (i = 0; i < MAX_OBJ_IDS_IN_GE_ACK - 1; i++) {
|
||||
data[i].next = &data[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
printf("Recieved Ack. Saved invoke ID was %i, service returned %i\n",
|
||||
Request_Invoke_ID, service_data->invoke_id);
|
||||
@@ -143,7 +143,7 @@ static void My_Get_Event_Ack_Handler(uint8_t *service_request,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA *lastData = &(data[0]);
|
||||
while (lastData->next) {
|
||||
lastData = lastData->next;
|
||||
}
|
||||
}
|
||||
LastReceivedObjectIdentifier = lastData->objectIdentifier;
|
||||
}
|
||||
}
|
||||
@@ -287,6 +287,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
|
||||
+3
-3
@@ -538,9 +538,9 @@ static void filename_create(char *filename)
|
||||
|
||||
if (filename) {
|
||||
datetime_local(&bdate, &btime, NULL, NULL);
|
||||
sprintf(filename, "mstp_%04d%02d%02d%02d%02d%02d.cap",
|
||||
(int)bdate.year, (int)bdate.month, (int)bdate.day,
|
||||
(int)btime.hour, (int)btime.min, (int)btime.sec);
|
||||
sprintf(filename, "mstp_%04d%02d%02d%02d%02d%02d.cap", (int)bdate.year,
|
||||
(int)bdate.month, (int)bdate.day, (int)btime.hour, (int)btime.min,
|
||||
(int)btime.sec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ static void My_Router_Handler(BACNET_ADDRESS *src,
|
||||
that are sent with a local unicast address. */
|
||||
if (npdu_len >= 2) {
|
||||
len += decode_unsigned16(npdu, &dnet);
|
||||
printf(": network number = %u. SNET=%u\n",
|
||||
(unsigned)dnet, (unsigned)src->net);
|
||||
printf(": network number = %u. SNET=%u\n", (unsigned)dnet,
|
||||
(unsigned)src->net);
|
||||
} else {
|
||||
printf(": network number = missing! SNET=%u\n", src->net);
|
||||
}
|
||||
@@ -251,7 +251,8 @@ int main(int argc, char *argv[])
|
||||
time_t timeout_seconds = 0;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("Usage: %s DNET status [MAC]\r\n", filename_remove_path(argv[0]));
|
||||
printf(
|
||||
"Usage: %s DNET status [MAC]\r\n", filename_remove_path(argv[0]));
|
||||
return 0;
|
||||
}
|
||||
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||
@@ -307,8 +308,7 @@ int main(int argc, char *argv[])
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds = apdu_timeout() / 1000;
|
||||
/* send the request */
|
||||
Send_Network_Number_Is(
|
||||
&Target_Router_Address, Target_Network_Number,
|
||||
Send_Network_Number_Is(&Target_Router_Address, Target_Network_Number,
|
||||
Target_Network_Number_Status);
|
||||
/* loop forever */
|
||||
for (;;) {
|
||||
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
|
||||
+27
-25
@@ -378,7 +378,7 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
|
||||
Device_Inc_Database_Revision();
|
||||
} else {
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -984,9 +984,11 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
/* Array element zero is the number of objects in the list */
|
||||
if (rpdata->array_index == 0) {
|
||||
apdu_len = encode_application_unsigned(&apdu[0], count);
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* if no index was specified, then try to encode the entire list
|
||||
*/
|
||||
/* into one packet. Note that more than likely you will have */
|
||||
/* to return an error if the number of encoded objects exceeds */
|
||||
/* to return an error if the number of encoded objects exceeds
|
||||
*/
|
||||
/* your maximum APDU size. */
|
||||
} else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
for (i = 1; i <= count; i++) {
|
||||
@@ -1135,8 +1137,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(
|
||||
@@ -1151,32 +1153,32 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
apdu_retries_set((uint8_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_APDU_TIMEOUT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
apdu_timeout_set((uint16_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_VENDOR_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_Vendor_Identifier((uint16_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
temp = Device_Set_System_Status(
|
||||
(BACNET_DEVICE_STATUS)value.type.Enumerated, false);
|
||||
@@ -1193,8 +1195,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_string_valid(wp_data, &value,
|
||||
characterstring_capacity(&My_Object_Name));
|
||||
status = write_property_string_valid(
|
||||
wp_data, &value, characterstring_capacity(&My_Object_Name));
|
||||
if (status) {
|
||||
/* All the object names in a device must be unique */
|
||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||
@@ -1214,8 +1216,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_LOCATION:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_LOC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_LOC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Location(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1224,8 +1226,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_DESC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_DESC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Description(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1233,8 +1235,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_MODEL_NAME:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_MOD_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_MOD_LEN);
|
||||
if (status) {
|
||||
Device_Set_Model_Name(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1244,8 +1246,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
case PROP_MAX_INFO_FRAMES:
|
||||
#if defined(BACDL_MSTP)
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
dlmstp_set_max_info_frames(
|
||||
@@ -1260,8 +1262,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
#endif
|
||||
case PROP_MAX_MASTER:
|
||||
#if defined(BACDL_MSTP)
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if ((value.type.Unsigned_Int > 0) &&
|
||||
(value.type.Unsigned_Int <= 127)) {
|
||||
|
||||
@@ -62,7 +62,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
||||
iLen += tag_len;
|
||||
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
|
||||
Response.cMyByte1 = (char)ulTemp;
|
||||
@@ -72,7 +72,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
||||
iLen += tag_len;
|
||||
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
|
||||
Response.cMyByte2 = (char)ulTemp;
|
||||
@@ -82,7 +82,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
||||
iLen += tag_len;
|
||||
if (tag_number != BACNET_APPLICATION_TAG_REAL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
iLen += decode_real(&pData[iLen], &Response.fMyReal);
|
||||
|
||||
@@ -91,7 +91,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
||||
iLen += tag_len;
|
||||
if (tag_number != BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
||||
strncpy(
|
||||
|
||||
@@ -100,11 +100,10 @@ static void MyErrorHandler(BACNET_ADDRESS *src,
|
||||
}
|
||||
|
||||
/* complex error reply function */
|
||||
static void MyPrivateTransferErrorHandler(
|
||||
BACNET_ADDRESS * src,
|
||||
static void MyPrivateTransferErrorHandler(BACNET_ADDRESS *src,
|
||||
uint8_t invoke_id,
|
||||
uint8_t service_choice,
|
||||
uint8_t * service_request,
|
||||
uint8_t *service_request,
|
||||
uint16_t service_len)
|
||||
{
|
||||
(void)src;
|
||||
@@ -163,8 +162,8 @@ static void Init_Service_Handlers(void)
|
||||
|
||||
/* handle any errors coming back */
|
||||
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY, MyErrorHandler);
|
||||
apdu_set_complex_error_handler(SERVICE_CONFIRMED_PRIVATE_TRANSFER,
|
||||
MyPrivateTransferErrorHandler);
|
||||
apdu_set_complex_error_handler(
|
||||
SERVICE_CONFIRMED_PRIVATE_TRANSFER, MyPrivateTransferErrorHandler);
|
||||
apdu_set_abort_handler(MyAbortHandler);
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
@@ -317,12 +316,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
Target_Device_Object_Instance, &max_apdu, &Target_Address);
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if (invoke_id == 0) { /* Safe to send a new request */
|
||||
switch (iType) {
|
||||
@@ -414,6 +413,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ uint8_t Send_Private_Transfer_Request(uint32_t device_id,
|
||||
/* is there a tsm available? */
|
||||
if (status) {
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
}
|
||||
}
|
||||
if (invoke_id) {
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
|
||||
@@ -134,8 +134,8 @@ static void AtomicReadFileAckHandler(uint8_t *service_request,
|
||||
data.endOfFile = true;
|
||||
}
|
||||
} else {
|
||||
result = fseek(pFile, data.type.stream.fileStartPosition,
|
||||
SEEK_SET);
|
||||
result = fseek(
|
||||
pFile, data.type.stream.fileStartPosition, SEEK_SET);
|
||||
if (result == 0) {
|
||||
/* unit to write in bytes -
|
||||
in our case, an octet is one byte */
|
||||
@@ -150,8 +150,8 @@ static void AtomicReadFileAckHandler(uint8_t *service_request,
|
||||
Target_File_Start_Position =
|
||||
data.type.stream.fileStartPosition +
|
||||
octets_written;
|
||||
printf("\r%d bytes",
|
||||
(int)Target_File_Start_Position);
|
||||
printf(
|
||||
"\r%d bytes", (int)Target_File_Start_Position);
|
||||
}
|
||||
fflush(pFile);
|
||||
} else {
|
||||
|
||||
@@ -297,8 +297,8 @@ int main(int argc, char *argv[])
|
||||
Target_Device_Object_Instance = strtol(argv[argi], NULL, 0);
|
||||
target_args++;
|
||||
} else if (target_args == 1) {
|
||||
if (bactext_object_type_strtol(
|
||||
argv[argi], &object_type) == false) {
|
||||
if (bactext_object_type_strtol(argv[argi], &object_type) ==
|
||||
false) {
|
||||
fprintf(stderr, "object-type=%s invalid\n", argv[argi]);
|
||||
return 1;
|
||||
}
|
||||
@@ -308,8 +308,8 @@ int main(int argc, char *argv[])
|
||||
Target_Object_Instance = strtol(argv[argi], NULL, 0);
|
||||
target_args++;
|
||||
} else if (target_args == 3) {
|
||||
if (bactext_property_strtol(
|
||||
argv[argi], &object_property) == false) {
|
||||
if (bactext_property_strtol(argv[argi], &object_property) ==
|
||||
false) {
|
||||
fprintf(stderr, "property=%s invalid\n", argv[argi]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+13
-17
@@ -143,7 +143,6 @@ static void My_Read_Property_Multiple_Ack_Handler(uint8_t *service_request,
|
||||
while (rpm_data) {
|
||||
rpm_ack_print_data(rpm_data);
|
||||
rpm_data = rpm_data_free(rpm_data);
|
||||
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "RPM Ack Malformed! Freeing memory...\n");
|
||||
@@ -214,9 +213,7 @@ static void cleanup(void)
|
||||
}
|
||||
|
||||
static void target_address_add(
|
||||
long dnet,
|
||||
BACNET_MAC_ADDRESS *mac,
|
||||
BACNET_MAC_ADDRESS *adr)
|
||||
long dnet, BACNET_MAC_ADDRESS *mac, BACNET_MAC_ADDRESS *adr)
|
||||
{
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
|
||||
@@ -416,17 +413,17 @@ int main(int argc, char *argv[])
|
||||
} else if (target_args >= 1) {
|
||||
if (tag_value_arg == 0) {
|
||||
if (rpm_object) {
|
||||
rpm_object->next = calloc(1,
|
||||
sizeof(BACNET_READ_ACCESS_DATA));
|
||||
rpm_object->next =
|
||||
calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
||||
rpm_object = rpm_object->next;
|
||||
} else {
|
||||
Read_Access_Data = calloc(1,
|
||||
sizeof(BACNET_READ_ACCESS_DATA));
|
||||
Read_Access_Data =
|
||||
calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
||||
rpm_object = Read_Access_Data;
|
||||
atexit(cleanup);
|
||||
}
|
||||
status = bactext_object_type_strtol(
|
||||
argv[argi], &object_type);
|
||||
status =
|
||||
bactext_object_type_strtol(argv[argi], &object_type);
|
||||
if (status == false) {
|
||||
fprintf(stderr, "Error: object-type=%s invalid\n",
|
||||
argv[argi]);
|
||||
@@ -445,7 +442,8 @@ int main(int argc, char *argv[])
|
||||
if (rpm_object->object_instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr,
|
||||
"object-instance=%u - it must be less than %u\n",
|
||||
rpm_object->object_instance, BACNET_MAX_INSTANCE + 1);
|
||||
rpm_object->object_instance,
|
||||
BACNET_MAX_INSTANCE + 1);
|
||||
return 1;
|
||||
}
|
||||
tag_value_arg++;
|
||||
@@ -455,9 +453,8 @@ int main(int argc, char *argv[])
|
||||
property_token = strtok(argv[argi], ",");
|
||||
/* add all the properties and optional index to our list */
|
||||
while (rpm_property) {
|
||||
scan_count = sscanf(
|
||||
property_token, "%u[%u]", &property_id,
|
||||
&property_array_index);
|
||||
scan_count = sscanf(property_token, "%u[%u]",
|
||||
&property_id, &property_array_index);
|
||||
if (scan_count > 0) {
|
||||
rpm_property->propertyIdentifier = property_id;
|
||||
if (rpm_property->propertyIdentifier >
|
||||
@@ -489,7 +486,6 @@ int main(int argc, char *argv[])
|
||||
/* start over with the next arg set */
|
||||
tag_value_arg = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -538,7 +534,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
@@ -582,6 +578,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (Error_Detected) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-2
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
@@ -243,6 +243,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (Error_Detected) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ static uint16_t BIP6_Net;
|
||||
static uint8_t BIP_Rx_Buffer[BIP_MPDU_MAX];
|
||||
static uint8_t BIP6_Rx_Buffer[BIP6_MPDU_MAX];
|
||||
/* buffer for transmitting from any port */
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
static uint8_t Tx_Buffer[MAX(BIP_MPDU_MAX,BIP6_MPDU_MAX)];
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
static uint8_t Tx_Buffer[MAX(BIP_MPDU_MAX, BIP6_MPDU_MAX)];
|
||||
/* main loop exit control */
|
||||
static bool Exit_Requested;
|
||||
|
||||
@@ -1149,16 +1149,16 @@ int main(int argc, char *argv[])
|
||||
/* input */
|
||||
current_seconds = time(NULL);
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = bip_receive(&src, &BIP_Rx_Buffer[0],
|
||||
sizeof(BIP_Rx_Buffer), 5);
|
||||
pdu_len =
|
||||
bip_receive(&src, &BIP_Rx_Buffer[0], sizeof(BIP_Rx_Buffer), 5);
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
debug_printf("BACnet/IP Received packet\n");
|
||||
my_routing_npdu_handler(BIP_Net, &src, &BIP_Rx_Buffer[0], pdu_len);
|
||||
}
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = bip6_receive(&src, &BIP6_Rx_Buffer[0],
|
||||
sizeof(BIP6_Rx_Buffer), 5);
|
||||
pdu_len =
|
||||
bip6_receive(&src, &BIP6_Rx_Buffer[0], sizeof(BIP6_Rx_Buffer), 5);
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
debug_printf("BACnet/IPv6 Received packet\n");
|
||||
|
||||
@@ -98,8 +98,8 @@ static uint16_t MSTP_Net;
|
||||
static uint8_t BIP_Rx_Buffer[BIP_MPDU_MAX];
|
||||
static uint8_t MSTP_Rx_Buffer[DLMSTP_MPDU_MAX];
|
||||
/* buffer for transmitting from any port */
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
static uint8_t Tx_Buffer[MAX(DLMSTP_MPDU_MAX,BIP_MPDU_MAX)];
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
static uint8_t Tx_Buffer[MAX(DLMSTP_MPDU_MAX, BIP_MPDU_MAX)];
|
||||
/* main loop exit control */
|
||||
static bool Exit_Requested;
|
||||
|
||||
@@ -1160,16 +1160,16 @@ int main(int argc, char *argv[])
|
||||
/* input */
|
||||
current_seconds = time(NULL);
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = bip_receive(&src, &BIP_Rx_Buffer[0],
|
||||
sizeof(BIP_Rx_Buffer), 5);
|
||||
pdu_len =
|
||||
bip_receive(&src, &BIP_Rx_Buffer[0], sizeof(BIP_Rx_Buffer), 5);
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
debug_printf("BACnet/IP Received packet\n");
|
||||
my_routing_npdu_handler(BIP_Net, &src, &BIP_Rx_Buffer[0], pdu_len);
|
||||
}
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = dlmstp_receive(&src, &MSTP_Rx_Buffer[0],
|
||||
sizeof(MSTP_Rx_Buffer), 5);
|
||||
pdu_len =
|
||||
dlmstp_receive(&src, &MSTP_Rx_Buffer[0], sizeof(MSTP_Rx_Buffer), 5);
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
debug_printf("BACnet MS/TP Received packet\n");
|
||||
|
||||
@@ -189,7 +189,8 @@ bool dl_ip_init(ROUTER_PORT *port, IP_DATA *ip_data)
|
||||
|
||||
/* bind the socket to the local port number */
|
||||
sin.sin_family = AF_INET;
|
||||
/* sin.sin_addr.s_addr, ip_data->local_addr.s_addr;// = htonl(INADDR_ANY); */
|
||||
/* sin.sin_addr.s_addr, ip_data->local_addr.s_addr;// =
|
||||
* htonl(INADDR_ANY); */
|
||||
sin.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
sin.sin_port = ip_data->port;
|
||||
|
||||
@@ -309,7 +310,7 @@ int dl_ip_recv(
|
||||
/* the signature of a BACnet/IP packet */
|
||||
if (data->buff[0] != BVLL_TYPE_BACNET_IP) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch (data->buff[1]) {
|
||||
case BVLC_ORIGINAL_UNICAST_NPDU:
|
||||
|
||||
+2
-2
@@ -569,7 +569,7 @@ bool parse_cmd(int argc, char *argv[])
|
||||
current->route_info.mac[0]) {
|
||||
current->params.mstp_params.max_master =
|
||||
current->route_info.mac[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (argv[optind + 1][0] != '-') {
|
||||
current->params.mstp_params.max_frames =
|
||||
@@ -781,7 +781,7 @@ uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
if (addr.net > 0 && addr.net < BACNET_BROADCAST_NETWORK &&
|
||||
data->src.net != addr.net) {
|
||||
memmove(&data->src, &addr, sizeof(BACNET_ADDRESS));
|
||||
}
|
||||
}
|
||||
|
||||
/* encode both source and destination for broadcast and router-to-router
|
||||
* communication */
|
||||
|
||||
@@ -62,8 +62,7 @@ BACMSG *recv_from_msgbox(MSGBOX_ID src, BACMSG *msg, int flags)
|
||||
{
|
||||
int recv_bytes;
|
||||
|
||||
recv_bytes =
|
||||
msgrcv(src, msg, sizeof(BACMSG) - sizeof(MSGTYPE), 0, flags);
|
||||
recv_bytes = msgrcv(src, msg, sizeof(BACMSG) - sizeof(MSGTYPE), 0, flags);
|
||||
if (recv_bytes > 0) {
|
||||
return msg;
|
||||
} else {
|
||||
|
||||
@@ -85,7 +85,7 @@ void *dl_mstp_thread(void *pArgs)
|
||||
|
||||
if (port->params.mstp_params.stopbits == 2) {
|
||||
shared_port_data.RS485MOD |= CSTOPB;
|
||||
}
|
||||
}
|
||||
|
||||
mstp_port.UserData = (void *)&shared_port_data;
|
||||
dlmstp_set_baud_rate(&mstp_port, port->params.mstp_params.baudrate);
|
||||
@@ -94,7 +94,7 @@ void *dl_mstp_thread(void *pArgs)
|
||||
dlmstp_set_max_master(&mstp_port, port->params.mstp_params.max_master);
|
||||
if (!dlmstp_init(&mstp_port, port->iface)) {
|
||||
printf("MSTP %s init failed. Stop.\n", port->iface);
|
||||
}
|
||||
}
|
||||
|
||||
port->port_id = create_msgbox();
|
||||
if (port->port_id == INVALID_MSGBOX_ID) {
|
||||
|
||||
@@ -133,14 +133,14 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
i = data->pdu[apdu_offset + i + 3] + 4;
|
||||
} else {
|
||||
i = i + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
buff_len = create_network_message(
|
||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, NULL);
|
||||
} else {
|
||||
buff_len = create_network_message(
|
||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, &buff);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK:
|
||||
@@ -158,7 +158,7 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
i = data->pdu[apdu_offset + i + 3] + 4;
|
||||
} else {
|
||||
i = i + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -207,7 +207,7 @@ uint16_t create_network_message(
|
||||
|
||||
if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE) {
|
||||
data_expecting_reply = true;
|
||||
}
|
||||
}
|
||||
init_npdu(&npdu_data, network_message_type, data_expecting_reply);
|
||||
|
||||
*buff = (uint8_t *)malloc(128); /* resolve different length */
|
||||
@@ -282,7 +282,7 @@ uint16_t create_network_message(
|
||||
}
|
||||
} else {
|
||||
(*buff)[buff_len++] = (uint8_t)0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NETWORK_MESSAGE_INVALID:
|
||||
|
||||
@@ -53,7 +53,7 @@ ROUTER_PORT *find_dnet(uint16_t net, BACNET_ADDRESS *addr)
|
||||
/* for broadcast messages no search is needed */
|
||||
if (net == BACNET_BROADCAST_NETWORK) {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
while (port != NULL) {
|
||||
/* check if DNET is directly connected to the router */
|
||||
|
||||
+1
-1
@@ -420,6 +420,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-2
@@ -267,9 +267,9 @@ int main(int argc, char *argv[])
|
||||
ucix_cleanup(ctx);
|
||||
#endif /* defined(BAC_UCI) */
|
||||
BACNET_CHARACTER_STRING DeviceName;
|
||||
if (Device_Object_Name(Device_Object_Instance_Number(),&DeviceName)) {
|
||||
if (Device_Object_Name(Device_Object_Instance_Number(), &DeviceName)) {
|
||||
printf("BACnet Device Name: %s\n", DeviceName.value);
|
||||
}
|
||||
}
|
||||
|
||||
dlenv_init();
|
||||
atexit(datalink_cleanup);
|
||||
|
||||
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
|
||||
atexit(datalink_cleanup);
|
||||
mstimer_init();
|
||||
/* send the request */
|
||||
datetime_local(override_date?NULL:&bdate,override_time?NULL:&btime,
|
||||
datetime_local(override_date ? NULL : &bdate, override_time ? NULL : &btime,
|
||||
NULL, NULL);
|
||||
Send_TimeSync_Remote(&dest, &bdate, &btime);
|
||||
mstimer_set(&apdu_timer, apdu_timeout());
|
||||
|
||||
+3
-4
@@ -183,8 +183,7 @@ int main(int argc, char *argv[])
|
||||
cov_data.timeRemaining = strtol(argv[5], NULL, 0);
|
||||
cov_data.listOfValues = &value_list;
|
||||
value_list.next = NULL;
|
||||
if (bactext_property_strtol(argv[6], &object_property) ==
|
||||
false) {
|
||||
if (bactext_property_strtol(argv[6], &object_property) == false) {
|
||||
fprintf(stderr, "property=%s invalid\n", argv[6]);
|
||||
return 1;
|
||||
}
|
||||
@@ -196,13 +195,13 @@ int main(int argc, char *argv[])
|
||||
value_list.priority = strtol(argv[9], NULL, 0);
|
||||
} else {
|
||||
value_list.priority = BACNET_NO_PRIORITY;
|
||||
}
|
||||
}
|
||||
/* optional index */
|
||||
if (argc > 10) {
|
||||
value_list.propertyArrayIndex = strtol(argv[10], NULL, 0);
|
||||
} else {
|
||||
value_list.propertyArrayIndex = BACNET_ARRAY_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cov_data.initiatingDeviceIdentifier >= BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
||||
|
||||
@@ -317,7 +317,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
@@ -367,6 +367,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (Error_Detected) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ static void My_Router_Handler(BACNET_ADDRESS *src,
|
||||
that are sent with a local unicast address. */
|
||||
if (npdu_len >= 2) {
|
||||
len += decode_unsigned16(npdu, &dnet);
|
||||
printf(": network number = %u. SNET=%u\n",
|
||||
(unsigned)dnet, (unsigned)src->net);
|
||||
printf(": network number = %u. SNET=%u\n", (unsigned)dnet,
|
||||
(unsigned)src->net);
|
||||
} else {
|
||||
printf(": network number = missing! SNET=%u\n", src->net);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
|
||||
+1
-1
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds += (current_seconds - last_seconds);
|
||||
if (elapsed_seconds > timeout_seconds) {
|
||||
|
||||
+5
-5
@@ -497,8 +497,8 @@ int main(int argc, char *argv[])
|
||||
/* loop forever */
|
||||
for (;;) {
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU,
|
||||
delay_milliseconds);
|
||||
pdu_len =
|
||||
datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, delay_milliseconds);
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||
@@ -507,13 +507,13 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
if (mstimer_expired(&datalink_timer)) {
|
||||
datalink_maintenance_timer(mstimer_interval(&datalink_timer)/1000);
|
||||
datalink_maintenance_timer(
|
||||
mstimer_interval(&datalink_timer) / 1000);
|
||||
mstimer_reset(&datalink_timer);
|
||||
}
|
||||
if (mstimer_expired(&apdu_timer)) {
|
||||
if (repeat_forever || retry_count) {
|
||||
Send_WhoIs_To_Network(
|
||||
&dest, Target_Object_Instance_Min,
|
||||
Send_WhoIs_To_Network(&dest, Target_Object_Instance_Min,
|
||||
Target_Object_Instance_Max);
|
||||
retry_count--;
|
||||
} else {
|
||||
|
||||
@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
|
||||
@@ -123,7 +123,6 @@ int main(int argc, char *argv[])
|
||||
int c = 0;
|
||||
uint16_t result_code = 0;
|
||||
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s IP port <IP:port[:mask]> [<IP:port[:mask]>]\r\n",
|
||||
filename_remove_path(argv[0]));
|
||||
@@ -148,8 +147,8 @@ int main(int argc, char *argv[])
|
||||
if (argc > 1) {
|
||||
argi = 1;
|
||||
if (!bip_get_addr_by_name(argv[argi], &Target_BBMD_Address)) {
|
||||
fprintf(stderr, "IP=%s - failed to convert address.\r\n",
|
||||
argv[argi]);
|
||||
fprintf(
|
||||
stderr, "IP=%s - failed to convert address.\r\n", argv[argi]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -172,8 +171,8 @@ int main(int argc, char *argv[])
|
||||
argi = 3;
|
||||
while (argc > argi) {
|
||||
bdt_entry = &BBMD_Table_Entry[bdti];
|
||||
c = sscanf(argv[argi], "%3u.%3u.%3u.%3u:%5u:%3u.%3u.%3u.%3u",
|
||||
&a[0], &a[1], &a[2], &a[3], &p, &m[0], &m[1], &m[2], &m[3]);
|
||||
c = sscanf(argv[argi], "%3u.%3u.%3u.%3u:%5u:%3u.%3u.%3u.%3u", &a[0],
|
||||
&a[1], &a[2], &a[3], &p, &m[0], &m[1], &m[2], &m[3]);
|
||||
if ((c == 4) || (c == 5) || (c == 9)) {
|
||||
bvlc_address_set(&bdt_entry->dest_address, a[0], a[1], a[2], a[3]);
|
||||
if ((c == 5) || (c == 9)) {
|
||||
@@ -216,8 +215,7 @@ int main(int argc, char *argv[])
|
||||
if (bvlc_get_function_code() != BVLC_INVALID) {
|
||||
if (bvlc_get_function_code() == BVLC_RESULT) {
|
||||
result_code = bvlc_get_last_result();
|
||||
printf("BVLC Result: %s\n",
|
||||
bvlc_result_code_name(result_code));
|
||||
printf("BVLC Result: %s\n", bvlc_result_code_name(result_code));
|
||||
break;
|
||||
}
|
||||
bvlc_set_function_code(BVLC_INVALID);
|
||||
|
||||
@@ -292,7 +292,7 @@ int main(int argc, char *argv[])
|
||||
Target_Object_Property_Index = strtol(argv[6], NULL, 0);
|
||||
if (Target_Object_Property_Index == -1) {
|
||||
Target_Object_Property_Index = BACNET_ARRAY_ALL;
|
||||
}
|
||||
}
|
||||
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\n",
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE + 1);
|
||||
@@ -338,7 +338,8 @@ int main(int argc, char *argv[])
|
||||
tag_value_arg++;
|
||||
args_remaining--;
|
||||
if (property_tag < 0) {
|
||||
property_tag = bacapp_known_property_tag(Target_Object_Type, Target_Object_Property);
|
||||
property_tag = bacapp_known_property_tag(
|
||||
Target_Object_Type, Target_Object_Property);
|
||||
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
|
||||
fprintf(stderr, "Error: tag=%u - it must be less than %u\n",
|
||||
property_tag, MAX_BACNET_APPLICATION_TAG);
|
||||
@@ -354,8 +355,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
} else {
|
||||
/* FIXME: show the expected entry format for the tag */
|
||||
fprintf(stderr, "Error: unable to parse the known property"
|
||||
" \"%s\"\r\n", value_string);
|
||||
fprintf(stderr,
|
||||
"Error: unable to parse the known property"
|
||||
" \"%s\"\r\n",
|
||||
value_string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -419,7 +422,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
@@ -465,6 +468,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+12
-9
@@ -70,11 +70,10 @@ static bool Error_Detected = false;
|
||||
/* Used for verbose */
|
||||
static bool Verbose = false;
|
||||
|
||||
static void MyWritePropertyMultipleErrorHandler(
|
||||
BACNET_ADDRESS * src,
|
||||
static void MyWritePropertyMultipleErrorHandler(BACNET_ADDRESS *src,
|
||||
uint8_t invoke_id,
|
||||
uint8_t service_choice,
|
||||
uint8_t * service_request,
|
||||
uint8_t *service_request,
|
||||
uint16_t service_len)
|
||||
{
|
||||
int len = 0;
|
||||
@@ -121,7 +120,6 @@ static void MyRejectHandler(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void MyWritePropertyMultipleSimpleAckHandler(
|
||||
BACNET_ADDRESS *src, uint8_t invoke_id)
|
||||
{
|
||||
@@ -428,7 +426,9 @@ int main(int argc, char *argv[])
|
||||
printf("tag=%u value=%s\n", property_tag, value_string);
|
||||
}
|
||||
if (property_tag < 0) {
|
||||
property_tag = bacapp_known_property_tag(wpm_object->object_type, wpm_property->propertyIdentifier);
|
||||
property_tag =
|
||||
bacapp_known_property_tag(wpm_object->object_type,
|
||||
wpm_property->propertyIdentifier);
|
||||
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
|
||||
fprintf(stderr, "Error: tag=%u - it must be less than %u\n",
|
||||
property_tag, MAX_BACNET_APPLICATION_TAG);
|
||||
@@ -439,13 +439,16 @@ int main(int argc, char *argv[])
|
||||
property_tag, value_string, &wpm_property->value);
|
||||
if (!status) {
|
||||
/* FIXME: show the expected entry format for the tag */
|
||||
fprintf(stderr, "Error: unable to parse the tag value\n");
|
||||
fprintf(
|
||||
stderr, "Error: unable to parse the tag value\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
/* FIXME: show the expected entry format for the tag */
|
||||
fprintf(stderr, "Error: unable to parse the known property"
|
||||
" \"%s\"\r\n", value_string);
|
||||
fprintf(stderr,
|
||||
"Error: unable to parse the known property"
|
||||
" \"%s\"\r\n",
|
||||
value_string);
|
||||
return 1;
|
||||
}
|
||||
wpm_property->value.next = NULL;
|
||||
@@ -493,7 +496,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
found = address_bind_request(
|
||||
|
||||
+148
-158
@@ -87,8 +87,8 @@ int bacapp_encode_application_data(
|
||||
#endif
|
||||
#if defined(BACAPP_UNSIGNED)
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
apdu_len = encode_application_unsigned(
|
||||
apdu, value->type.Unsigned_Int);
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu, value->type.Unsigned_Int);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SIGNED)
|
||||
@@ -104,8 +104,7 @@ int bacapp_encode_application_data(
|
||||
#endif
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||
apdu_len =
|
||||
encode_application_double(apdu, value->type.Double);
|
||||
apdu_len = encode_application_double(apdu, value->type.Double);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_OCTET_STRING)
|
||||
@@ -122,14 +121,14 @@ int bacapp_encode_application_data(
|
||||
#endif
|
||||
#if defined(BACAPP_BIT_STRING)
|
||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||
apdu_len = encode_application_bitstring(
|
||||
apdu, &value->type.Bit_String);
|
||||
apdu_len =
|
||||
encode_application_bitstring(apdu, &value->type.Bit_String);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_ENUMERATED)
|
||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||
apdu_len = encode_application_enumerated(
|
||||
apdu, value->type.Enumerated);
|
||||
apdu_len =
|
||||
encode_application_enumerated(apdu, value->type.Enumerated);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
@@ -148,7 +147,7 @@ int bacapp_encode_application_data(
|
||||
value->type.Object_Id.type, value->type.Object_Id.instance);
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_EMPTYLIST:
|
||||
/* Empty data list */
|
||||
apdu_len = 0; /* EMPTY */
|
||||
@@ -156,8 +155,7 @@ int bacapp_encode_application_data(
|
||||
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
apdu_len = bacapp_encode_datetime(apdu,
|
||||
&value->type.Date_Time);
|
||||
apdu_len = bacapp_encode_datetime(apdu, &value->type.Date_Time);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
/* BACnetLightingCommand */
|
||||
@@ -166,13 +164,12 @@ int bacapp_encode_application_data(
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
apdu_len = xy_color_encode(
|
||||
apdu, &value->type.XY_Color);
|
||||
apdu_len = xy_color_encode(apdu, &value->type.XY_Color);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_COLOR_COMMAND:
|
||||
/* BACnetColorCommand */
|
||||
apdu_len = color_command_encode(
|
||||
apdu, &value->type.Color_Command);
|
||||
apdu_len =
|
||||
color_command_encode(apdu, &value->type.Color_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE:
|
||||
/* BACnetWeeklySchedule */
|
||||
@@ -181,8 +178,7 @@ int bacapp_encode_application_data(
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
/* BACnetHostNPort */
|
||||
apdu_len = host_n_port_encode(apdu,
|
||||
&value->type.Host_Address);
|
||||
apdu_len = host_n_port_encode(apdu, &value->type.Host_Address);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetDeviceObjectPropertyReference */
|
||||
@@ -251,8 +247,8 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_REAL)
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
len = decode_real_safe(
|
||||
apdu, len_value_type, &(value->type.Real));
|
||||
len =
|
||||
decode_real_safe(apdu, len_value_type, &(value->type.Real));
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
@@ -287,8 +283,7 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
len = decode_date_safe(
|
||||
apdu, len_value_type, &value->type.Date);
|
||||
len = decode_date_safe(apdu, len_value_type, &value->type.Date);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_TIME)
|
||||
@@ -307,10 +302,9 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
value->type.Object_Id.instance = instance;
|
||||
} break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
len = bacapp_decode_datetime(apdu,
|
||||
&value->type.Date_Time);
|
||||
len = bacapp_decode_datetime(apdu, &value->type.Date_Time);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
len = lighting_command_decode(
|
||||
@@ -332,8 +326,7 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
len = host_n_port_decode(
|
||||
apdu, len_value_type, NULL,
|
||||
&value->type.Host_Address);
|
||||
apdu, len_value_type, NULL, &value->type.Host_Address);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetDeviceObjectPropertyReference */
|
||||
@@ -347,8 +340,7 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetObjectPropertyReference */
|
||||
len = bacapp_decode_obj_property_ref(
|
||||
apdu, len_value_type,
|
||||
len = bacapp_decode_obj_property_ref(apdu, len_value_type,
|
||||
&value->type.Object_Property_Reference);
|
||||
break;
|
||||
#endif
|
||||
@@ -601,8 +593,8 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_CHARACTER_STRING)
|
||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||
apdu_len = encode_context_character_string(apdu,
|
||||
context_tag_number, &value->type.Character_String);
|
||||
apdu_len = encode_context_character_string(
|
||||
apdu, context_tag_number, &value->type.Character_String);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_BIT_STRING)
|
||||
@@ -631,19 +623,18 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_OBJECT_ID)
|
||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||
apdu_len = encode_context_object_id(apdu,
|
||||
context_tag_number, value->type.Object_Id.type,
|
||||
value->type.Object_Id.instance);
|
||||
apdu_len = encode_context_object_id(apdu, context_tag_number,
|
||||
value->type.Object_Id.type, value->type.Object_Id.instance);
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
apdu_len = bacapp_encode_context_datetime(apdu,
|
||||
context_tag_number, &value->type.Date_Time);
|
||||
apdu_len = bacapp_encode_context_datetime(
|
||||
apdu, context_tag_number, &value->type.Date_Time);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
apdu_len = lighting_command_encode_context(apdu,
|
||||
context_tag_number, &value->type.Lighting_Command);
|
||||
apdu_len = lighting_command_encode_context(
|
||||
apdu, context_tag_number, &value->type.Lighting_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
@@ -661,26 +652,24 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
apdu, context_tag_number, &value->type.Color_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
apdu_len = host_n_port_context_encode(apdu,
|
||||
context_tag_number, &value->type.Host_Address);
|
||||
apdu_len = host_n_port_context_encode(
|
||||
apdu, context_tag_number, &value->type.Host_Address);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetDeviceObjectPropertyReference */
|
||||
apdu_len = bacapp_encode_context_device_obj_property_ref(
|
||||
apdu, context_tag_number,
|
||||
apdu_len = bacapp_encode_context_device_obj_property_ref(apdu,
|
||||
context_tag_number,
|
||||
&value->type.Device_Object_Property_Reference);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_REFERENCE:
|
||||
/* BACnetDeviceObjectReference */
|
||||
apdu_len = bacapp_encode_context_device_obj_ref(
|
||||
apdu, context_tag_number,
|
||||
&value->type.Device_Object_Reference);
|
||||
apdu_len = bacapp_encode_context_device_obj_ref(apdu,
|
||||
context_tag_number, &value->type.Device_Object_Reference);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetObjectPropertyReference */
|
||||
apdu_len = bacapp_encode_context_obj_property_ref(
|
||||
apdu, context_tag_number,
|
||||
&value->type.Object_Property_Reference);
|
||||
apdu_len = bacapp_encode_context_obj_property_ref(apdu,
|
||||
context_tag_number, &value->type.Object_Property_Reference);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -962,7 +951,7 @@ int bacapp_decode_context_data(uint8_t *apdu,
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
/**
|
||||
* @brief Context or Application tagged property value decoding
|
||||
*
|
||||
@@ -972,10 +961,9 @@ int bacapp_decode_context_data(uint8_t *apdu,
|
||||
* @param property - context property identifier
|
||||
* @return number of bytes decoded, or ERROR if errors occur
|
||||
*/
|
||||
int bacapp_decode_generic_property(
|
||||
uint8_t * apdu,
|
||||
int bacapp_decode_generic_property(uint8_t *apdu,
|
||||
int max_apdu_len,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
BACNET_PROPERTY_ID prop)
|
||||
{
|
||||
int len = 0;
|
||||
@@ -1029,8 +1017,7 @@ static int decode_priority_value(uint8_t *apdu,
|
||||
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
int bacapp_known_property_tag(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID property)
|
||||
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID property)
|
||||
{
|
||||
switch (property) {
|
||||
case PROP_MEMBER_OF:
|
||||
@@ -1238,8 +1225,8 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
case PROP_LOG_DEVICE_OBJECT_PROPERTY:
|
||||
case PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES:
|
||||
/* Properties using BACnetDeviceObjectPropertyReference */
|
||||
len = bacapp_decode_device_obj_property_ref(apdu,
|
||||
&value->type.Device_Object_Property_Reference);
|
||||
len = bacapp_decode_device_obj_property_ref(
|
||||
apdu, &value->type.Device_Object_Property_Reference);
|
||||
break;
|
||||
|
||||
case PROP_MANIPULATED_VARIABLE_REFERENCE:
|
||||
@@ -1247,8 +1234,7 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
case PROP_INPUT_REFERENCE:
|
||||
/* Properties using BACnetObjectPropertyReference */
|
||||
len = bacapp_decode_obj_property_ref(
|
||||
apdu, max_apdu_len,
|
||||
&value->type.Object_Property_Reference);
|
||||
apdu, max_apdu_len, &value->type.Object_Property_Reference);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_TIME_STAMPS:
|
||||
@@ -1261,33 +1247,32 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
|
||||
case PROP_DEFAULT_COLOR:
|
||||
/* Properties using BACnetxyColor */
|
||||
len = xy_color_decode(apdu, max_apdu_len,
|
||||
&value->type.XY_Color);
|
||||
len = xy_color_decode(apdu, max_apdu_len, &value->type.XY_Color);
|
||||
break;
|
||||
|
||||
case PROP_TRACKING_VALUE:
|
||||
case PROP_PRESENT_VALUE:
|
||||
if (object_type == OBJECT_COLOR) {
|
||||
/* Properties using BACnetxyColor */
|
||||
len = xy_color_decode(apdu, max_apdu_len,
|
||||
&value->type.XY_Color);
|
||||
len =
|
||||
xy_color_decode(apdu, max_apdu_len, &value->type.XY_Color);
|
||||
} else {
|
||||
/* Decode a "classic" simple property */
|
||||
len = bacapp_decode_generic_property(apdu, max_apdu_len, value,
|
||||
property);
|
||||
len = bacapp_decode_generic_property(
|
||||
apdu, max_apdu_len, value, property);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_COLOR_COMMAND:
|
||||
/* Properties using BACnetColorCommand */
|
||||
len = color_command_decode(apdu, max_apdu_len, NULL,
|
||||
&value->type.Color_Command);
|
||||
len = color_command_decode(
|
||||
apdu, max_apdu_len, NULL, &value->type.Color_Command);
|
||||
break;
|
||||
|
||||
case PROP_LIGHTING_COMMAND:
|
||||
/* Properties using BACnetLightingCommand */
|
||||
len = lighting_command_decode(apdu, max_apdu_len,
|
||||
&value->type.Lighting_Command);
|
||||
len = lighting_command_decode(
|
||||
apdu, max_apdu_len, &value->type.Lighting_Command);
|
||||
break;
|
||||
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
@@ -1301,7 +1286,8 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
apdu, max_apdu_len, &value->type.Weekly_Schedule);
|
||||
break;
|
||||
|
||||
/* properties without a specific decoder - fall through to default */
|
||||
/* properties without a specific decoder - fall through to default
|
||||
*/
|
||||
|
||||
case PROP_LIST_OF_GROUP_MEMBERS:
|
||||
/* Properties using ReadAccessSpecification */
|
||||
@@ -1326,8 +1312,8 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
case PROP_ACTION:
|
||||
default:
|
||||
/* Decode a "classic" simple property */
|
||||
len = bacapp_decode_generic_property(apdu, max_apdu_len, value,
|
||||
property);
|
||||
len = bacapp_decode_generic_property(
|
||||
apdu, max_apdu_len, value, property);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1335,7 +1321,7 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
/**
|
||||
* @brief Determine the BACnet Context Data number of APDU bytes consumed
|
||||
*
|
||||
@@ -1470,15 +1456,14 @@ bool bacapp_copy(BACNET_APPLICATION_DATA_VALUE *dest_value,
|
||||
src_value->type.Object_Id.instance;
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
status =
|
||||
lighting_command_copy(&dest_value->type.Lighting_Command,
|
||||
&src_value->type.Lighting_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
status =
|
||||
host_n_port_copy(&dest_value->type.Host_Address,
|
||||
status = host_n_port_copy(&dest_value->type.Host_Address,
|
||||
&src_value->type.Host_Address);
|
||||
break;
|
||||
#endif
|
||||
@@ -1537,7 +1522,7 @@ int bacapp_data_len(
|
||||
opening_tag_number_counter--;
|
||||
}
|
||||
} else if (IS_CONTEXT_SPECIFIC(apdu[apdu_len])) {
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
/* context-specific tagged data */
|
||||
len = bacapp_decode_context_data_len(
|
||||
&apdu[apdu_len], apdu_len_max - apdu_len, property);
|
||||
@@ -1586,8 +1571,8 @@ static int bacapp_snprintf_date(char *str, size_t str_len, BACNET_DATE *bdate)
|
||||
/* false positive cppcheck - snprintf allows null pointers */
|
||||
/* cppcheck-suppress nullPointer */
|
||||
/* cppcheck-suppress ctunullpointer */
|
||||
slen = snprintf(str, str_len, "%s, %s",
|
||||
bactext_day_of_week_name(bdate->wday),
|
||||
slen =
|
||||
snprintf(str, str_len, "%s, %s", bactext_day_of_week_name(bdate->wday),
|
||||
bactext_month_name(bdate->month));
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1601,8 +1586,7 @@ static int bacapp_snprintf_date(char *str, size_t str_len, BACNET_DATE *bdate)
|
||||
if (bdate->day == 255) {
|
||||
slen = snprintf(str, str_len, " (unspecified), ");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, " %u, ",
|
||||
(unsigned)bdate->day);
|
||||
slen = snprintf(str, str_len, " %u, ", (unsigned)bdate->day);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1616,8 +1600,7 @@ static int bacapp_snprintf_date(char *str, size_t str_len, BACNET_DATE *bdate)
|
||||
if (bdate->year == 2155) {
|
||||
slen = snprintf(str, str_len, "(unspecified)");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%u",
|
||||
(unsigned)bdate->year);
|
||||
slen = snprintf(str, str_len, "%u", (unsigned)bdate->year);
|
||||
}
|
||||
ret_val += slen;
|
||||
|
||||
@@ -1641,8 +1624,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
} else {
|
||||
/* false positive cppcheck - snprintf allows null pointers */
|
||||
/* cppcheck-suppress nullPointer */
|
||||
slen = snprintf(str, str_len, "%02u:",
|
||||
(unsigned)btime->hour);
|
||||
slen = snprintf(str, str_len, "%02u:", (unsigned)btime->hour);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1656,8 +1638,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
if (btime->min == 255) {
|
||||
slen = snprintf(str, str_len, "**:");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%02u:",
|
||||
(unsigned)btime->min);
|
||||
slen = snprintf(str, str_len, "%02u:", (unsigned)btime->min);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1671,8 +1652,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
if (btime->sec == 255) {
|
||||
slen = snprintf(str, str_len, "**.");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%02u.",
|
||||
(unsigned)btime->sec);
|
||||
slen = snprintf(str, str_len, "%02u.", (unsigned)btime->sec);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1686,8 +1666,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
if (btime->hundredths == 255) {
|
||||
slen = snprintf(str, str_len, "**");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%02u",
|
||||
(unsigned)btime->hundredths);
|
||||
slen = snprintf(str, str_len, "%02u", (unsigned)btime->hundredths);
|
||||
}
|
||||
ret_val += slen;
|
||||
|
||||
@@ -1696,8 +1675,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
#endif
|
||||
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
static int bacapp_snprintf_weeklyschedule(
|
||||
char *str,
|
||||
static int bacapp_snprintf_weeklyschedule(char *str,
|
||||
size_t str_len,
|
||||
BACNET_WEEKLY_SCHEDULE *ws,
|
||||
BACNET_ARRAY_INDEX arrayIndex)
|
||||
@@ -1708,9 +1686,8 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
BACNET_OBJECT_PROPERTY_VALUE dummyPropValue;
|
||||
BACNET_APPLICATION_DATA_VALUE dummyDataValue;
|
||||
|
||||
const char *weekdaynames[7] = {
|
||||
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
|
||||
};
|
||||
const char *weekdaynames[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
|
||||
"Sun" };
|
||||
const int loopend = ((arrayIndex == BACNET_ARRAY_ALL) ? 7 : 1);
|
||||
|
||||
// Find what inner type it uses
|
||||
@@ -1732,7 +1709,8 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
} else if (inner_tag == -2) {
|
||||
slen = snprintf(str, str_len, "(MIXED_TYPES; ");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "(%s; ", bactext_application_tag_name(inner_tag));
|
||||
slen = snprintf(
|
||||
str, str_len, "(%s; ", bactext_application_tag_name(inner_tag));
|
||||
}
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
@@ -1749,10 +1727,10 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
if (arrayIndex == BACNET_ARRAY_ALL) {
|
||||
slen = snprintf(str, str_len, "%s: [", weekdaynames[wi]);
|
||||
} else {
|
||||
slen = snprintf(
|
||||
str, str_len, "%s: [",
|
||||
(arrayIndex >= 1 && arrayIndex <= 7) ? weekdaynames[arrayIndex - 1] : "???"
|
||||
);
|
||||
slen = snprintf(str, str_len, "%s: [",
|
||||
(arrayIndex >= 1 && arrayIndex <= 7)
|
||||
? weekdaynames[arrayIndex - 1]
|
||||
: "???");
|
||||
}
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
@@ -1765,7 +1743,8 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
}
|
||||
|
||||
for (ti = 0; ti < ds->TV_Count; ti++) {
|
||||
slen = bacapp_snprintf_time(str, str_len, &ds->Time_Values[ti].Time);
|
||||
slen =
|
||||
bacapp_snprintf_time(str, str_len, &ds->Time_Values[ti].Time);
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1837,7 +1816,6 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extract the value into a text string
|
||||
* @param str - the buffer to store the extracted value, or NULL for length
|
||||
@@ -1856,7 +1834,7 @@ int bacapp_snprintf_value(
|
||||
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
|
||||
int ret_val = 0;
|
||||
int slen = 0;
|
||||
#if defined(BACAPP_OCTET_STRING) || defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_OCTET_STRING) || defined(BACAPP_TYPES_EXTRA)
|
||||
uint8_t *octet_str;
|
||||
#endif
|
||||
#ifdef __STDC_ISO_10646__
|
||||
@@ -1939,7 +1917,7 @@ int bacapp_snprintf_value(
|
||||
}
|
||||
}
|
||||
ret_val += slen;
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#ifdef __STDC_ISO_10646__
|
||||
if (characterstring_encoding(&value->type.Character_String) ==
|
||||
CHARACTER_UTF8) {
|
||||
while (len > 0) {
|
||||
@@ -1975,7 +1953,7 @@ int bacapp_snprintf_value(
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
if (isprint(*((unsigned char *)char_str))) {
|
||||
@@ -2125,14 +2103,12 @@ int bacapp_snprintf_value(
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
ret_val = bacapp_snprintf_date(str, str_len,
|
||||
&value->type.Date);
|
||||
ret_val = bacapp_snprintf_date(str, str_len, &value->type.Date);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_TIME)
|
||||
case BACNET_APPLICATION_TAG_TIME:
|
||||
ret_val = bacapp_snprintf_time(str, str_len,
|
||||
&value->type.Time);
|
||||
ret_val = bacapp_snprintf_time(str, str_len, &value->type.Time);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_OBJECT_ID)
|
||||
@@ -2172,10 +2148,9 @@ int bacapp_snprintf_value(
|
||||
ret_val += slen;
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
slen = bacapp_snprintf_date(str, str_len,
|
||||
&value->type.Date);
|
||||
slen = bacapp_snprintf_date(str, str_len, &value->type.Date);
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -2185,8 +2160,7 @@ int bacapp_snprintf_value(
|
||||
str_len = 0;
|
||||
}
|
||||
}
|
||||
slen = bacapp_snprintf_time(str, str_len,
|
||||
&value->type.Time);
|
||||
slen = bacapp_snprintf_time(str, str_len, &value->type.Time);
|
||||
ret_val += slen;
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
@@ -2252,18 +2226,16 @@ int bacapp_snprintf_value(
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE:
|
||||
/* BACnetWeeklySchedule */
|
||||
ret_val = bacapp_snprintf_weeklyschedule(
|
||||
str, str_len, &value->type.Weekly_Schedule, object_value->array_index);
|
||||
ret_val = bacapp_snprintf_weeklyschedule(str, str_len,
|
||||
&value->type.Weekly_Schedule, object_value->array_index);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
if (value->type.Host_Address.host_ip_address) {
|
||||
octet_str = octetstring_value(
|
||||
&value->type.Host_Address.host.ip_address);
|
||||
slen = snprintf(str, str_len, "%u.%u.%u.%u:%u",
|
||||
(unsigned)octet_str[0],
|
||||
(unsigned)octet_str[1],
|
||||
(unsigned)octet_str[2],
|
||||
(unsigned)octet_str[3],
|
||||
(unsigned)octet_str[0], (unsigned)octet_str[1],
|
||||
(unsigned)octet_str[2], (unsigned)octet_str[3],
|
||||
(unsigned)value->type.Host_Address.port);
|
||||
ret_val += slen;
|
||||
} else if (value->type.Host_Address.host_name) {
|
||||
@@ -2304,7 +2276,8 @@ int bacapp_snprintf_value(
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret_val = snprintf(str, str_len, "UnknownType(tag=%d)", value->tag);
|
||||
ret_val =
|
||||
snprintf(str, str_len, "UnknownType(tag=%d)", value->tag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2332,17 +2305,17 @@ bool bacapp_print_value(
|
||||
/* get the string length first */
|
||||
str_len = bacapp_snprintf_value(NULL, 0, object_value);
|
||||
if (str_len > 0) {
|
||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
char str[str_len+1];
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
char str[str_len + 1];
|
||||
#else
|
||||
char *str;
|
||||
str = calloc(sizeof(char), str_len+1);
|
||||
str = calloc(sizeof(char), str_len + 1);
|
||||
#endif
|
||||
bacapp_snprintf_value(str, str_len+1, object_value);
|
||||
bacapp_snprintf_value(str, str_len + 1, object_value);
|
||||
if (stream) {
|
||||
fprintf(stream, "%s", str);
|
||||
}
|
||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
/* nothing to do with stack based RAM */
|
||||
#else
|
||||
if (str) {
|
||||
@@ -2357,35 +2330,40 @@ bool bacapp_print_value(
|
||||
#endif
|
||||
|
||||
#ifdef BACAPP_PRINT_ENABLED
|
||||
static char* ltrim(char *str, const char *trimmedchars) {
|
||||
static char *ltrim(char *str, const char *trimmedchars)
|
||||
{
|
||||
if (str[0] == 0) {
|
||||
return str;
|
||||
}
|
||||
while(strchr(trimmedchars, *str)) {
|
||||
while (strchr(trimmedchars, *str)) {
|
||||
str++;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static char* rtrim(char *str, const char *trimmedchars) {
|
||||
static char *rtrim(char *str, const char *trimmedchars)
|
||||
{
|
||||
if (str[0] == 0) {
|
||||
return str;
|
||||
}
|
||||
char *end = str + strlen(str) - 1;
|
||||
while (strchr(trimmedchars, *end)) {
|
||||
*end = 0;
|
||||
if (end == str) break;
|
||||
if (end == str)
|
||||
break;
|
||||
end--;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static char* trim(char *str, const char *trimmedchars) {
|
||||
static char *trim(char *str, const char *trimmedchars)
|
||||
{
|
||||
return ltrim(rtrim(str, trimmedchars), trimmedchars);
|
||||
}
|
||||
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
static bool parse_weeklyschedule(
|
||||
char *str, BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
char *chunk, *comma, *space, *t, *v;
|
||||
int daynum = 0, tvnum = 0;
|
||||
@@ -2396,12 +2374,14 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
/*
|
||||
Format:
|
||||
|
||||
(1; Mon: [02:00:00.00 FALSE, 07:35:00.00 active, 07:40:00.00 inactive]; Tue: [02:00:00.00 inactive]; ...)
|
||||
(1; Mon: [02:00:00.00 FALSE, 07:35:00.00 active, 07:40:00.00 inactive];
|
||||
Tue: [02:00:00.00 inactive]; ...)
|
||||
|
||||
- the first number is the inner tag (e.g. 1 = boolean, 4 = real, 9 = enum)
|
||||
- Day name prefix is optional and ignored.
|
||||
- Entries are separated by semicolons.
|
||||
- There can be a full week, or only one entry - when using array index to modify a single day
|
||||
- There can be a full week, or only one entry - when using array index to
|
||||
modify a single day
|
||||
- time-value array can be empty: []
|
||||
*/
|
||||
|
||||
@@ -2410,7 +2390,9 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
// Parse the inner tag
|
||||
chunk = strtok(str, ";");
|
||||
chunk = ltrim(chunk, "(");
|
||||
if (false == bacapp_parse_application_data(BACNET_APPLICATION_TAG_UNSIGNED_INT, chunk, &dummy_value)) {
|
||||
if (false ==
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT, chunk, &dummy_value)) {
|
||||
// Try searching it by name
|
||||
if (false == bactext_application_tag_index(chunk, &inner_tag)) {
|
||||
return false;
|
||||
@@ -2421,7 +2403,7 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
|
||||
chunk = strtok(NULL, ";");
|
||||
|
||||
while(chunk != NULL) {
|
||||
while (chunk != NULL) {
|
||||
dsch = &value->type.Weekly_Schedule.weeklySchedule[daynum];
|
||||
|
||||
// Strip day name prefix, if present
|
||||
@@ -2455,18 +2437,22 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
|
||||
// Extract time and value
|
||||
t = chunk;
|
||||
// value starts one byte after the space, and there can be multiple spaces
|
||||
// value starts one byte after the space, and there can be
|
||||
// multiple spaces
|
||||
chunk = ltrim(space + 1, " ");
|
||||
v = chunk;
|
||||
|
||||
// Parse time
|
||||
if (false == bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, t, &dummy_value)) {
|
||||
if (false ==
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_TIME, t, &dummy_value)) {
|
||||
return false;
|
||||
}
|
||||
dsch->Time_Values[tvnum].Time = dummy_value.type.Time;
|
||||
|
||||
// Parse value
|
||||
if (false == bacapp_parse_application_data(inner_tag, v, &dummy_value)) {
|
||||
if (false ==
|
||||
bacapp_parse_application_data(inner_tag, v, &dummy_value)) {
|
||||
return false;
|
||||
}
|
||||
if (BACNET_STATUS_OK !=
|
||||
@@ -2570,7 +2556,7 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
int count = 0;
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
unsigned a[4] = { 0 }, p = 0;
|
||||
float x,y;
|
||||
float x, y;
|
||||
#endif
|
||||
|
||||
if (value && (tag_number != MAX_BACNET_APPLICATION_TAG)) {
|
||||
@@ -2579,9 +2565,11 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
switch (tag_number) {
|
||||
#if defined(BACAPP_BOOLEAN)
|
||||
case BACNET_APPLICATION_TAG_BOOLEAN:
|
||||
if (strcasecmp(argv, "true") == 0 || strcasecmp(argv, "active") == 0) {
|
||||
if (strcasecmp(argv, "true") == 0 ||
|
||||
strcasecmp(argv, "active") == 0) {
|
||||
value->type.Boolean = true;
|
||||
} else if (strcasecmp(argv, "false") == 0 || strcasecmp(argv, "inactive") == 0) {
|
||||
} else if (strcasecmp(argv, "false") == 0 ||
|
||||
strcasecmp(argv, "inactive") == 0) {
|
||||
value->type.Boolean = false;
|
||||
} else {
|
||||
status = strtol_checked(argv, &long_value);
|
||||
@@ -2611,10 +2599,11 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
#if defined(BACAPP_SIGNED)
|
||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||
status = strtol_checked(argv, &long_value);
|
||||
if (!status || long_value > INT32_MAX || long_value < INT32_MIN) {
|
||||
if (!status || long_value > INT32_MAX ||
|
||||
long_value < INT32_MIN) {
|
||||
return false;
|
||||
}
|
||||
value->type.Signed_Int = (int32_t) long_value;
|
||||
value->type.Signed_Int = (int32_t)long_value;
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_REAL)
|
||||
@@ -2658,7 +2647,7 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
if (!status || unsigned_long_value > UINT32_MAX) {
|
||||
return false;
|
||||
}
|
||||
value->type.Enumerated = (uint32_t) unsigned_long_value;
|
||||
value->type.Enumerated = (uint32_t)unsigned_long_value;
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
@@ -2713,14 +2702,13 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
/* FIXME: add parsing for lighting command */
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
count = sscanf(
|
||||
argv, "%f,%f", &x, &y);
|
||||
count = sscanf(argv, "%f,%f", &x, &y);
|
||||
if (count == 2) {
|
||||
value->type.XY_Color.x_coordinate = x;
|
||||
value->type.XY_Color.y_coordinate = y;
|
||||
@@ -2735,8 +2723,8 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
status = parse_weeklyschedule(argv, value);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
count = sscanf(argv, "%3u.%3u.%3u.%3u:%5u",
|
||||
&a[0], &a[1], &a[2], &a[3], &p);
|
||||
count = sscanf(argv, "%3u.%3u.%3u.%3u:%5u", &a[0], &a[1], &a[2],
|
||||
&a[3], &p);
|
||||
if ((count == 4) || (count == 5)) {
|
||||
uint8_t address[4];
|
||||
value->type.Host_Address.host_ip_address = true;
|
||||
@@ -2745,7 +2733,8 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
address[1] = (uint8_t)a[1];
|
||||
address[2] = (uint8_t)a[2];
|
||||
address[3] = (uint8_t)a[3];
|
||||
octetstring_init(&value->type.Host_Address.host.ip_address, address, 4);
|
||||
octetstring_init(
|
||||
&value->type.Host_Address.host.ip_address, address, 4);
|
||||
if (count == 4) {
|
||||
value->type.Host_Address.port = 0xBAC0U;
|
||||
} else {
|
||||
@@ -2928,7 +2917,7 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
&value->type.Bit_String, &test_value->type.Bit_String);
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
if (datetime_compare(&value->type.Date_Time,
|
||||
&test_value->type.Date_Time) == 0) {
|
||||
@@ -2941,8 +2930,8 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
status = xy_color_same(&value->type.XY_Color,
|
||||
&test_value->type.XY_Color);
|
||||
status = xy_color_same(
|
||||
&value->type.XY_Color, &test_value->type.XY_Color);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_COLOR_COMMAND:
|
||||
/* BACnetColorCommand */
|
||||
@@ -2951,12 +2940,13 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE:
|
||||
/* BACnetWeeklySchedule */
|
||||
status = bacnet_weeklyschedule_same(&value->type.Weekly_Schedule,
|
||||
status =
|
||||
bacnet_weeklyschedule_same(&value->type.Weekly_Schedule,
|
||||
&test_value->type.Weekly_Schedule);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
status = host_n_port_same(&value->type.Host_Address,
|
||||
&value->type.Host_Address);
|
||||
status = host_n_port_same(
|
||||
&value->type.Host_Address, &value->type.Host_Address);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
||||
+12
-17
@@ -691,8 +691,7 @@ int encode_application_boolean(uint8_t *apdu, bool boolean_value)
|
||||
} else {
|
||||
len_value = 0;
|
||||
}
|
||||
len =
|
||||
encode_tag(apdu, BACNET_APPLICATION_TAG_BOOLEAN, false, len_value);
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_BOOLEAN, false, len_value);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -1011,8 +1010,7 @@ int encode_context_bitstring(
|
||||
*
|
||||
* @return the number of apdu bytes consumed
|
||||
*/
|
||||
int decode_object_id_safe(
|
||||
uint8_t *apdu,
|
||||
int decode_object_id_safe(uint8_t *apdu,
|
||||
uint32_t len_value_type,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *instance)
|
||||
@@ -1025,8 +1023,8 @@ int decode_object_id_safe(
|
||||
if (apdu) {
|
||||
/* value is meaningless if apdu was NULL */
|
||||
if (object_type) {
|
||||
*object_type = (BACNET_OBJECT_TYPE)(
|
||||
((value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT));
|
||||
*object_type = (BACNET_OBJECT_TYPE)((
|
||||
(value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT));
|
||||
}
|
||||
if (instance) {
|
||||
*instance = (value & BACNET_MAX_INSTANCE);
|
||||
@@ -1049,9 +1047,7 @@ int decode_object_id_safe(
|
||||
* @return the number of apdu bytes consumed
|
||||
*/
|
||||
int decode_object_id(
|
||||
uint8_t *apdu,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *instance)
|
||||
uint8_t *apdu, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
|
||||
{
|
||||
const uint32_t len_value = 4;
|
||||
|
||||
@@ -1079,8 +1075,8 @@ int bacnet_object_id_decode(uint8_t *apdu,
|
||||
|
||||
len = decode_object_id_safe(NULL, len_value_type, object_type, instance);
|
||||
if (len <= apdu_len_max) {
|
||||
return decode_object_id_safe(apdu, len_value_type, object_type,
|
||||
instance);
|
||||
return decode_object_id_safe(
|
||||
apdu, len_value_type, object_type, instance);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1316,8 +1312,8 @@ int encode_application_octet_string(
|
||||
uint8_t *apdu_offset = NULL;
|
||||
|
||||
if (octet_string) {
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
false, octetstring_length(octet_string));
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_OCTET_STRING, false,
|
||||
octetstring_length(octet_string));
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[len];
|
||||
}
|
||||
@@ -1505,8 +1501,8 @@ int encode_application_character_string(
|
||||
uint8_t *apdu_offset = NULL;
|
||||
|
||||
len = encode_bacnet_character_string(NULL, char_string);
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_CHARACTER_STRING,
|
||||
false, (uint32_t)len);
|
||||
len = encode_tag(
|
||||
apdu, BACNET_APPLICATION_TAG_CHARACTER_STRING, false, (uint32_t)len);
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[len];
|
||||
}
|
||||
@@ -2980,8 +2976,7 @@ int encode_bacnet_address(uint8_t *apdu, BACNET_ADDRESS *destination)
|
||||
|
||||
if (destination) {
|
||||
/* network number */
|
||||
apdu_len +=
|
||||
encode_application_unsigned(apdu, destination->net);
|
||||
apdu_len += encode_application_unsigned(apdu, destination->net);
|
||||
/* encode mac address as an octet-string */
|
||||
if (destination->len != 0) {
|
||||
octetstring_init(&mac_addr, destination->adr, destination->len);
|
||||
|
||||
@@ -153,17 +153,14 @@ int bacapp_decode_device_obj_property_ref(
|
||||
uint32_t enumValue = 0;
|
||||
|
||||
/* object-identifier [0] BACnetObjectIdentifier */
|
||||
len =
|
||||
decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->objectIdentifier.type,
|
||||
&value->objectIdentifier.instance);
|
||||
len = decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->objectIdentifier.type, &value->objectIdentifier.instance);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
/* property-identifier [1] BACnetPropertyIdentifier */
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 1, &enumValue);
|
||||
len = decode_context_enumerated(&apdu[apdu_len], 1, &enumValue);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -172,8 +169,7 @@ int bacapp_decode_device_obj_property_ref(
|
||||
/* property-array-index [2] Unsigned OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2) &&
|
||||
!decode_is_closing_tag(&apdu[apdu_len])) {
|
||||
len = decode_context_unsigned(
|
||||
&apdu[apdu_len], 2, &value->arrayIndex);
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 2, &value->arrayIndex);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -210,8 +206,7 @@ int bacapp_decode_device_obj_property_ref(
|
||||
*
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_context_device_obj_property_ref(
|
||||
uint8_t *apdu,
|
||||
int bacapp_decode_context_device_obj_property_ref(uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value)
|
||||
{
|
||||
@@ -255,9 +250,7 @@ int bacapp_decode_context_device_obj_property_ref(
|
||||
* @return Bytes encoded or 0 on failure.
|
||||
*/
|
||||
int bacapp_encode_context_device_obj_ref(
|
||||
uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -291,8 +284,7 @@ int bacapp_encode_context_device_obj_ref(
|
||||
* @return Bytes encoded or 0 on failure.
|
||||
*/
|
||||
int bacapp_encode_device_obj_ref(
|
||||
uint8_t * apdu,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE * value)
|
||||
uint8_t *apdu, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -307,8 +299,7 @@ int bacapp_encode_device_obj_ref(
|
||||
apdu_len += len;
|
||||
}
|
||||
/* object-identifier [1] BACnetObjectIdentifier */
|
||||
len =
|
||||
encode_context_object_id(&apdu[apdu_len], 1,
|
||||
len = encode_context_object_id(&apdu[apdu_len], 1,
|
||||
value->objectIdentifier.type, value->objectIdentifier.instance);
|
||||
apdu_len += len;
|
||||
|
||||
@@ -330,8 +321,7 @@ int bacapp_encode_device_obj_ref(
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_device_obj_ref(
|
||||
uint8_t * apdu,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE * value)
|
||||
uint8_t *apdu, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -339,10 +329,8 @@ int bacapp_decode_device_obj_ref(
|
||||
/* device-identifier [0] BACnetObjectIdentifier OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0) &&
|
||||
!decode_is_closing_tag(&apdu[apdu_len])) {
|
||||
len =
|
||||
decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->deviceIdentifier.type,
|
||||
&value->deviceIdentifier.instance);
|
||||
len = decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->deviceIdentifier.type, &value->deviceIdentifier.instance);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -352,10 +340,8 @@ int bacapp_decode_device_obj_ref(
|
||||
value->deviceIdentifier.instance = BACNET_NO_DEV_ID;
|
||||
}
|
||||
/* object-identifier [1] BACnetObjectIdentifier */
|
||||
len =
|
||||
decode_context_object_id(&apdu[apdu_len], 1,
|
||||
&value->objectIdentifier.type,
|
||||
&value->objectIdentifier.instance);
|
||||
len = decode_context_object_id(&apdu[apdu_len], 1,
|
||||
&value->objectIdentifier.type, &value->objectIdentifier.instance);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -376,9 +362,7 @@ int bacapp_decode_device_obj_ref(
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_context_device_obj_ref(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE * value)
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
@@ -402,7 +386,6 @@ int bacapp_decode_context_device_obj_ref(
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Encode a BACnetObjectPropertyReference
|
||||
*
|
||||
@@ -418,8 +401,8 @@ int bacapp_decode_context_device_obj_ref(
|
||||
* @param reference - BACnetObjectPropertyReference
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bacapp_encode_obj_property_ref(uint8_t *apdu,
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE *reference)
|
||||
int bacapp_encode_obj_property_ref(
|
||||
uint8_t *apdu, BACNET_OBJECT_PROPERTY_REFERENCE *reference)
|
||||
{
|
||||
int len = 0;
|
||||
uint8_t *apdu_offset = NULL;
|
||||
@@ -547,9 +530,8 @@ int bacapp_decode_obj_property_ref(uint8_t *apdu,
|
||||
/* property-array-index [2] Unsigned OPTIONAL */
|
||||
if (apdu_len_max > apdu_len) {
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len = bacnet_unsigned_context_decode(
|
||||
&apdu[apdu_len], apdu_len_max - apdu_len, 2,
|
||||
&unsigned_value);
|
||||
len = bacnet_unsigned_context_decode(&apdu[apdu_len],
|
||||
apdu_len_max - apdu_len, 2, &unsigned_value);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (unsigned_value > UINT32_MAX) {
|
||||
@@ -580,11 +562,10 @@ int bacapp_decode_obj_property_ref(uint8_t *apdu,
|
||||
*
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_context_obj_property_ref(
|
||||
uint8_t * apdu,
|
||||
int bacapp_decode_context_obj_property_ref(uint8_t *apdu,
|
||||
uint16_t apdu_len_max,
|
||||
uint8_t tag_number,
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE * value)
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -597,8 +578,8 @@ int bacapp_decode_context_obj_property_ref(
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacapp_decode_obj_property_ref(&apdu[apdu_len],
|
||||
apdu_len_max - apdu_len, value);
|
||||
len = bacapp_decode_obj_property_ref(
|
||||
&apdu[apdu_len], apdu_len_max - apdu_len, value);
|
||||
if (len == 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
} else {
|
||||
|
||||
@@ -74,7 +74,6 @@ int decode_real(uint8_t *apdu, float *real_value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
+9
-10
@@ -48,8 +48,8 @@
|
||||
* emitting a warning, forcing Zephyr's sanitycheck() script to stop.
|
||||
* Until this is chased down, the definition is being provided here.
|
||||
*/
|
||||
#if __ZEPHYR__ && ! CONFIG_NATIVE_APPLICATION
|
||||
size_t strnlen (const char *, size_t);
|
||||
#if __ZEPHYR__ && !CONFIG_NATIVE_APPLICATION
|
||||
size_t strnlen(const char *, size_t);
|
||||
#endif
|
||||
|
||||
/** @file bacstr.c Manipulate Bit/Char/Octet Strings */
|
||||
@@ -58,7 +58,7 @@ size_t strnlen (const char *, size_t);
|
||||
#endif
|
||||
|
||||
/* check the limits of bitstring capacity */
|
||||
#if ((MAX_BITSTRING_BYTES * 8) > (UINT8_MAX+1))
|
||||
#if ((MAX_BITSTRING_BYTES * 8) > (UINT8_MAX + 1))
|
||||
#error "MAX_BITSTRING_BYTES cannot exceed 32!"
|
||||
#endif
|
||||
#if (((MAX_BITSTRING_BYTES * 8) > UINT8_MAX) && (UINT_MAX <= UINT8_MAX))
|
||||
@@ -231,9 +231,7 @@ bool bitstring_set_octet(
|
||||
* @return true on success or false on error.
|
||||
*/
|
||||
bool bitstring_set_bits_used(
|
||||
BACNET_BIT_STRING * bit_string,
|
||||
uint8_t bytes_used,
|
||||
uint8_t unused_bits)
|
||||
BACNET_BIT_STRING *bit_string, uint8_t bytes_used, uint8_t unused_bits)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -256,10 +254,10 @@ bool bitstring_set_bits_used(
|
||||
unsigned bitstring_bits_capacity(BACNET_BIT_STRING *bit_string)
|
||||
{
|
||||
if (bit_string) {
|
||||
if ((MAX_BITSTRING_BYTES * 8) <= (UINT8_MAX+1)) {
|
||||
if ((MAX_BITSTRING_BYTES * 8) <= (UINT8_MAX + 1)) {
|
||||
return (MAX_BITSTRING_BYTES * 8);
|
||||
} else {
|
||||
return (UINT8_MAX+1);
|
||||
return (UINT8_MAX + 1);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
@@ -500,7 +498,8 @@ bool characterstring_ansi_copy(
|
||||
size_t i; /* counter */
|
||||
|
||||
if (dest && src) {
|
||||
if ((src->encoding == CHARACTER_ANSI_X34) && (src->length < dest_max_len)) {
|
||||
if ((src->encoding == CHARACTER_ANSI_X34) &&
|
||||
(src->length < dest_max_len)) {
|
||||
for (i = 0; i < dest_max_len; i++) {
|
||||
if (i < src->length) {
|
||||
dest[i] = src->value[i];
|
||||
@@ -839,7 +838,7 @@ bool utf8_isvalid(const char *str, size_t length)
|
||||
return false;
|
||||
}
|
||||
/* Check characters. */
|
||||
pend = (unsigned char *) str + length;
|
||||
pend = (unsigned char *)str + length;
|
||||
for (p = (const unsigned char *)str; p < pend; p++) {
|
||||
c = *p;
|
||||
/* null in middle of string */
|
||||
|
||||
@@ -129,8 +129,8 @@ const char *bactext_unconfirmed_service_name(unsigned index)
|
||||
bacnet_unconfirmed_service_names, index, ASHRAE_Reserved_String);
|
||||
}
|
||||
|
||||
INDTEXT_DATA bacnet_application_tag_names[] = {
|
||||
{ BACNET_APPLICATION_TAG_NULL, "Null" },
|
||||
INDTEXT_DATA bacnet_application_tag_names[] = { { BACNET_APPLICATION_TAG_NULL,
|
||||
"Null" },
|
||||
{ BACNET_APPLICATION_TAG_BOOLEAN, "Boolean" },
|
||||
{ BACNET_APPLICATION_TAG_UNSIGNED_INT, "Unsigned Int" },
|
||||
{ BACNET_APPLICATION_TAG_SIGNED_INT, "Signed Int" },
|
||||
@@ -166,8 +166,7 @@ INDTEXT_DATA bacnet_application_tag_names[] = {
|
||||
{ BACNET_APPLICATION_TAG_READ_ACCESS_SPECIFICATION,
|
||||
"BACnetReadAccessSpecification" },
|
||||
{ BACNET_APPLICATION_TAG_LIGHTING_COMMAND, "BACnetLightingCommand" },
|
||||
{ BACNET_APPLICATION_TAG_HOST_N_PORT, "BACnetHostNPort" },
|
||||
{ 0, NULL } };
|
||||
{ BACNET_APPLICATION_TAG_HOST_N_PORT, "BACnetHostNPort" }, { 0, NULL } };
|
||||
|
||||
const char *bactext_application_tag_name(unsigned index)
|
||||
{
|
||||
@@ -744,8 +743,7 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
{ PROP_COLOR_COMMAND, "color-command" },
|
||||
{ PROP_HIGH_END_TRIM, "high-end-trim" },
|
||||
{ PROP_LOW_END_TRIM, "low-end-trim" },
|
||||
{ PROP_TRIM_FADE_TIME, "trim-fade-time" },
|
||||
{ 0, NULL }
|
||||
{ PROP_TRIM_FADE_TIME, "trim-fade-time" }, { 0, NULL }
|
||||
};
|
||||
|
||||
bool bactext_property_name_proprietary(unsigned index)
|
||||
|
||||
+33
-25
@@ -39,32 +39,33 @@
|
||||
#include "bacnet/bactimevalue.h"
|
||||
#include "bacnet/bacapp.h"
|
||||
|
||||
static bool is_data_value_schedule_compatible(uint8_t tag) {
|
||||
static bool is_data_value_schedule_compatible(uint8_t tag)
|
||||
{
|
||||
switch (tag) {
|
||||
/* Every member of the union must be listed here to allow decoding */
|
||||
case BACNET_APPLICATION_TAG_NULL:
|
||||
return true;
|
||||
#if defined (BACAPP_BOOLEAN)
|
||||
#if defined(BACAPP_BOOLEAN)
|
||||
case BACNET_APPLICATION_TAG_BOOLEAN:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_UNSIGNED)
|
||||
#if defined(BACAPP_UNSIGNED)
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_SIGNED)
|
||||
#if defined(BACAPP_SIGNED)
|
||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_REAL)
|
||||
#if defined(BACAPP_REAL)
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_DOUBLE)
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_ENUMERATED)
|
||||
#if defined(BACAPP_ENUMERATED)
|
||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||
return true;
|
||||
#endif
|
||||
@@ -102,7 +103,8 @@ int bacnet_time_value_encode(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_time_value(uint8_t *apdu, BACNET_TIME_VALUE *value) {
|
||||
int bacapp_encode_time_value(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
{
|
||||
return bacnet_time_value_encode(apdu, value);
|
||||
}
|
||||
|
||||
@@ -134,7 +136,8 @@ int bacnet_time_value_context_encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_time_value(uint8_t *apdu, uint8_t tag_number, BACNET_TIME_VALUE *value)
|
||||
int bacapp_encode_context_time_value(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_TIME_VALUE *value)
|
||||
{
|
||||
return bacnet_time_value_context_encode(apdu, tag_number, value);
|
||||
}
|
||||
@@ -156,8 +159,8 @@ int bacnet_application_to_primitive_data_value(
|
||||
|
||||
/** returns 0 if OK, -1 on error */
|
||||
int bacnet_primitive_to_application_data_value(
|
||||
struct BACnet_Application_Data_Value * dest,
|
||||
const struct BACnet_Primitive_Data_Value * src)
|
||||
struct BACnet_Application_Data_Value *dest,
|
||||
const struct BACnet_Primitive_Data_Value *src)
|
||||
{
|
||||
// make sure the value passed is valid
|
||||
if (!dest || !src) {
|
||||
@@ -169,19 +172,22 @@ int bacnet_primitive_to_application_data_value(
|
||||
return BACNET_STATUS_OK; /* OK */
|
||||
}
|
||||
|
||||
int bacnet_time_value_decode(uint8_t *apdu, int max_apdu_len, BACNET_TIME_VALUE *value)
|
||||
int bacnet_time_value_decode(
|
||||
uint8_t *apdu, int max_apdu_len, BACNET_TIME_VALUE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
BACNET_APPLICATION_DATA_VALUE full_data_value = { 0 };
|
||||
|
||||
len = bacnet_time_application_decode(&apdu[apdu_len], max_apdu_len, &value->Time);
|
||||
len = bacnet_time_application_decode(
|
||||
&apdu[apdu_len], max_apdu_len, &value->Time);
|
||||
if (len <= 0) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_decode_application_data(&apdu[apdu_len], max_apdu_len - apdu_len, &full_data_value);
|
||||
len = bacapp_decode_application_data(
|
||||
&apdu[apdu_len], max_apdu_len - apdu_len, &full_data_value);
|
||||
if (len <= 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -200,25 +206,31 @@ int bacapp_decode_time_value(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
return bacnet_time_value_decode(apdu, MAX_APDU, value);
|
||||
}
|
||||
|
||||
int bacnet_time_value_context_decode(uint8_t *apdu, int max_apdu_len, uint8_t tag_number, BACNET_TIME_VALUE *value)
|
||||
int bacnet_time_value_context_decode(uint8_t *apdu,
|
||||
int max_apdu_len,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if ((max_apdu_len - apdu_len) >= 1 && decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
if ((max_apdu_len - apdu_len) >= 1 &&
|
||||
decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len += 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = bacnet_time_value_decode(&apdu[apdu_len], max_apdu_len - apdu_len, value);
|
||||
len = bacnet_time_value_decode(
|
||||
&apdu[apdu_len], max_apdu_len - apdu_len, value);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((max_apdu_len - apdu_len) >= 1 && decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
if ((max_apdu_len - apdu_len) >= 1 &&
|
||||
decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len += 1;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -233,8 +245,7 @@ int bacapp_decode_context_time_value(
|
||||
return bacnet_time_value_context_decode(apdu, MAX_APDU, tag_number, value);
|
||||
}
|
||||
|
||||
int bacnet_time_values_context_decode(
|
||||
uint8_t * apdu,
|
||||
int bacnet_time_values_context_decode(uint8_t *apdu,
|
||||
const int max_apdu_len,
|
||||
const uint8_t tag_number,
|
||||
BACNET_TIME_VALUE *time_values,
|
||||
@@ -287,8 +298,7 @@ int bacnet_time_values_context_decode(
|
||||
}
|
||||
|
||||
/* Encodes a : [x] SEQUENCE OF BACnetTimeValue into a fixed-size buffer */
|
||||
int bacnet_time_values_context_encode(
|
||||
uint8_t * apdu,
|
||||
int bacnet_time_values_context_encode(uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE *time_values,
|
||||
unsigned int max_time_values)
|
||||
@@ -312,9 +322,7 @@ int bacnet_time_values_context_encode(
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
len =
|
||||
bacnet_time_value_encode(apdu_offset,
|
||||
&time_values[j]);
|
||||
len = bacnet_time_value_encode(apdu_offset, &time_values[j]);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
apdu_len += len;
|
||||
|
||||
@@ -784,8 +784,7 @@ int bvlc_bbmd_disabled_handler(BACNET_IP_ADDRESS *addr,
|
||||
npdu = &mtu[offset];
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: "
|
||||
debug_print_string("Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
debug_print_npdu(
|
||||
@@ -1105,14 +1104,13 @@ int bvlc_bbmd_enabled_handler(BACNET_IP_ADDRESS *addr,
|
||||
network layer. */
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: "
|
||||
debug_print_string("Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
(void)bbmd_fdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
(void)bbmd_bdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
debug_print_npdu("Original-Broadcast-NPDU",
|
||||
offset, npdu_len);
|
||||
debug_print_npdu(
|
||||
"Original-Broadcast-NPDU", offset, npdu_len);
|
||||
}
|
||||
} else {
|
||||
debug_print_string(
|
||||
@@ -1211,8 +1209,7 @@ int bvlc_register_with_bbmd(BACNET_IP_ADDRESS *bbmd_addr, uint16_t ttl_seconds)
|
||||
* 0 if no registration request is sent, or
|
||||
* -1 if registration fails.
|
||||
*/
|
||||
void bvlc_remote_bbmd_address(
|
||||
BACNET_IP_ADDRESS *bbmd_addr)
|
||||
void bvlc_remote_bbmd_address(BACNET_IP_ADDRESS *bbmd_addr)
|
||||
{
|
||||
bvlc_address_copy(bbmd_addr, &Remote_BBMD);
|
||||
}
|
||||
@@ -1222,8 +1219,7 @@ void bvlc_remote_bbmd_address(
|
||||
* Register Foreign Device
|
||||
* @return Lease time in seconds to use when registering.
|
||||
*/
|
||||
uint16_t bvlc_remote_bbmd_lifetime(
|
||||
void)
|
||||
uint16_t bvlc_remote_bbmd_lifetime(void)
|
||||
{
|
||||
return Remote_BBMD_TTL_Seconds;
|
||||
}
|
||||
|
||||
@@ -44,14 +44,13 @@
|
||||
#include "bacnet/basic/bbmd6/vmac.h"
|
||||
#include "bacnet/basic/bbmd6/h_bbmd6.h"
|
||||
|
||||
|
||||
static bool BVLC6_Debug;
|
||||
#if PRINT_ENABLED
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) \
|
||||
if (BVLC6_Debug) { \
|
||||
fprintf(stderr,__VA_ARGS__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
}
|
||||
#else
|
||||
@@ -740,8 +739,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
npdu = &mtu[offset];
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
PRINTF(
|
||||
"BIP6: Original-Broadcast-NPDU: "
|
||||
PRINTF("BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
}
|
||||
} else {
|
||||
@@ -766,8 +764,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
bvlc6_vmac_address_set(src, vmac_src);
|
||||
offset = header_len + (function_len - npdu_len);
|
||||
} else {
|
||||
PRINTF(
|
||||
"BIP6: Forwarded-NPDU: Unable to decode!\n");
|
||||
PRINTF("BIP6: Forwarded-NPDU: Unable to decode!\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -908,8 +905,7 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
network layer. */
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
PRINTF(
|
||||
"BIP6: Original-Broadcast-NPDU: "
|
||||
PRINTF("BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
/* Upon receipt of a BVLL Original-Broadcast-NPDU
|
||||
|
||||
@@ -49,7 +49,7 @@ static bool VMAC_Debug = false;
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) \
|
||||
if (VMAC_Debug) { \
|
||||
fprintf(stderr,__VA_ARGS__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -69,8 +69,8 @@ void npdu_network_number_set(uint16_t net)
|
||||
* @param status - 0=learned, 1=assigned
|
||||
* @return number of bytes sent
|
||||
*/
|
||||
int npdu_send_network_number_is(BACNET_ADDRESS *dst,
|
||||
uint16_t net, uint8_t status)
|
||||
int npdu_send_network_number_is(
|
||||
BACNET_ADDRESS *dst, uint16_t net, uint8_t status)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
int pdu_len = 0;
|
||||
@@ -84,13 +84,11 @@ int npdu_send_network_number_is(BACNET_ADDRESS *dst,
|
||||
transmit a local broadcast Network-Number-Is message
|
||||
back to the source device. */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_NETWORK_NUMBER_IS,
|
||||
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_NETWORK_NUMBER_IS,
|
||||
data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], dst,
|
||||
&my_address, &npdu_data);
|
||||
len = encode_unsigned16(
|
||||
&Handler_Transmit_Buffer[pdu_len], net);
|
||||
pdu_len = npdu_encode_pdu(
|
||||
&Handler_Transmit_Buffer[0], dst, &my_address, &npdu_data);
|
||||
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], net);
|
||||
pdu_len += len;
|
||||
Handler_Transmit_Buffer[pdu_len] = status;
|
||||
pdu_len++;
|
||||
@@ -120,17 +118,14 @@ int npdu_send_what_is_network_number(BACNET_ADDRESS *dst)
|
||||
datalink_get_broadcast_address(&daddr);
|
||||
}
|
||||
datalink_get_my_address(&saddr);
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER,
|
||||
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER,
|
||||
data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(
|
||||
&Handler_Transmit_Buffer[0],
|
||||
&daddr, &saddr, &npdu_data);
|
||||
&Handler_Transmit_Buffer[0], &daddr, &saddr, &npdu_data);
|
||||
|
||||
/* Now send the message */
|
||||
return datalink_send_pdu(
|
||||
dst, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
|
||||
}
|
||||
|
||||
/** @file h_npdu.c Handles messages at the NPDU level of the BACnet stack. */
|
||||
@@ -163,8 +158,8 @@ static void network_control_handler(BACNET_ADDRESS *src,
|
||||
case NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER:
|
||||
if (src->net == 0) {
|
||||
if (Local_Network_Number) {
|
||||
npdu_send_network_number_is(src, Local_Network_Number,
|
||||
Local_Network_Number_Status);
|
||||
npdu_send_network_number_is(
|
||||
src, Local_Network_Number, Local_Network_Number_Status);
|
||||
} else {
|
||||
/* Upon receipt of a What-Is-Network-Number message,
|
||||
a device that does not know the local network number
|
||||
@@ -225,9 +220,7 @@ static void network_control_handler(BACNET_ADDRESS *src,
|
||||
* @param pdu [in] Buffer containing the NPDU and APDU of the received packet.
|
||||
* @param pdu_len [in] The size of the received message in the pdu[] buffer.
|
||||
*/
|
||||
void npdu_handler(BACNET_ADDRESS *src,
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_len)
|
||||
void npdu_handler(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t pdu_len)
|
||||
{
|
||||
int apdu_offset = 0;
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
@@ -243,8 +236,8 @@ void npdu_handler(BACNET_ADDRESS *src,
|
||||
bacnet_npdu_decode(&pdu[0], pdu_len, &dest, src, &npdu_data);
|
||||
if (npdu_data.network_layer_message) {
|
||||
if ((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) {
|
||||
network_control_handler(src, &npdu_data,
|
||||
&pdu[apdu_offset], (uint16_t)(pdu_len - apdu_offset));
|
||||
network_control_handler(src, &npdu_data, &pdu[apdu_offset],
|
||||
(uint16_t)(pdu_len - apdu_offset));
|
||||
} else {
|
||||
debug_printf("NPDU: message for router. Discarded!\n");
|
||||
}
|
||||
|
||||
@@ -317,6 +317,5 @@ void Send_Network_Number_Is(BACNET_ADDRESS *dst, int dnet, int status)
|
||||
iArgs[0] = dnet;
|
||||
iArgs[1] = status;
|
||||
|
||||
Send_Network_Layer_Message(
|
||||
NETWORK_MESSAGE_NETWORK_NUMBER_IS, dst, iArgs);
|
||||
Send_Network_Layer_Message(NETWORK_MESSAGE_NETWORK_NUMBER_IS, dst, iArgs);
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ void Accumulator_Property_Lists(
|
||||
{
|
||||
if (pRequired) {
|
||||
*pRequired = Properties_Required;
|
||||
}
|
||||
}
|
||||
if (pOptional) {
|
||||
*pOptional = Properties_Optional;
|
||||
}
|
||||
}
|
||||
if (pProprietary) {
|
||||
*pProprietary = Properties_Proprietary;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ bool Accumulator_Valid_Instance(uint32_t object_instance)
|
||||
{
|
||||
if (object_instance < MAX_ACCUMULATORS) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ unsigned Accumulator_Instance_To_Index(uint32_t object_instance)
|
||||
|
||||
if (object_instance < MAX_ACCUMULATORS) {
|
||||
index = object_instance;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -342,8 +342,8 @@ bool Access_Credential_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
Access_Credential_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
ac_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
|
||||
@@ -462,8 +462,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_Door_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -482,8 +482,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
status = Access_Door_Present_Value_Relinquish(
|
||||
wp_data->object_instance, wp_data->priority);
|
||||
@@ -495,8 +495,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Access_Door_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -504,8 +504,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_DOOR_STATUS:
|
||||
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
ad_descr[object_index].door_status =
|
||||
(BACNET_DOOR_STATUS)value.type.Enumerated;
|
||||
@@ -517,8 +517,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_LOCK_STATUS:
|
||||
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
ad_descr[object_index].lock_status =
|
||||
(BACNET_LOCK_STATUS)value.type.Enumerated;
|
||||
@@ -530,8 +530,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_DOOR_ALARM_STATE:
|
||||
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
ad_descr[object_index].door_alarm_state =
|
||||
(BACNET_DOOR_ALARM_STATE)value.type.Enumerated;
|
||||
|
||||
@@ -308,8 +308,8 @@ bool Access_Rights_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_Rights_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
ar_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
|
||||
@@ -250,8 +250,8 @@ bool Access_User_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_User_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
au_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
@@ -276,4 +276,3 @@ bool Access_User_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -301,8 +301,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_Zone_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
az_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
@@ -310,8 +310,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_RELIABILITY:
|
||||
if (Access_Zone_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
az_descr[object_index].reliability =
|
||||
(BACNET_RELIABILITY)value.type.Enumerated;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -300,8 +300,8 @@ bool Analog_Input_Encode_Value_List(
|
||||
}
|
||||
out_of_service = AI_Descr[index].Out_Of_Service;
|
||||
present_value = AI_Descr[index].Present_Value;
|
||||
status = cov_value_list_encode_real(value_list, present_value,
|
||||
in_alarm, fault, overridden, out_of_service);
|
||||
status = cov_value_list_encode_real(value_list, present_value, in_alarm,
|
||||
fault, overridden, out_of_service);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -430,9 +430,8 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
break;
|
||||
|
||||
case PROP_EVENT_STATE:
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
Analog_Input_Event_State(rpdata->object_instance));
|
||||
apdu_len = encode_application_enumerated(
|
||||
&apdu[0], Analog_Input_Event_State(rpdata->object_instance));
|
||||
break;
|
||||
|
||||
case PROP_RELIABILITY:
|
||||
@@ -633,8 +632,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch ((int)wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (CurrentAI->Out_Of_Service == true) {
|
||||
Analog_Input_Present_Value_Set(
|
||||
@@ -648,8 +647,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Analog_Input_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -657,16 +656,16 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_UNITS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
CurrentAI->Units = value.type.Enumerated;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_COV_INCREMENT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (value.type.Real >= 0.0) {
|
||||
Analog_Input_COV_Increment_Set(
|
||||
@@ -681,8 +680,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_TIME_DELAY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAI->Time_Delay = value.type.Unsigned_Int;
|
||||
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
|
||||
@@ -690,40 +689,40 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFICATION_CLASS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAI->Notification_Class = value.type.Unsigned_Int;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_HIGH_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAI->High_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LOW_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAI->Low_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEADBAND:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAI->Deadband = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LIMIT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 2) {
|
||||
CurrentAI->Limit_Enable = value.type.Bit_String.value[0];
|
||||
@@ -736,8 +735,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_EVENT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentAI->Event_Enable = value.type.Bit_String.value[0];
|
||||
@@ -750,8 +749,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
switch ((BACNET_NOTIFY_TYPE)value.type.Enumerated) {
|
||||
case NOTIFY_EVENT:
|
||||
@@ -968,8 +967,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
break;
|
||||
} /* switch (ToState) */
|
||||
PRINTF("Analog-Input[%d]: Event_State goes from %s to %s.\n",
|
||||
object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
object_instance, bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
/* Notify Type */
|
||||
event_data.notifyType = CurrentAI->Notify_Type;
|
||||
@@ -1014,18 +1012,15 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
datetime_copy(&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL]);
|
||||
break;
|
||||
case EVENT_STATE_FAULT:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
datetime_copy(&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT]);
|
||||
break;
|
||||
case EVENT_STATE_NORMAL:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
datetime_copy(&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL]);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -425,8 +425,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -445,8 +445,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
status = Analog_Output_Present_Value_Relinquish(
|
||||
wp_data->object_instance, wp_data->priority);
|
||||
@@ -458,8 +458,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Analog_Output_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -382,8 +382,8 @@ bool Analog_Value_Encode_Value_List(
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, false);
|
||||
} else {
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, true);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, true);
|
||||
}
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, false);
|
||||
@@ -745,8 +745,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -772,24 +772,24 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentAV->Out_Of_Service = value.type.Boolean;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_UNITS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
CurrentAV->Units = value.type.Enumerated;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_COV_INCREMENT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (value.type.Real >= 0.0) {
|
||||
Analog_Value_COV_Increment_Set(
|
||||
@@ -804,8 +804,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_TIME_DELAY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAV->Time_Delay = value.type.Unsigned_Int;
|
||||
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
|
||||
@@ -813,40 +813,40 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFICATION_CLASS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAV->Notification_Class = value.type.Unsigned_Int;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_HIGH_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAV->High_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LOW_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAV->Low_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEADBAND:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAV->Deadband = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LIMIT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 2) {
|
||||
CurrentAV->Limit_Enable = value.type.Bit_String.value[0];
|
||||
@@ -859,8 +859,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_EVENT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentAV->Event_Enable = value.type.Bit_String.value[0];
|
||||
@@ -873,8 +873,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
switch ((BACNET_NOTIFY_TYPE)value.type.Enumerated) {
|
||||
case NOTIFY_EVENT:
|
||||
@@ -1097,8 +1097,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Event_State for (%s,%u) goes from %s to %s.\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_VALUE),
|
||||
(unsigned)object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
(unsigned)object_instance, bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
|
||||
@@ -309,8 +309,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
property shall be logical TRUE only if no changes have been
|
||||
made to the file data by internal processes or through File
|
||||
Access Services since the last time the object was archived. */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
if (value.type.Boolean) {
|
||||
/* FIXME: do something to wp_data->object_instance */
|
||||
@@ -323,8 +323,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* If the file size can be changed by writing to the file,
|
||||
and File_Access_Method is STREAM_ACCESS, then this property
|
||||
shall be writable. */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: do something with value.type.Unsigned
|
||||
to wp_data->object_instance */
|
||||
|
||||
@@ -429,8 +429,8 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated <= MAX_BINARY_PV) {
|
||||
Binary_Input_Present_Value_Set(wp_data->object_instance,
|
||||
@@ -443,16 +443,16 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Binary_Input_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
}
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated < MAX_POLARITY) {
|
||||
Binary_Input_Polarity_Set(wp_data->object_instance,
|
||||
|
||||
@@ -363,8 +363,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -396,8 +396,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
object_index = Binary_Output_Instance_To_Index(
|
||||
@@ -422,8 +422,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
object_index =
|
||||
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
||||
|
||||
@@ -457,8 +457,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -488,8 +488,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
priority = wp_data->priority;
|
||||
@@ -512,8 +512,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Binary_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -1513,8 +1513,8 @@ bool Channel_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
status = Channel_Present_Value_Set(wp_data, &value);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Channel_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -1531,16 +1531,16 @@ bool Channel_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
||||
break;
|
||||
case PROP_CHANNEL_NUMBER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
Channel_Number_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_CONTROL_GROUPS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (wp_data->array_index == 0) {
|
||||
/* Array element zero is the number of elements in the array
|
||||
|
||||
@@ -833,70 +833,57 @@ int Color_Temperature_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
encode_application_enumerated(&apdu[0], rpdata->object_type);
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Present_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(
|
||||
apdu, Color_Temperature_Present_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_MIN_PRES_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Min_Pres_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Min_Pres_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_MAX_PRES_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Max_Pres_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Max_Pres_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_TRACKING_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Tracking_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Tracking_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_COLOR_COMMAND:
|
||||
if (Color_Temperature_Command(rpdata->object_instance, &color_command)) {
|
||||
if (Color_Temperature_Command(
|
||||
rpdata->object_instance, &color_command)) {
|
||||
apdu_len = color_command_encode(apdu, &color_command);
|
||||
}
|
||||
break;
|
||||
case PROP_IN_PROGRESS:
|
||||
apdu_len =
|
||||
encode_application_enumerated(apdu,
|
||||
Color_Temperature_In_Progress(rpdata->object_instance));
|
||||
apdu_len = encode_application_enumerated(
|
||||
apdu, Color_Temperature_In_Progress(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_COLOR_TEMPERATURE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Color_Temperature(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_FADE_TIME:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Fade_Time(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_RAMP_RATE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Ramp_Rate(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_STEP_INCREMENT:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Step_Increment(rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Step_Increment(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
case PROP_TRANSITION:
|
||||
apdu_len =
|
||||
encode_application_enumerated(apdu,
|
||||
Color_Temperature_Transition(rpdata->object_instance));
|
||||
apdu_len = encode_application_enumerated(
|
||||
apdu, Color_Temperature_Transition(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DESCRIPTION:
|
||||
characterstring_init_ansi(
|
||||
&char_string, Color_Temperature_Description(rpdata->object_instance));
|
||||
apdu_len =
|
||||
encode_application_character_string(apdu, &char_string);
|
||||
characterstring_init_ansi(&char_string,
|
||||
Color_Temperature_Description(rpdata->object_instance));
|
||||
apdu_len = encode_application_character_string(apdu, &char_string);
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -195,8 +195,7 @@ int cl_decode_apdu(uint8_t *apdu,
|
||||
if (tag_number != 2) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len = decode_enumerated(
|
||||
&apdu[dec_len], len_value_type, &enum_value);
|
||||
len = decode_enumerated(&apdu[dec_len], len_value_type, &enum_value);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
@@ -783,8 +782,8 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch ((int)wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int >= MAX_COMMAND_ACTIONS) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -333,8 +333,8 @@ bool Credential_Data_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
case PROP_RELIABILITY:
|
||||
if (Credential_Data_Input_Out_Of_Service(
|
||||
wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
cdi_descr[object_index].reliability =
|
||||
(BACNET_RELIABILITY)value.type.Enumerated;
|
||||
|
||||
@@ -268,8 +268,7 @@ static void CharacterString_Value_Out_Of_Service_Set(
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @return the COV change flag status
|
||||
*/
|
||||
bool CharacterString_Value_Change_Of_Value(
|
||||
uint32_t object_instance)
|
||||
bool CharacterString_Value_Change_Of_Value(uint32_t object_instance)
|
||||
{
|
||||
bool changed = false;
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
@@ -286,8 +285,7 @@ bool CharacterString_Value_Change_Of_Value(
|
||||
* @brief Clear the COV change flag
|
||||
* @param object_instance - object-instance number of the object
|
||||
*/
|
||||
void CharacterString_Value_Change_Of_Value_Clear(
|
||||
uint32_t object_instance)
|
||||
void CharacterString_Value_Change_Of_Value_Clear(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
|
||||
@@ -298,14 +296,14 @@ void CharacterString_Value_Change_Of_Value_Clear(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief For a given object instance-number, loads the value_list with the COV data.
|
||||
* @brief For a given object instance-number, loads the value_list with the COV
|
||||
* data.
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param value_list - list of COV data
|
||||
* @return true if the value list is encoded
|
||||
*/
|
||||
bool CharacterString_Value_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list)
|
||||
uint32_t object_instance, BACNET_PROPERTY_VALUE *value_list)
|
||||
{
|
||||
bool status = false;
|
||||
const bool in_alarm = false;
|
||||
@@ -589,8 +587,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
if (status) {
|
||||
status = CharacterString_Value_Present_Value_Set(
|
||||
wp_data->object_instance, &value.type.Character_String);
|
||||
@@ -601,8 +599,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CharacterString_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -228,12 +228,11 @@ static object_functions_t My_Object_Table[] = {
|
||||
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
#endif
|
||||
#if (BACNET_PROTOCOL_REVISION >= 24)
|
||||
{ OBJECT_COLOR, Color_Init, Color_Count,
|
||||
Color_Index_To_Instance, Color_Valid_Instance,
|
||||
Color_Object_Name, Color_Read_Property,
|
||||
Color_Write_Property, Color_Property_Lists,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */,
|
||||
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
{ OBJECT_COLOR, Color_Init, Color_Count, Color_Index_To_Instance,
|
||||
Color_Valid_Instance, Color_Object_Name, Color_Read_Property,
|
||||
Color_Write_Property, Color_Property_Lists, NULL /* ReadRangeInfo */,
|
||||
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */,
|
||||
NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
{ OBJECT_COLOR_TEMPERATURE, Color_Temperature_Init, Color_Temperature_Count,
|
||||
Color_Temperature_Index_To_Instance, Color_Temperature_Valid_Instance,
|
||||
Color_Temperature_Object_Name, Color_Temperature_Read_Property,
|
||||
@@ -1353,8 +1352,7 @@ static int Read_Property_Common(
|
||||
}
|
||||
apdu = rpdata->application_data;
|
||||
if (property_list_common(rpdata->object_property)) {
|
||||
apdu_len = property_list_common_encode(rpdata,
|
||||
Object_Instance_Number);
|
||||
apdu_len = property_list_common_encode(rpdata, Object_Instance_Number);
|
||||
} else if (rpdata->object_property == PROP_OBJECT_NAME) {
|
||||
/* only array properties can have array options */
|
||||
if (rpdata->array_index != BACNET_ARRAY_ALL) {
|
||||
@@ -1374,9 +1372,8 @@ static int Read_Property_Common(
|
||||
} else if (rpdata->object_property == PROP_PROPERTY_LIST) {
|
||||
Device_Objects_Property_List(
|
||||
rpdata->object_type, rpdata->object_instance, &property_list);
|
||||
apdu_len = property_list_encode(rpdata,
|
||||
property_list.Required.pList, property_list.Optional.pList,
|
||||
property_list.Proprietary.pList);
|
||||
apdu_len = property_list_encode(rpdata, property_list.Required.pList,
|
||||
property_list.Optional.pList, property_list.Proprietary.pList);
|
||||
#endif
|
||||
} else if (pObject->Object_Read_Property) {
|
||||
apdu_len = pObject->Object_Read_Property(rpdata);
|
||||
@@ -1451,8 +1448,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(
|
||||
@@ -1467,32 +1464,32 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
apdu_retries_set((uint8_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_APDU_TIMEOUT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
apdu_timeout_set((uint16_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_VENDOR_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_Vendor_Identifier((uint16_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
result = Device_Set_System_Status(
|
||||
(BACNET_DEVICE_STATUS)value.type.Enumerated, false);
|
||||
@@ -1510,8 +1507,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_string_valid(wp_data, &value,
|
||||
characterstring_capacity(&My_Object_Name));
|
||||
status = write_property_string_valid(
|
||||
wp_data, &value, characterstring_capacity(&My_Object_Name));
|
||||
if (status) {
|
||||
/* All the object names in a device must be unique */
|
||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||
@@ -1531,8 +1528,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_LOCATION:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_LOC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_LOC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Location(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1541,8 +1538,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_DESC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_DESC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Description(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1550,8 +1547,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_MODEL_NAME:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_MOD_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_MOD_LEN);
|
||||
if (status) {
|
||||
Device_Set_Model_Name(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1560,8 +1557,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
#if defined(BACNET_TIME_MASTER)
|
||||
case PROP_TIME_SYNCHRONIZATION_INTERVAL:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int < 65535) {
|
||||
minutes = value.type.Unsigned_Int;
|
||||
@@ -1574,16 +1571,16 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_ALIGN_INTERVALS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Device_Align_Intervals_Set(value.type.Boolean);
|
||||
status = true;
|
||||
}
|
||||
break;
|
||||
case PROP_INTERVAL_OFFSET:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int < 65535) {
|
||||
minutes = value.type.Unsigned_Int;
|
||||
@@ -1604,8 +1601,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
#endif
|
||||
case PROP_UTC_OFFSET:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
if (status) {
|
||||
if ((value.type.Signed_Int < (12 * 60)) &&
|
||||
(value.type.Signed_Int > (-12 * 60))) {
|
||||
@@ -1619,8 +1616,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
#if defined(BACDL_MSTP)
|
||||
case PROP_MAX_INFO_FRAMES:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
dlmstp_set_max_info_frames(
|
||||
@@ -1633,8 +1630,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_MAX_MASTER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if ((value.type.Unsigned_Int > 0) &&
|
||||
(value.type.Unsigned_Int <= 127)) {
|
||||
|
||||
@@ -213,8 +213,7 @@ void routed_get_my_address(BACNET_ADDRESS *my_address)
|
||||
* meaning MAC broadcast, so it's an automatic match).
|
||||
* Else False if no match or invalid idx is given.
|
||||
*/
|
||||
bool Routed_Device_Address_Lookup(
|
||||
int idx, uint8_t dlen, uint8_t *dadr)
|
||||
bool Routed_Device_Address_Lookup(int idx, uint8_t dlen, uint8_t *dadr)
|
||||
{
|
||||
bool result = false;
|
||||
DEVICE_OBJECT_DATA *pDev = &Devices[idx];
|
||||
@@ -371,15 +370,12 @@ uint32_t Routed_Device_Index_To_Instance(unsigned index)
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @return index for the given instance-number, or 0 if not valid.
|
||||
*/
|
||||
static uint32_t Routed_Device_Instance_To_Index(
|
||||
uint32_t Instance_Number)
|
||||
static uint32_t Routed_Device_Instance_To_Index(uint32_t Instance_Number)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for ( i=0; i < MAX_NUM_DEVICES; i++) {
|
||||
if (Devices[i].bacObj.Object_Instance_Number == Instance_Number)
|
||||
{
|
||||
for (i = 0; i < MAX_NUM_DEVICES; i++) {
|
||||
if (Devices[i].bacObj.Object_Instance_Number == Instance_Number) {
|
||||
/* Found Instance, so return the Device Index Number */
|
||||
return i;
|
||||
}
|
||||
@@ -388,7 +384,6 @@ static uint32_t Routed_Device_Instance_To_Index(
|
||||
/* We did not find instance... so simply return an Index of 0
|
||||
All gateways will have at least a single root Device Object */
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,8 +487,8 @@ bool Routed_Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Routed_Device_Set_Object_Instance_Number(
|
||||
@@ -508,8 +503,8 @@ bool Routed_Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_string_valid(wp_data, &value,
|
||||
MAX_DEV_NAME_LEN);
|
||||
status =
|
||||
write_property_string_valid(wp_data, &value, MAX_DEV_NAME_LEN);
|
||||
if (status) {
|
||||
Routed_Device_Set_Object_Name(
|
||||
characterstring_encoding(&value.type.Character_String),
|
||||
|
||||
@@ -431,16 +431,16 @@ bool Integer_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
if (status) {
|
||||
Integer_Value_Present_Value_Set(wp_data->object_instance,
|
||||
value.type.Signed_Int, wp_data->priority);
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Integer_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -909,7 +909,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len, &value,
|
||||
PROP_REQUESTED_SHED_LEVEL);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point D\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point D\n");
|
||||
/* error! */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
@@ -935,7 +936,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
value.type.Real;
|
||||
status = true;
|
||||
} else {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point E\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point E\n");
|
||||
/* error! */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
@@ -946,10 +948,11 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_START_TIME:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_DATE);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
|
||||
if (!status) {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point F\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point F\n");
|
||||
/* don't continue if we don't have a valid date */
|
||||
break;
|
||||
}
|
||||
@@ -959,8 +962,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
bacapp_decode_application_data(wp_data->application_data + len,
|
||||
wp_data->application_data_len - len, &value);
|
||||
if (len) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_TIME);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
|
||||
if (status) {
|
||||
/* Write time and date and set written flag */
|
||||
Start_Time[object_index].date = start_date;
|
||||
@@ -968,7 +971,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
Start_Time_Property_Written[object_index] = true;
|
||||
}
|
||||
} else {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point G\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point G\n");
|
||||
status = false;
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
@@ -976,19 +980,20 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_SHED_DURATION:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
Shed_Duration[object_index] = value.type.Unsigned_Int;
|
||||
Load_Control_Request_Written[object_index] = true;
|
||||
} else {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point H\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point H\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DUTY_WINDOW:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
Duty_Window[object_index] = value.type.Unsigned_Int;
|
||||
Load_Control_Request_Written[object_index] = true;
|
||||
@@ -996,8 +1001,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_SHED_LEVELS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* re-write the size of the array? */
|
||||
if (wp_data->array_index == 0) {
|
||||
@@ -1020,8 +1025,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Load_Control_Enable[object_index] = value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -1111,8 +1111,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -1131,8 +1131,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
if (wp_data->priority == 6) {
|
||||
/* Command priority 6 is reserved for use by Minimum
|
||||
@@ -1154,8 +1154,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_LIGHTING_COMMAND:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
|
||||
if (status) {
|
||||
status = Lighting_Output_Lighting_Command_Set(
|
||||
wp_data->object_instance, &value.type.Lighting_Command);
|
||||
@@ -1166,8 +1166,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Lighting_Output_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -322,8 +322,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_MODE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
|
||||
object_index = Life_Safety_Point_Instance_To_Index(
|
||||
@@ -338,8 +338,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
object_index = Life_Safety_Point_Instance_To_Index(
|
||||
wp_data->object_instance);
|
||||
|
||||
@@ -603,8 +603,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
if (status) {
|
||||
/* All the object names in a device must be unique */
|
||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||
@@ -626,8 +626,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_DESCRIPTION:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
if (status) {
|
||||
status = Multistate_Input_Description_Write(
|
||||
wp_data->object_instance, &value.type.Character_String,
|
||||
@@ -635,8 +635,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
status = Multistate_Input_Present_Value_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
@@ -647,8 +647,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Multistate_Input_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -675,8 +675,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
if (element_len) {
|
||||
status = Multistate_Input_State_Text_Write(
|
||||
wp_data->object_instance, array_index,
|
||||
&value.type.Character_String,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
&value.type.Character_String, &wp_data->error_class,
|
||||
&wp_data->error_code);
|
||||
}
|
||||
max_states--;
|
||||
array_index++;
|
||||
@@ -686,8 +686,7 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len - len, &value);
|
||||
if (element_len < 0) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
break;
|
||||
}
|
||||
len += element_len;
|
||||
|
||||
@@ -375,8 +375,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -410,8 +410,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
level = MULTISTATE_NULL;
|
||||
object_index = Multistate_Output_Instance_To_Index(
|
||||
@@ -437,8 +437,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Multistate_Output_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -538,8 +538,8 @@ bool Multistate_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
status = Multistate_Value_Present_Value_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
@@ -550,8 +550,8 @@ bool Multistate_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Multistate_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -101,7 +101,7 @@ void Notification_Class_Init(void)
|
||||
255; /* PRINTF lowest priority for Normal message. */
|
||||
/* configure for every day, all day long */
|
||||
for (i = 0; i < MAX_BACNET_DAYS_OF_WEEK; i++) {
|
||||
NC_Info[NotifyIdx].Recipient_List->ValidDays |= (1<<i);
|
||||
NC_Info[NotifyIdx].Recipient_List->ValidDays |= (1 << i);
|
||||
}
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.hour = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.min = 0;
|
||||
@@ -112,8 +112,7 @@ void Notification_Class_Init(void)
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.sec = 59;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.hundredths = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->Transitions =
|
||||
TRANSITION_TO_OFFNORMAL_MASKED |
|
||||
TRANSITION_TO_FAULT_MASKED |
|
||||
TRANSITION_TO_OFFNORMAL_MASKED | TRANSITION_TO_FAULT_MASKED |
|
||||
TRANSITION_TO_NORMAL_MASKED;
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
@@ -418,8 +417,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRIORITY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (wp_data->array_index == 0) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -471,8 +470,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_ACK_REQUIRED:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentNotify->Ack_Required =
|
||||
|
||||
@@ -613,8 +613,8 @@ bool Network_Port_MAC_Address(
|
||||
memcpy(
|
||||
&ip_mac[0], &Object_List[index].Network.IPv4.IP_Address, 4);
|
||||
/* convert port from host-byte-order to network-byte-order */
|
||||
encode_unsigned16(&ip_mac[4],
|
||||
Object_List[index].Network.IPv4.Port);
|
||||
encode_unsigned16(
|
||||
&ip_mac[4], Object_List[index].Network.IPv4.Port);
|
||||
mac = &ip_mac[0];
|
||||
mac_len = sizeof(ip_mac);
|
||||
break;
|
||||
@@ -1326,9 +1326,7 @@ void *Network_Port_BBMD_BD_Table(uint32_t object_instance)
|
||||
* @return true if the Broadcast Distribution Table linked list head
|
||||
* property value was set
|
||||
*/
|
||||
bool Network_Port_BBMD_BD_Table_Set(
|
||||
uint32_t object_instance,
|
||||
void *bdt_head)
|
||||
bool Network_Port_BBMD_BD_Table_Set(uint32_t object_instance, void *bdt_head)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -1379,9 +1377,7 @@ void *Network_Port_BBMD_FD_Table(uint32_t object_instance)
|
||||
*
|
||||
* @return true if the BBMD-Accept-FD-Registrations property value was set
|
||||
*/
|
||||
bool Network_Port_BBMD_FD_Table_Set(
|
||||
uint32_t object_instance,
|
||||
void *fdt_head)
|
||||
bool Network_Port_BBMD_FD_Table_Set(uint32_t object_instance, void *fdt_head)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -1449,8 +1445,7 @@ static bool Network_Port_Remote_BBMD_IP_Address_And_Port(
|
||||
* @return true if ip-address was retrieved
|
||||
*/
|
||||
bool Network_Port_Remote_BBMD_IP_Address(
|
||||
uint32_t object_instance,
|
||||
uint8_t *a, uint8_t *b, uint8_t *c, uint8_t *d)
|
||||
uint32_t object_instance, uint8_t *a, uint8_t *b, uint8_t *c, uint8_t *d)
|
||||
{
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
bool status = false;
|
||||
@@ -1539,8 +1534,8 @@ uint16_t Network_Port_Remote_BBMD_BIP_Port(uint32_t object_instance)
|
||||
*
|
||||
* @return true if values are within range and property is set.
|
||||
*/
|
||||
bool Network_Port_Remote_BBMD_BIP_Port_Set(uint32_t object_instance,
|
||||
uint16_t value)
|
||||
bool Network_Port_Remote_BBMD_BIP_Port_Set(
|
||||
uint32_t object_instance, uint16_t value)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -1591,8 +1586,8 @@ uint16_t Network_Port_Remote_BBMD_BIP_Lifetime(uint32_t object_instance)
|
||||
*
|
||||
* @return true if values are within range and property is set.
|
||||
*/
|
||||
bool Network_Port_Remote_BBMD_BIP_Lifetime_Set(uint32_t object_instance,
|
||||
uint16_t value)
|
||||
bool Network_Port_Remote_BBMD_BIP_Lifetime_Set(
|
||||
uint32_t object_instance, uint16_t value)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -2357,13 +2352,12 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
case PROP_FD_BBMD_ADDRESS:
|
||||
Network_Port_Remote_BBMD_IP_Address_And_Port(
|
||||
rpdata->object_instance, &ip_address);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(&apdu[0],
|
||||
apdu_size, &ip_address);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(
|
||||
&apdu[0], apdu_size, &ip_address);
|
||||
break;
|
||||
case PROP_FD_SUBSCRIPTION_LIFETIME:
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0], Network_Port_Remote_BBMD_BIP_Lifetime(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
Network_Port_Remote_BBMD_BIP_Lifetime(rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
case PROP_BACNET_IPV6_MODE:
|
||||
@@ -2497,8 +2491,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_MAX_MASTER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
status = Network_Port_MSTP_Max_Master_Set(
|
||||
@@ -2514,8 +2508,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_MAX_INFO_FRAMES:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
status = Network_Port_MSTP_Max_Info_Frames_Set(
|
||||
|
||||
@@ -303,8 +303,8 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OCTET_STRING);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -327,8 +327,8 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentAV->Out_Of_Service = value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -309,8 +309,8 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -333,8 +333,8 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentAV->Out_Of_Service = value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ void Schedule_Init(void)
|
||||
for (j = 0; j < 7; j++) {
|
||||
psched->Weekly_Schedule[j].TV_Count = 0;
|
||||
}
|
||||
memcpy(&psched->Present_Value, &psched->Schedule_Default, sizeof(psched->Present_Value));
|
||||
memcpy(&psched->Present_Value, &psched->Schedule_Default,
|
||||
sizeof(psched->Present_Value));
|
||||
psched->Schedule_Default.context_specific = false;
|
||||
psched->Schedule_Default.tag = BACNET_APPLICATION_TAG_REAL;
|
||||
psched->Schedule_Default.type.Real = 21.0f; /* 21 C, room temperature */
|
||||
@@ -347,8 +348,8 @@ bool Schedule_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
suitable time for
|
||||
review by all interested parties. Say 6 months -> September
|
||||
2016 */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Schedule_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -421,6 +422,7 @@ void Schedule_Recalculate_PV(
|
||||
}
|
||||
|
||||
if (desc->Present_Value.tag == BACNET_APPLICATION_TAG_NULL) {
|
||||
memcpy(&desc->Present_Value, &desc->Schedule_Default, sizeof(desc->Present_Value));
|
||||
memcpy(&desc->Present_Value, &desc->Schedule_Default,
|
||||
sizeof(desc->Present_Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,8 +458,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
/* Section 12.25.5 can't enable a full log with stop when full
|
||||
* set */
|
||||
@@ -500,8 +500,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_STOP_WHEN_FULL:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
/* Only trigger this on a change of state */
|
||||
if (CurrentLog->bStopWhenFull != value.type.Boolean) {
|
||||
@@ -532,8 +532,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_RECORD_COUNT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int == 0) {
|
||||
/* Time to clear down the log */
|
||||
@@ -549,8 +549,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* logic
|
||||
* triggered and polled options.
|
||||
*/
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated != LOGGING_TYPE_COV) {
|
||||
CurrentLog->LoggingType =
|
||||
@@ -579,8 +579,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
case PROP_START_TIME:
|
||||
/* Copy the date part to safe place */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_DATE);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
@@ -591,8 +591,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len - len, &value);
|
||||
|
||||
if (len) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_TIME);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
@@ -630,8 +630,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
case PROP_STOP_TIME:
|
||||
/* Copy the date part to safe place */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_DATE);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
@@ -642,8 +642,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len - len, &value);
|
||||
|
||||
if (len) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_TIME);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
@@ -720,8 +720,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
}
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if ((CurrentLog->LoggingType == LOGGING_TYPE_POLLED) &&
|
||||
(value.type.Unsigned_Int == 0)) {
|
||||
@@ -745,8 +745,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_ALIGN_INTERVALS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentLog->bAlignIntervals = value.type.Boolean;
|
||||
}
|
||||
@@ -755,16 +755,16 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
case PROP_INTERVAL_OFFSET:
|
||||
/* We only log to 1 sec accuracy so must divide by 100 before
|
||||
* passing it on */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentLog->ulIntervalOffset = value.type.Unsigned_Int / 100;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_TRIGGER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
/* We will not allow triggered operation if polling with
|
||||
* aligning to the clock as that will produce non aligned
|
||||
|
||||
@@ -342,8 +342,7 @@ bool apdu_complex_error(uint8_t service_choice)
|
||||
* handling.
|
||||
*/
|
||||
void apdu_set_error_handler(
|
||||
BACNET_CONFIRMED_SERVICE service_choice,
|
||||
error_function pFunction)
|
||||
BACNET_CONFIRMED_SERVICE service_choice, error_function pFunction)
|
||||
{
|
||||
if ((service_choice < MAX_BACNET_CONFIRMED_SERVICE) &&
|
||||
(!apdu_complex_error(service_choice))) {
|
||||
@@ -359,8 +358,7 @@ void apdu_set_error_handler(
|
||||
* handling.
|
||||
*/
|
||||
void apdu_set_complex_error_handler(
|
||||
BACNET_CONFIRMED_SERVICE service_choice,
|
||||
complex_error_function pFunction)
|
||||
BACNET_CONFIRMED_SERVICE service_choice, complex_error_function pFunction)
|
||||
{
|
||||
if (apdu_complex_error(service_choice)) {
|
||||
Error_Function[service_choice].complex = pFunction;
|
||||
@@ -556,9 +554,9 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
/* PDU Type */
|
||||
switch (apdu[0] & 0xF0) {
|
||||
case PDU_TYPE_CONFIRMED_SERVICE_REQUEST:
|
||||
len = apdu_decode_confirmed_service_request(
|
||||
&apdu[0], apdu_len, &service_data, &service_choice,
|
||||
&service_request, &service_request_len);
|
||||
len = apdu_decode_confirmed_service_request(&apdu[0], apdu_len,
|
||||
&service_data, &service_choice, &service_request,
|
||||
&service_request_len);
|
||||
if (len == 0) {
|
||||
/* service data unable to be decoded - simply drop */
|
||||
break;
|
||||
@@ -672,8 +670,8 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
case SERVICE_CONFIRMED_VT_DATA:
|
||||
/* Security Services */
|
||||
case SERVICE_CONFIRMED_AUTHENTICATE:
|
||||
if (Confirmed_ACK_Function[service_choice].complex !=
|
||||
NULL) {
|
||||
if (Confirmed_ACK_Function[service_choice]
|
||||
.complex != NULL) {
|
||||
Confirmed_ACK_Function[service_choice].complex(
|
||||
service_request, service_request_len, src,
|
||||
&service_ack_data);
|
||||
@@ -697,16 +695,15 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
if (apdu_complex_error(service_choice)) {
|
||||
if (Error_Function[service_choice].complex) {
|
||||
Error_Function[service_choice].complex(src,
|
||||
invoke_id, service_choice,
|
||||
&apdu[3], apdu_len - 3);
|
||||
invoke_id, service_choice, &apdu[3],
|
||||
apdu_len - 3);
|
||||
}
|
||||
} else if (service_choice < MAX_BACNET_CONFIRMED_SERVICE) {
|
||||
len = bacerror_decode_error_class_and_code(&apdu[3],
|
||||
apdu_len - 3, &error_class, &error_code);
|
||||
len = bacerror_decode_error_class_and_code(
|
||||
&apdu[3], apdu_len - 3, &error_class, &error_code);
|
||||
if ((len != 0) &&
|
||||
(Error_Function[service_choice].error)) {
|
||||
Error_Function[service_choice].error(src,
|
||||
invoke_id,
|
||||
Error_Function[service_choice].error(src, invoke_id,
|
||||
(BACNET_ERROR_CLASS)error_class,
|
||||
(BACNET_ERROR_CODE)error_code);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
/** @file h_ccov.c Handles Confirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -60,8 +60,7 @@ static BACNET_COV_NOTIFICATION Confirmed_COV_Notification_Head;
|
||||
* @brief call the COV notification callbacks
|
||||
* @param cov_data - data decoded from the COV notification
|
||||
*/
|
||||
static void handler_ccov_notification_callback(
|
||||
BACNET_COV_DATA *cov_data)
|
||||
static void handler_ccov_notification_callback(BACNET_COV_DATA *cov_data)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -78,8 +77,7 @@ static void handler_ccov_notification_callback(
|
||||
* @brief Add a Confirmed COV notification callback
|
||||
* @param cb - COV notification callback to be added
|
||||
*/
|
||||
void handler_ccov_notification_add(
|
||||
BACNET_COV_NOTIFICATION *cb)
|
||||
void handler_ccov_notification_add(BACNET_COV_NOTIFICATION *cb)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -161,8 +159,7 @@ void handler_ccov_notification(uint8_t *service_request,
|
||||
PRINTF("%s ",
|
||||
bactext_property_name(pProperty_value->propertyIdentifier));
|
||||
} else {
|
||||
PRINTF("proprietary %u ",
|
||||
pProperty_value->propertyIdentifier);
|
||||
PRINTF("proprietary %u ", pProperty_value->propertyIdentifier);
|
||||
}
|
||||
if (pProperty_value->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
PRINTF("%u ", pProperty_value->propertyArrayIndex);
|
||||
|
||||
@@ -149,8 +149,7 @@ void handler_device_communication_control(uint8_t *service_request,
|
||||
#endif
|
||||
} else if (len == BACNET_STATUS_REJECT) {
|
||||
len = reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
REJECT_REASON_PARAMETER_OUT_OF_RANGE);
|
||||
service_data->invoke_id, REJECT_REASON_PARAMETER_OUT_OF_RANGE);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "DCC: Sending Reject!\n");
|
||||
#endif
|
||||
|
||||
@@ -92,9 +92,9 @@ void handler_read_property(uint8_t *service_request,
|
||||
if (npdu_len <= 0) {
|
||||
/* If 0 or negative, there were problems with the data or encoding. */
|
||||
len = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: npdu_encode_pdu error. Sending Abort!\n");
|
||||
#endif
|
||||
#endif
|
||||
} else if (service_data->segmented_message) {
|
||||
/* we don't support segmentation - send an abort */
|
||||
len = BACNET_STATUS_ABORT;
|
||||
@@ -103,17 +103,17 @@ void handler_read_property(uint8_t *service_request,
|
||||
#endif
|
||||
} else {
|
||||
len = rp_decode_service_request(service_request, service_len, &rpdata);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
if (len <= 0) {
|
||||
fprintf(stderr, "RP: Unable to decode Request!\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (len < 0) {
|
||||
/* bad decoding - skip to error/reject/abort handling */
|
||||
error = true;
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Bad Encoding.\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
/* When the object-type in the Object Identifier parameter
|
||||
contains the value DEVICE and the instance in the 'Object
|
||||
@@ -140,9 +140,9 @@ void handler_read_property(uint8_t *service_request,
|
||||
rpdata.object_instance = Network_Port_Index_To_Instance(0);
|
||||
}
|
||||
#endif
|
||||
apdu_len = rp_ack_encode_apdu_init(
|
||||
&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
|
||||
&rpdata);
|
||||
apdu_len =
|
||||
rp_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id, &rpdata);
|
||||
/* configure our storage */
|
||||
rpdata.application_data =
|
||||
&Handler_Transmit_Buffer[npdu_len + apdu_len];
|
||||
@@ -157,21 +157,22 @@ void handler_read_property(uint8_t *service_request,
|
||||
if (apdu_len > service_data->max_resp) {
|
||||
/* too big for the sender - send an abort!
|
||||
Setting of error code needed here as read property
|
||||
processing may have overridden the default set at start */
|
||||
processing may have overridden the default set at start
|
||||
*/
|
||||
rpdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
len = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Message too large.\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Sending Ack!\n");
|
||||
#endif
|
||||
#endif
|
||||
error = false;
|
||||
}
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Device_Read_Property: ");
|
||||
if (len == BACNET_STATUS_ABORT) {
|
||||
fprintf(stderr, "Abort!\n");
|
||||
@@ -182,7 +183,7 @@ void handler_read_property(uint8_t *service_request,
|
||||
} else {
|
||||
fprintf(stderr, "Unknown Len=%d\n", len);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout,__VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
@@ -73,9 +73,9 @@ void rp_ack_print_data(BACNET_READ_PROPERTY_DATA *data)
|
||||
/* FIXME: what if application_data_len is bigger than 255? */
|
||||
/* value? need to loop until all of the len is gone... */
|
||||
for (;;) {
|
||||
len = bacapp_decode_known_property(
|
||||
application_data, (unsigned)application_data_len, &value,
|
||||
data->object_type, data->object_property);
|
||||
len = bacapp_decode_known_property(application_data,
|
||||
(unsigned)application_data_len, &value, data->object_type,
|
||||
data->object_property);
|
||||
|
||||
if (len < 0) {
|
||||
PRINTF_ERR("RP Ack: unable to decode! %s:%s\n",
|
||||
|
||||
@@ -287,7 +287,8 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that both loops will */
|
||||
break; /* The berror flag ensures that both loops will
|
||||
*/
|
||||
/* be broken! */
|
||||
}
|
||||
decode_len += len;
|
||||
@@ -379,7 +380,8 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that */
|
||||
break; /* The berror flag ensures that
|
||||
*/
|
||||
/* both loops will be broken! */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout,__VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
@@ -124,9 +124,8 @@ int rpm_ack_decode_service_request(
|
||||
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||
rpm_property->value = value;
|
||||
while (value && (apdu_len > 0)) {
|
||||
len = bacapp_decode_known_property(
|
||||
apdu, (unsigned)apdu_len, value,
|
||||
rpm_object->object_type,
|
||||
len = bacapp_decode_known_property(apdu, (unsigned)apdu_len,
|
||||
value, rpm_object->object_type,
|
||||
rpm_property->propertyIdentifier);
|
||||
/* If len == 0 then it's an empty structure, which is OK. */
|
||||
if (len < 0) {
|
||||
@@ -155,7 +154,8 @@ int rpm_ack_decode_service_request(
|
||||
PRINTF_ERR("RPM Ack: decoded %s:%s len=%d\n",
|
||||
bactext_object_type_name(rpm_object->object_type),
|
||||
bactext_property_name(
|
||||
rpm_property->propertyIdentifier), len);
|
||||
rpm_property->propertyIdentifier),
|
||||
len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,8 +225,7 @@ void rpm_ack_print_data(BACNET_READ_ACCESS_DATA *rpm_data)
|
||||
bool array_value = false;
|
||||
|
||||
if (rpm_data) {
|
||||
PRINTF("%s #%lu\r\n",
|
||||
bactext_object_type_name(rpm_data->object_type),
|
||||
PRINTF("%s #%lu\r\n", bactext_object_type_name(rpm_data->object_type),
|
||||
(unsigned long)rpm_data->object_instance);
|
||||
PRINTF("{\r\n");
|
||||
listOfProperties = rpm_data->listOfProperties;
|
||||
|
||||
@@ -153,17 +153,17 @@ void handler_read_range(uint8_t *service_request,
|
||||
} else {
|
||||
memset(&data, 0, sizeof(data)); /* start with blank canvas */
|
||||
len = rr_decode_service_request(service_request, service_len, &data);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
if (len <= 0)
|
||||
fprintf(stderr, "RR: Unable to decode Request!\n");
|
||||
#endif
|
||||
#endif
|
||||
if (len < 0) {
|
||||
/* bad decoding - send an abort */
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER, true);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Bad Encoding. Sending Abort!\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
/* assume that there is an error */
|
||||
error = true;
|
||||
@@ -173,29 +173,31 @@ void handler_read_range(uint8_t *service_request,
|
||||
data.application_data = &Temp_Buf[0];
|
||||
data.application_data_len = len;
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
len = rr_ack_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, &data);
|
||||
#if PRINT_ENABLED
|
||||
len = rr_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, &data);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Sending Ack!\n");
|
||||
#endif
|
||||
#endif
|
||||
error = false;
|
||||
}
|
||||
if (error) {
|
||||
if (len == -2) {
|
||||
/* BACnet APDU too small to fit data, so proper response is Abort */
|
||||
/* BACnet APDU too small to fit data, so proper response is
|
||||
* Abort */
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Reply too big to fit into APDU!\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
len = bacerror_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_READ_RANGE,
|
||||
data.error_class, data.error_code);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Sending Error!\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
/** @file h_ucov.c Handles Unconfirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -57,8 +57,7 @@ static BACNET_COV_NOTIFICATION Unconfirmed_COV_Notification_Head;
|
||||
* @brief call the COV notification callbacks
|
||||
* @param cov_data - data decoded from the COV notification
|
||||
*/
|
||||
static void handler_ucov_notification_callback(
|
||||
BACNET_COV_DATA *cov_data)
|
||||
static void handler_ucov_notification_callback(BACNET_COV_DATA *cov_data)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -75,8 +74,7 @@ static void handler_ucov_notification_callback(
|
||||
* @brief Add a Confirmed COV notification callback
|
||||
* @param cb - COV notification callback to be added
|
||||
*/
|
||||
void handler_ucov_notification_add(
|
||||
BACNET_COV_NOTIFICATION *cb)
|
||||
void handler_ucov_notification_add(BACNET_COV_NOTIFICATION *cb)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -122,8 +120,7 @@ void handler_ucov_notification(
|
||||
cov_data.listOfValues = &property_value[0];
|
||||
PRINTF("UCOV: Received Notification!\n");
|
||||
/* decode the service request only */
|
||||
len =
|
||||
cov_notify_decode_service_request(
|
||||
len = cov_notify_decode_service_request(
|
||||
service_request, service_len, &cov_data);
|
||||
if (len > 0) {
|
||||
handler_ucov_notification_callback(&cov_data);
|
||||
@@ -141,8 +138,7 @@ void handler_ucov_notification(
|
||||
PRINTF("%s ",
|
||||
bactext_property_name(pProperty_value->propertyIdentifier));
|
||||
} else {
|
||||
PRINTF("proprietary %u ",
|
||||
pProperty_value->propertyIdentifier);
|
||||
PRINTF("proprietary %u ", pProperty_value->propertyIdentifier);
|
||||
}
|
||||
if (pProperty_value->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
PRINTF("%u ", pProperty_value->propertyArrayIndex);
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
/** @file h_wpm.c Handles Write Property Multiple requests. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -61,8 +61,8 @@
|
||||
* @return number of bytes decoded, or BACNET_STATUS_REJECT,
|
||||
* or BACNET_STATUS_ERROR
|
||||
*/
|
||||
static int write_property_multiple_decode(
|
||||
uint8_t *apdu, uint16_t apdu_len,
|
||||
static int write_property_multiple_decode(uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
write_property_function device_write_property)
|
||||
{
|
||||
@@ -83,8 +83,8 @@ static int write_property_multiple_decode(
|
||||
(3) an optional 'Property Array Index'
|
||||
(4) a 'Property Value'
|
||||
(5) an optional 'Priority' */
|
||||
len = wpm_decode_object_property(&apdu[offset],
|
||||
apdu_len - offset, wp_data);
|
||||
len = wpm_decode_object_property(
|
||||
&apdu[offset], apdu_len - offset, wp_data);
|
||||
if (len > 0) {
|
||||
offset += len;
|
||||
PRINTF("WPM: type=%lu instance=%lu property=%lu "
|
||||
@@ -160,11 +160,11 @@ void handler_write_property_multiple(uint8_t *service_request,
|
||||
PRINTF("WPM: Segmented message. Sending Abort!\n");
|
||||
} else {
|
||||
/* first time - detect malformed request before writing any data */
|
||||
len = write_property_multiple_decode(service_request, service_len,
|
||||
&wp_data, NULL);
|
||||
len = write_property_multiple_decode(
|
||||
service_request, service_len, &wp_data, NULL);
|
||||
if (len > 0) {
|
||||
len = write_property_multiple_decode(service_request, service_len,
|
||||
&wp_data, Device_Write_Property);
|
||||
len = write_property_multiple_decode(
|
||||
service_request, service_len, &wp_data, Device_Write_Property);
|
||||
}
|
||||
}
|
||||
/* encode the confirmed reply */
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
/** @file s_ack_alarm.c Send an Alarm Acknowledgment. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -58,8 +58,10 @@
|
||||
* @return invoke id of outgoing message, or 0 if communication is disabled,
|
||||
* or no tsm slot is available.
|
||||
*/
|
||||
uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
BACNET_ALARM_ACK_DATA *data, BACNET_ADDRESS *dest)
|
||||
uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_ALARM_ACK_DATA *data,
|
||||
BACNET_ADDRESS *dest)
|
||||
{
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
@@ -91,10 +93,9 @@ uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((uint16_t)pdu_len < pdu_size) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest,
|
||||
&npdu_data, pdu, (uint16_t)pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(dest, &npdu_data, pdu, pdu_len);
|
||||
tsm_set_confirmed_unsegmented_transaction(
|
||||
invoke_id, dest, &npdu_data, pdu, (uint16_t)pdu_len);
|
||||
bytes_sent = datalink_send_pdu(dest, &npdu_data, pdu, pdu_len);
|
||||
if (bytes_sent <= 0) {
|
||||
PRINTF("Failed to Send Alarm Ack Request (%s)!\n",
|
||||
strerror(errno));
|
||||
@@ -133,8 +134,7 @@ uint8_t Send_Alarm_Acknowledgement(
|
||||
max_apdu = sizeof(Handler_Transmit_Buffer);
|
||||
}
|
||||
invoke_id = Send_Alarm_Acknowledgement_Address(
|
||||
Handler_Transmit_Buffer, max_apdu,
|
||||
data, &dest);
|
||||
Handler_Transmit_Buffer, max_apdu, data, &dest);
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
|
||||
@@ -47,8 +47,10 @@
|
||||
* @return invoke id of outgoing message, or 0 if communication is disabled,
|
||||
* or no tsm slot is available.
|
||||
*/
|
||||
uint8_t Send_CEvent_Notify_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
BACNET_EVENT_NOTIFICATION_DATA *data, BACNET_ADDRESS *dest)
|
||||
uint8_t Send_CEvent_Notify_Address(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_EVENT_NOTIFICATION_DATA *data,
|
||||
BACNET_ADDRESS *dest)
|
||||
{
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
@@ -81,8 +83,8 @@ uint8_t Send_CEvent_Notify_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((uint16_t)pdu_len < pdu_size) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest,
|
||||
&npdu_data, pdu, (uint16_t)pdu_len);
|
||||
tsm_set_confirmed_unsegmented_transaction(
|
||||
invoke_id, dest, &npdu_data, pdu, (uint16_t)pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
@@ -131,8 +133,7 @@ uint8_t Send_CEvent_Notify(
|
||||
max_apdu = sizeof(Handler_Transmit_Buffer);
|
||||
}
|
||||
invoke_id = Send_CEvent_Notify_Address(
|
||||
Handler_Transmit_Buffer, max_apdu,
|
||||
data, &dest);
|
||||
Handler_Transmit_Buffer, max_apdu, data, &dest);
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
|
||||
@@ -144,7 +144,8 @@ uint8_t Send_COV_Subscribe(
|
||||
/* encode the APDU portion of the packet */
|
||||
if (cov_data->covSubscribeToProperty) {
|
||||
/* subscribe to 1 property */
|
||||
len = cov_subscribe_property_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
len = cov_subscribe_property_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len],
|
||||
sizeof(Handler_Transmit_Buffer) - pdu_len, invoke_id, cov_data);
|
||||
} else {
|
||||
/* subscribe to object */
|
||||
|
||||
+110
-179
@@ -43,8 +43,12 @@ static double clamp(double d, double min, double max)
|
||||
* @param brightness - return brightness of the CIE xy color 0..255
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
float *x_coordinate, float *y_coordinate, uint8_t *brightness)
|
||||
void color_rgb_to_xy(uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness)
|
||||
{
|
||||
/* Get the RGB values from your color object
|
||||
and convert them to be between 0 and 1.
|
||||
@@ -63,15 +67,12 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
This gamma correction is also applied to the screen
|
||||
of your computer or phone, thus we need this to create
|
||||
the same color on the light as on screen. */
|
||||
red = (red > 0.04045f) ?
|
||||
pow((red + 0.055f) / (1.0f + 0.055f), 2.4f) :
|
||||
(red / 12.92f);
|
||||
green = (green > 0.04045f) ?
|
||||
pow((green + 0.055f) / (1.0f + 0.055f), 2.4f) :
|
||||
(green / 12.92f);
|
||||
blue = (blue > 0.04045f) ?
|
||||
pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f) :
|
||||
(blue / 12.92f);
|
||||
red = (red > 0.04045f) ? pow((red + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (red / 12.92f);
|
||||
green = (green > 0.04045f) ? pow((green + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (green / 12.92f);
|
||||
blue = (blue > 0.04045f) ? pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (blue / 12.92f);
|
||||
|
||||
/* Convert the RGB values to XYZ using the
|
||||
Wide RGB D65 conversion formula */
|
||||
@@ -97,7 +98,7 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
/* Use the Y value of XYZ as brightness
|
||||
The Y value indicates the brightness
|
||||
of the converted color. */
|
||||
Y = Y*255.0f;
|
||||
Y = Y * 255.0f;
|
||||
Y = clamp(Y, 0.0f, 255.0f);
|
||||
if (brightness) {
|
||||
*brightness = (uint8_t)Y;
|
||||
@@ -114,8 +115,12 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
* @param brightness - brightness of the CIE xy color
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
float x_coordinate, float y_coordinate, uint8_t brightness)
|
||||
void color_rgb_from_xy(uint8_t *red,
|
||||
uint8_t *green,
|
||||
uint8_t *blue,
|
||||
float x_coordinate,
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
/* Calculate XYZ values */
|
||||
float x = x_coordinate;
|
||||
@@ -133,21 +138,21 @@ void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
float b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
||||
|
||||
/* Apply reverse gamma correction */
|
||||
r = r <= 0.0031308f ? 12.92f * r :
|
||||
(1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;
|
||||
g = g <= 0.0031308f ? 12.92f * g :
|
||||
(1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;
|
||||
b = b <= 0.0031308f ? 12.92f * b :
|
||||
(1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;
|
||||
r = r <= 0.0031308f ? 12.92f * r
|
||||
: (1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;
|
||||
g = g <= 0.0031308f ? 12.92f * g
|
||||
: (1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;
|
||||
b = b <= 0.0031308f ? 12.92f * b
|
||||
: (1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;
|
||||
|
||||
/* Convert the RGB values to your color object
|
||||
The rgb values from the above formulas are
|
||||
between 0.0 and 1.0. */
|
||||
r = r*255.0f;
|
||||
r = r * 255.0f;
|
||||
r = clamp(r, 0.0f, 255.0f);
|
||||
g = g*255;
|
||||
g = g * 255;
|
||||
g = clamp(g, 0.0f, 255.0f);
|
||||
b = b*255;
|
||||
b = b * 255;
|
||||
b = clamp(b, 0.0f, 255.0f);
|
||||
/* copy to return value if possible */
|
||||
if (red) {
|
||||
@@ -169,155 +174,81 @@ struct css_color_rgb {
|
||||
uint8_t blue;
|
||||
};
|
||||
static struct css_color_rgb CSS_Color_RGB_Table[] = {
|
||||
{"aliceblue", 240, 248, 255},
|
||||
{"antiquewhite", 250, 235, 215},
|
||||
{"aqua", 0, 255, 255},
|
||||
{"aquamarine", 127, 255, 212},
|
||||
{"azure", 240, 255, 255},
|
||||
{"beige", 245, 245, 220},
|
||||
{"bisque", 255, 228, 196},
|
||||
{"black", 0, 0, 0},
|
||||
{"blanchedalmond", 255, 235, 205},
|
||||
{"blue", 0, 0, 255},
|
||||
{"blueviolet", 138, 43, 226},
|
||||
{"brown", 165, 42, 42},
|
||||
{"burlywood", 222, 184, 135},
|
||||
{"cadetblue", 95, 158, 160},
|
||||
{"chartreuse", 127, 255, 0},
|
||||
{"chocolate", 210, 105, 30},
|
||||
{"coral", 255, 127, 80},
|
||||
{"cornflowerblue", 100, 149, 237},
|
||||
{"cornsilk", 255, 248, 220},
|
||||
{"crimson", 220, 20, 60},
|
||||
{"cyan", 0, 255, 255},
|
||||
{"darkblue", 0, 0, 139},
|
||||
{"darkcyan", 0, 139, 139},
|
||||
{"darkgoldenrod", 184, 134, 11},
|
||||
{"darkgray", 169, 169, 169},
|
||||
{"darkgreen", 0, 100, 0},
|
||||
{"darkgrey", 169, 169, 169},
|
||||
{"darkkhaki", 189, 183, 107},
|
||||
{"darkmagenta", 139, 0, 139},
|
||||
{"darkolivegreen", 85, 107, 47},
|
||||
{"darkorange", 255, 140, 0},
|
||||
{"darkorchid", 153, 50, 204},
|
||||
{"darkred", 139, 0, 0},
|
||||
{"darksalmon", 233, 150, 122},
|
||||
{"darkseagreen", 143, 188, 143},
|
||||
{"darkslateblue", 72, 61, 139},
|
||||
{"darkslategray", 47, 79, 79},
|
||||
{"darkslategrey", 47, 79, 79},
|
||||
{"darkturquoise", 0, 206, 209},
|
||||
{"darkviolet", 148, 0, 211},
|
||||
{"deeppink", 255, 20, 147},
|
||||
{"deepskyblue", 0, 191, 255},
|
||||
{"dimgray", 105, 105, 105},
|
||||
{"dimgrey", 105, 105, 105},
|
||||
{"dodgerblue", 30, 144, 255},
|
||||
{"firebrick", 178, 34, 34},
|
||||
{"floralwhite", 255, 250, 240},
|
||||
{"forestgreen", 34, 139, 34},
|
||||
{"fuchsia", 255, 0, 255},
|
||||
{"gainsboro", 220, 220, 220},
|
||||
{"ghostwhite", 248, 248, 255},
|
||||
{"gold", 255, 215, 0},
|
||||
{"goldenrod", 218, 165, 32},
|
||||
{"gray", 128, 128, 128},
|
||||
{"green", 0, 128, 0},
|
||||
{"greenyellow", 173, 255, 47},
|
||||
{"grey", 128, 128, 128},
|
||||
{"honeydew", 240, 255, 240},
|
||||
{"hotpink", 255, 105, 180},
|
||||
{"indianred", 205, 92, 92},
|
||||
{"indigo", 75, 0, 130},
|
||||
{"ivory", 255, 255, 240},
|
||||
{"khaki", 240, 230, 140},
|
||||
{"lavender", 230, 230, 250},
|
||||
{"lavenderblush", 255, 240, 245},
|
||||
{"lawngreen", 124, 252, 0},
|
||||
{"lemonchiffon", 255, 250, 205},
|
||||
{"lightblue", 173, 216, 230},
|
||||
{"lightcoral", 240, 128, 128},
|
||||
{"lightcyan", 224, 255, 255},
|
||||
{"lightgoldenrodyellow", 250, 250, 210},
|
||||
{"lightgray", 211, 211, 211},
|
||||
{"lightgreen", 144, 238, 144},
|
||||
{"lightgrey", 211, 211, 211},
|
||||
{"lightpink", 255, 182, 193},
|
||||
{"lightsalmon", 255, 160, 122},
|
||||
{"lightseagreen", 32, 178, 170},
|
||||
{"lightskyblue", 135, 206, 250},
|
||||
{"lightslategray", 119, 136, 153},
|
||||
{"lightslategrey", 119, 136, 153},
|
||||
{"lightsteelblue", 176, 196, 222},
|
||||
{"lightyellow", 255, 255, 224},
|
||||
{"lime", 0, 255, 0},
|
||||
{"limegreen", 50, 205, 50},
|
||||
{"linen", 250, 240, 230},
|
||||
{"magenta", 255, 0, 255},
|
||||
{"maroon", 128, 0, 0},
|
||||
{"mediumaquamarine", 102, 205, 170},
|
||||
{"mediumblue", 0, 0, 205},
|
||||
{"mediumorchid", 186, 85, 211},
|
||||
{"mediumpurple", 147, 112, 219},
|
||||
{"mediumseagreen", 60, 179, 113},
|
||||
{"mediumslateblue", 123, 104, 238},
|
||||
{"mediumspringgreen", 0, 250, 154},
|
||||
{"mediumturquoise", 72, 209, 204},
|
||||
{"mediumvioletred", 199, 21, 133},
|
||||
{"midnightblue", 25, 25, 112},
|
||||
{"mintcream", 245, 255, 250},
|
||||
{"mistyrose", 255, 228, 225},
|
||||
{"moccasin", 255, 228, 181},
|
||||
{"navajowhite", 255, 222, 173},
|
||||
{"navy", 0, 0, 128},
|
||||
{"navyblue", 0, 0, 128},
|
||||
{"oldlace", 253, 245, 230},
|
||||
{"olive", 128, 128, 0},
|
||||
{"olivedrab", 107, 142, 35},
|
||||
{"orange", 255, 165, 0},
|
||||
{"orangered", 255, 69, 0},
|
||||
{"orchid", 218, 112, 214},
|
||||
{"palegoldenrod", 238, 232, 170},
|
||||
{"palegreen", 152, 251, 152},
|
||||
{"paleturquoise", 175, 238, 238},
|
||||
{"palevioletred", 219, 112, 147},
|
||||
{"papayawhip", 255, 239, 213},
|
||||
{"peachpuff", 255, 218, 185},
|
||||
{"peru", 205, 133, 63},
|
||||
{"pink", 255, 192, 203},
|
||||
{"plum", 221, 160, 221},
|
||||
{"powderblue", 176, 224, 230},
|
||||
{"purple", 128, 0, 128},
|
||||
{"red", 255, 0, 0},
|
||||
{"rosybrown", 188, 143, 143},
|
||||
{"royalblue", 65, 105, 225},
|
||||
{"saddlebrown", 139, 69, 19},
|
||||
{"salmon", 250, 128, 114},
|
||||
{"sandybrown", 244, 164, 96},
|
||||
{"seagreen", 46, 139, 87},
|
||||
{"seashell", 255, 245, 238},
|
||||
{"sienna", 160, 82, 45},
|
||||
{"silver", 192, 192, 192},
|
||||
{"skyblue", 135, 206, 235},
|
||||
{"slateblue", 106, 90, 205},
|
||||
{"slategray", 112, 128, 144},
|
||||
{"slategrey", 112, 128, 144},
|
||||
{"snow", 255, 250, 250},
|
||||
{"springgreen", 0, 255, 127},
|
||||
{"steelblue", 70, 130, 180},
|
||||
{"tan", 210, 180, 140},
|
||||
{"teal", 0, 128, 128},
|
||||
{"thistle", 216, 191, 216},
|
||||
{"tomato", 255, 99, 71},
|
||||
{"turquoise", 64, 224, 208},
|
||||
{"violet", 238, 130, 238},
|
||||
{"wheat", 245, 222, 179},
|
||||
{"white", 255, 255, 255},
|
||||
{"whitesmoke", 245, 245, 245},
|
||||
{"yellow", 255, 255, 0},
|
||||
{"yellowgreen", 154, 205, 50},
|
||||
{NULL, 0, 0, 0}
|
||||
{ "aliceblue", 240, 248, 255 }, { "antiquewhite", 250, 235, 215 },
|
||||
{ "aqua", 0, 255, 255 }, { "aquamarine", 127, 255, 212 },
|
||||
{ "azure", 240, 255, 255 }, { "beige", 245, 245, 220 },
|
||||
{ "bisque", 255, 228, 196 }, { "black", 0, 0, 0 },
|
||||
{ "blanchedalmond", 255, 235, 205 }, { "blue", 0, 0, 255 },
|
||||
{ "blueviolet", 138, 43, 226 }, { "brown", 165, 42, 42 },
|
||||
{ "burlywood", 222, 184, 135 }, { "cadetblue", 95, 158, 160 },
|
||||
{ "chartreuse", 127, 255, 0 }, { "chocolate", 210, 105, 30 },
|
||||
{ "coral", 255, 127, 80 }, { "cornflowerblue", 100, 149, 237 },
|
||||
{ "cornsilk", 255, 248, 220 }, { "crimson", 220, 20, 60 },
|
||||
{ "cyan", 0, 255, 255 }, { "darkblue", 0, 0, 139 },
|
||||
{ "darkcyan", 0, 139, 139 }, { "darkgoldenrod", 184, 134, 11 },
|
||||
{ "darkgray", 169, 169, 169 }, { "darkgreen", 0, 100, 0 },
|
||||
{ "darkgrey", 169, 169, 169 }, { "darkkhaki", 189, 183, 107 },
|
||||
{ "darkmagenta", 139, 0, 139 }, { "darkolivegreen", 85, 107, 47 },
|
||||
{ "darkorange", 255, 140, 0 }, { "darkorchid", 153, 50, 204 },
|
||||
{ "darkred", 139, 0, 0 }, { "darksalmon", 233, 150, 122 },
|
||||
{ "darkseagreen", 143, 188, 143 }, { "darkslateblue", 72, 61, 139 },
|
||||
{ "darkslategray", 47, 79, 79 }, { "darkslategrey", 47, 79, 79 },
|
||||
{ "darkturquoise", 0, 206, 209 }, { "darkviolet", 148, 0, 211 },
|
||||
{ "deeppink", 255, 20, 147 }, { "deepskyblue", 0, 191, 255 },
|
||||
{ "dimgray", 105, 105, 105 }, { "dimgrey", 105, 105, 105 },
|
||||
{ "dodgerblue", 30, 144, 255 }, { "firebrick", 178, 34, 34 },
|
||||
{ "floralwhite", 255, 250, 240 }, { "forestgreen", 34, 139, 34 },
|
||||
{ "fuchsia", 255, 0, 255 }, { "gainsboro", 220, 220, 220 },
|
||||
{ "ghostwhite", 248, 248, 255 }, { "gold", 255, 215, 0 },
|
||||
{ "goldenrod", 218, 165, 32 }, { "gray", 128, 128, 128 },
|
||||
{ "green", 0, 128, 0 }, { "greenyellow", 173, 255, 47 },
|
||||
{ "grey", 128, 128, 128 }, { "honeydew", 240, 255, 240 },
|
||||
{ "hotpink", 255, 105, 180 }, { "indianred", 205, 92, 92 },
|
||||
{ "indigo", 75, 0, 130 }, { "ivory", 255, 255, 240 },
|
||||
{ "khaki", 240, 230, 140 }, { "lavender", 230, 230, 250 },
|
||||
{ "lavenderblush", 255, 240, 245 }, { "lawngreen", 124, 252, 0 },
|
||||
{ "lemonchiffon", 255, 250, 205 }, { "lightblue", 173, 216, 230 },
|
||||
{ "lightcoral", 240, 128, 128 }, { "lightcyan", 224, 255, 255 },
|
||||
{ "lightgoldenrodyellow", 250, 250, 210 }, { "lightgray", 211, 211, 211 },
|
||||
{ "lightgreen", 144, 238, 144 }, { "lightgrey", 211, 211, 211 },
|
||||
{ "lightpink", 255, 182, 193 }, { "lightsalmon", 255, 160, 122 },
|
||||
{ "lightseagreen", 32, 178, 170 }, { "lightskyblue", 135, 206, 250 },
|
||||
{ "lightslategray", 119, 136, 153 }, { "lightslategrey", 119, 136, 153 },
|
||||
{ "lightsteelblue", 176, 196, 222 }, { "lightyellow", 255, 255, 224 },
|
||||
{ "lime", 0, 255, 0 }, { "limegreen", 50, 205, 50 },
|
||||
{ "linen", 250, 240, 230 }, { "magenta", 255, 0, 255 },
|
||||
{ "maroon", 128, 0, 0 }, { "mediumaquamarine", 102, 205, 170 },
|
||||
{ "mediumblue", 0, 0, 205 }, { "mediumorchid", 186, 85, 211 },
|
||||
{ "mediumpurple", 147, 112, 219 }, { "mediumseagreen", 60, 179, 113 },
|
||||
{ "mediumslateblue", 123, 104, 238 }, { "mediumspringgreen", 0, 250, 154 },
|
||||
{ "mediumturquoise", 72, 209, 204 }, { "mediumvioletred", 199, 21, 133 },
|
||||
{ "midnightblue", 25, 25, 112 }, { "mintcream", 245, 255, 250 },
|
||||
{ "mistyrose", 255, 228, 225 }, { "moccasin", 255, 228, 181 },
|
||||
{ "navajowhite", 255, 222, 173 }, { "navy", 0, 0, 128 },
|
||||
{ "navyblue", 0, 0, 128 }, { "oldlace", 253, 245, 230 },
|
||||
{ "olive", 128, 128, 0 }, { "olivedrab", 107, 142, 35 },
|
||||
{ "orange", 255, 165, 0 }, { "orangered", 255, 69, 0 },
|
||||
{ "orchid", 218, 112, 214 }, { "palegoldenrod", 238, 232, 170 },
|
||||
{ "palegreen", 152, 251, 152 }, { "paleturquoise", 175, 238, 238 },
|
||||
{ "palevioletred", 219, 112, 147 }, { "papayawhip", 255, 239, 213 },
|
||||
{ "peachpuff", 255, 218, 185 }, { "peru", 205, 133, 63 },
|
||||
{ "pink", 255, 192, 203 }, { "plum", 221, 160, 221 },
|
||||
{ "powderblue", 176, 224, 230 }, { "purple", 128, 0, 128 },
|
||||
{ "red", 255, 0, 0 }, { "rosybrown", 188, 143, 143 },
|
||||
{ "royalblue", 65, 105, 225 }, { "saddlebrown", 139, 69, 19 },
|
||||
{ "salmon", 250, 128, 114 }, { "sandybrown", 244, 164, 96 },
|
||||
{ "seagreen", 46, 139, 87 }, { "seashell", 255, 245, 238 },
|
||||
{ "sienna", 160, 82, 45 }, { "silver", 192, 192, 192 },
|
||||
{ "skyblue", 135, 206, 235 }, { "slateblue", 106, 90, 205 },
|
||||
{ "slategray", 112, 128, 144 }, { "slategrey", 112, 128, 144 },
|
||||
{ "snow", 255, 250, 250 }, { "springgreen", 0, 255, 127 },
|
||||
{ "steelblue", 70, 130, 180 }, { "tan", 210, 180, 140 },
|
||||
{ "teal", 0, 128, 128 }, { "thistle", 216, 191, 216 },
|
||||
{ "tomato", 255, 99, 71 }, { "turquoise", 64, 224, 208 },
|
||||
{ "violet", 238, 130, 238 }, { "wheat", 245, 222, 179 },
|
||||
{ "white", 255, 255, 255 }, { "whitesmoke", 245, 245, 245 },
|
||||
{ "yellow", 255, 255, 0 }, { "yellowgreen", 154, 205, 50 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -330,9 +261,9 @@ static struct css_color_rgb CSS_Color_RGB_Table[] = {
|
||||
* https://www.w3.org/TR/2010/PR-css3-color-20101028/#html4
|
||||
* names do not have spaces
|
||||
*/
|
||||
const char * color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
|
||||
const char *color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
const char * name = "";
|
||||
const char *name = "";
|
||||
unsigned index = 0;
|
||||
|
||||
while (CSS_Color_RGB_Table[index].name) {
|
||||
@@ -355,8 +286,8 @@ const char * color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
|
||||
* @param name - CSS color name from W3C
|
||||
* @return index 0..color_rgb_count(), where color_rgb_count() is not found.
|
||||
*/
|
||||
unsigned color_rgb_from_ascii(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
const char *name)
|
||||
unsigned color_rgb_from_ascii(
|
||||
uint8_t *red, uint8_t *green, uint8_t *blue, const char *name)
|
||||
{
|
||||
unsigned index = 0;
|
||||
|
||||
@@ -386,7 +317,8 @@ unsigned color_rgb_from_ascii(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
* @param blue - return B value of sRGB
|
||||
* @return CSS ASCII color name from W3C or NULL if invalid index
|
||||
*/
|
||||
const char *color_rgb_from_index(unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue)
|
||||
const char *color_rgb_from_index(
|
||||
unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue)
|
||||
{
|
||||
unsigned index = 0;
|
||||
|
||||
@@ -431,8 +363,7 @@ unsigned color_rgb_count(void)
|
||||
* http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
|
||||
*/
|
||||
void color_rgb_from_temperature(
|
||||
uint16_t temperature_kelvin,
|
||||
uint8_t *r, uint8_t *g, uint8_t *b)
|
||||
uint16_t temperature_kelvin, uint8_t *r, uint8_t *g, uint8_t *b)
|
||||
{
|
||||
float red = 0, green = 0, blue = 0;
|
||||
|
||||
|
||||
+11
-16
@@ -24,7 +24,7 @@ bool days_is_leap_year(uint16_t year)
|
||||
{
|
||||
if ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ uint8_t days_per_month(uint16_t year, uint8_t month)
|
||||
return (29);
|
||||
} else if (month >= 1 && month <= 12) {
|
||||
return (month_days[month]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -200,10 +200,8 @@ uint32_t days_apart(uint16_t year1,
|
||||
* @param day - day of month (1-31)
|
||||
* @return number of days since epoch, or 0 if out of range
|
||||
*/
|
||||
uint32_t days_since_epoch(uint16_t epoch_year,
|
||||
uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
uint32_t days_since_epoch(
|
||||
uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day)
|
||||
{
|
||||
uint32_t days = 0; /* return value */
|
||||
uint16_t yy = 0; /* year */
|
||||
@@ -212,8 +210,8 @@ uint32_t days_since_epoch(uint16_t epoch_year,
|
||||
|
||||
/* validate the date conforms to our range */
|
||||
monthdays = days_per_month(year, month);
|
||||
if ((year >= epoch_year) && (year <= 9999) &&
|
||||
(monthdays > 0) && (day >= 1) && (day <= monthdays)) {
|
||||
if ((year >= epoch_year) && (year <= 9999) && (monthdays > 0) &&
|
||||
(day >= 1) && (day <= monthdays)) {
|
||||
for (yy = epoch_year; yy < year; yy++) {
|
||||
days += 365;
|
||||
if (days_is_leap_year(yy)) {
|
||||
@@ -238,12 +236,11 @@ uint32_t days_since_epoch(uint16_t epoch_year,
|
||||
* @param pDay - day of month (1-31)
|
||||
* @return nothing
|
||||
*/
|
||||
void days_since_epoch_to_date(
|
||||
uint16_t epoch_year,
|
||||
void days_since_epoch_to_date(uint16_t epoch_year,
|
||||
uint32_t days,
|
||||
uint16_t * pYear,
|
||||
uint8_t * pMonth,
|
||||
uint8_t * pDay)
|
||||
uint16_t *pYear,
|
||||
uint8_t *pMonth,
|
||||
uint8_t *pDay)
|
||||
{
|
||||
uint8_t month = 1;
|
||||
uint8_t day = 0;
|
||||
@@ -281,9 +278,7 @@ void days_since_epoch_to_date(
|
||||
* @param day - day of month (1-31)
|
||||
* @return true if the date is valid
|
||||
*/
|
||||
bool days_date_is_valid(uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
bool days_date_is_valid(uint16_t year, uint8_t month, uint8_t day)
|
||||
{
|
||||
uint8_t month_days = 0;
|
||||
bool valid = false; /* return value */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user