test
Fork of nRF51822 by
btle/btle.cpp@112:737b08b3b995, 2015-04-30 (annotated)
- Committer:
- rgrover1
- Date:
- Thu Apr 30 08:34:37 2015 +0100
- Revision:
- 112:737b08b3b995
- Parent:
- 103:138bdc859cc9
- Child:
- 122:df81fcbfa150
Synchronized with git rev 4ae92f89
Author: Rohit Grover
porting to v8.0 of the SDK
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rohit Grover |
22:c6ee8136847e | 1 | /* mbed Microcontroller Library |
Rohit Grover |
22:c6ee8136847e | 2 | * Copyright (c) 2006-2013 ARM Limited |
Rohit Grover |
22:c6ee8136847e | 3 | * |
Rohit Grover |
22:c6ee8136847e | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Rohit Grover |
22:c6ee8136847e | 5 | * you may not use this file except in compliance with the License. |
Rohit Grover |
22:c6ee8136847e | 6 | * You may obtain a copy of the License at |
Rohit Grover |
22:c6ee8136847e | 7 | * |
Rohit Grover |
22:c6ee8136847e | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Rohit Grover |
22:c6ee8136847e | 9 | * |
Rohit Grover |
22:c6ee8136847e | 10 | * Unless required by applicable law or agreed to in writing, software |
Rohit Grover |
22:c6ee8136847e | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Rohit Grover |
22:c6ee8136847e | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Rohit Grover |
22:c6ee8136847e | 13 | * See the License for the specific language governing permissions and |
Rohit Grover |
22:c6ee8136847e | 14 | * limitations under the License. |
Rohit Grover |
22:c6ee8136847e | 15 | */ |
Rohit Grover |
52:120bd37b9d0d | 16 | |
Rohit Grover |
22:c6ee8136847e | 17 | #include "common/common.h" |
Rohit Grover |
37:c29c330d942c | 18 | #include "nordic_common.h" |
Rohit Grover |
22:c6ee8136847e | 19 | |
Rohit Grover |
22:c6ee8136847e | 20 | #include "btle.h" |
Rohit Grover |
22:c6ee8136847e | 21 | |
Rohit Grover |
22:c6ee8136847e | 22 | #include "ble_stack_handler_types.h" |
Rohit Grover |
22:c6ee8136847e | 23 | #include "ble_flash.h" |
Rohit Grover |
37:c29c330d942c | 24 | #if NEED_BOND_MANAGER |
Rohit Grover |
22:c6ee8136847e | 25 | #include "ble_bondmngr.h" |
Rohit Grover |
37:c29c330d942c | 26 | #endif |
Rohit Grover |
22:c6ee8136847e | 27 | #include "ble_conn_params.h" |
Rohit Grover |
22:c6ee8136847e | 28 | |
Rohit Grover |
22:c6ee8136847e | 29 | #include "btle_gap.h" |
Rohit Grover |
22:c6ee8136847e | 30 | #include "btle_advertising.h" |
Rohit Grover |
22:c6ee8136847e | 31 | #include "custom/custom_helper.h" |
Rohit Grover |
22:c6ee8136847e | 32 | |
Rohit Grover |
22:c6ee8136847e | 33 | #include "softdevice_handler.h" |
Rohit Grover |
22:c6ee8136847e | 34 | #include "pstorage.h" |
Rohit Grover |
22:c6ee8136847e | 35 | |
Rohit Grover |
52:120bd37b9d0d | 36 | #include "GapEvents.h" |
Rohit Grover |
22:c6ee8136847e | 37 | #include "nRF51Gap.h" |
Rohit Grover |
22:c6ee8136847e | 38 | #include "nRF51GattServer.h" |
Rohit Grover |
22:c6ee8136847e | 39 | |
Rohit Grover |
56:a1071b629aa3 | 40 | #include "ble_hci.h" |
Rohit Grover |
56:a1071b629aa3 | 41 | |
Rohit Grover |
32:84dea0924a63 | 42 | #if NEED_BOND_MANAGER /* disabled by default */ |
Rohit Grover |
22:c6ee8136847e | 43 | static void service_error_callback(uint32_t nrf_error); |
Rohit Grover |
32:84dea0924a63 | 44 | #endif |
Rohit Grover |
56:a1071b629aa3 | 45 | extern "C" void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name); |
Rohit Grover |
56:a1071b629aa3 | 46 | void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name); |
Rohit Grover |
22:c6ee8136847e | 47 | |
Rohit Grover |
32:84dea0924a63 | 48 | #if NEED_BOND_MANAGER /* disabled by default */ |
Rohit Grover |
22:c6ee8136847e | 49 | static error_t bond_manager_init(void); |
Rohit Grover |
32:84dea0924a63 | 50 | #endif |
Rohit Grover |
22:c6ee8136847e | 51 | |
Rohit Grover |
22:c6ee8136847e | 52 | static void btle_handler(ble_evt_t *p_ble_evt); |
Rohit Grover |
22:c6ee8136847e | 53 | |
Rohit Grover |
22:c6ee8136847e | 54 | static void sys_evt_dispatch(uint32_t sys_evt) |
Rohit Grover |
22:c6ee8136847e | 55 | { |
Rohit Grover |
22:c6ee8136847e | 56 | pstorage_sys_event_handler(sys_evt); |
Rohit Grover |
22:c6ee8136847e | 57 | } |
Rohit Grover |
22:c6ee8136847e | 58 | |
Rohit Grover |
22:c6ee8136847e | 59 | error_t btle_init(void) |
Rohit Grover |
22:c6ee8136847e | 60 | { |
rgrover1 | 94:2bac1b3c5cfc | 61 | #if defined(TARGET_DELTA_DFCM_NNN40) || defined(TARGET_HRM1017) |
rgrover1 | 112:737b08b3b995 | 62 | SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, NULL); |
ytsuboi | 61:d0158c65d0d7 | 63 | #else |
rgrover1 | 112:737b08b3b995 | 64 | SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL); |
ytsuboi | 61:d0158c65d0d7 | 65 | #endif |
Rohit Grover |
56:a1071b629aa3 | 66 | |
Rohit Grover |
56:a1071b629aa3 | 67 | // Enable BLE stack |
Rohit Grover |
56:a1071b629aa3 | 68 | /** |
Rohit Grover |
56:a1071b629aa3 | 69 | * Using this call, the application can select whether to include the |
Rohit Grover |
56:a1071b629aa3 | 70 | * Service Changed characteristic in the GATT Server. The default in all |
Rohit Grover |
56:a1071b629aa3 | 71 | * previous releases has been to include the Service Changed characteristic, |
Rohit Grover |
56:a1071b629aa3 | 72 | * but this affects how GATT clients behave. Specifically, it requires |
Rohit Grover |
56:a1071b629aa3 | 73 | * clients to subscribe to this attribute and not to cache attribute handles |
Rohit Grover |
56:a1071b629aa3 | 74 | * between connections unless the devices are bonded. If the application |
Rohit Grover |
56:a1071b629aa3 | 75 | * does not need to change the structure of the GATT server attributes at |
Rohit Grover |
56:a1071b629aa3 | 76 | * runtime this adds unnecessary complexity to the interaction with peer |
Rohit Grover |
56:a1071b629aa3 | 77 | * clients. If the SoftDevice is enabled with the Service Changed |
Rohit Grover |
56:a1071b629aa3 | 78 | * Characteristics turned off, then clients are allowed to cache attribute |
Rohit Grover |
56:a1071b629aa3 | 79 | * handles making applications simpler on both sides. |
Rohit Grover |
56:a1071b629aa3 | 80 | */ |
Rohit Grover |
68:936d81c963fe | 81 | static const bool IS_SRVC_CHANGED_CHARACT_PRESENT = true; |
Rohit Grover |
56:a1071b629aa3 | 82 | ble_enable_params_t enableParams = { |
Rohit Grover |
56:a1071b629aa3 | 83 | .gatts_enable_params = { |
Rohit Grover |
56:a1071b629aa3 | 84 | .service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT |
Rohit Grover |
56:a1071b629aa3 | 85 | } |
Rohit Grover |
56:a1071b629aa3 | 86 | }; |
Rohit Grover |
56:a1071b629aa3 | 87 | if (sd_ble_enable(&enableParams) != NRF_SUCCESS) { |
Rohit Grover |
56:a1071b629aa3 | 88 | return ERROR_INVALID_PARAM; |
Rohit Grover |
56:a1071b629aa3 | 89 | } |
Rohit Grover |
56:a1071b629aa3 | 90 | |
Rohit Grover |
56:a1071b629aa3 | 91 | ble_gap_addr_t addr; |
Rohit Grover |
56:a1071b629aa3 | 92 | if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) { |
Rohit Grover |
56:a1071b629aa3 | 93 | return ERROR_INVALID_PARAM; |
Rohit Grover |
56:a1071b629aa3 | 94 | } |
Rohit Grover |
56:a1071b629aa3 | 95 | if (sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr) != NRF_SUCCESS) { |
Rohit Grover |
56:a1071b629aa3 | 96 | return ERROR_INVALID_PARAM; |
Rohit Grover |
56:a1071b629aa3 | 97 | } |
Rohit Grover |
22:c6ee8136847e | 98 | |
Rohit Grover |
22:c6ee8136847e | 99 | ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler)); |
Rohit Grover |
22:c6ee8136847e | 100 | ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch)); |
Rohit Grover |
22:c6ee8136847e | 101 | |
Rohit Grover |
32:84dea0924a63 | 102 | #if NEED_BOND_MANAGER /* disabled by default */ |
Rohit Grover |
22:c6ee8136847e | 103 | bond_manager_init(); |
Rohit Grover |
32:84dea0924a63 | 104 | #endif |
Rohit Grover |
22:c6ee8136847e | 105 | btle_gap_init(); |
Rohit Grover |
22:c6ee8136847e | 106 | |
Rohit Grover |
22:c6ee8136847e | 107 | return ERROR_NONE; |
Rohit Grover |
22:c6ee8136847e | 108 | } |
Rohit Grover |
22:c6ee8136847e | 109 | |
Rohit Grover |
22:c6ee8136847e | 110 | static void btle_handler(ble_evt_t *p_ble_evt) |
Rohit Grover |
22:c6ee8136847e | 111 | { |
Rohit Grover |
22:c6ee8136847e | 112 | /* Library service handlers */ |
Rohit Grover |
32:84dea0924a63 | 113 | #if NEED_BOND_MANAGER /* disabled by default */ |
Rohit Grover |
22:c6ee8136847e | 114 | ble_bondmngr_on_ble_evt(p_ble_evt); |
Rohit Grover |
32:84dea0924a63 | 115 | #endif |
Rohit Grover |
56:a1071b629aa3 | 116 | #if SDK_CONN_PARAMS_MODULE_ENABLE |
Rohit Grover |
22:c6ee8136847e | 117 | ble_conn_params_on_ble_evt(p_ble_evt); |
Rohit Grover |
56:a1071b629aa3 | 118 | #endif |
Rohit Grover |
22:c6ee8136847e | 119 | |
Rohit Grover |
22:c6ee8136847e | 120 | /* Custom event handler */ |
Rohit Grover |
22:c6ee8136847e | 121 | switch (p_ble_evt->header.evt_id) { |
Rohit Grover |
41:6e66cd970659 | 122 | case BLE_GAP_EVT_CONNECTED: { |
Rohit Grover |
41:6e66cd970659 | 123 | Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; |
Rohit Grover |
41:6e66cd970659 | 124 | nRF51Gap::getInstance().setConnectionHandle(handle); |
Rohit Grover |
56:a1071b629aa3 | 125 | const Gap::ConnectionParams_t *params = reinterpret_cast<Gap::ConnectionParams_t *>(&(p_ble_evt->evt.gap_evt.params.connected.conn_params)); |
rgrover1 | 77:9886b2865631 | 126 | const ble_gap_addr_t *peer = &p_ble_evt->evt.gap_evt.params.connected.peer_addr; |
rgrover1 | 112:737b08b3b995 | 127 | const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr; |
rgrover1 | 112:737b08b3b995 | 128 | nRF51Gap::getInstance().processConnectionEvent(handle, |
rgrover1 | 112:737b08b3b995 | 129 | static_cast<Gap::addr_type_t>(peer->addr_type), peer->addr, |
rgrover1 | 112:737b08b3b995 | 130 | static_cast<Gap::addr_type_t>(own->addr_type), own->addr, |
rgrover1 | 112:737b08b3b995 | 131 | params); |
Rohit Grover |
22:c6ee8136847e | 132 | break; |
Rohit Grover |
41:6e66cd970659 | 133 | } |
Rohit Grover |
22:c6ee8136847e | 134 | |
Rohit Grover |
41:6e66cd970659 | 135 | case BLE_GAP_EVT_DISCONNECTED: { |
Rohit Grover |
41:6e66cd970659 | 136 | Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; |
Rohit Grover |
22:c6ee8136847e | 137 | // Since we are not in a connection and have not started advertising, |
Rohit Grover |
22:c6ee8136847e | 138 | // store bonds |
Rohit Grover |
22:c6ee8136847e | 139 | nRF51Gap::getInstance().setConnectionHandle (BLE_CONN_HANDLE_INVALID); |
Rohit Grover |
32:84dea0924a63 | 140 | #if NEED_BOND_MANAGER /* disabled by default */ |
Rohit Grover |
22:c6ee8136847e | 141 | ASSERT_STATUS_RET_VOID ( ble_bondmngr_bonded_centrals_store()); |
Rohit Grover |
32:84dea0924a63 | 142 | #endif |
Rohit Grover |
56:a1071b629aa3 | 143 | |
Rohit Grover |
65:98215c4f3a25 | 144 | Gap::DisconnectionReason_t reason; |
Rohit Grover |
65:98215c4f3a25 | 145 | switch (p_ble_evt->evt.gap_evt.params.disconnected.reason) { |
Rohit Grover |
65:98215c4f3a25 | 146 | case BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION: |
Rohit Grover |
65:98215c4f3a25 | 147 | reason = Gap::LOCAL_HOST_TERMINATED_CONNECTION; |
Rohit Grover |
65:98215c4f3a25 | 148 | break; |
Rohit Grover |
65:98215c4f3a25 | 149 | case BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION: |
Rohit Grover |
65:98215c4f3a25 | 150 | reason = Gap::REMOTE_USER_TERMINATED_CONNECTION; |
Rohit Grover |
65:98215c4f3a25 | 151 | break; |
Rohit Grover |
65:98215c4f3a25 | 152 | case BLE_HCI_CONN_INTERVAL_UNACCEPTABLE: |
Rohit Grover |
65:98215c4f3a25 | 153 | reason = Gap::CONN_INTERVAL_UNACCEPTABLE; |
Rohit Grover |
65:98215c4f3a25 | 154 | break; |
Rohit Grover |
65:98215c4f3a25 | 155 | default: |
Rohit Grover |
65:98215c4f3a25 | 156 | /* Please refer to the underlying transport library for an |
Rohit Grover |
65:98215c4f3a25 | 157 | * interpretion of this reason's value. */ |
Rohit Grover |
65:98215c4f3a25 | 158 | reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason); |
Rohit Grover |
65:98215c4f3a25 | 159 | break; |
Rohit Grover |
56:a1071b629aa3 | 160 | } |
Rohit Grover |
65:98215c4f3a25 | 161 | nRF51Gap::getInstance().processDisconnectionEvent(handle, reason); |
Rohit Grover |
22:c6ee8136847e | 162 | break; |
Rohit Grover |
41:6e66cd970659 | 163 | } |
Rohit Grover |
22:c6ee8136847e | 164 | |
Rohit Grover |
22:c6ee8136847e | 165 | case BLE_GAP_EVT_SEC_PARAMS_REQUEST: { |
Rohit Grover |
22:c6ee8136847e | 166 | ble_gap_sec_params_t sec_params = {0}; |
Rohit Grover |
22:c6ee8136847e | 167 | |
rgrover1 | 112:737b08b3b995 | 168 | sec_params.bond = 1; /**< Perform bonding. */ |
rgrover1 | 112:737b08b3b995 | 169 | sec_params.mitm = CFG_BLE_SEC_PARAM_MITM; |
rgrover1 | 112:737b08b3b995 | 170 | sec_params.io_caps = CFG_BLE_SEC_PARAM_IO_CAPABILITIES; |
rgrover1 | 112:737b08b3b995 | 171 | sec_params.oob = CFG_BLE_SEC_PARAM_OOB; |
rgrover1 | 112:737b08b3b995 | 172 | sec_params.min_key_size = CFG_BLE_SEC_PARAM_MIN_KEY_SIZE; |
rgrover1 | 112:737b08b3b995 | 173 | sec_params.max_key_size = CFG_BLE_SEC_PARAM_MAX_KEY_SIZE; |
Rohit Grover |
22:c6ee8136847e | 174 | |
rgrover1 | 112:737b08b3b995 | 175 | ble_gap_sec_keyset_t sec_keyset = {0}; |
rgrover1 | 112:737b08b3b995 | 176 | |
rgrover1 | 112:737b08b3b995 | 177 | ASSERT_STATUS_RET_VOID(sd_ble_gap_sec_params_reply(nRF51Gap::getInstance().getConnectionHandle(), BLE_GAP_SEC_STATUS_SUCCESS, &sec_params, &sec_keyset)); |
Rohit Grover |
22:c6ee8136847e | 178 | } |
Rohit Grover |
22:c6ee8136847e | 179 | break; |
Rohit Grover |
22:c6ee8136847e | 180 | |
Rohit Grover |
22:c6ee8136847e | 181 | case BLE_GAP_EVT_TIMEOUT: |
rgrover1 | 112:737b08b3b995 | 182 | if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING) { |
Rohit Grover |
41:6e66cd970659 | 183 | nRF51Gap::getInstance().processEvent(GapEvents::GAP_EVENT_TIMEOUT); |
Rohit Grover |
22:c6ee8136847e | 184 | } |
Rohit Grover |
22:c6ee8136847e | 185 | break; |
Rohit Grover |
22:c6ee8136847e | 186 | |
Rohit Grover |
22:c6ee8136847e | 187 | case BLE_GATTC_EVT_TIMEOUT: |
Rohit Grover |
22:c6ee8136847e | 188 | case BLE_GATTS_EVT_TIMEOUT: |
Rohit Grover |
22:c6ee8136847e | 189 | // Disconnect on GATT Server and Client timeout events. |
Rohit Grover |
22:c6ee8136847e | 190 | // ASSERT_STATUS_RET_VOID (sd_ble_gap_disconnect(m_conn_handle, |
Rohit Grover |
22:c6ee8136847e | 191 | // BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION)); |
Rohit Grover |
22:c6ee8136847e | 192 | break; |
Rohit Grover |
22:c6ee8136847e | 193 | |
Rohit Grover |
22:c6ee8136847e | 194 | default: |
Rohit Grover |
22:c6ee8136847e | 195 | break; |
Rohit Grover |
22:c6ee8136847e | 196 | } |
Rohit Grover |
22:c6ee8136847e | 197 | |
Rohit Grover |
22:c6ee8136847e | 198 | nRF51GattServer::getInstance().hwCallback(p_ble_evt); |
Rohit Grover |
22:c6ee8136847e | 199 | } |
Rohit Grover |
22:c6ee8136847e | 200 | |
Rohit Grover |
32:84dea0924a63 | 201 | #if NEED_BOND_MANAGER /* disabled by default */ |
Rohit Grover |
22:c6ee8136847e | 202 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 203 | /*! |
Rohit Grover |
22:c6ee8136847e | 204 | @brief Initialises the bond manager |
Rohit Grover |
22:c6ee8136847e | 205 | |
Rohit Grover |
22:c6ee8136847e | 206 | @note Bond data will be cleared on reset if the bond delete |
Rohit Grover |
22:c6ee8136847e | 207 | button is pressed during initialisation (the button is |
Rohit Grover |
22:c6ee8136847e | 208 | defined as CFG_BLE_BOND_DELETE_BUTTON_NUM). |
Rohit Grover |
22:c6ee8136847e | 209 | |
Rohit Grover |
22:c6ee8136847e | 210 | @returns |
Rohit Grover |
22:c6ee8136847e | 211 | */ |
Rohit Grover |
22:c6ee8136847e | 212 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 213 | static error_t bond_manager_init(void) |
Rohit Grover |
22:c6ee8136847e | 214 | { |
Rohit Grover |
22:c6ee8136847e | 215 | ble_bondmngr_init_t bond_para = {0}; |
Rohit Grover |
22:c6ee8136847e | 216 | |
Rohit Grover |
22:c6ee8136847e | 217 | ASSERT_STATUS ( pstorage_init()); |
Rohit Grover |
22:c6ee8136847e | 218 | |
Rohit Grover |
22:c6ee8136847e | 219 | bond_para.flash_page_num_bond = CFG_BLE_BOND_FLASH_PAGE_BOND; |
Rohit Grover |
22:c6ee8136847e | 220 | bond_para.flash_page_num_sys_attr = CFG_BLE_BOND_FLASH_PAGE_SYS_ATTR; |
Rohit Grover |
22:c6ee8136847e | 221 | //bond_para.bonds_delete = boardButtonCheck(CFG_BLE_BOND_DELETE_BUTTON_NUM) ; |
Rohit Grover |
22:c6ee8136847e | 222 | bond_para.evt_handler = NULL; |
Rohit Grover |
22:c6ee8136847e | 223 | bond_para.error_handler = service_error_callback; |
Rohit Grover |
22:c6ee8136847e | 224 | |
Rohit Grover |
22:c6ee8136847e | 225 | ASSERT_STATUS( ble_bondmngr_init( &bond_para )); |
Rohit Grover |
22:c6ee8136847e | 226 | |
Rohit Grover |
22:c6ee8136847e | 227 | /* Init radio active/inactive notification to flash (to only perform flashing when the radio is inactive) */ |
Rohit Grover |
22:c6ee8136847e | 228 | // ASSERT_STATUS( ble_radio_notification_init(NRF_APP_PRIORITY_HIGH, |
Rohit Grover |
22:c6ee8136847e | 229 | // NRF_RADIO_NOTIFICATION_DISTANCE_4560US, |
Rohit Grover |
22:c6ee8136847e | 230 | // ble_flash_on_radio_active_evt) ); |
Rohit Grover |
22:c6ee8136847e | 231 | |
Rohit Grover |
22:c6ee8136847e | 232 | return ERROR_NONE; |
Rohit Grover |
22:c6ee8136847e | 233 | } |
Rohit Grover |
32:84dea0924a63 | 234 | #endif // #if NEED_BOND_MANAGER |
Rohit Grover |
22:c6ee8136847e | 235 | |
Rohit Grover |
32:84dea0924a63 | 236 | #if NEED_BOND_MANAGER /* disabled by default */ |
Rohit Grover |
22:c6ee8136847e | 237 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 238 | /*! |
Rohit Grover |
22:c6ee8136847e | 239 | @brief |
Rohit Grover |
22:c6ee8136847e | 240 | @param[in] nrf_error |
Rohit Grover |
22:c6ee8136847e | 241 | @returns |
Rohit Grover |
22:c6ee8136847e | 242 | */ |
Rohit Grover |
22:c6ee8136847e | 243 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 244 | static void service_error_callback(uint32_t nrf_error) |
Rohit Grover |
22:c6ee8136847e | 245 | { |
Rohit Grover |
22:c6ee8136847e | 246 | ASSERT_STATUS_RET_VOID( nrf_error ); |
Rohit Grover |
22:c6ee8136847e | 247 | } |
Rohit Grover |
32:84dea0924a63 | 248 | #endif // #if NEED_BOND_MANAGER |
Rohit Grover |
22:c6ee8136847e | 249 | |
Rohit Grover |
22:c6ee8136847e | 250 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 251 | /*! |
Rohit Grover |
22:c6ee8136847e | 252 | @brief Callback when an error occurs inside the SoftDevice |
Rohit Grover |
22:c6ee8136847e | 253 | |
Rohit Grover |
22:c6ee8136847e | 254 | @param[in] line_num |
Rohit Grover |
22:c6ee8136847e | 255 | @param[in] p-file_name |
Rohit Grover |
22:c6ee8136847e | 256 | |
Rohit Grover |
22:c6ee8136847e | 257 | @returns |
Rohit Grover |
22:c6ee8136847e | 258 | */ |
Rohit Grover |
22:c6ee8136847e | 259 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 260 | void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name) |
Rohit Grover |
22:c6ee8136847e | 261 | { |
Rohit Grover |
22:c6ee8136847e | 262 | ASSERT(false, (void) 0); |
Rohit Grover |
22:c6ee8136847e | 263 | } |
Rohit Grover |
22:c6ee8136847e | 264 | |
Rohit Grover |
22:c6ee8136847e | 265 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 266 | /*! |
Rohit Grover |
22:c6ee8136847e | 267 | @brief Handler for general errors above the SoftDevice layer. |
Rohit Grover |
22:c6ee8136847e | 268 | Typically we can' recover from this so we do a reset. |
Rohit Grover |
22:c6ee8136847e | 269 | |
Rohit Grover |
22:c6ee8136847e | 270 | @param[in] error_code |
Rohit Grover |
22:c6ee8136847e | 271 | @param[in] line_num |
Rohit Grover |
22:c6ee8136847e | 272 | @param[in] p-file_name |
Rohit Grover |
22:c6ee8136847e | 273 | |
Rohit Grover |
22:c6ee8136847e | 274 | @returns |
Rohit Grover |
22:c6ee8136847e | 275 | */ |
Rohit Grover |
22:c6ee8136847e | 276 | /**************************************************************************/ |
Rohit Grover |
22:c6ee8136847e | 277 | void app_error_handler(uint32_t error_code, |
Rohit Grover |
22:c6ee8136847e | 278 | uint32_t line_num, |
Rohit Grover |
22:c6ee8136847e | 279 | const uint8_t *p_file_name) |
Rohit Grover |
22:c6ee8136847e | 280 | { |
Rohit Grover |
22:c6ee8136847e | 281 | ASSERT_STATUS_RET_VOID( error_code ); |
Rohit Grover |
22:c6ee8136847e | 282 | NVIC_SystemReset(); |
rgrover1 | 77:9886b2865631 | 283 | } |