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@41:95b8d531628c, 2014-08-27 (annotated)
- Committer:
- mridup
- Date:
- Wed Aug 27 11:52:07 2014 +0000
- Revision:
- 41:95b8d531628c
- Parent:
- 33:96724af256a5
- Child:
- 55:0e4db6804c8d
SetAddress resets and re-inits the device.
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 | 33:96724af256a5 | 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); |
mridup | 2:a2b623661316 | 51 | virtual ble_error_t disconnect(void); |
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); |
mridup | 2:a2b623661316 | 55 | |
mridup | 2:a2b623661316 | 56 | void setConnectionHandle(uint16_t con_handle); |
mridup | 2:a2b623661316 | 57 | uint16_t getConnectionHandle(void); |
mridup | 41:95b8d531628c | 58 | |
mridup | 41:95b8d531628c | 59 | tHalUint8* getAddress(); |
mridup | 41:95b8d531628c | 60 | bool getIsSetAddress(); |
mridup | 2:a2b623661316 | 61 | |
mridup | 2:a2b623661316 | 62 | private: |
mridup | 2:a2b623661316 | 63 | uint16_t m_connectionHandle; |
mridup | 41:95b8d531628c | 64 | tHalUint8 bdaddr[BDADDR_SIZE]; |
mridup | 41:95b8d531628c | 65 | bool isSetAddress; |
mridup | 2:a2b623661316 | 66 | tBleStatus ret; |
mridup | 2:a2b623661316 | 67 | |
mridup | 2:a2b623661316 | 68 | //const char local_name[];// = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; |
mridup | 3:9c4c13795643 | 69 | //Local Variables |
mridup | 3:9c4c13795643 | 70 | //uint8_t *device_name; |
mridup | 2:a2b623661316 | 71 | BlueNRGGap() { |
mridup | 2:a2b623661316 | 72 | m_connectionHandle = BLE_CONN_HANDLE_INVALID; |
mridup | 41:95b8d531628c | 73 | isSetAddress = false; |
mridup | 2:a2b623661316 | 74 | //local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'}; |
mridup | 3:9c4c13795643 | 75 | |
mridup | 2:a2b623661316 | 76 | } |
mridup | 2:a2b623661316 | 77 | |
mridup | 2:a2b623661316 | 78 | BlueNRGGap(BlueNRGGap const &); |
mridup | 2:a2b623661316 | 79 | void operator=(BlueNRGGap const &); |
mridup | 2:a2b623661316 | 80 | }; |
mridup | 2:a2b623661316 | 81 | |
mridup | 2:a2b623661316 | 82 | #endif // ifndef __BLUENRG_GAP_H__ |