this is using the mbed os version 5-13-1

Dependencies:   mbed-http

Files at this revision

API Documentation at this revision

Comitter:
ocomeni
Date:
Sat May 18 10:50:49 2019 +0000
Branch:
PassingRegression
Parent:
112:a0999ea4ece0
Child:
114:b11bb96c09f3
Commit message:
BLE now working at startup.

Changed in this revision

source/BleManager.cpp Show annotated file Show diff for this revision Revisions of this file
source/BleManager.h Show annotated file Show diff for this revision Revisions of this file
source/Bounded.h Show diff for this revision Revisions of this file
source/Duration.h Show diff for this revision Revisions of this file
source/Types.h Show diff for this revision Revisions of this file
source/WiFiManager.cpp Show annotated file Show diff for this revision Revisions of this file
source/WiFiManager.h Show annotated file Show diff for this revision Revisions of this file
source/debug.cpp Show annotated file Show diff for this revision Revisions of this file
source/debug.h Show annotated file Show diff for this revision Revisions of this file
source/main-https.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/source/BleManager.cpp	Sat May 11 11:55:29 2019 +0000
+++ b/source/BleManager.cpp	Sat May 18 10:50:49 2019 +0000
@@ -29,7 +29,7 @@
 #define FILE_CODE       "btle"
 
 
-static const uint8_t DEVICE_NAME[] = "SM_device";
+//static const uint8_t DEVICE_NAME[] = "SM_device";
 //static const uint16_t uuid16_list[] = {LEDService::LED_SERVICE_UUID};
 extern UARTService *uart;
 extern char buffer[BUFFER_LEN];
@@ -62,13 +62,16 @@
  */
 SMDevice::SMDevice(BLE &ble, events::EventQueue &event_queue, 
                    BLEProtocol::AddressBytes_t &peer_address, ble_config_t ble_config) :
-        _led1(LED1, 0),
         _ble(ble),
         _event_queue(event_queue),
         _peer_address(peer_address),
         ble_config(ble_config),
         _handle(0),
