AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/bacnet.c
void bacnet_init(void)
{
    unsigned i;

    Ringbuf_Init(&Receive_Queue, (uint8_t *) & Receive_Buffer,
        sizeof(struct mstp_rx_packet), MSTP_RECEIVE_PACKET_COUNT);
    dlmstp_init(NULL);
    /* initialize objects */
    Device_Init(NULL);
    /* set up our confirmed service unrecognized service handler - required! */
    apdu_set_unrecognized_service_handler_handler
        (handler_unrecognized_service);
    /* we need to handle who-is to support dynamic device binding */
    apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
    apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
    /* Set the handlers for any confirmed services that we support. */
    /* We must implement read property - it's required! */
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
        handler_read_property);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
        handler_read_property_multiple);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
        handler_reinitialize_device);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
        handler_write_property);
    /* handle communication so we can shut up when asked */
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
        handler_device_communication_control);
    /* start the cyclic 1 second timer for DCC */
    timer_interval_start_seconds(&DCC_Timer, DCC_CYCLE_SECONDS);
    /* start the cyclic 1 second timer for COV */
    timer_interval_start_seconds(&COV_Timer, COV_CYCLE_SECONDS);
    /* start the cyclic 1 second timer for TSM */
    timer_interval_start_seconds(&TSM_Timer, TSM_CYCLE_SECONDS);
	for (i = 0; i < MAX_ANALOG_INPUTS; i++) {
        Analog_Input_Units_Set(
            Analog_Input_Index_To_Instance(i),
            UNITS_PERCENT);
    }
}
/**************************************************************************
* Description: initializes the BACnet library
* Returns: none
* Notes: none
**************************************************************************/
initializes the BACnet library
Returns: none
Notes: none
initializes the BACnet library Returns : none Notes : none
void bacnet_init(void)
{
    unsigned i;
    Ringbuf_Init(&Receive_Queue, (uint8_t *) & Receive_Buffer,
        sizeof(struct mstp_rx_packet), MSTP_RECEIVE_PACKET_COUNT);
    dlmstp_init(NULL);
    Device_Init(NULL);
    apdu_set_unrecognized_service_handler_handler
        (handler_unrecognized_service);
    apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
    apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
        handler_read_property);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
        handler_read_property_multiple);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
        handler_reinitialize_device);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
        handler_write_property);
    apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
        handler_device_communication_control);
    timer_interval_start_seconds(&DCC_Timer, DCC_CYCLE_SECONDS);
    timer_interval_start_seconds(&COV_Timer, COV_CYCLE_SECONDS);
    timer_interval_start_seconds(&TSM_Timer, TSM_CYCLE_SECONDS);
	for (i = 0; i < MAX_ANALOG_INPUTS; i++) {
        Analog_Input_Units_Set(
            Analog_Input_Index_To_Instance(i),
            UNITS_PERCENT);
    }
}
void bacnet_init ( void ) { unsigned i ; Ringbuf_Init ( & Receive_Queue , ( uint8_t * ) & Receive_Buffer , sizeof ( struct mstp_rx_packet ) , MSTP_RECEIVE_PACKET_COUNT ) ; dlmstp_init ( NULL ) ; Device_Init ( NULL ) ; apdu_set_unrecognized_service_handler_handler ( handler_unrecognized_service ) ; apdu_set_unconfirmed_handler ( SERVICE_UNCONFIRMED_WHO_IS , handler_who_is ) ; apdu_set_unconfirmed_handler ( SERVICE_UNCONFIRMED_WHO_HAS , handler_who_has ) ; apdu_set_confirmed_handler ( SERVICE_CONFIRMED_READ_PROPERTY , handler_read_property ) ; apdu_set_confirmed_handler ( SERVICE_CONFIRMED_READ_PROP_MULTIPLE , handler_read_property_multiple ) ; apdu_set_confirmed_handler ( SERVICE_CONFIRMED_REINITIALIZE_DEVICE , handler_reinitialize_device ) ; apdu_set_confirmed_handler ( SERVICE_CONFIRMED_WRITE_PROPERTY , handler_write_property ) ; apdu_set_confirmed_handler ( SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL , handler_device_communication_control ) ; timer_interval_start_seconds ( & DCC_Timer , DCC_CYCLE_SECONDS ) ; timer_interval_start_seconds ( & COV_Timer , COV_CYCLE_SECONDS ) ; timer_interval_start_seconds ( & TSM_Timer , TSM_CYCLE_SECONDS ) ; for ( i = 0 ; i < MAX_ANALOG_INPUTS ; i ++ ) { Analog_Input_Units_Set ( Analog_Input_Index_To_Instance ( i ) , UNITS_PERCENT ) ; } }
Description: initializes the BACnet library
Returns: none
Notes: none
Description : initializes the BACnet library Returns : none Notes : none
/* initialize objects */ /* set up our confirmed service unrecognized service handler - required! */ /* we need to handle who-is to support dynamic device binding */ /* Set the handlers for any confirmed services that we support. */ /* We must implement read property - it's required! */ /* handle communication so we can shut up when asked */ /* start the cyclic 1 second timer for DCC */ /* start the cyclic 1 second timer for COV */ /* start the cyclic 1 second timer for TSM */