Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Hello_BLE F446RE-BLE
Fork of X_NUCLEO_IDB0XA1 by
BlueNRGGattServer.h@65:f9958b8f2548, 2015-04-01 (annotated)
- Committer:
- mridup
- Date:
- Wed Apr 01 09:02:51 2015 +0000
- Revision:
- 65:f9958b8f2548
- Parent:
- 64:6d7b775c3f6d
- Child:
- 66:8c8813dd8e79
1. GapAdvertisingParams constants usage update; 2. Gap::getAddress() function; 3. BlueNRGGattServer Class update; 4. BlueNRGGap class update; 5. HandleDataWrittenEvent function update from btle.cpp
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mridup | 2:a2b623661316 | 1 | /* mbed Microcontroller Library |
| hemddabral | 58:027c65a54097 | 2 | * Copyright (c) 2006-2013 ARM Limited |
| hemddabral | 58:027c65a54097 | 3 | * |
| hemddabral | 58:027c65a54097 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| hemddabral | 58:027c65a54097 | 5 | * you may not use this file except in compliance with the License. |
| hemddabral | 58:027c65a54097 | 6 | * You may obtain a copy of the License at |
| hemddabral | 58:027c65a54097 | 7 | * |
| hemddabral | 58:027c65a54097 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| hemddabral | 58:027c65a54097 | 9 | * |
| hemddabral | 58:027c65a54097 | 10 | * Unless required by applicable law or agreed to in writing, software |
| hemddabral | 58:027c65a54097 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| hemddabral | 58:027c65a54097 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| hemddabral | 58:027c65a54097 | 13 | * See the License for the specific language governing permissions and |
| hemddabral | 58:027c65a54097 | 14 | * limitations under the License. |
| hemddabral | 58:027c65a54097 | 15 | */ |
| mridup | 64:6d7b775c3f6d | 16 | /** |
| mridup | 64:6d7b775c3f6d | 17 | ****************************************************************************** |
| mridup | 64:6d7b775c3f6d | 18 | * @file BlueNRGGattServer.cpp |
| mridup | 64:6d7b775c3f6d | 19 | * @author STMicroelectronics |
| mridup | 64:6d7b775c3f6d | 20 | * @brief Header file for BLE_API GattServer Class |
| mridup | 64:6d7b775c3f6d | 21 | ****************************************************************************** |
| mridup | 64:6d7b775c3f6d | 22 | * @copy |
| mridup | 64:6d7b775c3f6d | 23 | * |
| mridup | 64:6d7b775c3f6d | 24 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
| mridup | 64:6d7b775c3f6d | 25 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
| mridup | 64:6d7b775c3f6d | 26 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
| mridup | 64:6d7b775c3f6d | 27 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
| mridup | 64:6d7b775c3f6d | 28 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
| mridup | 64:6d7b775c3f6d | 29 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
| mridup | 64:6d7b775c3f6d | 30 | * |
| mridup | 64:6d7b775c3f6d | 31 | * <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2> |
| mridup | 64:6d7b775c3f6d | 32 | */ |
| mridup | 64:6d7b775c3f6d | 33 | |
| mridup | 2:a2b623661316 | 34 | #ifndef __BLUENRG_GATT_SERVER_H__ |
| mridup | 2:a2b623661316 | 35 | #define __BLUENRG_GATT_SERVER_H__ |
| mridup | 2:a2b623661316 | 36 | |
| mridup | 2:a2b623661316 | 37 | #include "mbed.h" |
| mridup | 13:4c30346287e4 | 38 | #include "blecommon.h" |
| mridup | 5:31dedfa19a12 | 39 | #include "btle.h" |
| mridup | 2:a2b623661316 | 40 | #include "GattService.h" |
| hemddabral | 33:96724af256a5 | 41 | #include "public/GattServer.h" |
| hemddabral | 52:94638d2461c1 | 42 | #include <vector> |
| hemddabral | 52:94638d2461c1 | 43 | #include <map> |
| mridup | 2:a2b623661316 | 44 | |
| mridup | 2:a2b623661316 | 45 | #define BLE_TOTAL_CHARACTERISTICS 10 |
| mridup | 2:a2b623661316 | 46 | |
| hemddabral | 53:8c10d592ca49 | 47 | |
| hemddabral | 52:94638d2461c1 | 48 | using namespace std; |
| hemddabral | 52:94638d2461c1 | 49 | |
| mridup | 2:a2b623661316 | 50 | class BlueNRGGattServer : public GattServer |
| mridup | 2:a2b623661316 | 51 | { |
| mridup | 2:a2b623661316 | 52 | public: |
| mridup | 2:a2b623661316 | 53 | static BlueNRGGattServer &getInstance() { |
| mridup | 2:a2b623661316 | 54 | static BlueNRGGattServer m_instance; |
| mridup | 2:a2b623661316 | 55 | return m_instance; |
| mridup | 2:a2b623661316 | 56 | } |
| hemddabral | 52:94638d2461c1 | 57 | |
| hemddabral | 58:027c65a54097 | 58 | /* Functions that must be implemented from GattServer */ |
| mridup | 2:a2b623661316 | 59 | virtual ble_error_t addService(GattService &); |
| mridup | 2:a2b623661316 | 60 | virtual ble_error_t readValue(uint16_t handle, uint8_t buffer[], uint16_t *const lengthP); |
| mridup | 2:a2b623661316 | 61 | virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t, bool localOnly = false); |
| mridup | 65:f9958b8f2548 | 62 | virtual ble_error_t initializeGATTDatabase(void); |
| mridup | 2:a2b623661316 | 63 | |
| mridup | 6:08cfc94b5f49 | 64 | /* BlueNRG Functions */ |
| mridup | 2:a2b623661316 | 65 | void eventCallback(void); |
| mridup | 6:08cfc94b5f49 | 66 | //void hwCallback(void *pckt); |
| mridup | 26:047d45ea379e | 67 | ble_error_t Read_Request_CB(tHalUint16 handle); |
| mridup | 27:b4c21a9e8b39 | 68 | GattCharacteristic* getCharacteristicFromHandle(tHalUint16 charHandle); |
| mridup | 27:b4c21a9e8b39 | 69 | |
| mridup | 2:a2b623661316 | 70 | private: |
| hemddabral | 52:94638d2461c1 | 71 | static const int MAX_SERVICE_COUNT = 10; |
| mridup | 2:a2b623661316 | 72 | uint8_t serviceCount; |
| mridup | 2:a2b623661316 | 73 | uint8_t characteristicCount; |
| hemddabral | 51:963982e7c17c | 74 | tHalUint16 servHandle, charHandle; |
| hemddabral | 52:94638d2461c1 | 75 | |
| hemddabral | 52:94638d2461c1 | 76 | std::map<tHalUint16, tHalUint16> bleCharHanldeMap; // 1st argument is characteristic, 2nd argument is service |
| mridup | 2:a2b623661316 | 77 | GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS]; |
| mridup | 7:55ac052585db | 78 | tHalUint16 bleCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS]; |
| hemddabral | 58:027c65a54097 | 79 | |
| mridup | 2:a2b623661316 | 80 | BlueNRGGattServer() { |
| mridup | 2:a2b623661316 | 81 | serviceCount = 0; |
| mridup | 2:a2b623661316 | 82 | characteristicCount = 0; |
| mridup | 2:a2b623661316 | 83 | }; |
| mridup | 2:a2b623661316 | 84 | |
| mridup | 2:a2b623661316 | 85 | BlueNRGGattServer(BlueNRGGattServer const &); |
| mridup | 2:a2b623661316 | 86 | void operator=(BlueNRGGattServer const &); |
| hemddabral | 53:8c10d592ca49 | 87 | |
| hemddabral | 53:8c10d592ca49 | 88 | static const int CHAR_DESC_TYPE_16_BIT=0x01; |
| hemddabral | 53:8c10d592ca49 | 89 | static const int CHAR_DESC_TYPE_128_BIT=0x02; |
| hemddabral | 53:8c10d592ca49 | 90 | static const int CHAR_DESC_SECURITY_PERMISSION=0x00; |
| hemddabral | 53:8c10d592ca49 | 91 | static const int CHAR_DESC_ACCESS_PERMISSION=0x03; |
| hemddabral | 53:8c10d592ca49 | 92 | static const int CHAR_ATTRIBUTE_LEN_IS_FIXED=0x00; |
| mridup | 2:a2b623661316 | 93 | }; |
| mridup | 2:a2b623661316 | 94 | |
| mridup | 2:a2b623661316 | 95 | #endif |
