test firmware for BLE Micro V1.3 1. test io, vcc and ble 2. act as a UART to BLE bridge

Dependencies:   BLE_API Buffer mbed

Fork of BLE_LEDBlinker by Bluetooth Low Energy

Committer:
arch
Date:
Tue Dec 08 08:34:22 2015 +0000
Revision:
12:c4090cb58976
Parent:
11:c8cbc4bc2c17
fix USBTX/USBRX pins config

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arch 11:c8cbc4bc2c17 1 /* mbed Microcontroller Library
arch 11:c8cbc4bc2c17 2 * Copyright (c) 2006-2013 ARM Limited
arch 11:c8cbc4bc2c17 3 *
arch 11:c8cbc4bc2c17 4 * Licensed under the Apache License, Version 2.0 (the "License");
arch 11:c8cbc4bc2c17 5 * you may not use this file except in compliance with the License.
arch 11:c8cbc4bc2c17 6 * You may obtain a copy of the License at
arch 11:c8cbc4bc2c17 7 *
arch 11:c8cbc4bc2c17 8 * http://www.apache.org/licenses/LICENSE-2.0
arch 11:c8cbc4bc2c17 9 *
arch 11:c8cbc4bc2c17 10 * Unless required by applicable law or agreed to in writing, software
arch 11:c8cbc4bc2c17 11 * distributed under the License is distributed on an "AS IS" BASIS,
arch 11:c8cbc4bc2c17 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
arch 11:c8cbc4bc2c17 13 * See the License for the specific language governing permissions and
arch 11:c8cbc4bc2c17 14 * limitations under the License.
arch 11:c8cbc4bc2c17 15 */
arch 11:c8cbc4bc2c17 16
arch 11:c8cbc4bc2c17 17 #include "nRF5xServiceDiscovery.h"
arch 11:c8cbc4bc2c17 18 #include "nRF5xGattClient.h"
arch 11:c8cbc4bc2c17 19
arch 11:c8cbc4bc2c17 20 #if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
arch 11:c8cbc4bc2c17 21 void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
arch 11:c8cbc4bc2c17 22 {
arch 11:c8cbc4bc2c17 23 nRF5xServiceDiscovery &sdSingleton = nRF5xGattClient::getInstance().discovery;
arch 11:c8cbc4bc2c17 24
arch 11:c8cbc4bc2c17 25 switch (p_ble_evt->header.evt_id) {
arch 11:c8cbc4bc2c17 26 case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
arch 11:c8cbc4bc2c17 27 switch (p_ble_evt->evt.gattc_evt.gatt_status) {
arch 11:c8cbc4bc2c17 28 case BLE_GATT_STATUS_SUCCESS:
arch 11:c8cbc4bc2c17 29 sdSingleton.setupDiscoveredServices(&p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp);
arch 11:c8cbc4bc2c17 30 break;
arch 11:c8cbc4bc2c17 31
arch 11:c8cbc4bc2c17 32 case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
arch 11:c8cbc4bc2c17 33 default:
arch 11:c8cbc4bc2c17 34 sdSingleton.terminate();
arch 11:c8cbc4bc2c17 35 break;
arch 11:c8cbc4bc2c17 36 }
arch 11:c8cbc4bc2c17 37 break;
arch 11:c8cbc4bc2c17 38
arch 11:c8cbc4bc2c17 39 case BLE_GATTC_EVT_CHAR_DISC_RSP:
arch 11:c8cbc4bc2c17 40 switch (p_ble_evt->evt.gattc_evt.gatt_status) {
arch 11:c8cbc4bc2c17 41 case BLE_GATT_STATUS_SUCCESS:
arch 11:c8cbc4bc2c17 42 sdSingleton.setupDiscoveredCharacteristics(&p_ble_evt->evt.gattc_evt.params.char_disc_rsp);
arch 11:c8cbc4bc2c17 43 break;
arch 11:c8cbc4bc2c17 44
arch 11:c8cbc4bc2c17 45 case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
arch 11:c8cbc4bc2c17 46 default:
arch 11:c8cbc4bc2c17 47 sdSingleton.terminateCharacteristicDiscovery();
arch 11:c8cbc4bc2c17 48 break;
arch 11:c8cbc4bc2c17 49 }
arch 11:c8cbc4bc2c17 50 break;
arch 11:c8cbc4bc2c17 51
arch 11:c8cbc4bc2c17 52 case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP:
arch 11:c8cbc4bc2c17 53 if (sdSingleton.isActive()) {
arch 11:c8cbc4bc2c17 54 sdSingleton.processDiscoverUUIDResponse(&p_ble_evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp);
arch 11:c8cbc4bc2c17 55 }
arch 11:c8cbc4bc2c17 56 break;
arch 11:c8cbc4bc2c17 57
arch 11:c8cbc4bc2c17 58 case BLE_GATTC_EVT_READ_RSP: {
arch 11:c8cbc4bc2c17 59 GattReadCallbackParams response = {
arch 11:c8cbc4bc2c17 60 .connHandle = p_ble_evt->evt.gattc_evt.conn_handle,
arch 11:c8cbc4bc2c17 61 .handle = p_ble_evt->evt.gattc_evt.params.read_rsp.handle,
arch 11:c8cbc4bc2c17 62 .offset = p_ble_evt->evt.gattc_evt.params.read_rsp.offset,
arch 11:c8cbc4bc2c17 63 .len = p_ble_evt->evt.gattc_evt.params.read_rsp.len,
arch 11:c8cbc4bc2c17 64 .data = p_ble_evt->evt.gattc_evt.params.read_rsp.data,
arch 11:c8cbc4bc2c17 65 };
arch 11:c8cbc4bc2c17 66 nRF5xGattClient::getInstance().processReadResponse(&response);
arch 11:c8cbc4bc2c17 67 }
arch 11:c8cbc4bc2c17 68 break;
arch 11:c8cbc4bc2c17 69
arch 11:c8cbc4bc2c17 70 case BLE_GATTC_EVT_WRITE_RSP: {
arch 11:c8cbc4bc2c17 71 GattWriteCallbackParams response = {
arch 11:c8cbc4bc2c17 72 .connHandle = p_ble_evt->evt.gattc_evt.conn_handle,
arch 11:c8cbc4bc2c17 73 .handle = p_ble_evt->evt.gattc_evt.params.write_rsp.handle,
arch 11:c8cbc4bc2c17 74 .writeOp = (GattWriteCallbackParams::WriteOp_t)(p_ble_evt->evt.gattc_evt.params.write_rsp.write_op),
arch 11:c8cbc4bc2c17 75 .offset = p_ble_evt->evt.gattc_evt.params.write_rsp.offset,
arch 11:c8cbc4bc2c17 76 .len = p_ble_evt->evt.gattc_evt.params.write_rsp.len,
arch 11:c8cbc4bc2c17 77 .data = p_ble_evt->evt.gattc_evt.params.write_rsp.data,
arch 11:c8cbc4bc2c17 78 };
arch 11:c8cbc4bc2c17 79 nRF5xGattClient::getInstance().processWriteResponse(&response);
arch 11:c8cbc4bc2c17 80 }
arch 11:c8cbc4bc2c17 81 break;
arch 11:c8cbc4bc2c17 82
arch 11:c8cbc4bc2c17 83 case BLE_GATTC_EVT_HVX: {
arch 11:c8cbc4bc2c17 84 GattHVXCallbackParams params;
arch 11:c8cbc4bc2c17 85 params.connHandle = p_ble_evt->evt.gattc_evt.conn_handle;
arch 11:c8cbc4bc2c17 86 params.handle = p_ble_evt->evt.gattc_evt.params.hvx.handle;
arch 11:c8cbc4bc2c17 87 params.type = static_cast<HVXType_t>(p_ble_evt->evt.gattc_evt.params.hvx.type);
arch 11:c8cbc4bc2c17 88 params.len = p_ble_evt->evt.gattc_evt.params.hvx.len;
arch 11:c8cbc4bc2c17 89 params.data = p_ble_evt->evt.gattc_evt.params.hvx.data;
arch 11:c8cbc4bc2c17 90
arch 11:c8cbc4bc2c17 91 nRF5xGattClient::getInstance().processHVXEvent(&params);
arch 11:c8cbc4bc2c17 92 }
arch 11:c8cbc4bc2c17 93 break;
arch 11:c8cbc4bc2c17 94 }
arch 11:c8cbc4bc2c17 95
arch 11:c8cbc4bc2c17 96 sdSingleton.progressCharacteristicDiscovery();
arch 11:c8cbc4bc2c17 97 sdSingleton.progressServiceDiscovery();
arch 11:c8cbc4bc2c17 98 }
arch 11:c8cbc4bc2c17 99 #endif