https://developer.mbed.org/users/TheoHavercroft/code/nrf51-sdk/
Fork of nRF51822 by
Diff: btle/btle_gap.cpp
- Revision:
- 17:c3e11bb6cb72
- Parent:
- 0:eff01767de02
- Child:
- 22:c6ee8136847e
--- a/btle/btle_gap.cpp Fri May 30 13:32:48 2014 +0100 +++ b/btle/btle_gap.cpp Wed Jun 04 09:19:57 2014 +0100 @@ -31,42 +31,48 @@ /**************************************************************************/ error_t btle_gap_init(void) { - ble_gap_conn_params_t gap_conn_params = { 0 }; + ble_gap_conn_params_t gap_conn_params = {0}; - gap_conn_params.min_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MIN_INTERVAL_MS) ; // in 1.25ms unit - gap_conn_params.max_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MAX_INTERVAL_MS) ; // in 1.25ms unit - gap_conn_params.slave_latency = CFG_GAP_CONNECTION_SLAVE_LATENCY ; - gap_conn_params.conn_sup_timeout = CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10 ; // in 10ms unit + gap_conn_params.min_conn_interval = msec_to_1_25msec( + CFG_GAP_CONNECTION_MIN_INTERVAL_MS); // in 1.25ms units + gap_conn_params.max_conn_interval = msec_to_1_25msec( + CFG_GAP_CONNECTION_MAX_INTERVAL_MS); // in 1.25ms unit + gap_conn_params.slave_latency = CFG_GAP_CONNECTION_SLAVE_LATENCY; + gap_conn_params.conn_sup_timeout = + CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10; // in 10ms unit - ble_gap_conn_sec_mode_t sec_mode; - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed + ble_gap_conn_sec_mode_t sec_mode; + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed - ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) CFG_GAP_LOCAL_NAME, strlen(CFG_GAP_LOCAL_NAME)) ); - ASSERT_STATUS( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE) ); - ASSERT_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params) ); - ASSERT_STATUS( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL) ); + ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode, + (const uint8_t *) + CFG_GAP_LOCAL_NAME, + strlen(CFG_GAP_LOCAL_NAME))); + ASSERT_STATUS( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE)); + ASSERT_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params)); + ASSERT_STATUS( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL)); - /* Connection Parameters */ - enum { - FIRST_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER), - NEXT_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER), - MAX_UPDATE_COUNT = 3 - }; + /* Connection Parameters */ + enum { + FIRST_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER), + NEXT_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER), + MAX_UPDATE_COUNT = 3 + }; - ble_conn_params_init_t cp_init = { 0 }; + ble_conn_params_init_t cp_init = {0}; - cp_init.p_conn_params = NULL ; - cp_init.first_conn_params_update_delay = FIRST_UPDATE_DELAY ; - cp_init.next_conn_params_update_delay = NEXT_UPDATE_DELAY ; - cp_init.max_conn_params_update_count = MAX_UPDATE_COUNT ; - cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID ; - cp_init.disconnect_on_fail = true ; - cp_init.evt_handler = NULL ; - cp_init.error_handler = error_callback; + cp_init.p_conn_params = NULL; + cp_init.first_conn_params_update_delay = FIRST_UPDATE_DELAY; + cp_init.next_conn_params_update_delay = NEXT_UPDATE_DELAY; + cp_init.max_conn_params_update_count = MAX_UPDATE_COUNT; + cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID; + cp_init.disconnect_on_fail = true; + cp_init.evt_handler = NULL; + cp_init.error_handler = error_callback; - ASSERT_STATUS ( ble_conn_params_init(&cp_init) ); + ASSERT_STATUS ( ble_conn_params_init(&cp_init)); - return ERROR_NONE; + return ERROR_NONE; } /**************************************************************************/ @@ -81,10 +87,10 @@ /**************************************************************************/ static inline uint32_t msec_to_1_25msec(uint32_t interval_ms) { - return (interval_ms * 4) / 5 ; + return (interval_ms * 4) / 5; } static void error_callback(uint32_t nrf_error) { - ASSERT_STATUS_RET_VOID( nrf_error ); + ASSERT_STATUS_RET_VOID( nrf_error ); }