HW layer for the Nucleo board, it only work with old BLE_API

Dependents:   Hello_BLE F446RE-BLE

Fork of X_NUCLEO_IDB0XA1 by ST

Committer:
Wolfgang Betz
Date:
Wed Jul 22 11:25:50 2015 +0200
Revision:
90:26c0c9807ab4
Child:
94:2993df23d1ac
Preparing ble_wb

- new gitmodule for BLE_API
- updating ReadMe.txt
- synching X_NUCLEO_IDB0XA1 with mbed
- synching test application

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 90:26c0c9807ab4 1 /* mbed Microcontroller Library
Wolfgang Betz 90:26c0c9807ab4 2 * Copyright (c) 2006-2013 ARM Limited
Wolfgang Betz 90:26c0c9807ab4 3 *
Wolfgang Betz 90:26c0c9807ab4 4 * Licensed under the Apache License, Version 2.0 (the "License");
Wolfgang Betz 90:26c0c9807ab4 5 * you may not use this file except in compliance with the License.
Wolfgang Betz 90:26c0c9807ab4 6 * You may obtain a copy of the License at
Wolfgang Betz 90:26c0c9807ab4 7 *
Wolfgang Betz 90:26c0c9807ab4 8 * http://www.apache.org/licenses/LICENSE-2.0
Wolfgang Betz 90:26c0c9807ab4 9 *
Wolfgang Betz 90:26c0c9807ab4 10 * Unless required by applicable law or agreed to in writing, software
Wolfgang Betz 90:26c0c9807ab4 11 * distributed under the License is distributed on an "AS IS" BASIS,
Wolfgang Betz 90:26c0c9807ab4 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Wolfgang Betz 90:26c0c9807ab4 13 * See the License for the specific language governing permissions and
Wolfgang Betz 90:26c0c9807ab4 14 * limitations under the License.
Wolfgang Betz 90:26c0c9807ab4 15 */
Wolfgang Betz 90:26c0c9807ab4 16
Wolfgang Betz 90:26c0c9807ab4 17 /**
Wolfgang Betz 90:26c0c9807ab4 18 ******************************************************************************
Wolfgang Betz 90:26c0c9807ab4 19 * @file BlueNRGGap.h
Wolfgang Betz 90:26c0c9807ab4 20 * @author STMicroelectronics
Wolfgang Betz 90:26c0c9807ab4 21 * @brief Header file for BlueNRG BLE_API Gap Class
Wolfgang Betz 90:26c0c9807ab4 22 ******************************************************************************
Wolfgang Betz 90:26c0c9807ab4 23 * @copy
Wolfgang Betz 90:26c0c9807ab4 24 *
Wolfgang Betz 90:26c0c9807ab4 25 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
Wolfgang Betz 90:26c0c9807ab4 26 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
Wolfgang Betz 90:26c0c9807ab4 27 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
Wolfgang Betz 90:26c0c9807ab4 28 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
Wolfgang Betz 90:26c0c9807ab4 29 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
Wolfgang Betz 90:26c0c9807ab4 30 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
Wolfgang Betz 90:26c0c9807ab4 31 *
Wolfgang Betz 90:26c0c9807ab4 32 * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
Wolfgang Betz 90:26c0c9807ab4 33 */
Wolfgang Betz 90:26c0c9807ab4 34
Wolfgang Betz 90:26c0c9807ab4 35 #ifndef __BLUENRG_GAP_H__
Wolfgang Betz 90:26c0c9807ab4 36 #define __BLUENRG_GAP_H__
Wolfgang Betz 90:26c0c9807ab4 37
Wolfgang Betz 90:26c0c9807ab4 38 #include "mbed.h"
Wolfgang Betz 90:26c0c9807ab4 39 #include "blecommon.h"
Wolfgang Betz 90:26c0c9807ab4 40 #include "btle.h"
Wolfgang Betz 90:26c0c9807ab4 41 #include "GapAdvertisingParams.h"
Wolfgang Betz 90:26c0c9807ab4 42 #include "GapAdvertisingData.h"
Wolfgang Betz 90:26c0c9807ab4 43 #include <ble/Gap.h>
Wolfgang Betz 90:26c0c9807ab4 44
Wolfgang Betz 90:26c0c9807ab4 45 #define BLE_CONN_HANDLE_INVALID 0x0
Wolfgang Betz 90:26c0c9807ab4 46 #define BDADDR_SIZE 6
Wolfgang Betz 90:26c0c9807ab4 47
Wolfgang Betz 90:26c0c9807ab4 48 #define BLUENRG_GAP_ADV_INTERVAL_MIN (0)
Wolfgang Betz 90:26c0c9807ab4 49 #define BLUENRG_GAP_ADV_INTERVAL_MAX (0)
Wolfgang Betz 90:26c0c9807ab4 50 #define BLE_GAP_ADV_NONCON_INTERVAL_MIN (0)
Wolfgang Betz 90:26c0c9807ab4 51
Wolfgang Betz 90:26c0c9807ab4 52
Wolfgang Betz 90:26c0c9807ab4 53 /**************************************************************************/
Wolfgang Betz 90:26c0c9807ab4 54 /*!
Wolfgang Betz 90:26c0c9807ab4 55 \brief
Wolfgang Betz 90:26c0c9807ab4 56
Wolfgang Betz 90:26c0c9807ab4 57 */
Wolfgang Betz 90:26c0c9807ab4 58 /**************************************************************************/
Wolfgang Betz 90:26c0c9807ab4 59 class BlueNRGGap : public Gap
Wolfgang Betz 90:26c0c9807ab4 60 {
Wolfgang Betz 90:26c0c9807ab4 61 public:
Wolfgang Betz 90:26c0c9807ab4 62 static BlueNRGGap &getInstance() {
Wolfgang Betz 90:26c0c9807ab4 63 static BlueNRGGap m_instance;
Wolfgang Betz 90:26c0c9807ab4 64 return m_instance;
Wolfgang Betz 90:26c0c9807ab4 65 }
Wolfgang Betz 90:26c0c9807ab4 66
Wolfgang Betz 90:26c0c9807ab4 67 // <<<ANDREA>>>
Wolfgang Betz 90:26c0c9807ab4 68 enum AdvType_t {
Wolfgang Betz 90:26c0c9807ab4 69 ADV_IND = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED,//Gap::ADV_IND,
Wolfgang Betz 90:26c0c9807ab4 70 ADV_DIRECT_IND = GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED,//Gap::ADV_DIRECT_IND,
Wolfgang Betz 90:26c0c9807ab4 71 ADV_SCAN_IND = GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED,//Gap::ADV_SCAN_IND,
Wolfgang Betz 90:26c0c9807ab4 72 ADV_NONCONN_IND = GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED//Gap::ADV_NONCONN_IND
Wolfgang Betz 90:26c0c9807ab4 73 };
Wolfgang Betz 90:26c0c9807ab4 74
Wolfgang Betz 90:26c0c9807ab4 75 /* Functions that must be implemented from Gap */
Wolfgang Betz 90:26c0c9807ab4 76 virtual ble_error_t setAddress(addr_type_t type, const Address_t address);
Wolfgang Betz 90:26c0c9807ab4 77 virtual ble_error_t getAddress(addr_type_t *typeP, Address_t address);
Wolfgang Betz 90:26c0c9807ab4 78 virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &);
Wolfgang Betz 90:26c0c9807ab4 79 virtual ble_error_t startAdvertising(const GapAdvertisingParams &);
Wolfgang Betz 90:26c0c9807ab4 80 virtual ble_error_t stopAdvertising(void);
Wolfgang Betz 90:26c0c9807ab4 81 virtual ble_error_t stopScan();
Wolfgang Betz 90:26c0c9807ab4 82 virtual uint16_t getMinAdvertisingInterval(void) const;
Wolfgang Betz 90:26c0c9807ab4 83 virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const;
Wolfgang Betz 90:26c0c9807ab4 84 virtual uint16_t getMaxAdvertisingInterval(void) const;
Wolfgang Betz 90:26c0c9807ab4 85 virtual ble_error_t disconnect(DisconnectionReason_t reason);
Wolfgang Betz 90:26c0c9807ab4 86 virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason);
Wolfgang Betz 90:26c0c9807ab4 87 virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params);
Wolfgang Betz 90:26c0c9807ab4 88 virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params);
Wolfgang Betz 90:26c0c9807ab4 89 virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params);
Wolfgang Betz 90:26c0c9807ab4 90
Wolfgang Betz 90:26c0c9807ab4 91 virtual ble_error_t setDeviceName(const uint8_t *deviceName);
Wolfgang Betz 90:26c0c9807ab4 92 virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);
Wolfgang Betz 90:26c0c9807ab4 93 virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance);
Wolfgang Betz 90:26c0c9807ab4 94 virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
Wolfgang Betz 90:26c0c9807ab4 95
Wolfgang Betz 90:26c0c9807ab4 96 virtual ble_error_t setTxPower(int8_t txPower);
Wolfgang Betz 90:26c0c9807ab4 97 virtual void getPermittedTxPowerValues(const int8_t **, size_t *);
Wolfgang Betz 90:26c0c9807ab4 98 // <<<ANDREA>>>
Wolfgang Betz 90:26c0c9807ab4 99
Wolfgang Betz 90:26c0c9807ab4 100
Wolfgang Betz 90:26c0c9807ab4 101 void setConnectionHandle(uint16_t con_handle);
Wolfgang Betz 90:26c0c9807ab4 102 uint16_t getConnectionHandle(void);
Wolfgang Betz 90:26c0c9807ab4 103
Wolfgang Betz 90:26c0c9807ab4 104 //tHalUint8* getAddress();
Wolfgang Betz 90:26c0c9807ab4 105 bool getIsSetAddress();
Wolfgang Betz 90:26c0c9807ab4 106
Wolfgang Betz 90:26c0c9807ab4 107 protected:
Wolfgang Betz 90:26c0c9807ab4 108 virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams);
Wolfgang Betz 90:26c0c9807ab4 109
Wolfgang Betz 90:26c0c9807ab4 110 private:
Wolfgang Betz 90:26c0c9807ab4 111 uint16_t m_connectionHandle;
Wolfgang Betz 90:26c0c9807ab4 112 uint8_t bdaddr[BDADDR_SIZE];
Wolfgang Betz 90:26c0c9807ab4 113 bool isSetAddress;
Wolfgang Betz 90:26c0c9807ab4 114 tBleStatus ret;
Wolfgang Betz 90:26c0c9807ab4 115 uint8_t *DeviceName;
Wolfgang Betz 90:26c0c9807ab4 116 uint8_t deviceAppearance[2];
Wolfgang Betz 90:26c0c9807ab4 117
Wolfgang Betz 90:26c0c9807ab4 118 BlueNRGGap() {
Wolfgang Betz 90:26c0c9807ab4 119 m_connectionHandle = BLE_CONN_HANDLE_INVALID;
Wolfgang Betz 90:26c0c9807ab4 120 isSetAddress = false;
Wolfgang Betz 90:26c0c9807ab4 121 DeviceName = NULL;
Wolfgang Betz 90:26c0c9807ab4 122 }
Wolfgang Betz 90:26c0c9807ab4 123
Wolfgang Betz 90:26c0c9807ab4 124 BlueNRGGap(BlueNRGGap const &);
Wolfgang Betz 90:26c0c9807ab4 125 void operator=(BlueNRGGap const &);
Wolfgang Betz 90:26c0c9807ab4 126 };
Wolfgang Betz 90:26c0c9807ab4 127
Wolfgang Betz 90:26c0c9807ab4 128 #endif // ifndef __BLUENRG_GAP_H__