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