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.
Dependents: BLE_Acceleration_Statejudging
Fork of nRF51822 by
Diff: source/nRF5xGap.cpp
- Revision:
- 575:7023a8204a1b
- Parent:
- 571:bbf6410b6a89
- Child:
- 577:d38f01a3e701
diff -r 7a531ae7a53c -r 7023a8204a1b source/nRF5xGap.cpp
--- a/source/nRF5xGap.cpp Mon Jan 11 10:19:23 2016 +0000
+++ b/source/nRF5xGap.cpp Mon Jan 11 10:19:24 2016 +0000
@@ -14,20 +14,17 @@
* limitations under the License.
*/
-#include "nRF5xGap.h"
+#include "nRF5xn.h"
#include "mbed.h"
+#include "ble/BLE.h"
#include "common/common.h"
#include "ble_advdata.h"
#include "ble_hci.h"
-nRF5xGap &nRF5xGap::getInstance() {
- static nRF5xGap m_instance;
- return m_instance;
-}
-
void radioNotificationStaticCallback(bool param) {
- nRF5xGap::getInstance().processRadioNotificationEvent(param);
+ nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap();
+ gap.processRadioNotificationEvent(param);
}
/**************************************************************************/
@@ -338,6 +335,29 @@
/**************************************************************************/
/*!
+ @brief Clear nRF5xGap's state.
+
+ @returns ble_error_t
+
+ @retval BLE_ERROR_NONE
+ Everything executed properly
+*/
+/**************************************************************************/
+ble_error_t nRF5xGap::reset(void)
+{
+ /* Clear all state that is from the parent, including private members */
+ if (Gap::reset() != BLE_ERROR_NONE) {
+ return BLE_ERROR_INVALID_STATE;
+ }
+
+ /* Clear derived class members */
+ m_connectionHandle = BLE_CONN_HANDLE_INVALID;
+
+ return BLE_ERROR_NONE;
+}
+
+/**************************************************************************/
+/*!
@brief Sets the 16-bit connection handle
*/
/**************************************************************************/
@@ -367,7 +387,7 @@
@code
uint8_t device_address[6] = { 0xca, 0xfe, 0xf0, 0xf0, 0xf0, 0xf0 };
- nrf.getGap().setAddress(Gap::BLEProtocol::AddressType::RANDOM_STATIC, device_address);
+ nrf.getGap().setAddress(Gap::ADDR_TYPE_RANDOM_STATIC, device_address);
@endcode
*/
@@ -381,12 +401,12 @@
When using Random Private addresses, the cycle mode must be Auto.
In auto mode, the given address is ignored.
*/
- if ((type == BLEProtocol::AddressType::PUBLIC) || (type == BLEProtocol::AddressType::RANDOM_STATIC))
+ if ((type == ADDR_TYPE_PUBLIC) || (type == ADDR_TYPE_RANDOM_STATIC))
{
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_NONE;
memcpy(dev_addr.addr, address, ADDR_LEN);
}
- else if ((type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE) || (type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE))
+ else if ((type == ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE) || (type == ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE))
{
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_AUTO;
// address is ignored when in auto mode
