Slimming down the Atmel AVR port.

This commit is contained in:
skarg
2007-10-19 03:21:45 +00:00
parent bfefe8cd62
commit 194c6d17ac
9 changed files with 386 additions and 167 deletions
+1
View File
@@ -40,6 +40,7 @@
#include "bits.h"
#include "bacstr.h"
#include "bacint.h"
#include "bacreal.h"
/* NOTE: byte order plays a role in decoding multibyte values */
/* http://www.unixpapa.com/incnote/byteorder.html */
+23 -12
View File
@@ -135,10 +135,30 @@ int iam_decode_service_request(uint8_t * apdu,
return apdu_len;
}
int iam_send(uint8_t * buffer)
int iam_encode_pdu(uint8_t * buffer,
BACNET_ADDRESS *dest,
BACNET_NPDU_DATA *npdu_data)
{
int len = 0;
int pdu_len = 0;
/* I-Am is a global broadcast */
datalink_get_broadcast_address(dest);
/* encode the NPDU portion of the packet */
npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data);
/* encode the APDU portion of the packet */
len = iam_encode_apdu(&buffer[pdu_len],
Device_Object_Instance_Number(),
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
pdu_len += len;
return pdu_len;
}
int iam_send(uint8_t * buffer)
{
int pdu_len = 0;
BACNET_ADDRESS dest;
int bytes_sent = 0;
BACNET_NPDU_DATA npdu_data;
@@ -146,17 +166,8 @@ int iam_send(uint8_t * buffer)
/* if we are forbidden to send, don't send! */
if (!dcc_communication_enabled())
return 0;
/* I-Am is a global broadcast */
datalink_get_broadcast_address(&dest);
/* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len = npdu_encode_pdu(&buffer[0], &dest, NULL, &npdu_data);
/* encode the APDU portion of the packet */
len = iam_encode_apdu(&buffer[pdu_len],
Device_Object_Instance_Number(),
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
pdu_len += len;
/* encode the data */
pdu_len = iam_encode_pdu(buffer, &dest, &npdu_data);
/* send data */
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &buffer[0], pdu_len);