예제 #1
0
uint32_t dfu_transport_update_start()
{
    uint32_t err_code;
    
    m_pkt_type = PKT_TYPE_INVALID;

    leds_init();

    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    dfu_register_callback(dfu_cb_handler);
    
    err_code = hci_mem_pool_open();
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    sec_params_init();
    advertising_start();
    
    return NRF_SUCCESS;
}
예제 #2
0
uint32_t hci_transport_open(void)
{
    mp_tx_buffer                 = NULL;
    m_tx_buffer_length           = 0;
    m_tx_retry_counter           = 0;
    m_is_slip_decode_ready       = false;
    m_tx_state                   = TX_STATE_IDLE;
    m_packet_expected_seq_number = INITIAL_ACK_NUMBER_EXPECTED;
    m_packet_transmit_seq_number = INITIAL_ACK_NUMBER_TX;
    m_tx_done_result_code        = HCI_TRANSPORT_TX_DONE_FAILURE;
    
    uint32_t err_code = app_timer_create(&m_app_timer_id, 
                                         APP_TIMER_MODE_REPEATED, 
                                         hci_transport_timeout_handle);
    if (err_code != NRF_SUCCESS)
    {    
        // @note: conduct required interface adjustment.
        return NRF_ERROR_INTERNAL;
    }
    
    err_code = hci_mem_pool_open();
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }    
    
    err_code = hci_slip_open();
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }     
    
    err_code = hci_mem_pool_rx_produce(RX_BUF_SIZE, (void **)&mp_slip_used_rx_buffer);
    if (err_code != NRF_SUCCESS)
    {
        // @note: conduct required interface adjustment.
        return NRF_ERROR_INTERNAL;
    }   
    
    err_code = hci_slip_rx_buffer_register(mp_slip_used_rx_buffer, RX_BUF_SIZE);
    
    return err_code;    
}