Added support for obtaining BLE device name by parsing advertising data.

Fork of BLE_BlueNRG by Mridupawan Das

Committer:
hemddabral
Date:
Thu Jul 31 11:09:28 2014 +0000
Revision:
7:e293b0f43dc7
Parent:
6:08cfc94b5f49
Added support for parsing BLE device name from advertising data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mridup 2:a2b623661316 1 /* mbed Microcontroller Library
mridup 2:a2b623661316 2 * Copyright (c) 2006-2013 ARM Limited
mridup 2:a2b623661316 3 *
mridup 2:a2b623661316 4 * Licensed under the Apache License, Version 2.0 (the "License");
mridup 2:a2b623661316 5 * you may not use this file except in compliance with the License.
mridup 2:a2b623661316 6 * You may obtain a copy of the License at
mridup 2:a2b623661316 7 *
mridup 2:a2b623661316 8 * http://www.apache.org/licenses/LICENSE-2.0
mridup 2:a2b623661316 9 *
mridup 2:a2b623661316 10 * Unless required by applicable law or agreed to in writing, software
mridup 2:a2b623661316 11 * distributed under the License is distributed on an "AS IS" BASIS,
mridup 2:a2b623661316 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mridup 2:a2b623661316 13 * See the License for the specific language governing permissions and
mridup 2:a2b623661316 14 * limitations under the License.
mridup 2:a2b623661316 15 */
mridup 2:a2b623661316 16
mridup 2:a2b623661316 17 #include "mbed.h"
mridup 2:a2b623661316 18 #include "BlueNRGDevice.h"
mridup 2:a2b623661316 19
mridup 2:a2b623661316 20 #include "btle.h"
mridup 2:a2b623661316 21
mridup 2:a2b623661316 22 /**
mridup 6:08cfc94b5f49 23 * The singleton which represents the BlueNRG transport for the BLEDevice.
mridup 2:a2b623661316 24 */
mridup 2:a2b623661316 25 static BlueNRGDevice deviceInstance;
mridup 2:a2b623661316 26
mridup 2:a2b623661316 27 /**
mridup 2:a2b623661316 28 * BLE-API requires an implementation of the following function in order to
mridup 2:a2b623661316 29 * obtain its transport handle.
mridup 2:a2b623661316 30 */
mridup 2:a2b623661316 31 BLEDeviceInstanceBase *
mridup 2:a2b623661316 32 createBLEDeviceInstance(void)
mridup 2:a2b623661316 33 {
mridup 2:a2b623661316 34 return (&deviceInstance);
mridup 2:a2b623661316 35 }
mridup 2:a2b623661316 36
mridup 2:a2b623661316 37 /**************************************************************************/
mridup 2:a2b623661316 38 /*!
mridup 2:a2b623661316 39 @brief Constructor
mridup 2:a2b623661316 40 */
mridup 2:a2b623661316 41 /**************************************************************************/
mridup 2:a2b623661316 42 BlueNRGDevice::BlueNRGDevice(void)
mridup 2:a2b623661316 43 {
mridup 2:a2b623661316 44 }
mridup 2:a2b623661316 45
mridup 2:a2b623661316 46 /**************************************************************************/
mridup 2:a2b623661316 47 /*!
mridup 2:a2b623661316 48 @brief Destructor
mridup 2:a2b623661316 49 */
mridup 2:a2b623661316 50 /**************************************************************************/
mridup 2:a2b623661316 51 BlueNRGDevice::~BlueNRGDevice(void)
mridup 2:a2b623661316 52 {
mridup 2:a2b623661316 53 }
mridup 2:a2b623661316 54
mridup 2:a2b623661316 55 /**************************************************************************/
mridup 2:a2b623661316 56 /*!
mridup 2:a2b623661316 57 @brief Initialises anything required to start using BLE
mridup 2:a2b623661316 58
mridup 2:a2b623661316 59 @returns ble_error_t
mridup 2:a2b623661316 60
mridup 2:a2b623661316 61 @retval BLE_ERROR_NONE
mridup 2:a2b623661316 62 Everything executed properly
mridup 2:a2b623661316 63
mridup 2:a2b623661316 64 @section EXAMPLE
mridup 2:a2b623661316 65
mridup 2:a2b623661316 66 @code
mridup 2:a2b623661316 67
mridup 2:a2b623661316 68 @endcode
mridup 2:a2b623661316 69 */
mridup 2:a2b623661316 70 /**************************************************************************/
mridup 2:a2b623661316 71 ble_error_t BlueNRGDevice::init(void)
mridup 2:a2b623661316 72 {
mridup 2:a2b623661316 73 /* ToDo: Clear memory contents, reset the SD, etc. */
mridup 2:a2b623661316 74 btle_init();
mridup 2:a2b623661316 75
mridup 2:a2b623661316 76 return BLE_ERROR_NONE;
mridup 2:a2b623661316 77 }
mridup 2:a2b623661316 78
mridup 2:a2b623661316 79 /**************************************************************************/
mridup 2:a2b623661316 80 /*!
mridup 2:a2b623661316 81 @brief Resets the BLE HW, removing any existing services and
mridup 2:a2b623661316 82 characteristics
mridup 2:a2b623661316 83
mridup 2:a2b623661316 84 @returns ble_error_t
mridup 2:a2b623661316 85
mridup 2:a2b623661316 86 @retval BLE_ERROR_NONE
mridup 2:a2b623661316 87 Everything executed properly
mridup 2:a2b623661316 88
mridup 2:a2b623661316 89 @section EXAMPLE
mridup 2:a2b623661316 90
mridup 2:a2b623661316 91 @code
mridup 2:a2b623661316 92
mridup 2:a2b623661316 93 @endcode
mridup 2:a2b623661316 94 */
mridup 2:a2b623661316 95 /**************************************************************************/
mridup 2:a2b623661316 96 ble_error_t BlueNRGDevice::reset(void)
mridup 2:a2b623661316 97 {
mridup 2:a2b623661316 98 wait(0.5);
mridup 2:a2b623661316 99
mridup 2:a2b623661316 100 /* Reset BlueNRG SPI interface */
mridup 2:a2b623661316 101 //BlueNRG_RST();
mridup 2:a2b623661316 102
mridup 2:a2b623661316 103 /* Wait for the radio to come back up */
mridup 2:a2b623661316 104 wait(1);
mridup 2:a2b623661316 105
mridup 2:a2b623661316 106 return BLE_ERROR_NONE;
mridup 2:a2b623661316 107 }
mridup 2:a2b623661316 108
mridup 2:a2b623661316 109 void BlueNRGDevice::waitForEvent(void)
mridup 2:a2b623661316 110 {
mridup 2:a2b623661316 111 HCI_Process();//Send App Events??
mridup 2:a2b623661316 112
mridup 2:a2b623661316 113 }