indented using indent.sh script.
This commit is contained in:
@@ -181,8 +181,7 @@ void handler_atomic_read_file(
|
|||||||
error = true;
|
error = true;
|
||||||
} else if (bacfile_read_stream_data(&data)) {
|
} else if (bacfile_read_stream_data(&data)) {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr, "ARF: fileStartRecord %d, %u RecordCount.\n",
|
||||||
"ARF: fileStartRecord %d, %u RecordCount.\n",
|
|
||||||
data.type.record.fileStartRecord,
|
data.type.record.fileStartRecord,
|
||||||
data.type.record.RecordCount);
|
data.type.record.RecordCount);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
/** @file h_cov.c Handles Change of Value (COV) services. */
|
/** @file h_cov.c Handles Change of Value (COV) services. */
|
||||||
|
|
||||||
typedef struct BACnet_COV_Address{
|
typedef struct BACnet_COV_Address {
|
||||||
bool valid:1;
|
bool valid:1;
|
||||||
BACNET_ADDRESS dest;
|
BACNET_ADDRESS dest;
|
||||||
} BACNET_COV_ADDRESS;
|
} BACNET_COV_ADDRESS;
|
||||||
@@ -106,7 +106,8 @@ static BACNET_ADDRESS *cov_address_get(
|
|||||||
* Removes the address from the list of COV addresses, if it is not
|
* Removes the address from the list of COV addresses, if it is not
|
||||||
* used by other COV subscriptions
|
* used by other COV subscriptions
|
||||||
*/
|
*/
|
||||||
static void cov_address_remove_unused(void)
|
static void cov_address_remove_unused(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
unsigned cov_index = 0;
|
unsigned cov_index = 0;
|
||||||
@@ -137,7 +138,7 @@ static void cov_address_remove_unused(void)
|
|||||||
* @return index number 0..N, or -1 if unable to add
|
* @return index number 0..N, or -1 if unable to add
|
||||||
*/
|
*/
|
||||||
static int cov_address_add(
|
static int cov_address_add(
|
||||||
BACNET_ADDRESS *dest)
|
BACNET_ADDRESS * dest)
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = -1;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
@@ -475,8 +476,8 @@ static bool cov_send_request(
|
|||||||
datalink_get_my_address(&my_address);
|
datalink_get_my_address(&my_address);
|
||||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||||
pdu_len =
|
pdu_len =
|
||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest,
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address,
|
||||||
&my_address, &npdu_data);
|
&npdu_data);
|
||||||
/* load the COV data structure for outgoing message */
|
/* load the COV data structure for outgoing message */
|
||||||
cov_data.subscriberProcessIdentifier =
|
cov_data.subscriberProcessIdentifier =
|
||||||
cov_subscription->subscriberProcessIdentifier;
|
cov_subscription->subscriberProcessIdentifier;
|
||||||
@@ -504,13 +505,12 @@ static bool cov_send_request(
|
|||||||
}
|
}
|
||||||
pdu_len += len;
|
pdu_len += len;
|
||||||
if (cov_subscription->flag.issueConfirmedNotifications) {
|
if (cov_subscription->flag.issueConfirmedNotifications) {
|
||||||
tsm_set_confirmed_unsegmented_transaction(invoke_id,
|
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest, &npdu_data,
|
||||||
dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
&Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
|
||||||
(uint16_t) pdu_len);
|
|
||||||
}
|
}
|
||||||
bytes_sent =
|
bytes_sent =
|
||||||
datalink_send_pdu(dest, &npdu_data,
|
datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||||
&Handler_Transmit_Buffer[0], pdu_len);
|
pdu_len);
|
||||||
if (bytes_sent > 0) {
|
if (bytes_sent > 0) {
|
||||||
status = true;
|
status = true;
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
|
|||||||
@@ -45,10 +45,12 @@
|
|||||||
|
|
||||||
/** @file s_awfs.c Send part of an Atomic Write File Stream request. */
|
/** @file s_awfs.c Send part of an Atomic Write File Stream request. */
|
||||||
|
|
||||||
uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id,
|
uint8_t Send_Atomic_Write_File_Stream(
|
||||||
|
uint32_t device_id,
|
||||||
uint32_t file_instance,
|
uint32_t file_instance,
|
||||||
int fileStartPosition,
|
int fileStartPosition,
|
||||||
BACNET_OCTET_STRING * fileData) {
|
BACNET_OCTET_STRING * fileData)
|
||||||
|
{
|
||||||
BACNET_ADDRESS dest;
|
BACNET_ADDRESS dest;
|
||||||
BACNET_ADDRESS my_address;
|
BACNET_ADDRESS my_address;
|
||||||
BACNET_NPDU_DATA npdu_data;
|
BACNET_NPDU_DATA npdu_data;
|
||||||
@@ -61,31 +63,32 @@ uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id,
|
|||||||
BACNET_ATOMIC_WRITE_FILE_DATA data;
|
BACNET_ATOMIC_WRITE_FILE_DATA data;
|
||||||
|
|
||||||
/* if we are forbidden to send, don't send! */
|
/* if we are forbidden to send, don't send! */
|
||||||
if (!dcc_communication_enabled ())
|
if (!dcc_communication_enabled())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* is the device bound? */
|
/* is the device bound? */
|
||||||
status = address_get_by_device (device_id, &max_apdu, &dest);
|
status = address_get_by_device(device_id, &max_apdu, &dest);
|
||||||
/* is there a tsm available? */
|
/* is there a tsm available? */
|
||||||
if (status)
|
if (status)
|
||||||
invoke_id = tsm_next_free_invokeID ();
|
invoke_id = tsm_next_free_invokeID();
|
||||||
if (invoke_id) {
|
if (invoke_id) {
|
||||||
/* load the data for the encoding */
|
/* load the data for the encoding */
|
||||||
data.object_type = OBJECT_FILE;
|
data.object_type = OBJECT_FILE;
|
||||||
data.object_instance = file_instance;
|
data.object_instance = file_instance;
|
||||||
data.access = FILE_STREAM_ACCESS;
|
data.access = FILE_STREAM_ACCESS;
|
||||||
data.type.stream.fileStartPosition = fileStartPosition;
|
data.type.stream.fileStartPosition = fileStartPosition;
|
||||||
status = octetstring_copy (&data.fileData[0], fileData);
|
status = octetstring_copy(&data.fileData[0], fileData);
|
||||||
if (status) {
|
if (status) {
|
||||||
/* encode the NPDU portion of the packet */
|
/* encode the NPDU portion of the packet */
|
||||||
datalink_get_my_address (&my_address);
|
datalink_get_my_address(&my_address);
|
||||||
npdu_encode_npdu_data (&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
||||||
pdu_len =
|
pdu_len =
|
||||||
npdu_encode_pdu (&Handler_Transmit_Buffer[0], &dest, &my_address,
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest,
|
||||||
&npdu_data);
|
&my_address, &npdu_data);
|
||||||
/* encode the APDU portion of the packet */
|
/* encode the APDU portion of the packet */
|
||||||
len =
|
len =
|
||||||
awf_encode_apdu (&Handler_Transmit_Buffer[pdu_len], invoke_id, &data);
|
awf_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id,
|
||||||
|
&data);
|
||||||
pdu_len += len;
|
pdu_len += len;
|
||||||
/* will the APDU fit the target device?
|
/* will the APDU fit the target device?
|
||||||
note: if there is a bottleneck router in between
|
note: if there is a bottleneck router in between
|
||||||
@@ -93,33 +96,33 @@ uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id,
|
|||||||
we have a way to check for that and update the
|
we have a way to check for that and update the
|
||||||
max_apdu in the address binding table. */
|
max_apdu in the address binding table. */
|
||||||
if ((unsigned) pdu_len <= max_apdu) {
|
if ((unsigned) pdu_len <= max_apdu) {
|
||||||
tsm_set_confirmed_unsegmented_transaction (invoke_id, &dest,
|
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||||
&npdu_data,
|
&npdu_data, &Handler_Transmit_Buffer[0],
|
||||||
&Handler_Transmit_Buffer
|
(uint16_t) pdu_len);
|
||||||
[0], (uint16_t) pdu_len);
|
|
||||||
bytes_sent =
|
bytes_sent =
|
||||||
datalink_send_pdu (&dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
datalink_send_pdu(&dest, &npdu_data,
|
||||||
pdu_len);
|
&Handler_Transmit_Buffer[0], pdu_len);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (bytes_sent <= 0)
|
if (bytes_sent <= 0)
|
||||||
fprintf (stderr, "Failed to Send AtomicWriteFile Request (%s)!\n",
|
fprintf(stderr,
|
||||||
strerror (errno));
|
"Failed to Send AtomicWriteFile Request (%s)!\n",
|
||||||
|
strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
tsm_free_invoke_id (invoke_id);
|
tsm_free_invoke_id(invoke_id);
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf (stderr,
|
fprintf(stderr,
|
||||||
"Failed to Send AtomicWriteFile Request "
|
"Failed to Send AtomicWriteFile Request "
|
||||||
"(payload [%d] exceeds destination maximum APDU [%u])!\n",
|
"(payload [%d] exceeds destination maximum APDU [%u])!\n",
|
||||||
pdu_len, max_apdu);
|
pdu_len, max_apdu);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tsm_free_invoke_id (invoke_id);
|
tsm_free_invoke_id(invoke_id);
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf (stderr,
|
fprintf(stderr,
|
||||||
"Failed to Send AtomicWriteFile Request "
|
"Failed to Send AtomicWriteFile Request "
|
||||||
"(payload [%d] exceeds octet string capacity)!\n", pdu_len);
|
"(payload [%d] exceeds octet string capacity)!\n", pdu_len);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ uint8_t Send_Write_Property_Multiple_Request_Data(
|
|||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
||||||
&npdu_data);
|
&npdu_data);
|
||||||
|
|
||||||
len = wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu,
|
len =
|
||||||
|
wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu,
|
||||||
invoke_id, write_access_data);
|
invoke_id, write_access_data);
|
||||||
|
|
||||||
pdu_len += len;
|
pdu_len += len;
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ static uint32_t timeval_diff_ms(
|
|||||||
|
|
||||||
static void mstp_monitor_i_am(
|
static void mstp_monitor_i_am(
|
||||||
uint8_t mac,
|
uint8_t mac,
|
||||||
uint8_t *pdu,
|
uint8_t * pdu,
|
||||||
uint16_t pdu_len)
|
uint16_t pdu_len)
|
||||||
{
|
{
|
||||||
BACNET_ADDRESS src = { 0 };
|
BACNET_ADDRESS src = { 0 };
|
||||||
@@ -150,10 +150,9 @@ static void mstp_monitor_i_am(
|
|||||||
if (pdu[0] == BACNET_PROTOCOL_VERSION) {
|
if (pdu[0] == BACNET_PROTOCOL_VERSION) {
|
||||||
MSTP_Fill_BACnet_Address(&src, mac);
|
MSTP_Fill_BACnet_Address(&src, mac);
|
||||||
apdu_offset = npdu_decode(&pdu[0], &dest, &src, &npdu_data);
|
apdu_offset = npdu_decode(&pdu[0], &dest, &src, &npdu_data);
|
||||||
if ((!npdu_data.network_layer_message) &&
|
if ((!npdu_data.network_layer_message) && (apdu_offset > 0) &&
|
||||||
(apdu_offset > 0) && (apdu_offset < pdu_len) &&
|
(apdu_offset < pdu_len) && ((dest.net == 0) ||
|
||||||
((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) &&
|
(dest.net == BACNET_BROADCAST_NETWORK)) && (src.net == 0)) {
|
||||||
(src.net == 0)) {
|
|
||||||
apdu_len = pdu_len - apdu_offset;
|
apdu_len = pdu_len - apdu_offset;
|
||||||
apdu = &pdu[apdu_offset];
|
apdu = &pdu[apdu_offset];
|
||||||
pdu_type = apdu[0] & 0xF0;
|
pdu_type = apdu[0] & 0xF0;
|
||||||
@@ -162,8 +161,9 @@ static void mstp_monitor_i_am(
|
|||||||
service_choice = apdu[1];
|
service_choice = apdu[1];
|
||||||
service_request = &apdu[2];
|
service_request = &apdu[2];
|
||||||
if (service_choice == SERVICE_UNCONFIRMED_I_AM) {
|
if (service_choice == SERVICE_UNCONFIRMED_I_AM) {
|
||||||
len = iam_decode_service_request(service_request,
|
len =
|
||||||
&device_id, NULL, NULL, NULL);
|
iam_decode_service_request(service_request, &device_id,
|
||||||
|
NULL, NULL, NULL);
|
||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
MSTP_Statistics[mac].device_id = device_id;
|
MSTP_Statistics[mac].device_id = device_id;
|
||||||
}
|
}
|
||||||
@@ -272,11 +272,10 @@ static void packet_statistics(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((mstp_port->ReceivedValidFrame) ||
|
if ((mstp_port->ReceivedValidFrame) ||
|
||||||
(mstp_port->ReceivedValidFrameNotForUs)){
|
(mstp_port->ReceivedValidFrameNotForUs)) {
|
||||||
if ((mstp_port->DataLength <= mstp_port->InputBufferSize) &&
|
if ((mstp_port->DataLength <= mstp_port->InputBufferSize) &&
|
||||||
(mstp_port->DataLength > 0)) {
|
(mstp_port->DataLength > 0)) {
|
||||||
mstp_monitor_i_am(src,
|
mstp_monitor_i_am(src, &mstp_port->InputBuffer[0],
|
||||||
&mstp_port->InputBuffer[0],
|
|
||||||
mstp_port->DataLength);
|
mstp_port->DataLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -754,8 +753,8 @@ static bool read_received_packet(
|
|||||||
mstp_port->HeaderCRCActual = header[7];
|
mstp_port->HeaderCRCActual = header[7];
|
||||||
mstp_port->HeaderCRC = 0xFF;
|
mstp_port->HeaderCRC = 0xFF;
|
||||||
for (i = 2; i < 8; i++) {
|
for (i = 2; i < 8; i++) {
|
||||||
mstp_port->HeaderCRC = CRC_Calc_Header(header[i],
|
mstp_port->HeaderCRC =
|
||||||
mstp_port->HeaderCRC);
|
CRC_Calc_Header(header[i], mstp_port->HeaderCRC);
|
||||||
}
|
}
|
||||||
if (mstp_port->HeaderCRC != 0x55) {
|
if (mstp_port->HeaderCRC != 0x55) {
|
||||||
mstp_port->ReceivedInvalidFrame = true;
|
mstp_port->ReceivedInvalidFrame = true;
|
||||||
@@ -792,11 +791,9 @@ static bool read_received_packet(
|
|||||||
mstp_port->DataCRC);
|
mstp_port->DataCRC);
|
||||||
}
|
}
|
||||||
mstp_port->DataCRC =
|
mstp_port->DataCRC =
|
||||||
CRC_Calc_Data(mstp_port->DataCRCActualMSB,
|
CRC_Calc_Data(mstp_port->DataCRCActualMSB, mstp_port->DataCRC);
|
||||||
mstp_port->DataCRC);
|
|
||||||
mstp_port->DataCRC =
|
mstp_port->DataCRC =
|
||||||
CRC_Calc_Data(mstp_port->DataCRCActualLSB,
|
CRC_Calc_Data(mstp_port->DataCRCActualLSB, mstp_port->DataCRC);
|
||||||
mstp_port->DataCRC);
|
|
||||||
if (mstp_port->DataCRC == 0xF0B8) {
|
if (mstp_port->DataCRC == 0xF0B8) {
|
||||||
mstp_port->ReceivedValidFrame = true;
|
mstp_port->ReceivedValidFrame = true;
|
||||||
mstp_port->ReceivedValidFrameNotForUs = true;
|
mstp_port->ReceivedValidFrameNotForUs = true;
|
||||||
@@ -851,13 +848,14 @@ static BOOL WINAPI CtrlCHandler(
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
static void print_com_ports(void)
|
static void print_com_ports(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
printf("List of available COM ports:\r\n");
|
printf("List of available COM ports:\r\n");
|
||||||
/* try to open all 255 COM ports */
|
/* try to open all 255 COM ports */
|
||||||
for (i=1; i<256; i++) {
|
for (i = 1; i < 256; i++) {
|
||||||
if (RS485_Interface_Valid(i)) {
|
if (RS485_Interface_Valid(i)) {
|
||||||
printf("COM%u\r\n", i);
|
printf("COM%u\r\n", i);
|
||||||
}
|
}
|
||||||
@@ -964,10 +962,10 @@ int main(
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
RS485_Set_Interface(argv[1]);
|
RS485_Set_Interface(argv[1]);
|
||||||
} else {
|
} else {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
print_com_ports();
|
print_com_ports();
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
my_baud = strtol(argv[2], NULL, 0);
|
my_baud = strtol(argv[2], NULL, 0);
|
||||||
|
|||||||
@@ -124,5 +124,4 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ extern "C" {
|
|||||||
uint16_t Analog_Value_Units(
|
uint16_t Analog_Value_Units(
|
||||||
uint32_t instance);
|
uint32_t instance);
|
||||||
bool Analog_Value_Units_Set(
|
bool Analog_Value_Units_Set(
|
||||||
uint32_t instance, uint16_t unit);
|
uint32_t instance,
|
||||||
|
uint16_t unit);
|
||||||
|
|
||||||
bool Analog_Value_Out_Of_Service(
|
bool Analog_Value_Out_Of_Service(
|
||||||
uint32_t instance);
|
uint32_t instance);
|
||||||
|
|||||||
@@ -551,7 +551,8 @@ bool bacfile_write_record_data(
|
|||||||
}
|
}
|
||||||
for (i = 0; i < data->type.record.returnedRecordCount; i++) {
|
for (i = 0; i < data->type.record.returnedRecordCount; i++) {
|
||||||
if (fwrite(octetstring_value(&data->fileData[i]),
|
if (fwrite(octetstring_value(&data->fileData[i]),
|
||||||
octetstring_length(&data->fileData[i]), 1, pFile) != 1) {
|
octetstring_length(&data->fileData[i]), 1,
|
||||||
|
pFile) != 1) {
|
||||||
/* do something if it fails? */
|
/* do something if it fails? */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,7 +599,7 @@ bool bacfile_read_ack_record_data(
|
|||||||
FILE *pFile = NULL;
|
FILE *pFile = NULL;
|
||||||
char *pFilename = NULL;
|
char *pFilename = NULL;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
char dummy_data[MAX_OCTET_STRING_BYTES] = {0};
|
char dummy_data[MAX_OCTET_STRING_BYTES] = { 0 };
|
||||||
char *pData = NULL;
|
char *pData = NULL;
|
||||||
|
|
||||||
pFilename = bacfile_name(instance);
|
pFilename = bacfile_name(instance);
|
||||||
@@ -616,10 +617,11 @@ bool bacfile_read_ack_record_data(
|
|||||||
}
|
}
|
||||||
for (i = 0; i < data->type.record.RecordCount; i++) {
|
for (i = 0; i < data->type.record.RecordCount; i++) {
|
||||||
if (fwrite(octetstring_value(&data->fileData[i]),
|
if (fwrite(octetstring_value(&data->fileData[i]),
|
||||||
octetstring_length(&data->fileData[i]), 1, pFile) != 1) {
|
octetstring_length(&data->fileData[i]), 1,
|
||||||
|
pFile) != 1) {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "Failed to write to %s (%lu)!\n", pFilename,
|
fprintf(stderr, "Failed to write to %s (%lu)!\n",
|
||||||
(unsigned long) instance);
|
pFilename, (unsigned long) instance);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,4 +138,3 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1173,7 +1173,7 @@ int Device_Read_Property_Local(
|
|||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
uint16_t apdu_max =0;
|
uint16_t apdu_max = 0;
|
||||||
|
|
||||||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
@@ -1818,7 +1818,7 @@ void Device_Init(
|
|||||||
struct uci_context *ctx;
|
struct uci_context *ctx;
|
||||||
fprintf(stderr, "Device_Init\n");
|
fprintf(stderr, "Device_Init\n");
|
||||||
ctx = ucix_init("bacnet_dev");
|
ctx = ucix_init("bacnet_dev");
|
||||||
if(!ctx)
|
if (!ctx)
|
||||||
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
||||||
uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name");
|
uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name");
|
||||||
if (uciname != 0) {
|
if (uciname != 0) {
|
||||||
|
|||||||
@@ -440,15 +440,11 @@ extern "C" {
|
|||||||
* - The interface between the implemented Objects and the BAC-stack services,
|
* - The interface between the implemented Objects and the BAC-stack services,
|
||||||
* specifically the handlers, which are mediated through function calls to
|
* specifically the handlers, which are mediated through function calls to
|
||||||
* the Device object.
|
* the Device object.
|
||||||
*/
|
*//** @defgroup ObjHelpers Object Helper Functions
|
||||||
|
|
||||||
/** @defgroup ObjHelpers Object Helper Functions
|
|
||||||
* @ingroup ObjFrmwk
|
* @ingroup ObjFrmwk
|
||||||
* This section describes the function templates for the helper functions that
|
* This section describes the function templates for the helper functions that
|
||||||
* provide common object support.
|
* provide common object support.
|
||||||
*/
|
*//** @defgroup ObjIntf Handler-to-Object Interface Functions
|
||||||
|
|
||||||
/** @defgroup ObjIntf Handler-to-Object Interface Functions
|
|
||||||
* @ingroup ObjFrmwk
|
* @ingroup ObjFrmwk
|
||||||
* This section describes the fairly limited set of functions that link the
|
* This section describes the fairly limited set of functions that link the
|
||||||
* BAC-stack handlers to the BACnet Object instances. All of these calls are
|
* BAC-stack handlers to the BACnet Object instances. All of these calls are
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ int main(
|
|||||||
struct uci_context *ctx;
|
struct uci_context *ctx;
|
||||||
|
|
||||||
ctx = ucix_init("bacnet_dev");
|
ctx = ucix_init("bacnet_dev");
|
||||||
if(!ctx)
|
if (!ctx)
|
||||||
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
||||||
uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0);
|
uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0);
|
||||||
printf("ID: %i", uciId);
|
printf("ID: %i", uciId);
|
||||||
|
|||||||
@@ -89,18 +89,18 @@ extern "C" {
|
|||||||
uint8_t hundredths);
|
uint8_t hundredths);
|
||||||
/* utility test for validity */
|
/* utility test for validity */
|
||||||
bool datetime_is_valid(
|
bool datetime_is_valid(
|
||||||
BACNET_DATE *bdate,
|
BACNET_DATE * bdate,
|
||||||
BACNET_TIME *btime);
|
BACNET_TIME * btime);
|
||||||
bool datetime_time_is_valid(
|
bool datetime_time_is_valid(
|
||||||
BACNET_TIME *btime);
|
BACNET_TIME * btime);
|
||||||
bool datetime_date_is_valid(
|
bool datetime_date_is_valid(
|
||||||
BACNET_DATE *bdate);
|
BACNET_DATE * bdate);
|
||||||
/* date and time calculations and summaries */
|
/* date and time calculations and summaries */
|
||||||
uint32_t datetime_days_since_epoch(
|
uint32_t datetime_days_since_epoch(
|
||||||
BACNET_DATE *bdate);
|
BACNET_DATE * bdate);
|
||||||
void datetime_days_since_epoch_into_date(
|
void datetime_days_since_epoch_into_date(
|
||||||
uint32_t days,
|
uint32_t days,
|
||||||
BACNET_DATE *bdate);
|
BACNET_DATE * bdate);
|
||||||
bool datetime_is_leap_year(
|
bool datetime_is_leap_year(
|
||||||
uint16_t year);
|
uint16_t year);
|
||||||
uint8_t datetime_month_days(
|
uint8_t datetime_month_days(
|
||||||
@@ -115,9 +115,9 @@ extern "C" {
|
|||||||
uint8_t month,
|
uint8_t month,
|
||||||
uint8_t day);
|
uint8_t day);
|
||||||
uint32_t datetime_seconds_since_midnight(
|
uint32_t datetime_seconds_since_midnight(
|
||||||
BACNET_TIME *btime);
|
BACNET_TIME * btime);
|
||||||
uint16_t datetime_minutes_since_midnight(
|
uint16_t datetime_minutes_since_midnight(
|
||||||
BACNET_TIME *btime);
|
BACNET_TIME * btime);
|
||||||
|
|
||||||
/* utility comparison functions:
|
/* utility comparison functions:
|
||||||
if the date/times are the same, return is 0
|
if the date/times are the same, return is 0
|
||||||
|
|||||||
+52
-20
@@ -18,24 +18,56 @@
|
|||||||
|
|
||||||
#ifndef _UCI_H__
|
#ifndef _UCI_H__
|
||||||
#define _UCI_H__
|
#define _UCI_H__
|
||||||
struct uci_context* ucix_init(const char *config_file);
|
struct uci_context *ucix_init(
|
||||||
struct uci_context* ucix_init_path(const char *path, const char *config_file);
|
const char *config_file);
|
||||||
void ucix_cleanup(struct uci_context *ctx);
|
struct uci_context *ucix_init_path(
|
||||||
void ucix_save(struct uci_context *ctx);
|
const char *path,
|
||||||
void ucix_save_state(struct uci_context *ctx);
|
const char *config_file);
|
||||||
const char* ucix_get_option(struct uci_context *ctx,
|
void ucix_cleanup(
|
||||||
const char *p, const char *s, const char *o);
|
struct uci_context *ctx);
|
||||||
int ucix_get_option_int(struct uci_context *ctx,
|
void ucix_save(
|
||||||
const char *p, const char *s, const char *o, int def);
|
struct uci_context *ctx);
|
||||||
void ucix_add_section(struct uci_context *ctx,
|
void ucix_save_state(
|
||||||
const char *p, const char *s, const char *t);
|
struct uci_context *ctx);
|
||||||
void ucix_add_option(struct uci_context *ctx,
|
const char *ucix_get_option(
|
||||||
const char *p, const char *s, const char *o, const char *t);
|
struct uci_context *ctx,
|
||||||
void ucix_add_option_int(struct uci_context *ctx,
|
const char *p,
|
||||||
const char *p, const char *s, const char *o, int t);
|
const char *s,
|
||||||
int ucix_commit(struct uci_context *ctx, const char *p);
|
const char *o);
|
||||||
void ucix_revert(struct uci_context *ctx,
|
int ucix_get_option_int(
|
||||||
const char *p, const char *s, const char *o);
|
struct uci_context *ctx,
|
||||||
void ucix_del(struct uci_context *ctx, const char *p,
|
const char *p,
|
||||||
const char *s, const char *o);
|
const char *s,
|
||||||
|
const char *o,
|
||||||
|
int def);
|
||||||
|
void ucix_add_section(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *t);
|
||||||
|
void ucix_add_option(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o,
|
||||||
|
const char *t);
|
||||||
|
void ucix_add_option_int(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o,
|
||||||
|
int t);
|
||||||
|
int ucix_commit(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p);
|
||||||
|
void ucix_revert(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o);
|
||||||
|
void ucix_del(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ int Device_Read_Property_Local(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
apdu = rpdata->application_data;
|
apdu = rpdata->application_data;
|
||||||
switch ((int)rpdata->object_property) {
|
switch ((int) rpdata->object_property) {
|
||||||
case PROP_DESCRIPTION:
|
case PROP_DESCRIPTION:
|
||||||
characterstring_init_ansi(&char_string, "BACnet Demo");
|
characterstring_init_ansi(&char_string, "BACnet Demo");
|
||||||
apdu_len =
|
apdu_len =
|
||||||
@@ -851,7 +851,7 @@ bool Device_Write_Property_Local(
|
|||||||
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch ((int)wp_data->object_property) {
|
switch ((int) wp_data->object_property) {
|
||||||
case PROP_OBJECT_IDENTIFIER:
|
case PROP_OBJECT_IDENTIFIER:
|
||||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/// Default spurious interrupt handler. Infinite loop.
|
/// Default spurious interrupt handler. Infinite loop.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void AT91F_Spurious_handler( void )
|
void AT91F_Spurious_handler(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
@@ -15,7 +16,8 @@ void AT91F_Spurious_handler( void )
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/// Default handler for fast interrupt requests. Infinite loop.
|
/// Default handler for fast interrupt requests. Infinite loop.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void AT91F_Default_FIQ_handler( void )
|
void AT91F_Default_FIQ_handler(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
@@ -23,7 +25,8 @@ void AT91F_Default_FIQ_handler( void )
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/// Default handler for standard interrupt requests. Infinite loop.
|
/// Default handler for standard interrupt requests. Infinite loop.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void AT91F_Default_IRQ_handler( void )
|
void AT91F_Default_IRQ_handler(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,8 +295,7 @@ int Device_Read_Property(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Device_Object_List_Identifier(rpdata->array_index,
|
if (Device_Object_List_Identifier(rpdata->array_index,
|
||||||
&object_type,
|
&object_type, &instance))
|
||||||
&instance))
|
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0], object_type,
|
encode_application_object_id(&apdu[0], object_type,
|
||||||
instance);
|
instance);
|
||||||
|
|||||||
@@ -875,9 +875,8 @@ bool dlmstp_init(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
poSharedData =
|
poSharedData = (SHARED_MSTP_DATA *) ((struct mstp_port_struct_t *)
|
||||||
(SHARED_MSTP_DATA *) ((struct mstp_port_struct_t *) mstp_port)->
|
mstp_port)->UserData;
|
||||||
UserData;
|
|
||||||
if (!poSharedData) {
|
if (!poSharedData) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ void RS485_Set_Interface(
|
|||||||
* ALGORITHM: none
|
* ALGORITHM: none
|
||||||
* NOTES: none
|
* NOTES: none
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
bool RS485_Interface_Valid(unsigned port_number)
|
bool RS485_Interface_Valid(
|
||||||
|
unsigned port_number)
|
||||||
{
|
{
|
||||||
HANDLE h = 0;
|
HANDLE h = 0;
|
||||||
DWORD err = 0;
|
DWORD err = 0;
|
||||||
@@ -139,17 +140,12 @@ bool RS485_Interface_Valid(unsigned port_number)
|
|||||||
char ifname[255] = "";
|
char ifname[255] = "";
|
||||||
|
|
||||||
sprintf(ifname, "\\\\.\\COM%u", port_number);
|
sprintf(ifname, "\\\\.\\COM%u", port_number);
|
||||||
h = CreateFile(
|
h = CreateFile(ifname, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||||
ifname,
|
OPEN_EXISTING, 0, NULL);
|
||||||
GENERIC_READ | GENERIC_WRITE, 0,
|
|
||||||
NULL, OPEN_EXISTING, 0,
|
|
||||||
NULL);
|
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
err = GetLastError();
|
err = GetLastError();
|
||||||
if ((err == ERROR_ACCESS_DENIED) ||
|
if ((err == ERROR_ACCESS_DENIED) || (err == ERROR_GEN_FAILURE) ||
|
||||||
(err == ERROR_GEN_FAILURE) ||
|
(err == ERROR_SHARING_VIOLATION) || (err == ERROR_SEM_TIMEOUT)) {
|
||||||
(err == ERROR_SHARING_VIOLATION) ||
|
|
||||||
(err == ERROR_SEM_TIMEOUT)) {
|
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ extern "C" {
|
|||||||
void RS485_Print_Error(
|
void RS485_Print_Error(
|
||||||
void);
|
void);
|
||||||
|
|
||||||
bool RS485_Interface_Valid(unsigned port_number);
|
bool RS485_Interface_Valid(
|
||||||
|
unsigned port_number);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
+110
-53
@@ -1735,59 +1735,116 @@ INDTEXT_DATA bacnet_error_code_names[] = {
|
|||||||
,
|
,
|
||||||
{ERROR_CODE_COMMUNICATION_DISABLED, "access-denied"}
|
{ERROR_CODE_COMMUNICATION_DISABLED, "access-denied"}
|
||||||
,
|
,
|
||||||
{ERROR_CODE_SUCCESS, "success"},
|
{ERROR_CODE_SUCCESS, "success"}
|
||||||
{ERROR_CODE_ACCESS_DENIED, "access-denied"},
|
,
|
||||||
{ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"},
|
{ERROR_CODE_ACCESS_DENIED, "access-denied"}
|
||||||
{ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"},
|
,
|
||||||
{ERROR_CODE_BAD_SIGNATURE, "bad-signature"},
|
{ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"}
|
||||||
{ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"},
|
,
|
||||||
{ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"},
|
{ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"}
|
||||||
{ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"},
|
,
|
||||||
{ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"},
|
{ERROR_CODE_BAD_SIGNATURE, "bad-signature"}
|
||||||
{ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"},
|
,
|
||||||
{ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED, "destination-device-id-required"},
|
{ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"}
|
||||||
{ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"},
|
,
|
||||||
{ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"},
|
{ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"}
|
||||||
{ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"},
|
,
|
||||||
{ERROR_CODE_INCORRECT_KEY, "incorrect-key"},
|
{ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"}
|
||||||
{ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"},
|
,
|
||||||
{ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"},
|
{ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"}
|
||||||
{ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"},
|
,
|
||||||
{ERROR_CODE_NOT_KEY_SERVER, "not-key-server"},
|
{ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"}
|
||||||
{ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"},
|
,
|
||||||
{ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"},
|
{ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED,
|
||||||
{ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"},
|
"destination-device-id-required"}
|
||||||
{ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"},
|
,
|
||||||
{ERROR_CODE_UNKNOWN_KEY, "unknown-key"},
|
{ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"}
|
||||||
{ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"},
|
,
|
||||||
{ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"},
|
{ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"}
|
||||||
{ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"},
|
,
|
||||||
{ERROR_CODE_ROUTER_BUSY, "router-busy"},
|
{ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"}
|
||||||
{ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"},
|
,
|
||||||
{ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"},
|
{ERROR_CODE_INCORRECT_KEY, "incorrect-key"}
|
||||||
{ERROR_CODE_SECURITY_ERROR, "security-error"},
|
,
|
||||||
{ERROR_CODE_ADDRESSING_ERROR, "addressing-error"},
|
{ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"}
|
||||||
{ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"},
|
,
|
||||||
{ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"},
|
{ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"}
|
||||||
{ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED, "register-foreign-device-failed"},
|
,
|
||||||
{ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"},
|
{ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"}
|
||||||
{ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"},
|
,
|
||||||
{ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"},
|
{ERROR_CODE_NOT_KEY_SERVER, "not-key-server"}
|
||||||
{ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"},
|
,
|
||||||
{ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"},
|
{ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"}
|
||||||
{ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME, "abort-application-exceeded-reply-time"},
|
,
|
||||||
{ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"},
|
{ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"}
|
||||||
{ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"},
|
,
|
||||||
{ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE, "abort-window-size-out-of-range"},
|
{ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"}
|
||||||
{ERROR_CODE_FILE_FULL, "file-full"},
|
,
|
||||||
{ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"},
|
{ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"}
|
||||||
{ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"},
|
,
|
||||||
{ERROR_CODE_INTERNAL_ERROR, "internal-error"},
|
{ERROR_CODE_UNKNOWN_KEY, "unknown-key"}
|
||||||
{ERROR_CODE_NOT_CONFIGURED, "not-configured"},
|
,
|
||||||
{ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"},
|
{ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"}
|
||||||
{ERROR_CODE_VALUE_TOO_LONG, "value-too-long"},
|
,
|
||||||
{ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"},
|
{ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"}
|
||||||
{ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"},
|
,
|
||||||
|
{ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ROUTER_BUSY, "router-busy"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_SECURITY_ERROR, "security-error"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ADDRESSING_ERROR, "addressing-error"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED,
|
||||||
|
"register-foreign-device-failed"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME,
|
||||||
|
"abort-application-exceeded-reply-time"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE,
|
||||||
|
"abort-window-size-out-of-range"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_FILE_FULL, "file-full"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_INTERNAL_ERROR, "internal-error"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_NOT_CONFIGURED, "not-configured"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_VALUE_TOO_LONG, "value-too-long"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"}
|
||||||
|
,
|
||||||
|
{ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"}
|
||||||
|
,
|
||||||
{0, NULL}
|
{0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+13
-19
@@ -93,8 +93,7 @@ bool datetime_ymd_is_valid(
|
|||||||
uint8_t monthdays = 0; /* days in a month */
|
uint8_t monthdays = 0; /* days in a month */
|
||||||
|
|
||||||
monthdays = datetime_month_days(year, month);
|
monthdays = datetime_month_days(year, month);
|
||||||
if ((year >= 1900) && (monthdays > 0) &&
|
if ((year >= 1900) && (monthdays > 0) && (day >= 1) && (day <= monthdays)) {
|
||||||
(day >= 1) && (day <= monthdays)) {
|
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ bool datetime_ymd_is_valid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool datetime_date_is_valid(
|
bool datetime_date_is_valid(
|
||||||
BACNET_DATE *bdate)
|
BACNET_DATE * bdate)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool status = false; /* true if value date */
|
bool status = false; /* true if value date */
|
||||||
@@ -139,7 +138,7 @@ static uint32_t days_since_epoch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t datetime_days_since_epoch(
|
uint32_t datetime_days_since_epoch(
|
||||||
BACNET_DATE *bdate)
|
BACNET_DATE * bdate)
|
||||||
{
|
{
|
||||||
uint32_t days = 0;
|
uint32_t days = 0;
|
||||||
|
|
||||||
@@ -188,7 +187,7 @@ static void days_since_epoch_into_ymd(
|
|||||||
|
|
||||||
void datetime_days_since_epoch_into_date(
|
void datetime_days_since_epoch_into_date(
|
||||||
uint32_t days,
|
uint32_t days,
|
||||||
BACNET_DATE *bdate)
|
BACNET_DATE * bdate)
|
||||||
{
|
{
|
||||||
uint16_t year = 0;
|
uint16_t year = 0;
|
||||||
uint8_t month = 0;
|
uint8_t month = 0;
|
||||||
@@ -209,7 +208,7 @@ uint8_t datetime_day_of_week(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool datetime_time_is_valid(
|
bool datetime_time_is_valid(
|
||||||
BACNET_TIME *btime)
|
BACNET_TIME * btime)
|
||||||
{
|
{
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
@@ -232,8 +231,8 @@ bool datetime_time_is_valid(
|
|||||||
* @return true if the date and time are valid
|
* @return true if the date and time are valid
|
||||||
*/
|
*/
|
||||||
bool datetime_is_valid(
|
bool datetime_is_valid(
|
||||||
BACNET_DATE *bdate,
|
BACNET_DATE * bdate,
|
||||||
BACNET_TIME *btime)
|
BACNET_TIME * btime)
|
||||||
{
|
{
|
||||||
return datetime_date_is_valid(bdate) && datetime_time_is_valid(btime);
|
return datetime_date_is_valid(bdate) && datetime_time_is_valid(btime);
|
||||||
}
|
}
|
||||||
@@ -447,15 +446,12 @@ static void seconds_since_midnight_into_hms(
|
|||||||
* @return seconds since midnight
|
* @return seconds since midnight
|
||||||
*/
|
*/
|
||||||
uint32_t datetime_seconds_since_midnight(
|
uint32_t datetime_seconds_since_midnight(
|
||||||
BACNET_TIME *btime)
|
BACNET_TIME * btime)
|
||||||
{
|
{
|
||||||
uint32_t seconds = 0;
|
uint32_t seconds = 0;
|
||||||
|
|
||||||
if (btime) {
|
if (btime) {
|
||||||
seconds = seconds_since_midnight(
|
seconds = seconds_since_midnight(btime->hour, btime->min, btime->sec);
|
||||||
btime->hour,
|
|
||||||
btime->min,
|
|
||||||
btime->sec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return seconds;
|
return seconds;
|
||||||
@@ -468,14 +464,12 @@ uint32_t datetime_seconds_since_midnight(
|
|||||||
* @return minutes since midnight
|
* @return minutes since midnight
|
||||||
*/
|
*/
|
||||||
uint16_t datetime_minutes_since_midnight(
|
uint16_t datetime_minutes_since_midnight(
|
||||||
BACNET_TIME *btime)
|
BACNET_TIME * btime)
|
||||||
{
|
{
|
||||||
uint32_t minutes = 0;
|
uint32_t minutes = 0;
|
||||||
|
|
||||||
if (btime) {
|
if (btime) {
|
||||||
minutes = minutes_since_midnight(
|
minutes = minutes_since_midnight(btime->hour, btime->min);
|
||||||
btime->hour,
|
|
||||||
btime->min);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return minutes;
|
return minutes;
|
||||||
@@ -983,8 +977,8 @@ void testDateEpoch(
|
|||||||
for (month = 1; month <= 12; month++) {
|
for (month = 1; month <= 12; month++) {
|
||||||
for (day = 1; day <= datetime_month_days(year, month); day++) {
|
for (day = 1; day <= datetime_month_days(year, month); day++) {
|
||||||
days = days_since_epoch(year, month, day);
|
days = days_since_epoch(year, month, day);
|
||||||
days_since_epoch_into_ymd(days,
|
days_since_epoch_into_ymd(days, &test_year, &test_month,
|
||||||
&test_year, &test_month, &test_day);
|
&test_day);
|
||||||
ct_test(pTest, year == test_year);
|
ct_test(pTest, year == test_year);
|
||||||
ct_test(pTest, month == test_month);
|
ct_test(pTest, month == test_month);
|
||||||
ct_test(pTest, day == test_day);
|
ct_test(pTest, day == test_day);
|
||||||
|
|||||||
@@ -923,7 +923,7 @@ BACNET_PROPERTY_ID property_list_special_property(
|
|||||||
{
|
{
|
||||||
int property = -1; /* return value */
|
int property = -1; /* return value */
|
||||||
unsigned required, optional, proprietary;
|
unsigned required, optional, proprietary;
|
||||||
struct special_property_list_t PropertyList = {{0}};
|
struct special_property_list_t PropertyList = { {0} };
|
||||||
|
|
||||||
property_list_special(object_type, &PropertyList);
|
property_list_special(object_type, &PropertyList);
|
||||||
required = PropertyList.Required.count;
|
required = PropertyList.Required.count;
|
||||||
@@ -967,7 +967,7 @@ unsigned property_list_special_count(
|
|||||||
BACNET_PROPERTY_ID special_property)
|
BACNET_PROPERTY_ID special_property)
|
||||||
{
|
{
|
||||||
unsigned count = 0; /* return value */
|
unsigned count = 0; /* return value */
|
||||||
struct special_property_list_t PropertyList = {{0}};
|
struct special_property_list_t PropertyList = { {0} };
|
||||||
|
|
||||||
property_list_special(object_type, &PropertyList);
|
property_list_special(object_type, &PropertyList);
|
||||||
if (special_property == PROP_ALL) {
|
if (special_property == PROP_ALL) {
|
||||||
@@ -997,16 +997,15 @@ void testPropList(
|
|||||||
unsigned object_id = 0, object_name = 0, object_type = 0;
|
unsigned object_id = 0, object_name = 0, object_type = 0;
|
||||||
|
|
||||||
for (i = 0; i < OBJECT_PROPRIETARY_MIN; i++) {
|
for (i = 0; i < OBJECT_PROPRIETARY_MIN; i++) {
|
||||||
count = property_list_special_count((BACNET_OBJECT_TYPE)i, PROP_ALL);
|
count = property_list_special_count((BACNET_OBJECT_TYPE) i, PROP_ALL);
|
||||||
ct_test(pTest, count >= 3);
|
ct_test(pTest, count >= 3);
|
||||||
object_id = 0;
|
object_id = 0;
|
||||||
object_name = 0;
|
object_name = 0;
|
||||||
object_type = 0;
|
object_type = 0;
|
||||||
for (j = 0; j < count; j++) {
|
for (j = 0; j < count; j++) {
|
||||||
property = property_list_special_property(
|
property =
|
||||||
(BACNET_OBJECT_TYPE)i,
|
property_list_special_property((BACNET_OBJECT_TYPE) i,
|
||||||
PROP_ALL,
|
PROP_ALL, j);
|
||||||
j);
|
|
||||||
if (property == PROP_OBJECT_TYPE) {
|
if (property == PROP_OBJECT_TYPE) {
|
||||||
object_type++;
|
object_type++;
|
||||||
}
|
}
|
||||||
|
|||||||
+81
-35
@@ -27,7 +27,12 @@
|
|||||||
|
|
||||||
static struct uci_ptr ptr;
|
static struct uci_ptr ptr;
|
||||||
|
|
||||||
static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
static inline int ucix_get_ptr(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o,
|
||||||
|
const char *t)
|
||||||
{
|
{
|
||||||
memset(&ptr, 0, sizeof(ptr));
|
memset(&ptr, 0, sizeof(ptr));
|
||||||
ptr.package = p;
|
ptr.package = p;
|
||||||
@@ -37,65 +42,74 @@ static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const cha
|
|||||||
return uci_lookup_ptr(ctx, &ptr, NULL, true);
|
return uci_lookup_ptr(ctx, &ptr, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct uci_context* ucix_init(const char *config_file)
|
struct uci_context *ucix_init(
|
||||||
|
const char *config_file)
|
||||||
{
|
{
|
||||||
struct uci_context *ctx = uci_alloc_context();
|
struct uci_context *ctx = uci_alloc_context();
|
||||||
// uci_add_history_path(ctx, "/var/state");
|
// uci_add_history_path(ctx, "/var/state");
|
||||||
uci_add_delta_path(ctx, "/var/state");
|
uci_add_delta_path(ctx, "/var/state");
|
||||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
if (uci_load(ctx, config_file, NULL) != UCI_OK) {
|
||||||
{
|
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir,
|
||||||
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
config_file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct uci_context* ucix_init_path(const char *path, const char *config_file)
|
struct uci_context *ucix_init_path(
|
||||||
|
const char *path,
|
||||||
|
const char *config_file)
|
||||||
{
|
{
|
||||||
struct uci_context *ctx = uci_alloc_context();
|
struct uci_context *ctx = uci_alloc_context();
|
||||||
if(path)
|
if (path)
|
||||||
uci_set_confdir(ctx, path);
|
uci_set_confdir(ctx, path);
|
||||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
if (uci_load(ctx, config_file, NULL) != UCI_OK) {
|
||||||
{
|
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir,
|
||||||
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
config_file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_cleanup(struct uci_context *ctx)
|
void ucix_cleanup(
|
||||||
|
struct uci_context *ctx)
|
||||||
{
|
{
|
||||||
uci_free_context(ctx);
|
uci_free_context(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_save(struct uci_context *ctx)
|
void ucix_save(
|
||||||
|
struct uci_context *ctx)
|
||||||
{
|
{
|
||||||
uci_set_savedir(ctx, "/tmp/.uci/");
|
uci_set_savedir(ctx, "/tmp/.uci/");
|
||||||
uci_save(ctx, NULL);
|
uci_save(ctx, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_save_state(struct uci_context *ctx)
|
void ucix_save_state(
|
||||||
|
struct uci_context *ctx)
|
||||||
{
|
{
|
||||||
uci_set_savedir(ctx, "/var/state/");
|
uci_set_savedir(ctx, "/var/state/");
|
||||||
uci_save(ctx, NULL);
|
uci_save(ctx, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
const char *ucix_get_option(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o)
|
||||||
{
|
{
|
||||||
struct uci_element *e = NULL;
|
struct uci_element *e = NULL;
|
||||||
const char *value = NULL;
|
const char *value = NULL;
|
||||||
if(ucix_get_ptr(ctx, p, s, o, NULL))
|
if (ucix_get_ptr(ctx, p, s, o, NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||||
return NULL;
|
return NULL;
|
||||||
e = ptr.last;
|
e = ptr.last;
|
||||||
switch (e->type)
|
switch (e->type) {
|
||||||
{
|
|
||||||
case UCI_TYPE_SECTION:
|
case UCI_TYPE_SECTION:
|
||||||
value = uci_to_section(e)->type;
|
value = uci_to_section(e)->type;
|
||||||
break;
|
break;
|
||||||
case UCI_TYPE_OPTION:
|
case UCI_TYPE_OPTION:
|
||||||
switch(ptr.o->type) {
|
switch (ptr.o->type) {
|
||||||
case UCI_TYPE_STRING:
|
case UCI_TYPE_STRING:
|
||||||
value = ptr.o->v.string;
|
value = ptr.o->v.string;
|
||||||
break;
|
break;
|
||||||
@@ -111,7 +125,12 @@ const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def)
|
int ucix_get_option_int(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o,
|
||||||
|
int def)
|
||||||
{
|
{
|
||||||
const char *tmp = ucix_get_option(ctx, p, s, o);
|
const char *tmp = ucix_get_option(ctx, p, s, o);
|
||||||
int ret = def;
|
int ret = def;
|
||||||
@@ -121,55 +140,82 @@ int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, c
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t)
|
void ucix_add_section(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *t)
|
||||||
{
|
{
|
||||||
if(ucix_get_ptr(ctx, p, s, NULL, t))
|
if (ucix_get_ptr(ctx, p, s, NULL, t))
|
||||||
return;
|
return;
|
||||||
uci_set(ctx, &ptr);
|
uci_set(ctx, &ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
void ucix_add_option(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o,
|
||||||
|
const char *t)
|
||||||
{
|
{
|
||||||
if(ucix_get_ptr(ctx, p, s, o, (t)?(t):("")))
|
if (ucix_get_ptr(ctx, p, s, o, (t) ? (t) : ("")))
|
||||||
return;
|
return;
|
||||||
uci_set(ctx, &ptr);
|
uci_set(ctx, &ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t)
|
void ucix_add_option_int(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o,
|
||||||
|
int t)
|
||||||
{
|
{
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
snprintf(tmp, 64, "%d", t);
|
snprintf(tmp, 64, "%d", t);
|
||||||
ucix_add_option(ctx, p, s, o, tmp);
|
ucix_add_option(ctx, p, s, o, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
void ucix_del(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o)
|
||||||
{
|
{
|
||||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
if (!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||||
uci_delete(ctx, &ptr);
|
uci_delete(ctx, &ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
void ucix_revert(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p,
|
||||||
|
const char *s,
|
||||||
|
const char *o)
|
||||||
{
|
{
|
||||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
if (!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||||
uci_revert(ctx, &ptr);
|
uci_revert(ctx, &ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucix_for_each_section_type(struct uci_context *ctx,
|
void ucix_for_each_section_type(
|
||||||
const char *p, const char *t,
|
struct uci_context *ctx,
|
||||||
void (*cb)(const char*, void*), void *priv)
|
const char *p,
|
||||||
|
const char *t,
|
||||||
|
void (*cb) (const char *,
|
||||||
|
void *),
|
||||||
|
void *priv)
|
||||||
{
|
{
|
||||||
struct uci_element *e;
|
struct uci_element *e;
|
||||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
if (ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||||
return;
|
return;
|
||||||
uci_foreach_element(&ptr.p->sections, e)
|
uci_foreach_element(&ptr.p->sections, e)
|
||||||
if (!strcmp(t, uci_to_section(e)->type))
|
if (!strcmp(t, uci_to_section(e)->type))
|
||||||
cb(e->name, priv);
|
cb(e->name, priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ucix_commit(struct uci_context *ctx, const char *p)
|
int ucix_commit(
|
||||||
|
struct uci_context *ctx,
|
||||||
|
const char *p)
|
||||||
{
|
{
|
||||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
if (ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||||
return 1;
|
return 1;
|
||||||
return uci_commit(ctx, &ptr.p, false);
|
return uci_commit(ctx, &ptr.p, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -274,25 +274,27 @@ int wpm_encode_apdu(
|
|||||||
|
|
||||||
wpm_object = write_access_data;
|
wpm_object = write_access_data;
|
||||||
|
|
||||||
while(wpm_object){
|
while (wpm_object) {
|
||||||
|
|
||||||
len = wpm_encode_apdu_object_begin(&apdu[apdu_len],
|
len =
|
||||||
|
wpm_encode_apdu_object_begin(&apdu[apdu_len],
|
||||||
wpm_object->object_type, wpm_object->object_instance);
|
wpm_object->object_type, wpm_object->object_instance);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
wpm_property = wpm_object->listOfProperties;
|
wpm_property = wpm_object->listOfProperties;
|
||||||
|
|
||||||
while(wpm_property){
|
while (wpm_property) {
|
||||||
wpdata.object_property = wpm_property->propertyIdentifier;
|
wpdata.object_property = wpm_property->propertyIdentifier;
|
||||||
wpdata.array_index = wpm_property->propertyArrayIndex;
|
wpdata.array_index = wpm_property->propertyArrayIndex;
|
||||||
wpdata.priority = wpm_property->priority;
|
wpdata.priority = wpm_property->priority;
|
||||||
|
|
||||||
wpdata.application_data_len = bacapp_encode_data(&apdu_temp[0],
|
wpdata.application_data_len =
|
||||||
&wpm_property->value);
|
bacapp_encode_data(&apdu_temp[0], &wpm_property->value);
|
||||||
memcpy(&wpdata.application_data[0], &apdu_temp[0],
|
memcpy(&wpdata.application_data[0], &apdu_temp[0],
|
||||||
wpdata.application_data_len);
|
wpdata.application_data_len);
|
||||||
|
|
||||||
len = wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata);
|
len =
|
||||||
|
wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
wpm_property = wpm_property->next;
|
wpm_property = wpm_property->next;
|
||||||
|
|||||||
Reference in New Issue
Block a user