moved npdu handler code into npdu.c
This commit is contained in:
@@ -53,36 +53,8 @@ uint32_t Device_Id = 111;
|
|||||||
// flag to send an I-Am
|
// flag to send an I-Am
|
||||||
bool I_Am_Request = true;
|
bool I_Am_Request = true;
|
||||||
|
|
||||||
void Process_PDU(
|
// FIXME: if we handle multiple ports, then a port neutral version
|
||||||
BACNET_ADDRESS *src, // source address
|
// of this would be nice. Then it could be moved into iam.c
|
||||||
uint8_t *pdu, // PDU data
|
|
||||||
uint16_t pdu_len) // length PDU
|
|
||||||
{
|
|
||||||
int apdu_offset = 0;
|
|
||||||
BACNET_ADDRESS dest = {0};
|
|
||||||
BACNET_NPDU_DATA npdu_data = {0};
|
|
||||||
|
|
||||||
apdu_offset = npdu_decode(
|
|
||||||
&pdu[0], // data to decode
|
|
||||||
&dest, // destination address - get the DNET/DLEN/DADR if in there
|
|
||||||
src, // source address - get the SNET/SLEN/SADR if in there
|
|
||||||
&npdu_data); // amount of data to decode
|
|
||||||
if (npdu_data.network_layer_message)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"main: network layer message received!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
apdu_handler(
|
|
||||||
src,
|
|
||||||
npdu_data.data_expecting_reply,
|
|
||||||
&pdu[apdu_offset],
|
|
||||||
pdu_len - apdu_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Send_IAm(void)
|
void Send_IAm(void)
|
||||||
{
|
{
|
||||||
int pdu_len = 0;
|
int pdu_len = 0;
|
||||||
@@ -130,15 +102,15 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// input
|
// input
|
||||||
pdu_len = ethernet_receive(
|
pdu_len = ethernet_receive(
|
||||||
&src, // source address
|
&src,
|
||||||
&Rx_Buf[0],
|
&Rx_Buf[0],
|
||||||
MAX_MPDU);
|
MAX_MPDU);
|
||||||
|
|
||||||
// process
|
// process
|
||||||
if (pdu_len)
|
if (pdu_len)
|
||||||
{
|
{
|
||||||
Process_PDU(
|
npdu_handler(
|
||||||
&src, // source address
|
&src,
|
||||||
&Rx_Buf[0],
|
&Rx_Buf[0],
|
||||||
pdu_len);
|
pdu_len);
|
||||||
}
|
}
|
||||||
@@ -148,6 +120,7 @@ int main(int argc, char *argv[])
|
|||||||
Send_IAm();
|
Send_IAm();
|
||||||
}
|
}
|
||||||
// output
|
// output
|
||||||
|
|
||||||
// blink LEDs, Turn on or off outputs, etc
|
// blink LEDs, Turn on or off outputs, etc
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user