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@58:027c65a54097, 2014-10-07 (annotated)
- Committer:
- hemddabral
- Date:
- Tue Oct 07 10:13:02 2014 +0000
- Revision:
- 58:027c65a54097
- Parent:
- 55:0e4db6804c8d
- Child:
- 59:68e45913b2c4
code cleanup and indentation.
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 | 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, |
hemddabral | 58:027c65a54097 | 46 | const uint8_t address[6]); |
mridup | 2:a2b623661316 | 47 | virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, |
hemddabral | 58:027c65a54097 | 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 | 58:027c65a54097 | 75 | |
mridup | 2:a2b623661316 | 76 | BlueNRGGap() { |
mridup | 2:a2b623661316 | 77 | m_connectionHandle = BLE_CONN_HANDLE_INVALID; |
mridup | 41:95b8d531628c | 78 | isSetAddress = false; |
hemddabral | 55:0e4db6804c8d | 79 | DeviceName = NULL; |
hemddabral | 55:0e4db6804c8d | 80 | //local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; |
mridup | 2:a2b623661316 | 81 | } |
mridup | 2:a2b623661316 | 82 | |
mridup | 2:a2b623661316 | 83 | BlueNRGGap(BlueNRGGap const &); |
mridup | 2:a2b623661316 | 84 | void operator=(BlueNRGGap const &); |
mridup | 2:a2b623661316 | 85 | }; |
mridup | 2:a2b623661316 | 86 | |
mridup | 2:a2b623661316 | 87 | #endif // ifndef __BLUENRG_GAP_H__ |