AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/demo/handler/h_cov.c
int handler_cov_encode_subscriptions(
    uint8_t * apdu,
    int max_apdu)
{
    int len = 0;
    int apdu_len = 0;
    unsigned index = 0;

    if (apdu) {
        for (index = 0; index < MAX_COV_SUBCRIPTIONS; index++) {
            if (COV_Subscriptions[index].flag.valid) {
                len =
                    cov_encode_subscription(&apdu[apdu_len],
                    max_apdu - apdu_len, &COV_Subscriptions[index]);
                apdu_len += len;
                /* TODO: too late here to notice that we overran the buffer */
                if (apdu_len > max_apdu) {
                    return -2;
                }
            }
        }
    }

    return apdu_len;
}
/** Handle a request to list all the COV subscriptions.
 * @ingroup DSCOV
 *  Invoked by a request to read the Device object's PROP_ACTIVE_COV_SUBSCRIPTIONS.
 *  Loops through the list of COV Subscriptions, and, for each valid one,
 *  adds its description to the APDU.
 *  @note This function needs some work to better handle buffer overruns.
 *  @param apdu [out] Buffer in which the APDU contents are built.
 *  @param max_apdu [in] Max length of the APDU buffer.
 *  @return How many bytes were encoded in the buffer, or -2 if the response
 *          would not fit within the buffer.
 */
Handle a request to list all the COV subscriptions.
@ingroup DSCOV
Invoked by a request to read the Device object's PROP_ACTIVE_COV_SUBSCRIPTIONS.
Loops through the list of COV Subscriptions, and, for each valid one,
adds its description to the APDU.
@note This function needs some work to better handle buffer overruns.
@param apdu [out] Buffer in which the APDU contents are built.
@param max_apdu [in] Max length of the APDU buffer.
@return How many bytes were encoded in the buffer, or -2 if the response
would not fit within the buffer.
Handle a request to list all the COV subscriptions . @ingroup DSCOV Invoked by a request to read the Device object ' s PROP_ACTIVE_COV_SUBSCRIPTIONS . Loops through the list of COV Subscriptions and for each valid one adds its description to the APDU . @note This function needs some work to better handle buffer overruns . @param apdu [ out ] Buffer in which the APDU contents are built . @param max_apdu [ in ] Max length of the APDU buffer . @return How many bytes were encoded in the buffer or - 2 if the response would not fit within the buffer .
int handler_cov_encode_subscriptions(
    uint8_t * apdu,
    int max_apdu)
{
    int len = 0;
    int apdu_len = 0;
    unsigned index = 0;
    if (apdu) {
        for (index = 0; index < MAX_COV_SUBCRIPTIONS; index++) {
            if (COV_Subscriptions[index].flag.valid) {
                len =
                    cov_encode_subscription(&apdu[apdu_len],
                    max_apdu - apdu_len, &COV_Subscriptions[index]);
                apdu_len += len;
                if (apdu_len > max_apdu) {
                    return -2;
                }
            }
        }
    }
    return apdu_len;
}
int handler_cov_encode_subscriptions ( uint8_t * apdu , int max_apdu ) { int len = 0 ; int apdu_len = 0 ; unsigned index = 0 ; if ( apdu ) { for ( index = 0 ; index < MAX_COV_SUBCRIPTIONS ; index ++ ) { if ( COV_Subscriptions [ index ] . flag . valid ) { len = cov_encode_subscription ( & apdu [ apdu_len ] , max_apdu - apdu_len , & COV_Subscriptions [ index ] ) ; apdu_len += len ; if ( apdu_len > max_apdu ) { return -2 ; } } } } return apdu_len ; }
Handle a request to list all the COV subscriptions.
Handle a request to list all the COV subscriptions .
/* TODO: too late here to notice that we overran the buffer */