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