HW layer for the Nucleo board, it only work with old BLE_API
Dependents: Hello_BLE F446RE-BLE
Fork of X_NUCLEO_IDB0XA1 by
BlueNRGGap.h@55:0e4db6804c8d, 2014-10-01 (annotated)
- Committer:
- hemddabral
- Date:
- Wed Oct 01 08:49:52 2014 +0000
- Revision:
- 55:0e4db6804c8d
- Parent:
- 41:95b8d531628c
- Child:
- 58:027c65a54097
added support for BLE_API version 116 (WIP)
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 | #ifndef __BLUENRG_GAP_H__ |
mridup | 2:a2b623661316 | 18 | #define __BLUENRG_GAP_H__ |
mridup | 2:a2b623661316 | 19 | |
mridup | 2:a2b623661316 | 20 | #include "mbed.h" |
mridup | 2:a2b623661316 | 21 | #include "blecommon.h" |
mridup | 2:a2b623661316 | 22 | #include "btle.h" |
mridup | 2:a2b623661316 | 23 | #include "GapAdvertisingParams.h" |
mridup | 2:a2b623661316 | 24 | #include "GapAdvertisingData.h" |
hemddabral | 55:0e4db6804c8d | 25 | #include <public/Gap.h> |
mridup | 2:a2b623661316 | 26 | |
mridup | 2:a2b623661316 | 27 | #define BLE_CONN_HANDLE_INVALID 0x0 |
mridup | 41:95b8d531628c | 28 | #define BDADDR_SIZE 6 |
mridup | 2:a2b623661316 | 29 | |
mridup | 2:a2b623661316 | 30 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 31 | /*! |
mridup | 2:a2b623661316 | 32 | \brief |
mridup | 2:a2b623661316 | 33 | |
mridup | 2:a2b623661316 | 34 | */ |
mridup | 2:a2b623661316 | 35 | /**************************************************************************/ |
mridup | 2:a2b623661316 | 36 | class BlueNRGGap : public Gap |
mridup | 2:a2b623661316 | 37 | { |
mridup | 2:a2b623661316 | 38 | public: |
mridup | 2:a2b623661316 | 39 | static BlueNRGGap &getInstance() { |
mridup | 2:a2b623661316 | 40 | static BlueNRGGap m_instance; |
mridup | 2:a2b623661316 | 41 | return m_instance; |
mridup | 2:a2b623661316 | 42 | } |
mridup | 2:a2b623661316 | 43 | |
mridup | 2:a2b623661316 | 44 | /* Functions that must be implemented from Gap */ |
mridup | 2:a2b623661316 | 45 | virtual ble_error_t setAddress(addr_type_t type, |
mridup | 2:a2b623661316 | 46 | const uint8_t address[6]); |
mridup | 2:a2b623661316 | 47 | virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, |
mridup | 2:a2b623661316 | 48 | const GapAdvertisingData &); |
mridup | 2:a2b623661316 | 49 | virtual ble_error_t startAdvertising(const GapAdvertisingParams &); |
mridup | 2:a2b623661316 | 50 | virtual ble_error_t stopAdvertising(void); |
hemddabral | 55:0e4db6804c8d | 51 | virtual ble_error_t disconnect(DisconnectionReason_t reason); |
hemddabral | 32:d1f250acad29 | 52 | virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params); |
hemddabral | 32:d1f250acad29 | 53 | virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params); |
hemddabral | 32:d1f250acad29 | 54 | virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params); |
hemddabral | 55:0e4db6804c8d | 55 | |
hemddabral | 55:0e4db6804c8d | 56 | virtual ble_error_t setDeviceName(const uint8_t *deviceName); |
hemddabral | 55:0e4db6804c8d | 57 | virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP); |
hemddabral | 55:0e4db6804c8d | 58 | virtual ble_error_t setAppearance(uint16_t appearance); |
hemddabral | 55:0e4db6804c8d | 59 | virtual ble_error_t getAppearance(uint16_t *appearanceP); |
hemddabral | 55:0e4db6804c8d | 60 | |
mridup | 2:a2b623661316 | 61 | |
mridup | 2:a2b623661316 | 62 | void setConnectionHandle(uint16_t con_handle); |
mridup | 2:a2b623661316 | 63 | uint16_t getConnectionHandle(void); |
mridup | 41:95b8d531628c | 64 | |
mridup | 41:95b8d531628c | 65 | tHalUint8* getAddress(); |
mridup | 41:95b8d531628c | 66 | bool getIsSetAddress(); |
mridup | 2:a2b623661316 | 67 | |
mridup | 2:a2b623661316 | 68 | private: |
mridup | 2:a2b623661316 | 69 | uint16_t m_connectionHandle; |
mridup | 41:95b8d531628c | 70 | tHalUint8 bdaddr[BDADDR_SIZE]; |
mridup | 41:95b8d531628c | 71 | bool isSetAddress; |
mridup | 2:a2b623661316 | 72 | tBleStatus ret; |
hemddabral | 55:0e4db6804c8d | 73 | uint8_t *DeviceName; |
hemddabral | 55:0e4db6804c8d | 74 | uint8_t deviceAppearance[2]; |
hemddabral | 55:0e4db6804c8d | 75 | |
mridup | 2:a2b623661316 | 76 | |
mridup | 2:a2b623661316 | 77 | //const char local_name[];// = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; |
mridup | 3:9c4c13795643 | 78 | //Local Variables |
mridup | 3:9c4c13795643 | 79 | //uint8_t *device_name; |
mridup | 2:a2b623661316 | 80 | BlueNRGGap() { |
mridup | 2:a2b623661316 | 81 | m_connectionHandle = BLE_CONN_HANDLE_INVALID; |
mridup | 41:95b8d531628c | 82 | isSetAddress = false; |
hemddabral | 55:0e4db6804c8d | 83 | DeviceName = NULL; |
hemddabral | 55:0e4db6804c8d | 84 | //local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; |
mridup | 2:a2b623661316 | 85 | } |
mridup | 2:a2b623661316 | 86 | |
mridup | 2:a2b623661316 | 87 | BlueNRGGap(BlueNRGGap const &); |
mridup | 2:a2b623661316 | 88 | void operator=(BlueNRGGap const &); |
mridup | 2:a2b623661316 | 89 | }; |
mridup | 2:a2b623661316 | 90 | |
mridup | 2:a2b623661316 | 91 | #endif // ifndef __BLUENRG_GAP_H__ |