AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/bdk-atxx4-mstp/dlmstp.c
int dlmstp_send_pdu(
    BACNET_ADDRESS * dest,      /* destination address */
    BACNET_NPDU_DATA * npdu_data,       /* network information */
    uint8_t * pdu,      /* any data to be sent - may be null */
    unsigned pdu_len)
{       /* number of bytes of data */
    int bytes_sent = 0;
    struct mstp_pdu_packet *pkt;
    uint16_t i = 0;

    pkt = (struct mstp_pdu_packet *) Ringbuf_Data_Peek(&PDU_Queue);
    if (pkt) {
        pkt->data_expecting_reply = npdu_data->data_expecting_reply;
        for (i = 0; i < pdu_len; i++) {
            pkt->buffer[i] = pdu[i];
        }
        pkt->length = pdu_len;
        if (dest && dest->mac_len) {
            pkt->destination_mac = dest->mac[0];
        } else {
            /* mac_len = 0 is a broadcast address */
            pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
        }
        if (Ringbuf_Data_Put(&PDU_Queue, (uint8_t *)pkt)) {
            bytes_sent = pdu_len;
        }
    }

    return bytes_sent;
}
/* returns number of bytes sent on success, zero on failure */
returns number of bytes sent on success, zero on failure
returns number of bytes sent on success zero on failure
int dlmstp_send_pdu(
    BACNET_ADDRESS * dest,      
    BACNET_NPDU_DATA * npdu_data,       
    uint8_t * pdu,      
    unsigned pdu_len)
{       
    int bytes_sent = 0;
    struct mstp_pdu_packet *pkt;
    uint16_t i = 0;
    pkt = (struct mstp_pdu_packet *) Ringbuf_Data_Peek(&PDU_Queue);
    if (pkt) {
        pkt->data_expecting_reply = npdu_data->data_expecting_reply;
        for (i = 0; i < pdu_len; i++) {
            pkt->buffer[i] = pdu[i];
        }
        pkt->length = pdu_len;
        if (dest && dest->mac_len) {
            pkt->destination_mac = dest->mac[0];
        } else {
            pkt->destination_mac = MSTP_BROADCAST_ADDRESS;
        }
        if (Ringbuf_Data_Put(&PDU_Queue, (uint8_t *)pkt)) {
            bytes_sent = pdu_len;
        }
    }
    return bytes_sent;
}
int dlmstp_send_pdu ( BACNET_ADDRESS * dest , BACNET_NPDU_DATA * npdu_data , uint8_t * pdu , unsigned pdu_len ) { int bytes_sent = 0 ; struct mstp_pdu_packet * pkt ; uint16_t i = 0 ; pkt = ( struct mstp_pdu_packet * ) Ringbuf_Data_Peek ( & PDU_Queue ) ; if ( pkt ) { pkt -> data_expecting_reply = npdu_data -> data_expecting_reply ; for ( i = 0 ; i < pdu_len ; i ++ ) { pkt -> buffer [ i ] = pdu [ i ] ; } pkt -> length = pdu_len ; if ( dest && dest -> mac_len ) { pkt -> destination_mac = dest -> mac [ 0 ] ; } else { pkt -> destination_mac = MSTP_BROADCAST_ADDRESS ; } if ( Ringbuf_Data_Put ( & PDU_Queue , ( uint8_t * ) pkt ) ) { bytes_sent = pdu_len ; } } return bytes_sent ; }
returns number of bytes sent on success, zero on failure
returns number of bytes sent on success zero on failure
/* destination address */ /* network information */ /* any data to be sent - may be null */ /* number of bytes of data */ /* mac_len = 0 is a broadcast address */