Nordic stack and drivers for the mbed BLE API
Dependents: BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more
source/btle/btle_discovery.cpp@549:3f782c64d014, 2016-01-11 (annotated)
- Committer:
- vcoubard
- Date:
- Mon Jan 11 10:19:06 2016 +0000
- Revision:
- 549:3f782c64d014
- Parent:
- 548:920e941cbe1e
- Child:
- 563:9c4b96f7be8d
Synchronized with git rev a5a46f2f
Author: Rohit Grover
Release 2.0.7
=============
* Fix a bug in the assembly sequence that starts the Nordic bootloader. With
GCC, a MOV instruction was getting converted into an ADDS, which came with
an unwanted side-effect of updating the XPSR. We relocated the offending MOV
instruction such that it would not affect a conditional branch statement.
This would show only with GCC, and when jumping to the bootloader while in
handler mode.
* Fix hardfaults generated from the handling of Radio Notification events.
Radio notification events are interrupts generated at very high priority.
They have the potential to pre-empt other interrupt handling, causing race
conditions when interrupted handlers were involved in calling into BLE_API.
Radio-notification events should defer their callback handling to low-
priority handlers through the use of Tickers or Timeouts.
* Introduce watchdog header file from Nordic SDK 8.1.
* Update license headers to reflect the latest licenses from Nordic.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 542:1bf9c597f44f | 1 | /* mbed Microcontroller Library |
vcoubard | 542:1bf9c597f44f | 2 | * Copyright (c) 2006-2013 ARM Limited |
vcoubard | 542:1bf9c597f44f | 3 | * |
vcoubard | 542:1bf9c597f44f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
vcoubard | 542:1bf9c597f44f | 5 | * you may not use this file except in compliance with the License. |
vcoubard | 542:1bf9c597f44f | 6 | * You may obtain a copy of the License at |
vcoubard | 542:1bf9c597f44f | 7 | * |
vcoubard | 542:1bf9c597f44f | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
vcoubard | 542:1bf9c597f44f | 9 | * |
vcoubard | 542:1bf9c597f44f | 10 | * Unless required by applicable law or agreed to in writing, software |
vcoubard | 542:1bf9c597f44f | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
vcoubard | 542:1bf9c597f44f | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
vcoubard | 542:1bf9c597f44f | 13 | * See the License for the specific language governing permissions and |
vcoubard | 542:1bf9c597f44f | 14 | * limitations under the License. |
vcoubard | 542:1bf9c597f44f | 15 | */ |
vcoubard | 542:1bf9c597f44f | 16 | |
vcoubard | 542:1bf9c597f44f | 17 | #include "nRF5xServiceDiscovery.h" |
vcoubard | 542:1bf9c597f44f | 18 | #include "nRF5xGattClient.h" |
vcoubard | 542:1bf9c597f44f | 19 | |
vcoubard | 542:1bf9c597f44f | 20 | #if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110) |
vcoubard | 542:1bf9c597f44f | 21 | void bleGattcEventHandler(const ble_evt_t *p_ble_evt) |
vcoubard | 542:1bf9c597f44f | 22 | { |
vcoubard | 549:3f782c64d014 | 23 | nRF5xServiceDiscovery &sdSingleton = nRF5xGattClient::getInstance().discovery; |
vcoubard | 542:1bf9c597f44f | 24 | |
vcoubard | 542:1bf9c597f44f | 25 | switch (p_ble_evt->header.evt_id) { |
vcoubard | 542:1bf9c597f44f | 26 | case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: |
vcoubard | 542:1bf9c597f44f | 27 | switch (p_ble_evt->evt.gattc_evt.gatt_status) { |
vcoubard | 542:1bf9c597f44f | 28 | case BLE_GATT_STATUS_SUCCESS: |
vcoubard | 542:1bf9c597f44f | 29 | sdSingleton.setupDiscoveredServices(&p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp); |
vcoubard | 542:1bf9c597f44f | 30 | break; |
vcoubard | 542:1bf9c597f44f | 31 | |
vcoubard | 542:1bf9c597f44f | 32 | case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND: |
vcoubard | 542:1bf9c597f44f | 33 | default: |
vcoubard | 542:1bf9c597f44f | 34 | sdSingleton.terminate(); |
vcoubard | 542:1bf9c597f44f | 35 | break; |
vcoubard | 542:1bf9c597f44f | 36 | } |
vcoubard | 542:1bf9c597f44f | 37 | break; |
vcoubard | 542:1bf9c597f44f | 38 | |
vcoubard | 542:1bf9c597f44f | 39 | case BLE_GATTC_EVT_CHAR_DISC_RSP: |
vcoubard | 542:1bf9c597f44f | 40 | switch (p_ble_evt->evt.gattc_evt.gatt_status) { |
vcoubard | 542:1bf9c597f44f | 41 | case BLE_GATT_STATUS_SUCCESS: |
vcoubard | 542:1bf9c597f44f | 42 | sdSingleton.setupDiscoveredCharacteristics(&p_ble_evt->evt.gattc_evt.params.char_disc_rsp); |
vcoubard | 542:1bf9c597f44f | 43 | break; |
vcoubard | 542:1bf9c597f44f | 44 | |
vcoubard | 542:1bf9c597f44f | 45 | case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND: |
vcoubard | 542:1bf9c597f44f | 46 | default: |
vcoubard | 549:3f782c64d014 | 47 | sdSingleton.terminateCharacteristicDiscovery(); |
vcoubard | 542:1bf9c597f44f | 48 | break; |
vcoubard | 542:1bf9c597f44f | 49 | } |
vcoubard | 542:1bf9c597f44f | 50 | break; |
vcoubard | 542:1bf9c597f44f | 51 | |
vcoubard | 542:1bf9c597f44f | 52 | case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP: |
vcoubard | 542:1bf9c597f44f | 53 | if (sdSingleton.isActive()) { |
vcoubard | 542:1bf9c597f44f | 54 | sdSingleton.processDiscoverUUIDResponse(&p_ble_evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp); |
vcoubard | 542:1bf9c597f44f | 55 | } |
vcoubard | 542:1bf9c597f44f | 56 | break; |
vcoubard | 542:1bf9c597f44f | 57 | |
vcoubard | 542:1bf9c597f44f | 58 | case BLE_GATTC_EVT_READ_RSP: { |
vcoubard | 542:1bf9c597f44f | 59 | GattReadCallbackParams response = { |
vcoubard | 542:1bf9c597f44f | 60 | .connHandle = p_ble_evt->evt.gattc_evt.conn_handle, |
vcoubard | 542:1bf9c597f44f | 61 | .handle = p_ble_evt->evt.gattc_evt.params.read_rsp.handle, |
vcoubard | 542:1bf9c597f44f | 62 | .offset = p_ble_evt->evt.gattc_evt.params.read_rsp.offset, |
vcoubard | 542:1bf9c597f44f | 63 | .len = p_ble_evt->evt.gattc_evt.params.read_rsp.len, |
vcoubard | 542:1bf9c597f44f | 64 | .data = p_ble_evt->evt.gattc_evt.params.read_rsp.data, |
vcoubard | 542:1bf9c597f44f | 65 | }; |
vcoubard | 542:1bf9c597f44f | 66 | nRF5xGattClient::getInstance().processReadResponse(&response); |
vcoubard | 542:1bf9c597f44f | 67 | } |
vcoubard | 542:1bf9c597f44f | 68 | break; |
vcoubard | 542:1bf9c597f44f | 69 | |
vcoubard | 542:1bf9c597f44f | 70 | case BLE_GATTC_EVT_WRITE_RSP: { |
vcoubard | 542:1bf9c597f44f | 71 | GattWriteCallbackParams response = { |
vcoubard | 542:1bf9c597f44f | 72 | .connHandle = p_ble_evt->evt.gattc_evt.conn_handle, |
vcoubard | 542:1bf9c597f44f | 73 | .handle = p_ble_evt->evt.gattc_evt.params.write_rsp.handle, |
vcoubard | 542:1bf9c597f44f | 74 | .writeOp = (GattWriteCallbackParams::WriteOp_t)(p_ble_evt->evt.gattc_evt.params.write_rsp.write_op), |
vcoubard | 542:1bf9c597f44f | 75 | .offset = p_ble_evt->evt.gattc_evt.params.write_rsp.offset, |
vcoubard | 542:1bf9c597f44f | 76 | .len = p_ble_evt->evt.gattc_evt.params.write_rsp.len, |
vcoubard | 542:1bf9c597f44f | 77 | .data = p_ble_evt->evt.gattc_evt.params.write_rsp.data, |
vcoubard | 542:1bf9c597f44f | 78 | }; |
vcoubard | 542:1bf9c597f44f | 79 | nRF5xGattClient::getInstance().processWriteResponse(&response); |
vcoubard | 542:1bf9c597f44f | 80 | } |
vcoubard | 542:1bf9c597f44f | 81 | break; |
vcoubard | 542:1bf9c597f44f | 82 | |
vcoubard | 542:1bf9c597f44f | 83 | case BLE_GATTC_EVT_HVX: { |
vcoubard | 542:1bf9c597f44f | 84 | GattHVXCallbackParams params; |
vcoubard | 542:1bf9c597f44f | 85 | params.connHandle = p_ble_evt->evt.gattc_evt.conn_handle; |
vcoubard | 542:1bf9c597f44f | 86 | params.handle = p_ble_evt->evt.gattc_evt.params.hvx.handle; |
vcoubard | 542:1bf9c597f44f | 87 | params.type = static_cast<HVXType_t>(p_ble_evt->evt.gattc_evt.params.hvx.type); |
vcoubard | 542:1bf9c597f44f | 88 | params.len = p_ble_evt->evt.gattc_evt.params.hvx.len; |
vcoubard | 542:1bf9c597f44f | 89 | params.data = p_ble_evt->evt.gattc_evt.params.hvx.data; |
vcoubard | 542:1bf9c597f44f | 90 | |
vcoubard | 542:1bf9c597f44f | 91 | nRF5xGattClient::getInstance().processHVXEvent(¶ms); |
vcoubard | 542:1bf9c597f44f | 92 | } |
vcoubard | 542:1bf9c597f44f | 93 | break; |
vcoubard | 542:1bf9c597f44f | 94 | } |
vcoubard | 542:1bf9c597f44f | 95 | |
vcoubard | 542:1bf9c597f44f | 96 | sdSingleton.progressCharacteristicDiscovery(); |
vcoubard | 542:1bf9c597f44f | 97 | sdSingleton.progressServiceDiscovery(); |
vcoubard | 542:1bf9c597f44f | 98 | } |
vcoubard | 542:1bf9c597f44f | 99 | #endif |