BLE lib
Fork of Nucleo_BLE_BlueNRG by
BlueNRGGap.h@0:a948f5f3904c, 2014-12-19 (annotated)
- Committer:
- sjallouli
- Date:
- Fri Dec 19 18:56:07 2014 +0000
- Revision:
- 0:a948f5f3904c
BLE_BlueNRG for Nucleo board
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sjallouli | 0:a948f5f3904c | 1 | /* mbed Microcontroller Library |
sjallouli | 0:a948f5f3904c | 2 | * Copyright (c) 2006-2013 ARM Limited |
sjallouli | 0:a948f5f3904c | 3 | * |
sjallouli | 0:a948f5f3904c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
sjallouli | 0:a948f5f3904c | 5 | * you may not use this file except in compliance with the License. |
sjallouli | 0:a948f5f3904c | 6 | * You may obtain a copy of the License at |
sjallouli | 0:a948f5f3904c | 7 | * |
sjallouli | 0:a948f5f3904c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
sjallouli | 0:a948f5f3904c | 9 | * |
sjallouli | 0:a948f5f3904c | 10 | * Unless required by applicable law or agreed to in writing, software |
sjallouli | 0:a948f5f3904c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
sjallouli | 0:a948f5f3904c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
sjallouli | 0:a948f5f3904c | 13 | * See the License for the specific language governing permissions and |
sjallouli | 0:a948f5f3904c | 14 | * limitations under the License. |
sjallouli | 0:a948f5f3904c | 15 | */ |
sjallouli | 0:a948f5f3904c | 16 | |
sjallouli | 0:a948f5f3904c | 17 | #ifndef __BLUENRG_GAP_H__ |
sjallouli | 0:a948f5f3904c | 18 | #define __BLUENRG_GAP_H__ |
sjallouli | 0:a948f5f3904c | 19 | |
sjallouli | 0:a948f5f3904c | 20 | #include "mbed.h" |
sjallouli | 0:a948f5f3904c | 21 | #include "blecommon.h" |
sjallouli | 0:a948f5f3904c | 22 | #include "btle.h" |
sjallouli | 0:a948f5f3904c | 23 | #include "GapAdvertisingParams.h" |
sjallouli | 0:a948f5f3904c | 24 | #include "GapAdvertisingData.h" |
sjallouli | 0:a948f5f3904c | 25 | #include <public/Gap.h> |
sjallouli | 0:a948f5f3904c | 26 | |
sjallouli | 0:a948f5f3904c | 27 | #define BLE_CONN_HANDLE_INVALID 0x0 |
sjallouli | 0:a948f5f3904c | 28 | #define BDADDR_SIZE 6 |
sjallouli | 0:a948f5f3904c | 29 | |
sjallouli | 0:a948f5f3904c | 30 | /**************************************************************************/ |
sjallouli | 0:a948f5f3904c | 31 | /*! |
sjallouli | 0:a948f5f3904c | 32 | \brief |
sjallouli | 0:a948f5f3904c | 33 | |
sjallouli | 0:a948f5f3904c | 34 | */ |
sjallouli | 0:a948f5f3904c | 35 | /**************************************************************************/ |
sjallouli | 0:a948f5f3904c | 36 | class BlueNRGGap : public Gap |
sjallouli | 0:a948f5f3904c | 37 | { |
sjallouli | 0:a948f5f3904c | 38 | public: |
sjallouli | 0:a948f5f3904c | 39 | static BlueNRGGap &getInstance() { |
sjallouli | 0:a948f5f3904c | 40 | static BlueNRGGap m_instance; |
sjallouli | 0:a948f5f3904c | 41 | return m_instance; |
sjallouli | 0:a948f5f3904c | 42 | } |
sjallouli | 0:a948f5f3904c | 43 | |
sjallouli | 0:a948f5f3904c | 44 | /* Functions that must be implemented from Gap */ |
sjallouli | 0:a948f5f3904c | 45 | virtual ble_error_t setAddress(addr_type_t type, |
sjallouli | 0:a948f5f3904c | 46 | const uint8_t address[6]); |
sjallouli | 0:a948f5f3904c | 47 | virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, |
sjallouli | 0:a948f5f3904c | 48 | const GapAdvertisingData &); |
sjallouli | 0:a948f5f3904c | 49 | virtual ble_error_t startAdvertising(const GapAdvertisingParams &); |
sjallouli | 0:a948f5f3904c | 50 | virtual ble_error_t stopAdvertising(void); |
sjallouli | 0:a948f5f3904c | 51 | virtual ble_error_t disconnect(DisconnectionReason_t reason); |
sjallouli | 0:a948f5f3904c | 52 | virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params); |
sjallouli | 0:a948f5f3904c | 53 | virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params); |
sjallouli | 0:a948f5f3904c | 54 | virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params); |
sjallouli | 0:a948f5f3904c | 55 | |
sjallouli | 0:a948f5f3904c | 56 | virtual ble_error_t setDeviceName(const uint8_t *deviceName); |
sjallouli | 0:a948f5f3904c | 57 | virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP); |
sjallouli | 0:a948f5f3904c | 58 | virtual ble_error_t setAppearance(uint16_t appearance); |
sjallouli | 0:a948f5f3904c | 59 | virtual ble_error_t getAppearance(uint16_t *appearanceP); |
sjallouli | 0:a948f5f3904c | 60 | |
sjallouli | 0:a948f5f3904c | 61 | |
sjallouli | 0:a948f5f3904c | 62 | void setConnectionHandle(uint16_t con_handle); |
sjallouli | 0:a948f5f3904c | 63 | uint16_t getConnectionHandle(void); |
sjallouli | 0:a948f5f3904c | 64 | |
sjallouli | 0:a948f5f3904c | 65 | tHalUint8* getAddress(); |
sjallouli | 0:a948f5f3904c | 66 | bool getIsSetAddress(); |
sjallouli | 0:a948f5f3904c | 67 | |
sjallouli | 0:a948f5f3904c | 68 | private: |
sjallouli | 0:a948f5f3904c | 69 | uint16_t m_connectionHandle; |
sjallouli | 0:a948f5f3904c | 70 | tHalUint8 bdaddr[BDADDR_SIZE]; |
sjallouli | 0:a948f5f3904c | 71 | bool isSetAddress; |
sjallouli | 0:a948f5f3904c | 72 | tBleStatus ret; |
sjallouli | 0:a948f5f3904c | 73 | uint8_t *DeviceName; |
sjallouli | 0:a948f5f3904c | 74 | uint8_t deviceAppearance[2]; |
sjallouli | 0:a948f5f3904c | 75 | |
sjallouli | 0:a948f5f3904c | 76 | BlueNRGGap() { |
sjallouli | 0:a948f5f3904c | 77 | m_connectionHandle = BLE_CONN_HANDLE_INVALID; |
sjallouli | 0:a948f5f3904c | 78 | isSetAddress = false; |
sjallouli | 0:a948f5f3904c | 79 | DeviceName = NULL; |
sjallouli | 0:a948f5f3904c | 80 | } |
sjallouli | 0:a948f5f3904c | 81 | |
sjallouli | 0:a948f5f3904c | 82 | BlueNRGGap(BlueNRGGap const &); |
sjallouli | 0:a948f5f3904c | 83 | void operator=(BlueNRGGap const &); |
sjallouli | 0:a948f5f3904c | 84 | }; |
sjallouli | 0:a948f5f3904c | 85 | |
sjallouli | 0:a948f5f3904c | 86 | #endif // ifndef __BLUENRG_GAP_H__ |