CSSE4011_BLE_IMU IMU Seeed Tiny Ble
Dependencies: BLE_API_Tiny_BLE MPU6050-DMP-Seeed-Tiny-BLE mbed
nRF51822/nRF51Gap.h@0:f90c3452d779, 2015-06-10 (annotated)
- Committer:
- flywind
- Date:
- Wed Jun 10 09:46:16 2015 +0000
- Revision:
- 0:f90c3452d779
CSSE4011_Seed-Tiny-BLE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
flywind | 0:f90c3452d779 | 1 | /* mbed Microcontroller Library |
flywind | 0:f90c3452d779 | 2 | * Copyright (c) 2006-2013 ARM Limited |
flywind | 0:f90c3452d779 | 3 | * |
flywind | 0:f90c3452d779 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
flywind | 0:f90c3452d779 | 5 | * you may not use this file except in compliance with the License. |
flywind | 0:f90c3452d779 | 6 | * You may obtain a copy of the License at |
flywind | 0:f90c3452d779 | 7 | * |
flywind | 0:f90c3452d779 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
flywind | 0:f90c3452d779 | 9 | * |
flywind | 0:f90c3452d779 | 10 | * Unless required by applicable law or agreed to in writing, software |
flywind | 0:f90c3452d779 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
flywind | 0:f90c3452d779 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
flywind | 0:f90c3452d779 | 13 | * See the License for the specific language governing permissions and |
flywind | 0:f90c3452d779 | 14 | * limitations under the License. |
flywind | 0:f90c3452d779 | 15 | */ |
flywind | 0:f90c3452d779 | 16 | |
flywind | 0:f90c3452d779 | 17 | #ifndef __NRF51822_GAP_H__ |
flywind | 0:f90c3452d779 | 18 | #define __NRF51822_GAP_H__ |
flywind | 0:f90c3452d779 | 19 | |
flywind | 0:f90c3452d779 | 20 | #include "mbed.h" |
flywind | 0:f90c3452d779 | 21 | #include "blecommon.h" |
flywind | 0:f90c3452d779 | 22 | #include "ble.h" |
flywind | 0:f90c3452d779 | 23 | #include "GapAdvertisingParams.h" |
flywind | 0:f90c3452d779 | 24 | #include "GapAdvertisingData.h" |
flywind | 0:f90c3452d779 | 25 | #include "public/Gap.h" |
flywind | 0:f90c3452d779 | 26 | |
flywind | 0:f90c3452d779 | 27 | #include "nrf_soc.h" |
flywind | 0:f90c3452d779 | 28 | #include "ble_radio_notification.h" |
flywind | 0:f90c3452d779 | 29 | |
flywind | 0:f90c3452d779 | 30 | /**************************************************************************/ |
flywind | 0:f90c3452d779 | 31 | /*! |
flywind | 0:f90c3452d779 | 32 | \brief |
flywind | 0:f90c3452d779 | 33 | |
flywind | 0:f90c3452d779 | 34 | */ |
flywind | 0:f90c3452d779 | 35 | /**************************************************************************/ |
flywind | 0:f90c3452d779 | 36 | class nRF51Gap : public Gap |
flywind | 0:f90c3452d779 | 37 | { |
flywind | 0:f90c3452d779 | 38 | public: |
flywind | 0:f90c3452d779 | 39 | static nRF51Gap &getInstance() { |
flywind | 0:f90c3452d779 | 40 | static nRF51Gap m_instance; |
flywind | 0:f90c3452d779 | 41 | return m_instance; |
flywind | 0:f90c3452d779 | 42 | } |
flywind | 0:f90c3452d779 | 43 | |
flywind | 0:f90c3452d779 | 44 | /* Functions that must be implemented from Gap */ |
flywind | 0:f90c3452d779 | 45 | virtual ble_error_t setAddress(addr_type_t type, const address_t address); |
flywind | 0:f90c3452d779 | 46 | virtual ble_error_t getAddress(addr_type_t *typeP, address_t address); |
flywind | 0:f90c3452d779 | 47 | virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &); |
flywind | 0:f90c3452d779 | 48 | |
flywind | 0:f90c3452d779 | 49 | virtual uint16_t getMinAdvertisingInterval(void) const {return GAP_DURATION_UNITS_TO_MS(BLE_GAP_ADV_INTERVAL_MIN);} |
flywind | 0:f90c3452d779 | 50 | virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const {return GAP_DURATION_UNITS_TO_MS(BLE_GAP_ADV_NONCON_INTERVAL_MIN);} |
flywind | 0:f90c3452d779 | 51 | virtual uint16_t getMaxAdvertisingInterval(void) const {return GAP_DURATION_UNITS_TO_MS(BLE_GAP_ADV_INTERVAL_MAX);} |
flywind | 0:f90c3452d779 | 52 | |
flywind | 0:f90c3452d779 | 53 | virtual ble_error_t startAdvertising(const GapAdvertisingParams &); |
flywind | 0:f90c3452d779 | 54 | virtual ble_error_t stopAdvertising(void); |
flywind | 0:f90c3452d779 | 55 | virtual ble_error_t disconnect(DisconnectionReason_t reason); |
flywind | 0:f90c3452d779 | 56 | |
flywind | 0:f90c3452d779 | 57 | virtual ble_error_t setDeviceName(const uint8_t *deviceName); |
flywind | 0:f90c3452d779 | 58 | virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP); |
flywind | 0:f90c3452d779 | 59 | virtual ble_error_t setAppearance(uint16_t appearance); |
flywind | 0:f90c3452d779 | 60 | virtual ble_error_t getAppearance(uint16_t *appearanceP); |
flywind | 0:f90c3452d779 | 61 | |
flywind | 0:f90c3452d779 | 62 | void setConnectionHandle(uint16_t con_handle); |
flywind | 0:f90c3452d779 | 63 | uint16_t getConnectionHandle(void); |
flywind | 0:f90c3452d779 | 64 | |
flywind | 0:f90c3452d779 | 65 | virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params); |
flywind | 0:f90c3452d779 | 66 | virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params); |
flywind | 0:f90c3452d779 | 67 | virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params); |
flywind | 0:f90c3452d779 | 68 | |
flywind | 0:f90c3452d779 | 69 | virtual void setOnRadioNotification(RadioNotificationEventCallback_t callback) { |
flywind | 0:f90c3452d779 | 70 | Gap::setOnRadioNotification(callback); |
flywind | 0:f90c3452d779 | 71 | ble_radio_notification_init(NRF_APP_PRIORITY_HIGH, NRF_RADIO_NOTIFICATION_DISTANCE_800US, onRadioNotification); |
flywind | 0:f90c3452d779 | 72 | } |
flywind | 0:f90c3452d779 | 73 | |
flywind | 0:f90c3452d779 | 74 | private: |
flywind | 0:f90c3452d779 | 75 | uint16_t m_connectionHandle; |
flywind | 0:f90c3452d779 | 76 | nRF51Gap() { |
flywind | 0:f90c3452d779 | 77 | m_connectionHandle = BLE_CONN_HANDLE_INVALID; |
flywind | 0:f90c3452d779 | 78 | } |
flywind | 0:f90c3452d779 | 79 | |
flywind | 0:f90c3452d779 | 80 | nRF51Gap(nRF51Gap const &); |
flywind | 0:f90c3452d779 | 81 | void operator=(nRF51Gap const &); |
flywind | 0:f90c3452d779 | 82 | }; |
flywind | 0:f90c3452d779 | 83 | |
flywind | 0:f90c3452d779 | 84 | #endif // ifndef __NRF51822_GAP_H__ |