add "LE Device Address" 0x1B to advertising data types

Fork of BLE_API by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
vcoubard
Date:
Mon Jan 11 08:51:46 2016 +0000
Parent:
1081:c8f980f52363
Child:
1083:ec594a5c119b
Commit message:
Synchronized with git rev 1e448f87
Author: Rohit Grover
Merge pull request #141 from andresag01/develop

Improve API to facilitate full shutdown procedure

Changed in this revision

ble/Gap.h Show annotated file Show diff for this revision Revisions of this file
ble/GattClient.h Show annotated file Show diff for this revision Revisions of this file
ble/GattServer.h Show annotated file Show diff for this revision Revisions of this file
ble/SecurityManager.h Show annotated file Show diff for this revision Revisions of this file
ble/ServiceDiscovery.h Show annotated file Show diff for this revision Revisions of this file
source/BLE.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ble/Gap.h	Mon Jan 11 08:51:45 2016 +0000
+++ b/ble/Gap.h	Mon Jan 11 08:51:46 2016 +0000
@@ -993,6 +993,42 @@
         radioNotificationCallback.attach(tptr, mptr);
     }
 
+public:
+    /**
+     * Clear all Gap state of the associated object.
+     *
+     * This function is meant to be overridden in the platform-specific
+     * sub-class. Nevertheless, the sub-class is only expected to reset its
+     * state and not the data held in Gap members. This shall be achieved by a
+     * call to Gap::reset() from the sub-class' reset() implementation.
+     *
+     * @return BLE_ERROR_NONE on success.
+     *
+     * @note: Currently a call to reset() does not reset the advertising and
+     * scan parameters to default values.
+     */
+    virtual ble_error_t reset(void) {
+        /* Clear Gap state */
+        state.advertising = 0;
+        state.connected = 0;
+
+        /* Clear scanning state */
+        scanningActive = false;
+
+        /* Clear advertising and scanning data */
+        _advPayload.clear();
+        _scanResponse.clear();
+
+        /* Clear callbacks */
+        timeoutCallbackChain.clear();
+        connectionCallChain.clear();
+        disconnectionCallChain.clear();
+        radioNotificationCallback = NULL;
+        onAdvertisementReport = NULL;
+
+        return BLE_ERROR_NONE;
+    }
+
 protected:
     Gap() :
         _advParams(),
--- a/ble/GattClient.h	Mon Jan 11 08:51:45 2016 +0000
+++ b/ble/GattClient.h	Mon Jan 11 08:51:46 2016 +0000
@@ -325,6 +325,26 @@
         return onHVXCallbackChain;
     }
 
+public:
+    /**
+     * Clear all GattClient state of the associated object.
+     *
+     * This function is meant to be overridden in the platform-specific
+     * sub-class. Nevertheless, the sub-class is only expected to reset its
+     * state and not the data held in GattClient members. This shall be achieved
+     * by a call to GattClient::reset() from the sub-class' reset()
+     * implementation.
+     *
+     * @return BLE_ERROR_NONE on success.
+     */
+    virtual ble_error_t reset(void) {
+        onDataReadCallbackChain.clear();
+        onDataWriteCallbackChain.clear();
+        onHVXCallbackChain.clear();
+
+        return BLE_ERROR_NONE;
+    }
+
 protected:
     GattClient() {
         /* Empty */
--- a/ble/GattServer.h	Mon Jan 11 08:51:45 2016 +0000
+++ b/ble/GattServer.h	Mon Jan 11 08:51:46 2016 +0000
@@ -396,6 +396,32 @@
         dataSentCallChain.call(count);
     }
 
+public:
+    /**
+     * Clear all GattServer state of the associated object.
+     *
+     * This function is meant to be overridden in the platform-specific
+     * sub-class. Nevertheless, the sub-class is only expected to reset its
+     * state and not the data held in GattServer members. This shall be achieved
+     * by a call to GattServer::reset() from the sub-class' reset()
+     * implementation.
+     *
+     * @return BLE_ERROR_NONE on success.
+     */
+    virtual ble_error_t reset(void) {
+        serviceCount = 0;
+        characteristicCount = 0;
+
+        dataSentCallChain.clear();
+        dataWrittenCallChain.clear();
+        dataReadCallChain.clear();
+        updatesEnabledCallback = NULL;
+        updatesDisabledCallback = NULL;
+        confirmationReceivedCallback = NULL;
+
+        return BLE_ERROR_NONE;
+    }
+
 protected:
     uint8_t serviceCount;
     uint8_t characteristicCount;
--- a/ble/SecurityManager.h	Mon Jan 11 08:51:45 2016 +0000
+++ b/ble/SecurityManager.h	Mon Jan 11 08:51:46 2016 +0000
@@ -231,6 +231,28 @@
         /* empty */
     }
 
+public:
+    /**
+     * Clear all SecurityManager state of the associated object.
+     *
+     * This function is meant to be overridden in the platform-specific
+     * sub-class. Nevertheless, the sub-class is only expected to reset its
+     * state and not the data held in SecurityManager members. This shall be
+     * achieved by a call to SecurityManager::reset() from the sub-class'
+     * reset() implementation.
+     *
+     * @return BLE_ERROR_NONE on success.
+     */
+    virtual ble_error_t reset(void) {
+        securitySetupInitiatedCallback = NULL;
+        securitySetupCompletedCallback = NULL;
+        linkSecuredCallback = NULL;
+        securityContextStoredCallback = NULL;
+        passkeyDisplayCallback = NULL;
+
+        return BLE_ERROR_NONE;
+    }
+
 protected:
     SecuritySetupInitiatedCallback_t securitySetupInitiatedCallback;
     SecuritySetupCompletedCallback_t securitySetupCompletedCallback;
--- a/ble/ServiceDiscovery.h	Mon Jan 11 08:51:45 2016 +0000
+++ b/ble/ServiceDiscovery.h	Mon Jan 11 08:51:46 2016 +0000
@@ -132,6 +132,27 @@
      */
     virtual void        onTermination(TerminationCallback_t callback) = 0;
 
+    /**
+     * Clear all ServiceDiscovery state of the associated object.
+     *
+     * This function is meant to be overridden in the platform-specific
+     * sub-class. Nevertheless, the sub-class is only expected to reset its
+     * state and not the data held in ServiceDiscovery members. This shall be
+     * achieved by a call to ServiceDiscovery::reset() from the sub-class'
+     * reset() implementation.
+     *
+     * @return BLE_ERROR_NONE on success.
+     */
+    virtual ble_error_t reset(void) {
+        connHandle = 0;
+        matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN);
+        serviceCallback = NULL;
+        matchingCharacteristicUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN);
+        characteristicCallback = NULL;
+
+        return BLE_ERROR_NONE;
+    }
+
 protected:
     Gap::Handle_t            connHandle; /**< Connection handle as provided by the SoftDevice. */
     UUID                     matchingServiceUUID;
--- a/source/BLE.cpp	Mon Jan 11 08:51:45 2016 +0000
+++ b/source/BLE.cpp	Mon Jan 11 08:51:46 2016 +0000
@@ -131,7 +131,6 @@
 
 ble_error_t BLE::shutdown(void)
 {
-    clearAdvertisingPayload();
     if (!transport) {
         error("bad handle to underlying transport");
     }