BLE_API wrapper library for STMicroelectronics' BlueNRG Bluetooth Low Energy expansion board shield (Component)

Dependents:   Nucleo_Zumo_BLE_IDB04A1 contest_IOT5 contest_IOT6 contest_IOT_10 ... more

Fork of X_NUCLEO_IDB0XA1 by ST Expansion SW Team

Arduino Connector Compatibility Warning

X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 are Arduino compatible with an exception: instead of using pin D13 for the SPI clock, they use pin D3. The default configuration for this library is having the SPI clock on pin D3.

To be fully Arduino compatible, X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 need a small HW patch.

For X-NUCLEO-IDB04A1 this patch consists in removing zero resistor R10 and instead soldering zero resistor R11. For X-NUCLEO-IDB05A1 this patch consists in removing zero resistor R4 and instead soldering zero resistor R6.

In case you patch your board, then you also have to configure this library to use pin D13 to drive the SPI clock (see macro IDB0XA1_D13_PATCH in file x_nucleo_idb0xa1_targets.h).

If you use pin D13 for the SPI clock, please be aware that on STM32 Nucleo boards you may not drive the LED, otherwise you will get a conflict: the LED on STM32 Nucleo boards is connected to pin D13.

Referring to the current list of tested platforms (see X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 pages), the patch is required by ST-Nucleo-F103RB; ST-Nucleo-F302R8; ST-Nucleo-F411RE; and ST-Nucleo-F446RE.

Committer:
Wolfgang Betz
Date:
Tue Oct 06 14:25:08 2015 +0200
Revision:
130:770ce14d3d15
Child:
131:e09947216ccb
Include mbed-classic version

Derived from
- repo (on Codex): gitolite@codex.cro.st.com:x-nucleodev/X-NUCLEO-IKC01A1-MBED.git
- branch: ble_wb
- SHA1 ID: 5ccc73e35868169e42132c0d1c056f908a6d70c0

Who changed what in which revision?

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