Added support for obtaining BLE device name by parsing advertising data.
Fork of BLE_BlueNRG by
BlueNRGGattServer.cpp@2:a2b623661316, 2014-07-21 (annotated)
- Committer:
- mridup
- Date:
- Mon Jul 21 08:28:47 2014 +0000
- Revision:
- 2:a2b623661316
- Child:
- 5:31dedfa19a12
Latest Changes 21/07
Who changed what in which revision?
User | Revision | Line number | New 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 "BlueNRGGattServer.h" |
mridup | 2:a2b623661316 | 18 | #include "mbed.h" |
mridup | 2:a2b623661316 | 19 | |
mridup | 2:a2b623661316 | 20 | //#include "common/common.h" |
mridup | 2:a2b623661316 | 21 | //#include "btle/custom/custom_helper.h" |
mridup | 2:a2b623661316 | 22 | |
mridup | 2:a2b623661316 | 23 | #include "BlueNRGGap.h" |
mridup | 2:a2b623661316 | 24 | |
mridup | 2:a2b623661316 | 25 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 26 | /*! |
mridup | 2:a2b623661316 | 27 | @brief Adds a new service to the GATT table on the peripheral |
mridup | 2:a2b623661316 | 28 | |
mridup | 2:a2b623661316 | 29 | @returns ble_error_t |
mridup | 2:a2b623661316 | 30 | |
mridup | 2:a2b623661316 | 31 | @retval BLE_ERROR_NONE |
mridup | 2:a2b623661316 | 32 | Everything executed properly |
mridup | 2:a2b623661316 | 33 | |
mridup | 2:a2b623661316 | 34 | @section EXAMPLE |
mridup | 2:a2b623661316 | 35 | |
mridup | 2:a2b623661316 | 36 | @code |
mridup | 2:a2b623661316 | 37 | |
mridup | 2:a2b623661316 | 38 | @endcode |
mridup | 2:a2b623661316 | 39 | */ |
mridup | 2:a2b623661316 | 40 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 41 | ble_error_t BlueNRGGattServer::addService(GattService &service) |
mridup | 2:a2b623661316 | 42 | { |
mridup | 2:a2b623661316 | 43 | /* ToDo: Make sure we don't overflow the array, etc. */ |
mridup | 2:a2b623661316 | 44 | /* ToDo: Make sure this service UUID doesn't already exist (?) */ |
mridup | 2:a2b623661316 | 45 | /* ToDo: Basic validation */ |
mridup | 2:a2b623661316 | 46 | |
mridup | 2:a2b623661316 | 47 | |
mridup | 2:a2b623661316 | 48 | return BLE_ERROR_NONE; |
mridup | 2:a2b623661316 | 49 | } |
mridup | 2:a2b623661316 | 50 | |
mridup | 2:a2b623661316 | 51 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 52 | /*! |
mridup | 2:a2b623661316 | 53 | @brief Reads the value of a characteristic, based on the service |
mridup | 2:a2b623661316 | 54 | and characteristic index fields |
mridup | 2:a2b623661316 | 55 | |
mridup | 2:a2b623661316 | 56 | @param[in] charHandle |
mridup | 2:a2b623661316 | 57 | The handle of the GattCharacteristic to read from |
mridup | 2:a2b623661316 | 58 | @param[in] buffer |
mridup | 2:a2b623661316 | 59 | Buffer to hold the the characteristic's value |
mridup | 2:a2b623661316 | 60 | (raw byte array in LSB format) |
mridup | 2:a2b623661316 | 61 | @param[in] len |
mridup | 2:a2b623661316 | 62 | The number of bytes read into the buffer |
mridup | 2:a2b623661316 | 63 | |
mridup | 2:a2b623661316 | 64 | @returns ble_error_t |
mridup | 2:a2b623661316 | 65 | |
mridup | 2:a2b623661316 | 66 | @retval BLE_ERROR_NONE |
mridup | 2:a2b623661316 | 67 | Everything executed properly |
mridup | 2:a2b623661316 | 68 | |
mridup | 2:a2b623661316 | 69 | @section EXAMPLE |
mridup | 2:a2b623661316 | 70 | |
mridup | 2:a2b623661316 | 71 | @code |
mridup | 2:a2b623661316 | 72 | |
mridup | 2:a2b623661316 | 73 | @endcode |
mridup | 2:a2b623661316 | 74 | */ |
mridup | 2:a2b623661316 | 75 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 76 | ble_error_t BlueNRGGattServer::readValue(uint16_t charHandle, uint8_t buffer[], uint16_t *const lengthP) |
mridup | 2:a2b623661316 | 77 | { |
mridup | 2:a2b623661316 | 78 | |
mridup | 2:a2b623661316 | 79 | return BLE_ERROR_NONE; |
mridup | 2:a2b623661316 | 80 | } |
mridup | 2:a2b623661316 | 81 | |
mridup | 2:a2b623661316 | 82 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 83 | /*! |
mridup | 2:a2b623661316 | 84 | @brief Updates the value of a characteristic, based on the service |
mridup | 2:a2b623661316 | 85 | and characteristic index fields |
mridup | 2:a2b623661316 | 86 | |
mridup | 2:a2b623661316 | 87 | @param[in] charHandle |
mridup | 2:a2b623661316 | 88 | The handle of the GattCharacteristic to write to |
mridup | 2:a2b623661316 | 89 | @param[in] buffer |
mridup | 2:a2b623661316 | 90 | Data to use when updating the characteristic's value |
mridup | 2:a2b623661316 | 91 | (raw byte array in LSB format) |
mridup | 2:a2b623661316 | 92 | @param[in] len |
mridup | 2:a2b623661316 | 93 | The number of bytes in buffer |
mridup | 2:a2b623661316 | 94 | |
mridup | 2:a2b623661316 | 95 | @returns ble_error_t |
mridup | 2:a2b623661316 | 96 | |
mridup | 2:a2b623661316 | 97 | @retval BLE_ERROR_NONE |
mridup | 2:a2b623661316 | 98 | Everything executed properly |
mridup | 2:a2b623661316 | 99 | |
mridup | 2:a2b623661316 | 100 | @section EXAMPLE |
mridup | 2:a2b623661316 | 101 | |
mridup | 2:a2b623661316 | 102 | @code |
mridup | 2:a2b623661316 | 103 | |
mridup | 2:a2b623661316 | 104 | @endcode |
mridup | 2:a2b623661316 | 105 | */ |
mridup | 2:a2b623661316 | 106 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 107 | ble_error_t BlueNRGGattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len, bool localOnly) |
mridup | 2:a2b623661316 | 108 | { |
mridup | 2:a2b623661316 | 109 | |
mridup | 2:a2b623661316 | 110 | |
mridup | 2:a2b623661316 | 111 | return BLE_ERROR_NONE; |
mridup | 2:a2b623661316 | 112 | } |