-        _is_connecting(false) { }
+        _is_connecting(false), 
+        _led1(LED1, 0)
+{ 
+    isConnected = false;
+}
 
 SMDevice::~SMDevice()
 {
@@ -272,10 +275,11 @@
     dbg_printf(LOG, "Disconnected\r\n");
 #ifndef DEMO_BLE_SECURITY
     dbg_printf(LOG, "Restarting advertising...\r\n");
-    _ble.gap().startAdvertising();
+    _ble.gap().startAdvertising(ble::LEGACY_ADVERTISING_HANDLE);
 #else
     _event_queue.break_dispatch();
 #endif
+    isConnected = false;
 }
 
 /** End demonstration unexpectedly. Called if timeout is reached during advertising,
@@ -303,11 +307,17 @@
 /** Send data aynchronously using BLE                                       */
 void SMDevice::sendBLEUartData(char * str)
 {
-    Gap::GapState_t gapState = _ble.gap().getState();
-    if(gapState.connected){    
+    //Gap::GapState_t gapState = _ble.gap().getState();
+    //Gap::GapState_t gapState = _ble.getGapState();
+    //gapState.connected
+    if(isConnected){    
         uart->writeString(str);
         uart->writeString("\n");    //flushes uart output buffer and sends data
     }
+    else
+    {
+        dbg_printf(LOG, "BLE not connected\r\n");
+    }
 }
 
 
@@ -356,14 +366,15 @@
 
 void SMDevice::reportGapState()
 {
-     Gap::GapState_t gapState = _ble.gap().getState();
+     //Gap::GapState_t gapState = _ble.gap().getState();
      char connStr[20] = " Not Connected ";
      char advStr[20] = " Not Advertising ";
-     char devName[20] = "";
-     if(gapState.advertising){
+     //char devName[20] = "";
+     //if(gapState.advertising){
+     if(_ble.gap().isAdvertisingActive(ble::LEGACY_ADVERTISING_HANDLE)){
          strncpy(advStr, " Advertising ", 20);
      }
-     if(gapState.connected){
+     if(isConnected){
          strncpy(connStr, " Connected ", 20);
      }
      dbg_printf(LOG, "\n Advertising Status = %s\n Connection Status = %s\n", advStr, connStr);
@@ -391,7 +402,7 @@
     advertising_data.addData(
         GapAdvertisingData::COMPLETE_LOCAL_NAME,
         (const uint8_t *)ble_config.deviceName,
-        sizeof(ble_config.deviceName)
+        strlen(ble_config.deviceName)
         );
     /* Setup primary service */
     uart = new UARTService(_ble);
@@ -427,7 +438,7 @@
     _ble.gap().setAdvertisingInterval(ble_config.advInterval); /* setting in ble_config */
     _ble.gap().setAdvertisingTimeout(ble_config.advTimeout);   /* setting in ble_config */
 
-    error = _ble.gap().startAdvertising();
+    error = _ble.gap().startAdvertising(ble::LEGACY_ADVERTISING_HANDLE);
 
     if (error) {
         dbg_printf(LOG, "Error during Gap::startAdvertising.\r\n");
@@ -475,13 +486,14 @@
         return;
     }
     dbg_printf(LOG, "SM::setLinkSecurity setup\r\n");
+    isConnected = true;
 }
 
 void SMDevicePeripheral::stopAdvertising()
 {
     if (_ble.hasInitialized()) {
         ble_error_t error;
-        error = _ble.gap().stopAdvertising();;
+        error = _ble.gap().stopAdvertising(ble::LEGACY_ADVERTISING_HANDLE);;
         if(error){
             dbg_printf(LOG, " Error stopping advertising...\r\n");
             return;
@@ -494,7 +506,7 @@
 {
     if (_ble.hasInitialized()) {
         ble_error_t error;
-        error = _ble.gap().startAdvertising();
+        error = _ble.gap().startAdvertising(ble::LEGACY_ADVERTISING_HANDLE);
         if(error){
             dbg_printf(LOG, " Error Restarting advertising...\r\n");
             return;
--- a/source/BleManager.h	Sat May 11 11:55:29 2019 +0000
+++ b/source/BleManager.h	Sat May 18 10:50:49 2019 +0000
@@ -87,8 +87,11 @@
     void shutDown();
     void sendBLEUartData(char * str);
 
+protected:
+    // connection status
+    bool isConnected;
 private:
-    /** Override to start chosen activity when initialisation completes */
+   /** Override to start chosen activity when initialisation completes */
     virtual void start() = 0;
 
     /** This is called when BLE interface is initialised and starts the demonstration */
--- a/source/Bounded.h	Sat May 11 11:55:29 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2018 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef BLE_COMMON_BOUNDED_H_
-#define BLE_COMMON_BOUNDED_H_
-
-#include <stdint.h>
-
-namespace ble {
-
-/**
- * Restrict values of an integer type to a defined range.
- *
- * The range is a closed interval that includes its left-bound (Min) and
- * right-bound value (Max).
- *
- * @tparam Rep The C++ integer type used to represent the values.
- * @tparam Min Minimum value allowed.
- * @tparam Max Maximum value allowed.
- */
-template<typename Rep, Rep Min, Rep Max>
-struct Bounded {
-    /**
-     * Construct a bounded integer.
-     *
-     * If v is out of the range [Min : Max], then if it is less than Min, the
-     * value of the bounded integer will be Min. If it greater than Max, then
-     * the value of the bounded integer will be Max.
-     *
-     * @param v The value to store.
-     */
-    Bounded(Rep v) : _value(v)
-    {
-        if (v < Min) {
-            _value = v;
-        } else if (v > Max) {
-            _value = v;
-        }
-    }
-
-    /**
-     * Access the inner value.
-     *
-     * @return The current value.
-     */
-    Rep value() const
-    {
-        return _value;
-    }
-
-    /**
-     * The left-bound value.
-     *
-     * @return The lowest value that this type can represent
-     */
-    static Rep min()
-    {
-        return Min;
-    }
-
-    /**
-     * The right-bound value.
-     *
-     * @return The highest value that this type can represent
-     */
-    static Rep max()
-    {
-        return Max;
-    }
-
-    /**
-     * The left-bound value.
-     */
-    static const Rep MIN = Min;
-
-    /**
-     * The right-bound value.
-     */
-    static const Rep MAX = Max;
-
-private:
-    Rep _value;
-};
-
-/* ---------------------- Static variable initialization -------------------- */
-
-template<typename T, T Min, T Max>
-const T Bounded<T, Min, Max>::MIN;
-
-template<typename T, T Min, T Max>
-const T Bounded<T, Min, Max>::MAX;
-
-} // namespace ble
-
-#endif //BLE_COMMON_BOUNDED_H_
--- a/source/Duration.h	Sat May 11 11:55:29 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,578 +0,0 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2018 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef BLE_COMMON_DURATION_H_
-#define BLE_COMMON_DURATION_H_
-
-#include <stdint.h>
-#include <stddef.h>
-#include "platform/mbed_assert.h"
-
-namespace ble {
-
-#if !defined(DOXYGEN_ONLY)
-
-/**
- * Define a compile time range.
- * @tparam Min left-bound
- * @tparam Max right-bound
- */
-template<uint32_t Min, uint32_t Max>
-struct Range {
-    static const uint32_t MIN = Min;
-    static const uint32_t MAX = Max;
-};
-
-/**
- * Deduce default range for C++ basic integer types.
- *
- *
- * @tparam Rep The C++ integer type.
- */
-template<typename Rep>
-struct DefaultRange;
-
-/**
- * DefaultRange specialization for uint8_t.
- */
-template<>
-struct DefaultRange<uint8_t> {
-    typedef Range<0, 0xFF> type;
-};
-
-/**
- * DefaultRange specialization for uint16_t.
- */
-template<>
-struct DefaultRange<uint16_t > {
-    typedef Range<0, 0xFFFF> type;
-};
-
-/**
- * DefaultRange specialization for uint32_t
- */
-template<>
-struct DefaultRange<uint32_t> {
-    typedef Range<0, 0xFFFFFFFF> type;
-};
-
-/**
- * Represent an integral compile time value that can be used in Duration.
- *
- * @tparam T Type of the integral value.
- * @tparam V The integer value representing a never ending duration.
- */
-template<typename T, T V>
-struct Value {
-    static const T VALUE = V;
-};
-
-#endif
-
-/**
- * Model BLE durations.
- *
- * @tparam Rep The representation type of the duration.
- * @tparam TB The time base in micro seconds.
- * @tparam Range Closed interval of the duration
- * @tparam Forever The special value (if applicable) that represents a forever
- * duration.
- */
-template<
-    typename Rep,
-    uint32_t TB,
-    typename Range = typename DefaultRange<Rep>::type,
-    typename Forever = void*
->
-struct Duration {
-    /**
-     * Type of the actual representation.
-     */
-    typedef Rep representation_t;
-
-    /**
-     * Construct a default Duration.
-     *
-     * It is initialized with the minimum value acceptable.
-     */
-    Duration() : duration(Range::MIN)
-    {
-    }
-
-    /**
-     * Construct a Duration from an integer value.
-     *
-     * @param v The value of the duration in TIME_BASE units.
-     */
-    explicit Duration(Rep v) : duration(clamp(v))
-    {
-    }
-
-    /**
-     * Construct a Duration from another Duration.
-     *
-     * @note The operation fail at compile time if there is a loss of precision.
-     *
-     * @tparam OtherRep The type used to represent the other Duration.
-     * @tparam OtherTB The time base in micro seconds of the other Duration.
-     * @tparam OtherRange The range of the other Duration.
-     * @tparam OtherF The forever value of the other type.
-     *
-     * @param other The Duration used to construct this object.
-     */
-    template<typename OtherRep, uint32_t OtherTB, typename OtherRange, typename OtherF>
-    Duration(Duration<OtherRep, OtherTB, OtherRange, OtherF> other) :
-        duration(clamp(other.value() * (OtherTB / TB)))
-    {
-        MBED_STATIC_ASSERT(OtherTB >= TB && (OtherTB % TB) == 0, "Incompatible units");
-    }
-
-    /**
-     * Construct a new Duration from a Duration in milliseconds.
-     *
-     * @note The result of the conversion is rounded up.
-     *
-     * @tparam OtherRep The representation type used by other_ms.
-     * @tparam OtherRange The range used by other_ms.
-     * @tparam OtherF The forever value used by other_ms.
-     *
-     * @param other_ms The Duration in millisecond to convert.
-     */
-    template<typename OtherRep, typename OtherRange, typename OtherF>
-    explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = NULL) :
-        duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB))
-    {
-    }
-
-    /**
-     * Return the duration in TB units.
-     *
-     * @return The duration in TB units.
-     */
-    Rep value() const
-    {
-        return duration;
-    }
-
-    /**
-     * Return the duration in milliseconds.
-     *
-     * @return The duration in milliseconds.
-     */
-    uint32_t valueInMs() const
-    {
-        return ((uint32_t)duration * TB) / 1000;
-    }
-
-    /**
-     * The time base.
-     */
-    static const uint32_t TIME_BASE = TB;
-
-    /**
-     * Left-bound of the duration range.
-     */
-    static const Rep MIN = Range::MIN;
-
-    /**
-     * Right bound of the duration range.
-     */
-    static const Rep MAX = Range::MAX;
-
-    /**
-     * Return the minimum duration.
-     *
-     * @return The minimum duration.
-     */
-    static Duration min()
-    {
-        return Duration(MIN);
-    }
-
-    /**
-     * Return the maximum duration.
-     *
-     * @return The maximum duration.
-     */
-    static Duration max()
-    {
-        return Duration(MAX);
-    }
-
-    /**
-     * Return a pointer to the value of the duration.
-     *
-     * @return a pointer to the value of the duration.
-     */
-    const Rep* storage() const
-    {
-        return &duration;
-    }
-
-    /**
-     * Return the Duration value meaning forever.
-     * @return the Duration value meaning forever.
-     */
-    static Duration forever()
-    {
-        return Duration(Forever::VALUE);
-    }
-
-private:
-    static Rep clamp(Rep in)
-    {
-        if (in < MIN) {
-            return MIN;
-        } else if (in > MAX) {
-            return MAX;
-        } else {
-            return in;
-        }
-    }
-
-    Rep duration;
-};
-
-/**
- * Type that represents micro seconds.
- */
-typedef Duration<uint32_t, 1> microsecond_t;
-
-/**
- * Type that represents milliseconds.
- */
-typedef Duration<uint32_t, 1000 * microsecond_t::TIME_BASE> millisecond_t;
-
-/**
- * Type that represents seconds.
- */
-typedef Duration<uint32_t, 1000 * millisecond_t::TIME_BASE> second_t;
-
-/**
- * Cast a duration to another.
- *
- * @tparam DurationOut Type of the Duration in output.
- * @tparam RepIn The representation type of duration.
- * @tparam TBIn The timebase of duration.
- * @tparam RangeIn The range of duration.
- * @tparam FIn The Forever value of duration.
- * @param duration The duration to convert.
- * @return The converted duration. It is rounded up if precision is lost.
- *
- * @related Duration
- */
-template<typename DurationOut, typename RepIn, uint32_t TBIn, typename RangeIn, typename FIn>
-DurationOut durationCast(Duration<RepIn, TBIn, RangeIn, FIn> duration)
-{
-    return DurationOut(((duration.value() * TBIn) + DurationOut::TIME_BASE - 1) / DurationOut::TIME_BASE);
-}
-
-/**
- * Add two durations together and return the result in microseconds.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return The result of the addition of the two durations in microseconds.
- *
- * @related Duration
- */
-template<
-    typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
-    typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS>
-microsecond_t  operator+(
-    Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
-    Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
-)
-{
-    return microsecond_t((lhs.value() * lhs.TIME_BASE) + (rhs.value() * rhs.TIME_BASE));
-}
-
-/**
- * Add two durations together.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return The addition of the two durations in input.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t TB, typename Range, typename F>
-Duration<Rep, TB, Range, F> operator+(
-    Duration<Rep, TB, Range, F> lhs,
-    Duration<Rep, TB, Range, F> rhs
-)
-{
-    return Duration<Rep, TB, Range, F>(lhs.value() + rhs.value());
-}
-
-/**
- * Multiply a duration and a positive integer.
- *
- * @param lhs The duration.
- * @param rhs The integer.
- *
- * @return A duration that represents the multiplication of lhs with rhs.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t TB, typename Range, typename F>
-Duration<Rep, TB, Range, F> operator*(Duration<Rep, TB, Range, F> lhs, uint32_t rhs)
-{
-    return Duration<Rep, TB, Range, F>(lhs.value() * rhs);
-}
-
-/**
- * Multiply a duration and a positive integer.
- *
- * @param lhs The integer.
- * @param rhs The multiplication.
- *
- * @return A duration that represents the multiplication of lhs with rhs.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t TB, typename Range, typename F>
-Duration<Rep, TB, Range, F> operator*(uint32_t lhs, Duration<Rep, TB, Range, F> rhs)
-{
-    return Duration<Rep, TB, Range, F>(lhs * rhs.value());
-}
-
-/**
- * Indicate if the duration lhs is less than the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is less than rhs and false otherwise.
- *
- * @related Duration
- */
-template<
-    typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
-    typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS
->
-bool operator<(Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs)
-{
-    return lhs.value() * lhs.TIME_BASE < rhs.value() * rhs.TIME_BASE;
-}
-
-/**
- * Indicate if the duration lhs is less than the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is less than rhs and false otherwise.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t Us, typename Range, typename F>
-bool operator<(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
-{
-    return lhs.value() < rhs.value();
-}
-
-/**
- * Indicate if the duration lhs is less than or equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is less than or equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<
-    typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
-    typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS
->
-bool operator<=(
-    Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
-    Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
-)
-{
-    return lhs.value() * lhs.TIME_BASE <= rhs.value() * rhs.TIME_BASE;
-}
-
-/**
- * Indicate if the duration lhs is less than or equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is less than or equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t Us, typename Range>
-bool operator<=(Duration<Rep, Us, Range> lhs, Duration<Rep, Us, Range> rhs)
-{
-    return lhs.value() <= rhs.value();
-}
-
-/**
- * Indicate if the duration lhs is equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<
-    typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
-    typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS
->
-bool operator==(
-    Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
-    Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
-)
-{
-    return lhs.value() * lhs.TIME_BASE == rhs.value() * rhs.TIME_BASE;
-}
-
-/**
- * Indicate if the duration lhs is equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t Us, typename Range, typename F>
-bool operator==(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
-{
-    return lhs.value() == rhs.value();
-}
-
-/**
- * Indicate if the duration lhs is not equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is not equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<
-    typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
-    typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS
->
-bool operator!=(
-    Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
-    Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
-)
-{
-    return !(lhs == rhs);
-}
-
-/**
- * Indicate if the duration lhs is not equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is not equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t Us, typename Range, typename F>
-bool operator!=(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
-{
-    return !(lhs == rhs);
-}
-
-/**
- * Indicate if the duration lhs greater or equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is greater or equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<
-    typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
-    typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS
->
-bool operator>=(
-    Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
-    Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
-)
-{
-    return rhs <= lhs;
-}
-
-/**
- * Indicate if the duration lhs greater or equal to the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is greater or equal to rhs and false otherwise.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t Us, typename Range, typename F>
-bool operator>=(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
-{
-    return rhs <= lhs;
-}
-
-/**
- * Indicate if the duration lhs greater than the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is greater than rhs and false otherwise.
- *
- * @related Duration
- */
-template<
-    typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
-    typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS
->
-bool operator>(
-    Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
-    Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
-)
-{
-    return rhs < lhs;
-}
-
-/**
- * Indicate if the duration lhs greater than the duration rhs.
- * @param lhs Left hand side operand.
- * @param rhs Right hand side operand.
- * @return true if lhs is greater than rhs and false otherwise.
- *
- * @related Duration
- */
-template<typename Rep, uint32_t Us, typename Range, typename F>
-bool operator>(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
-{
-    return rhs < lhs;
-}
-
-/* ---------------------- Static variable initialization -------------------- */
-
-#if !defined(DOXYGEN_ONLY)
-
-template<uint32_t Min, uint32_t Max>
-const uint32_t Range<Min, Max>::MIN;
-
-template<uint32_t Min, uint32_t Max>
-const uint32_t Range<Min, Max>::MAX;
-
-template<typename T, T V>
-const T Value<T, V>::VALUE;
-
-#endif
-
-template<typename Rep, uint32_t TB, typename Range, typename Forever>
-const uint32_t Duration<Rep, TB, Range, Forever>::TIME_BASE;
-
-template<typename Rep, uint32_t TB, typename Range, typename Forever>
-const Rep Duration<Rep, TB, Range, Forever>::MIN;
-
-template<typename Rep, uint32_t TB, typename Range, typename Forever>
-const Rep Duration<Rep, TB, Range, Forever>::MAX;
-
-}
-
-#endif //BLE_COMMON_DURATION_H_
--- a/source/Types.h	Sat May 11 11:55:29 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,965 +0,0 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2018 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef BLE_GAP_TYPES_H
-#define BLE_GAP_TYPES_H
-
-#include "Duration.h"
-#include "Bounded.h"
-#include "ble/SafeEnum.h"
-
-namespace ble {
-
-/**
- * @addtogroup ble
- * @{
- * @addtogroup gap
- * @{
- */
-
-/* BLE units, using microseconds as the common denominator */
-
-/**
- * Time interval between two advertisements.
- *
- * The duration is in unit of 625µs and ranges from 0x20 to 0xFFFFFF .
- *
- * @note before Bluetooth 5 range was 0x20 to 0xFFFF.
- */
-typedef Duration<uint32_t, 625, Range<0x20, 0xFFFFFF> > adv_interval_t;
-
-/**
- * Advertising process duration.
- *
- * The duration is in unit of 10ms and ranges from 0x0001 to 0xFFFF. The special
- * value 0x0000 means the advertising process never ends; it is accessible with
- * adv_duration_t::forever().
- */
-typedef Duration<uint16_t, 10000, Range<0x00, 0xFFFF>, /* forever */ Value<uint16_t, 0x0000> > adv_duration_t;
-
-/**
- * Scan process duration.
- *
- * The duration is in unit of 10ms and ranges from 0x0001 to 0xFFFF. The special
- * value 0x0000 means the scan process never ends; it is accessible with
- * scan_duration_t::forever().
- */
-typedef Duration<uint16_t, 10000, Range<0x00, 0xFFFF>, /* forever */ Value<uint16_t, 0x0000> > scan_duration_t;
-
-/**
- * Time interval between two scan processes.
- *
- * The duration is in unit of 1.28s and ranges from 0x0001 to 0xFFFF. The special
- * value 0x0000 is used to indicate that scan_period_t is not used.
- */
-typedef Duration<uint16_t, 1280000, Range<0x00, 0xFFFF> > scan_period_t;
-
-/**
- * Time interval between two scans.
- *
- * The duration is in unit of 625µs and ranges from 0x04 to 0xFFFF.
- */
-typedef Duration<uint16_t, 625, Range<0x04, 0xFFFF> > scan_interval_t;
-
-/**
- * Duration of a scan.
- *
- * The duration is in unit of 625µs and ranges from 0x04 to 0xFFFF.
- */
-typedef Duration<uint16_t, 625, Range<0x04, 0xFFFF> > scan_window_t;
-
-/**
- * Time interval between two connection events.
- *
- * The interval is in unit of 1.250 milliseconds and ranges from 0x06 to 0xC80.
- */
-typedef Duration<uint16_t, 1250, Range<0x06, 0x0C80> > conn_interval_t;
-
-/**
- * Time after which a connection is loss of devices have not exchanged data.
- *
- * The duration is in unit of 10 milliseconds and ranges from 0x0A to 0xC80.
- *
- * @note this time should be no larger than (1 + ConnLatency) * ConnIntervalMax * 2
- */
-typedef Duration<uint16_t, 10000, Range<0x0A, 0x0C80> > supervision_timeout_t;
-
-/**
- * Duration of a connection event.
- *
- * The duration is in unit of 625µs and ranges from 0x0 to 0xFFFF .
- */
-typedef Duration<uint16_t, 625, Range<0, 0xFFFF> > conn_event_length_t;
-
-/**
- * Time after which a periodic sync link is considered lost if the receiver hasn't
- * received anything from the advertiser.
- *
- * The duration is in unit of 10 milliseconds and ranges from 0x0A to 0x4000.
- */
-typedef Duration<uint16_t, 10000, Range<0x0A, 0x4000> > sync_timeout_t;
-
-/**
- * Interval between two periodic advertising events.
- *
- * The duration is in unit of 1.250ms and ranges from 0x06 to 0xFFFF.
- */
-typedef Duration<uint16_t, 1250, Range<0x06, 0xFFFF> > periodic_interval_t;
-
-/**
- * Number of connection events that can be skipped by the slave.
- *
- * It ranges from 0 to 0x1F3.
- */
-typedef Bounded<uint16_t, 0, 0x01F3> slave_latency_t;
-
-/**
- * Handle of an advertising set.
- *
- * @note Range of valid handle is comprised between 0x00 and 0xEF.
- */
-typedef uint8_t advertising_handle_t;
-
-/**
- * Handle of a sync representing a periodic advertiser.
- *
- * @note Range of valid handle is comprised between 0x0000 and 0xFFFF.
- */
-typedef uint16_t periodic_sync_handle_t;
-
-/**
- * Encapsulates the peripheral advertising modes.
- *
- * It determines how the device appears to other scanner and peripheral
- * devices in the scanning range.
- */
-struct advertising_type_t : SafeEnum<advertising_type_t, uint8_t> {
-    /// enumeration of advertising_type_t values
-    enum type {
-        /**
-         * Device is connectable, scannable and doesn't expect connection from a
-         * specific peer.
-         *
-         * @see Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1.
-         */
-        CONNECTABLE_UNDIRECTED = 0x00,
-
-        /**
-         * Device is connectable and expects connection from a specific peer.
-         * (3.75 ms or smaller Advertising Interval)
-         * @see Vol 3, Part C, Section 9.3.3 and Vol 6, Part B, Section 2.3.1.2.
-         */
-        CONNECTABLE_DIRECTED = 0x01,
-
-        /**
-         * Device is scannable but not connectable.
-         *
-         * @see Vol 6, Part B, Section 2.3.1.4.
-         */
-        SCANNABLE_UNDIRECTED = 0x02,
-
-        /**
-         * Device is not connectable and not scannable.
-         *
-         * @see Vol 3, Part C, Section 9.3.2 and Vol 6, Part B, Section 2.3.1.3.
-         */
-        NON_CONNECTABLE_UNDIRECTED = 0x03,
-
-        /**
-         * Device is connectable and expects connection from a specific peer (sent at long user set intervals).
-         */
-        CONNECTABLE_DIRECTED_LOW_DUTY = 0x04,
-
-#if !defined(DOXYGEN_ONLY)
-        // used by the PAL; naming in line with the the spec.
-        ADV_IND = 0x00,
-        ADV_DIRECT_IND = 0x01,
-        ADV_SCAN_IND = 0x02,
-        ADV_NONCONN_IND = 0x03,
-        ADV_DIRECT_IND_LOW_DUTY_CYCLE = 0x04
-#endif
-    };
-
-    /**
-     * Construct a new advertising_type_t value.
-     *
-     * @param value The value of the advertising_type_t created.
-     */
-    advertising_type_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-
-/** Used to indicate if the packet is complete and if it's truncated.
- */
-struct advertising_data_status_t : SafeEnum<advertising_data_status_t, uint8_t> {
-    /// enumeration of advertising_data_status_t values
-    enum type {
-        COMPLETE = 0x00, /// Advertising payload complete.
-        INCOMPLETE_MORE_DATA = 0x01, /// Partial advertising payload, more to come.
-        INCOMPLETE_DATA_TRUNCATED = 0x02 /// Advertising payload incomplete, and no more is coming.
-    };
-
-    /**
-     * Construct a new advertising_data_status_t value.
-     *
-     * @param value The value of the advertising_data_status_t created.
-     */
-    advertising_data_status_t(type value) : SafeEnum(value)
-    {
-    }
-
-#if !defined(DOXYGEN_ONLY)
-
-    /**
-     * Explicit constructor from a raw value.
-     */
-    explicit advertising_data_status_t(uint8_t raw_value) :
-        SafeEnum(raw_value)
-    {
-    }
-
-#endif
-
-};
-
-/** Properties of an advertising event.
- */
-struct advertising_event_t {
-
-private:
-    // Implementation note: The object is constructed from the field Event_Type
-    // of an LE Extended Advertising.
-    // Indexes and functions of bits are defined in BLUETOOTH SPECIFICATION
-    // Version 5.0 | Vol 2, Part E -
-    // Section 7.7.65.13 LE Extended Advertising report Event
-    enum {
-        CONNECTABLE_BIT = 0,
-        SCANNABLE_ADVERTISING_BIT = 1,
-        DIRECTED_ADVERTISING_BIT = 2,
-        SCAN_RESPONSE_BIT = 3,
-        LEGACY_PDU_BIT = 4,
-        DATA_STATUS_INDEX = 5,
-        DATA_STATUS_MASK = 0x03
-    };
-
-public:
-
-#if !defined(DOXYGEN_ONLY)
-
-    /** Create based on a raw value.
-     *
-     * @param value
-     */
-    explicit advertising_event_t(uint8_t value) : value(value)
-    {
-    }
-
-#endif
-
-    /** Is advertising connectable.
-     *
-     * @return True if connectable.
-     */
-    bool connectable() const
-    {
-        return static_cast<bool>(value & (1 << CONNECTABLE_BIT));
-    }
-
-    /** Is advertising scannable.
-     *
-     * @return True if scannable
-     */
-    bool scannable_advertising() const
-    {
-        return static_cast<bool>(value & (1 << SCANNABLE_ADVERTISING_BIT));
-    }
-
-    /** Is advertising directed.
-     *
-     * @return True if directed.
-     */
-    bool directed_advertising() const
-    {
-        return static_cast<bool>(value & (1 << DIRECTED_ADVERTISING_BIT));
-    }
-
-    /** Is this a scan response.
-     *
-     * @return True if scan response.
-     */
-    bool scan_response() const
-    {
-        return static_cast<bool>(value & (1 << SCAN_RESPONSE_BIT));
-    }
-
-    /** Is this legacy advertising.
-     *
-     * @return True if legacy.
-     */
-    bool legacy_advertising() const
-    {
-        return static_cast<bool>(value & (1 << LEGACY_PDU_BIT));
-    }
-
-    /** Payload completeness status.
-     *
-     * @return @see advertising_data_status_t for details.
-     */
-    advertising_data_status_t data_status() const
-    {
-        return static_cast<advertising_data_status_t::type>(
-            (value >> DATA_STATUS_INDEX) & DATA_STATUS_MASK
-        );
-    }
-
-    /** Is payload complete.
-     *
-     * @return True if payload is coplete.
-     */
-    bool complete() const
-    {
-        return data_status() == advertising_data_status_t::COMPLETE;
-    }
-
-    /** Is there more data coming.
-     *
-     * @return True if more data coming.
-     */
-    bool more_data_to_come() const
-    {
-        return data_status() == advertising_data_status_t::INCOMPLETE_MORE_DATA;
-    }
-
-    /** Is the payload truncated.
-     *
-     * @return True if no more data coming.
-     */
-    bool truncated() const
-    {
-        return data_status() == advertising_data_status_t::INCOMPLETE_DATA_TRUNCATED;
-    }
-
-private:
-    uint8_t value;
-};
-
-/**
- * Identify an advertising SID. Range: [0x00, 0x0F]
- */
-typedef uint8_t advertising_sid_t;
-
-/** Received signal strength. Range <-127, 20>.
- *  @note Special value 127 means RSSI is not available. */
-typedef int8_t rssi_t;
-
-/**
- * Describe the advertising power.
- *
- * Values between -127 and +126 are considered power values in dBm while
- * the special value 127 can be used as a wildcard to indicate that the host
- * has no preference or if the power information is not available.
- */
-typedef int8_t advertising_power_t;
-
-/**
- * Advertising policy filter modes.
- *
- * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2.
- */
-struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8_t> {
-    /// enumeration of advertising_filter_policy_t values
-    enum type {
-        /**
-         * Process connection and scan requests from all devices. The whitelist is
-         * not used.
-         */
-        NO_FILTER = 0x00,
-
-        /**
-         * Process connection requests from all devices but filter out scan requests
-         * of devices that are not in the whitelist.
-         */
-        FILTER_SCAN_REQUESTS = 0x01,
-
-        /**
-         * Process scan requests from all devices but filter out connection requests
-         * of devices that are not in the whitelist.
-         */
-        FILTER_CONNECTION_REQUEST = 0x02,
-
-        /**
-         * Filter out scan or connection requests of devices that are not in the
-         * whitelist.
-         */
-        FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
-    };
-
-    /**
-     * Construct a advertising_filter_policy_t.
-     * @param value The value of the advertising_filter_policy_t created.
-     */
-    advertising_filter_policy_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-/**
- * Scanning policy filter mode.
- *
- * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
- */
-struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
-    /// enumeration of scanning_filter_policy_t values
-    enum type {
-        /**
-        * Accept all advertising packets except directed advertising packets not
-        * addressed to this device.
-        */
-        NO_FILTER = 0x00,
-
-        /**
-        * Accept only advertising packets from devices in the whitelist except
-        * directed advertising packets not addressed to this device.
-        */
-        FILTER_ADVERTISING = 0x01,
-
-        /**
-         * Accept all advertising packets except directed advertising packets
-         * where the initiator's identity address does not address this device.
-         *
-         * @note Directed advertising packets where the initiator's address is a
-         * resolvable private address that cannot be resolved are also accepted.
-         */
-        NO_FILTER_INCLUDE_UNRESOLVABLE_DIRECTED = 2,
-
-        /**
-         * Accept all advertising packets except:
-         * - Advertising packets where the advertiser's
-         * identity address is not in the whitelist.
-         * - Directed advertising packets where the initiator's identity address
-         * does not address this device.
-         *
-         * @note Directed advertising packets where the initiator's address is a
-         * resolvable private address that cannot be resolved are also accepted.
-         */
-        FILTER_ADVERTISING_INCLUDE_UNRESOLVABLE_DIRECTED = 3
-    };
-
-    /**
-     * Construct a new instance of scanning_filter_policy_t.
-     *
-     * @param value The value of the scanning_filter_policy_t created.
-     */
-    scanning_filter_policy_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-/**
- * Filter policy that you can use during connection initiation.
- */
-struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t> {
-    /// enumeration of initiator_filter_policy_t values.
-    enum type {
-        /**
-        * The whitelist is not used to determine which advertiser to connect to.
-        */
-        NO_FILTER,
-
-        /**
-        * The whitelist is used to determine which advertiser to connect to.
-        */
-        USE_WHITE_LIST
-    };
-
-    /**
-     * Construct a initiator_filter_policy_t.
-     * @param value The value of the initiator_filter_policy_t.
-     */
-    initiator_filter_policy_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-/**
- * Scanning policy filter mode.
- *
- * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
- */
-struct duplicates_filter_t : SafeEnum<duplicates_filter_t, uint8_t> {
-    /// enumeration of duplicates_filter_t values
-    enum type {
-        /**
-         * Disable duplicate filtering.
-         */
-        DISABLE,
-
-        /**
-         * Enable duplicate filtering.
-         */
-        ENABLE,
-
-        /**
-         * Enable duplicate filtering, and reset the cache periodically.
-         */
-        PERIODIC_RESET
-    };
-
-    /**
-     * Construct a new duplicates_filter_t value.
-     * @param value The value of the duplicates_filter_t created.
-     */
-    duplicates_filter_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-/**
- * Type used to model the own address used during the following GAP operations:
- * advertising, scanning and initiating
- */
-struct own_address_type_t : SafeEnum<own_address_type_t, uint8_t> {
-    /// enumeration of own_address_type_t values.
-    enum type {
-        /**
-         * Use the public device address.
-         */
-        PUBLIC = 0x00,
-
-        /**
-         * Use the random device address.
-         */
-        RANDOM = 0x01,
-
-        /**
-         * Generated resolvable private address based on the local IRK from the
-         * resolving list. Use the public address if no entry match in the resolving
-         * list.
-         */
-        RESOLVABLE_PRIVATE_ADDRESS_PUBLIC_FALLBACK = 0x02,
-
-        /**
-         * Generated resolvable private address based on the local IRK from the
-         * resolving list. Use the random address if no entry match in the resolving
-         * list.
-         */
-        RESOLVABLE_PRIVATE_ADDRESS_RANDOM_FALLBACK = 0x03,
-    };
-
-    /**
-     * Construct a new instance of own_address_type_t.
-     * @param value The value of the own_address_type_t created.
-     */
-    own_address_type_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-/**
- * Type of an address to connect to.
- *
- * It is used to connect to a device directly with directed advertising.
- */
-struct target_peer_address_type_t : SafeEnum<target_peer_address_type_t, uint8_t> {
-    /// enumeration of target_peer_address_type_t values.
-    enum type {
-        PUBLIC = 0x00, /**< Public Device Address or Public Identity Address. */
-        RANDOM = 0x01, /**< Random Device Address or Random (static) Identity Address. */
-    };
-
-    /**
-     * Create a new target_peer_address_type_t.
-     * @param value The value of the target_peer_address_type_t created.
-     */
-    target_peer_address_type_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-/**
- * Accuracy of the master clock.
- */
-struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t> {
-    /// enumeration of clock_accuracy_t values.
-    enum type {
-        /**
-         * 500 PPM
-         */
-        PPM_500 = 0x00,
-
-        /**
-         * 250 PPM
-         */
-        PPM_250 = 0x01,
-
-        /**
-         * 150 PPM
-         */
-        PPM_150 = 0x02,
-
-        /**
-         * 100 PPM
-         */
-        PPM_100 = 0x03,
-
-        /**
-         * 75 PPM
-         */
-        PPM_75 = 0x04,
-
-        /**
-         * 50 PPM
-         */
-        PPM_50 = 0x05,
-
-        /**
-         * 30 PPM
-         */
-        PPM_30 = 0x06,
-
-        /**
-         * 20 PPM
-         */
-        PPM_20 = 0x07
-    };
-
-    /** Get clock accuracy.
-     *
-     * @return Parts per million as a number.
-     */
-    uint16_t get_ppm()
-    {
-        switch (value()) {
-            case PPM_500:
-                return 500;
-            case PPM_250:
-                return 250;
-            case PPM_150:
-                return 150;
-            case PPM_100:
-                return 100;
-            case PPM_75:
-                return 75;
-            case PPM_50:
-                return 50;
-            case PPM_30:
-                return 30;
-            case PPM_20:
-                return 20;
-            default:
-                return 0;
-        }
-    }
-
-    /**
-     * Construct a new clock_accuracy_t value.
-     * @param value The value of the clock_accuracy_t created.
-     */
-    clock_accuracy_t(type value) : SafeEnum(value)
-    {
-    }
-
-#if !defined(DOXYGEN_ONLY)
-
-    /**
-     * Construct a new clock_accuracy_t value from a raw value.
-     * @param raw_value The value of the clock accuracy.
-     */
-    explicit clock_accuracy_t(uint8_t raw_value) : SafeEnum(raw_value)
-    {
-    }
-
-#endif
-};
-
-/**
- * Enumeration of GAP roles.
- *
- * @note The BLE API does not express the broadcaster and scanner roles.
- *
- * @attention A device can fulfill different roles concurrently.
- */
-struct connection_role_t : SafeEnum<connection_role_t, uint8_t> {
-    /** struct scoped enum wrapped by the class */
-    enum type {
-        /**
-         * Central Role.
-         *
-         * The device can scan and initiate connection to peripherals. It
-         * acts as the master when a connection is established.
-         *
-         * @note A central is a scanner.
-         */
-        CENTRAL = 0x00,
-
-        /**
-         * Peripheral Role.
-         *
-         * The device can advertise, and you can connect it by a central. It
-         * acts as a slave when connected.
-         *
-         * @note A peripheral is a broadcaster.
-         */
-        PERIPHERAL = 0x01
-    };
-
-    /**
-     * Construct a new instance of role_t.
-     *
-     * @param value The value of the role_t created.
-     */
-    connection_role_t(type value) : SafeEnum(value)
-    {
-    }
-
-#if !defined(DOXYGEN_ONLY)
-
-    /**
-     * Explicit constructor from a raw value.
-     * @param raw_value The role.
-     */
-    explicit connection_role_t(uint8_t raw_value) : SafeEnum(raw_value)
-    {
-    }
-
-#endif
-};
-
-/**
- * Enumeration of disconnection reasons that should be transmited to the peer.
- */
-struct local_disconnection_reason_t : SafeEnum<local_disconnection_reason_t, uint8_t> {
-    /// enumeration of local_disconnection_reason_t values.
-    enum type {
-        /**
-         * GAP or GATT failed to authenticate the peer.
-         */
-        AUTHENTICATION_FAILURE = 0x05,
-
-        /**
-         * Connection terminated by the user.
-         */
-        USER_TERMINATION = 0x13,
-
-        /**
-         * Connection termination due to low resources.
-         */
-        LOW_RESOURCES = 0x14,
-
-        /**
-         * Connection termination due to power off.
-         */
-        POWER_OFF = 0x15,
-
-        /**
-         * Remote feature not supported.
-         */
-        UNSUPPORTED_REMOTE_FEATURE = 0x1A,
-
-        /**
-         * Not possible to pai with a unit key.
-         */
-        PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED = 0x29,
-
-        /**
-         * Connection parameters were unacceptable.
-         */
-        UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
-    };
-
-    /**
-     * Construct a new instance of disconnection_reason_t.
-     *
-     * @param value The value of the local_disconnection_reason_t created.
-     */
-    local_disconnection_reason_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-
-/**
- * Enumeration of disconnection reasons received in a disconnection event.
- */
-struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
-    /// enumeration of disconnection_reason_t values.
-    enum type {
-        /**
-         * GAP or GATT failed to authenticate the peer.
-         */
-        AUTHENTICATION_FAILURE = 0x05,
-
-        /**
-         * The connection timed out.
-         */
-        CONNECTION_TIMEOUT = 0x08,
-
-        /**
-         * Connection terminated by the user.
-         */
-        REMOTE_USER_TERMINATED_CONNECTION = 0x13,
-
-        /**
-         * Remote device terminated connection due to low resources.
-         */
-        REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14,
-
-        /**
-         * Remote device terminated connection due to power off.
-         */
-        REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15,
-
-        /**
-         * Indicate that the local user or the internal
-         * Bluetooth subsystem terminated the connection.
-         */
-        LOCAL_HOST_TERMINATED_CONNECTION = 0x16,
-
-        /**
-         * Connection parameters were unacceptable.
-         */
-        UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
-    };
-
-    /**
-     * Construct a new instance of disconnection_reason_t.
-     *
-     * @param value The value of the disconnection_reason_t created.
-     */
-    disconnection_reason_t(type value) : SafeEnum(value)
-    {
-    }
-};
-
-/**
- * Privacy Configuration of the peripheral role.
- *
- * @note This configuration also applies to the broadcaster role configuration.
- */
-struct peripheral_privacy_configuration_t {
-    /**
-     * Indicates if nonresolvable random address should be used when the
-     * peripheral advertises nonconnectable packets.
-     *
-     * Resolvable random address continues to be used for connectable packets.
-     */
-    bool use_non_resolvable_random_address;
-
-    /**
-     * Resolution strategy for initiator resolvable addresses when a
-     * connection request is received.
-     */
-    enum resolution_strategy_t {
-        /**
-         * Do not resolve the address of the initiator and accept the
-         * connection request.
-         */
-        DO_NOT_RESOLVE,
-
-        /**
-         * If a bond is present in the secure database and the address
-         * resolution fails, then reject the connection request with the error
-         * code AUTHENTICATION_FAILLURE.
-         */
-        REJECT_NON_RESOLVED_ADDRESS,
-
-        /**
-         * Perform the pairing procedure if the initiator resolvable
-         * address failed the resolution process.
-         */
-        PERFORM_PAIRING_PROCEDURE,
-
-        /**
-         * Perform the authentication procedure if the initiator resolvable
-         * address failed the resolution process.
-         */
-        PERFORM_AUTHENTICATION_PROCEDURE
-    };
-
-    MBED_DEPRECATED_SINCE("mbed-os-5.11", "Use resolution_strategy_t instead.")
-    typedef resolution_strategy_t ResolutionStrategy;
-
-    /**
-     * Connection strategy to use when a connection request contains a
-     * private resolvable address.
-     */
-    resolution_strategy_t resolution_strategy;
-};
-
-/**
- * Privacy configuration of the central role.
- *
- * @note This configuration is also used when the local device operates as
- * an observer.
- */
-struct central_privay_configuration_t {
-    /**
-     * Indicates if nonresolvable random address should be used when the
-     * central or observer sends scan request packets.
-     *
-     * Resolvable random address continues to be used for connection requests.
-     */
-    bool use_non_resolvable_random_address;
-
-
-    /**
-     * Resolution strategy of resolvable addresses received in advertising
-     * packets.
-     */
-    enum resolution_strategy_t {
-        /**
-         * Do not resolve the address received in advertising packets.
-         */
-        DO_NOT_RESOLVE,
-
-        /**
-         * Resolve the resolvable addresses in the advertising packet and
-         * forward advertising packet to the application independently of
-         * the address resolution procedure result.
-         */
-        RESOLVE_AND_FORWARD,
-
-        /**
-         * Filter out packets containing a resolvable address that cannot be resolved
-         * by this device.
-         *
-         * @note Filtering is applied if the local device contains at least
-         * one bond.
-         */
-        RESOLVE_AND_FILTER
-    };
-
-    MBED_DEPRECATED_SINCE("mbed-os-5.11", "Use resolution_strategy_t instead.")
-    typedef resolution_strategy_t ResolutionStrategy;
-
-    /**
-     * Resolution strategy applied to advertising packets received by the
-     * local device.
-     */
-    resolution_strategy_t resolution_strategy;
-};
-
-
-/**
- * @}
- * @}
- */
-
-} // namespace ble
-
-#endif //BLE_GAP_TYPES_H
--- a/source/WiFiManager.cpp	Sat May 11 11:55:29 2019 +0000
+++ b/source/WiFiManager.cpp	Sat May 18 10:50:49 2019 +0000
@@ -39,6 +39,7 @@
     chunkNum = 0;
     socket = NULL;
     https_connection_active = false;
+    use_full_hostname       = false;
     wifiBusy = 0;
     wifiWatchdogTimer.start();
     watchdogCnt = 0;
@@ -510,7 +511,7 @@
 #endif
     char * serverAddress = new char[100];
     char *p = strstr(internet_config.url, "//");
-    if(p != NULL)
+    if(p != NULL && use_full_hostname == false)
     {
         strcpy(serverAddress,p+2);
     }
@@ -758,15 +759,8 @@
     return error;
 }
 
-
-void WiFiManager::gethostbyname_callback(nsapi_error_t res, SocketAddress *addr)
+void WiFiManager::processGetHostByNameResult(nsapi_error_t result, SocketAddress *address)
 {
-    nsapi_error_t result = res;
-    SocketAddress *address = new SocketAddress;
-    address = addr;
-#ifdef DNANUDGE_DEBUG
-    callback_semaphore.release();
-#endif
     dbg_printf(LOG, "gethostbyname_callback called... result = %d \r\n", result);
     print_memory_info();
     responseBytes = new uint8_t[HOSTNAME_RESPONSE_LEN]; //malloc(HOSTNAME_RESPONSE_LEN);
@@ -795,8 +789,7 @@
         responseBytes[i++] = 0;
         responseBytes[i]   = 0;
         printBufferInHex(responseBytes, HOSTNAME_RESPONSE_LEN);
-        _event_queue.call_in(10, this, &WiFiManager::sendATresponseBytes, 
-                                    CONNECT_EVENT, HOSTNAME_RESPONSE_LEN);
+        sendATresponseBytes(CONNECT_EVENT, HOSTNAME_RESPONSE_LEN);
     }
     else
     {
@@ -810,10 +803,24 @@
             sprintf(responseString, "\r\nHOSTNAME TRANSLATION FAILURE : error code = %d \r\n", result);
             sendATresponseString(AT_EVENT);
         }
+        use_full_hostname = not use_full_hostname;
    }
     wifiBusy = 0;
     backgroundTaskCompleted = true;
+    
+}
 
+void WiFiManager::gethostbyname_callback(nsapi_error_t res, SocketAddress *addr)
+{
+    nsapi_error_t result = res;
+    SocketAddress *address = new SocketAddress;
+    address = addr;
+    _event_queue.call(this, &WiFiManager::processGetHostByNameResult, 
+                                    result, address);
+    
+#ifdef DNANUDGE_DEBUG
+    callback_semaphore.release();
+#endif
 }   
 
 void WiFiManager::sendSocketConnectionEvent()
--- a/source/WiFiManager.h	Sat May 11 11:55:29 2019 +0000
+++ b/source/WiFiManager.h	Sat May 18 10:50:49 2019 +0000
@@ -80,6 +80,7 @@
     Ticker watchDogTick;
     uint32_t watchdogCnt;
     http_result_t http_result;
+    bool     use_full_hostname;
 #ifdef DNANUDGE_DEBUG
     rtos::Semaphore callback_semaphore;
 #endif    
@@ -129,6 +130,7 @@
     void                  sendDebugMessage();
     void                  callWifiWatchDog();
     void                  callWifiWatchDogIsr();
+    void                  processGetHostByNameResult(nsapi_error_t result, SocketAddress *addr);
 
 
 
--- a/source/debug.cpp	Sat May 11 11:55:29 2019 +0000
+++ b/source/debug.cpp	Sat May 18 10:50:49 2019 +0000
@@ -92,7 +92,7 @@
 * @retval       None 
 */
 //#define DEBUG_ENABLED
-void initialise_debug(void)
+void initialise_debug(uint8_t debug_level=NONE)
 {   
   memset(g_dbg_buffer, 0, sizeof(g_dbg_buffer));
   
@@ -102,7 +102,7 @@
 #ifdef DEBUG_ENABLED  
   current_debug_level = (LOG | ERR | TXT | DBG); //NONE; // 
 #else
-  current_debug_level = NONE; // 
+  current_debug_level = debug_level; // 
 #endif
   dbg_data_mode = DATA_ASCII;
   dbg_rx_pos = 0;
--- a/source/debug.h	Sat May 11 11:55:29 2019 +0000
+++ b/source/debug.h	Sat May 18 10:50:49 2019 +0000
@@ -68,7 +68,7 @@
 
 //--- Global function prototypes ----------------------------------------//
 
-void initialise_debug(void);
+void initialise_debug(uint8_t debug_level);
 
 void set_debug_level(uint8_t debug_level);
 
--- a/source/main-https.cpp	Sat May 11 11:55:29 2019 +0000
+++ b/source/main-https.cpp	Sat May 18 10:50:49 2019 +0000
@@ -47,6 +47,7 @@
 char buffer[BUFFER_LEN];
 static EventQueue eventQueue_atcmd(/* event count */ 32 * EVENTS_EVENT_SIZE);
 static EventQueue eventQueue_wifi(/* event count */ 32 * EVENTS_EVENT_SIZE);
+static EventQueue eventQueue_ble(/* event count */ 10 * EVENTS_EVENT_SIZE);
 
 /*  Queue and memory pool for AT to Wifi commands */
 static MemoryPool<wifi_cmd_message_t, 16> aT2WiFimPool;
@@ -83,7 +84,7 @@
 Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024, &atcmd_stk[0]);
 #else
 // using global heap
-Thread btle_thread(BTLE_THREAD_PRIORITY, 1024);
+Thread btle_thread(BTLE_THREAD_PRIORITY, 4*1024);
 Thread wifi_thread(WIFI_THREAD_PRIORITY, 4*1024);
 Thread atcmd_thread(ATCMD_THREAD_PRIORITY, 4*1024);
 #endif
@@ -132,8 +133,9 @@
 }
 
 
-void printWaitAbortKeyPress(int numSecs)
+void printWaitAbortKeyPress(int numSecs, const char * printStr=NULL)
 {
+    dbg_printf(LOG, "%s", printStr);
     dbg_printf(LOG, "Waiting for %d seconds... [press key to abort]\n", numSecs);
     char fmtstr[20];
     for(int i=0;i<numSecs;i++){
@@ -142,7 +144,7 @@
         sprintf(fmtstr, "BLE: loop # %d\n", i);
         peripheral->sendBLEUartData(fmtstr);
         wait(0.5);
-        eventQueue_atcmd.dispatch(500);        // Dispatch time - 500msec
+        //eventQueue_atcmd.dispatch(500);        // Dispatch time - 500msec
         if(device->readable()){
             dbg_printf(LOG, "keypress detected aborting....\n");
             device->getc();
@@ -217,7 +219,8 @@
 #define PAUSE_SECONDS_BLE 0
 int main() {
     device = new RawSerial(USBTX, USBRX, 2*DEFAULT_BAUD_RATE);
-    initialise_debug();
+    uint8_t debug_level = (LOG | ERR | TXT | DBG);
+    initialise_debug(debug_level);
 #ifdef MBED_MAJOR_VERSION
     dbg_printf(LOG, "Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
 #endif
@@ -227,7 +230,6 @@
     setupDefaultWiFiConfig();
     setupDefaultBleConfig();
     BLE& _ble = BLE::Instance();
-    events::EventQueue queue(/* event count */ 10 * EVENTS_EVENT_SIZE);
 #if MBED_CONF_APP_FILESYSTEM_SUPPORT
     /* if filesystem creation fails or there is no filesystem the security manager
      * will fallback to storing the security database in memory */
@@ -236,16 +238,18 @@
     }
 #endif
     dbg_printf(LOG, "\r\n PERIPHERAL \r\n\r\n");
-    peripheral = new SMDevicePeripheral(_ble, queue, peer_address, ble_config);
+    peripheral = new SMDevicePeripheral(_ble, eventQueue_ble, peer_address, ble_config);
 
     peripheral->run();
-    btle_thread.start(callback(&queue, &EventQueue::dispatch_forever));
-
+    btle_thread.start(callback(&eventQueue_ble, &EventQueue::dispatch_forever));
+    //btle_thread.start(callback(peripheral, &SMDevicePeripheral::run));
+    printWaitAbortKeyPress(120, "Wait after BLE dispatch\r\n");
     int start = Kernel::get_ms_count();
     network = WiFiInterface::get_default_instance();
     if (!network) {
         dbg_printf(LOG, "ERROR: No WiFiInterface found.\n");
     }
+    printWaitAbortKeyPress(120, "Wait after WiFi instantiation\r\n");
     wiFiManager = new WiFiManager(wifi_config, network, 
                                   eventQueue_wifi,
                                   &aT2WiFimPool, &aT2WiFiCmdQueue,
@@ -258,6 +262,8 @@
     dbg_printf(LOG, "\r\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \r\n");
     wifi_thread.start(callback(wiFiManager, &WiFiManager::runMain));
     dbg_printf(LOG, "\r\n after starting wifi thread \r\n");
+    printWaitAbortKeyPress(120, "Wait after WiFi Manager dispatch\r\n");
+    initialise_debug(NONE);
     // dispatch wifi event queue on event thread
     wifi_evt_thread.start(callback(&eventQueue_wifi, &EventQueue::dispatch_forever));
     // dispatch atcmd event queue on event thread