test
Dependents: BLE_HeartRate_IDB0XA1_EPUDEE_Avril2018
Fork of X_NUCLEO_IDB0XA1 by
x-nucleo-idb0xa1/BlueNRGDevice.h@168:ad1dff5dca1f, 2015-11-04 (annotated)
- Committer:
- Wolfgang Betz
- Date:
- Wed Nov 04 14:23:19 2015 +0100
- Revision:
- 168:ad1dff5dca1f
- Parent:
- 167:abc42e7158a6
- Child:
- 177:65d9b1b75fca
- Child:
- 229:9981f62cdb1a
Remove instance variable 'instanceID'
Who changed what in which revision?
User | Revision | Line number | New 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 BlueNRGDevice.h |
Wolfgang Betz |
130:770ce14d3d15 | 20 | * @author STMicroelectronics |
Wolfgang Betz |
130:770ce14d3d15 | 21 | * @brief Header file for BLEDeviceInstanceBase based BlueNRGDevice |
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>© COPYRIGHT 2013 STMicroelectronics</center></h2> |
Wolfgang Betz |
130:770ce14d3d15 | 33 | */ |
Wolfgang Betz |
130:770ce14d3d15 | 34 | |
Wolfgang Betz |
130:770ce14d3d15 | 35 | #ifndef __BLUENRG_DEVICE_H__ |
Wolfgang Betz |
130:770ce14d3d15 | 36 | #define __BLUENRG_DEVICE_H__ |
Wolfgang Betz |
130:770ce14d3d15 | 37 | |
Wolfgang Betz |
130:770ce14d3d15 | 38 | #define BLUENRG |
Wolfgang Betz |
130:770ce14d3d15 | 39 | #define DEBUG_BLUENRG_USER |
Wolfgang Betz |
130:770ce14d3d15 | 40 | |
Wolfgang Betz |
130:770ce14d3d15 | 41 | #include "btle.h" |
Wolfgang Betz |
130:770ce14d3d15 | 42 | |
Wolfgang Betz |
144:bdf5e8432131 | 43 | #include "mbed-drivers/mbed.h" |
Wolfgang Betz |
131:e09947216ccb | 44 | #include "ble/blecommon.h" |
Andrea Palmieri |
167:abc42e7158a6 | 45 | #include "ble/BLEInstanceBase.h" |
Wolfgang Betz |
131:e09947216ccb | 46 | #include "ble/BLE.h" |
Wolfgang Betz |
130:770ce14d3d15 | 47 | #include "BlueNRGGap.h" |
Wolfgang Betz |
130:770ce14d3d15 | 48 | #include "BlueNRGGattServer.h" |
Wolfgang Betz |
132:51056160fa4a | 49 | #include "BlueNRGGattClient.h" |
Wolfgang Betz |
130:770ce14d3d15 | 50 | |
Wolfgang Betz |
130:770ce14d3d15 | 51 | |
Wolfgang Betz |
130:770ce14d3d15 | 52 | class BlueNRGDevice : public BLEInstanceBase |
Wolfgang Betz |
130:770ce14d3d15 | 53 | { |
Wolfgang Betz |
130:770ce14d3d15 | 54 | |
Wolfgang Betz |
130:770ce14d3d15 | 55 | public: |
Wolfgang Betz |
130:770ce14d3d15 | 56 | BlueNRGDevice(PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, PinName irq); |
Wolfgang Betz |
130:770ce14d3d15 | 57 | virtual ~BlueNRGDevice(void); |
Wolfgang Betz |
130:770ce14d3d15 | 58 | |
Andrea Palmieri |
167:abc42e7158a6 | 59 | virtual ble_error_t init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback); |
Wolfgang Betz |
130:770ce14d3d15 | 60 | virtual ble_error_t shutdown(void); |
Wolfgang Betz |
130:770ce14d3d15 | 61 | virtual const char *getVersion(void); |
Wolfgang Betz |
130:770ce14d3d15 | 62 | virtual Gap& getGap(); |
Wolfgang Betz |
130:770ce14d3d15 | 63 | virtual const Gap& getGap() const; |
Wolfgang Betz |
130:770ce14d3d15 | 64 | virtual GattServer& getGattServer(); |
Wolfgang Betz |
130:770ce14d3d15 | 65 | virtual const GattServer& getGattServer() const; |
Wolfgang Betz |
130:770ce14d3d15 | 66 | virtual void waitForEvent(void); |
Wolfgang Betz |
130:770ce14d3d15 | 67 | |
Wolfgang Betz |
130:770ce14d3d15 | 68 | virtual GattClient& getGattClient() { |
Wolfgang Betz |
132:51056160fa4a | 69 | return BlueNRGGattClient::getInstance(); |
Wolfgang Betz |
130:770ce14d3d15 | 70 | } |
Wolfgang Betz |
130:770ce14d3d15 | 71 | |
Wolfgang Betz |
130:770ce14d3d15 | 72 | virtual SecurityManager& getSecurityManager() { |
Wolfgang Betz |
130:770ce14d3d15 | 73 | return *sm; |
Wolfgang Betz |
130:770ce14d3d15 | 74 | } |
Wolfgang Betz |
130:770ce14d3d15 | 75 | |
Wolfgang Betz |
130:770ce14d3d15 | 76 | virtual const SecurityManager& getSecurityManager() const { |
Wolfgang Betz |
130:770ce14d3d15 | 77 | return *sm; |
Wolfgang Betz |
130:770ce14d3d15 | 78 | } |
Wolfgang Betz |
130:770ce14d3d15 | 79 | ble_error_t reset(void); |
Andrea Palmieri |
167:abc42e7158a6 | 80 | virtual bool hasInitialized(void) const { |
Andrea Palmieri |
167:abc42e7158a6 | 81 | return isInitialized; |
Andrea Palmieri |
167:abc42e7158a6 | 82 | } |
Wolfgang Betz |
130:770ce14d3d15 | 83 | |
Wolfgang Betz |
130:770ce14d3d15 | 84 | bool dataPresent(); |
Wolfgang Betz |
130:770ce14d3d15 | 85 | int32_t spiRead(uint8_t *buffer, uint8_t buff_size); |
Wolfgang Betz |
130:770ce14d3d15 | 86 | int32_t spiWrite(uint8_t* data1, uint8_t* data2, uint8_t Nb_bytes1, uint8_t Nb_bytes2); |
Wolfgang Betz |
130:770ce14d3d15 | 87 | void disable_irq(); |
Wolfgang Betz |
130:770ce14d3d15 | 88 | void enable_irq(); |
Wolfgang Betz |
130:770ce14d3d15 | 89 | |
Wolfgang Betz |
130:770ce14d3d15 | 90 | private: |
Wolfgang Betz |
130:770ce14d3d15 | 91 | bool isInitialized; |
Wolfgang Betz |
130:770ce14d3d15 | 92 | |
Wolfgang Betz |
130:770ce14d3d15 | 93 | SPI spi_; |
Wolfgang Betz |
130:770ce14d3d15 | 94 | DigitalOut nCS_; |
Wolfgang Betz |
130:770ce14d3d15 | 95 | DigitalOut rst_; |
Wolfgang Betz |
130:770ce14d3d15 | 96 | InterruptIn irq_; |
Wolfgang Betz |
130:770ce14d3d15 | 97 | |
Wolfgang Betz |
130:770ce14d3d15 | 98 | //FIXME: TBI (by now just placeholders to let build |
Wolfgang Betz |
130:770ce14d3d15 | 99 | /*** betzw: placeholders ***/ |
Wolfgang Betz |
130:770ce14d3d15 | 100 | SecurityManager *sm; |
Wolfgang Betz |
130:770ce14d3d15 | 101 | }; |
Wolfgang Betz |
130:770ce14d3d15 | 102 | |
Wolfgang Betz |
130:770ce14d3d15 | 103 | #endif |