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

Dependencies:   mbed-http

Branch:
PassingRegression
Revision:
113:888e262ff0a9
Parent:
108:3c8fb2c6e7bf
Child:
116:2296cf274661
--- 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;