title: How to get advertisement and response data from a bluetooth low energy device in swift 4?
body: <p>My IOS application is trying to get advertisement and response data from a blue device without connect to it. The advertisement and response data should all be 31 bytes long (we used 4 bytes of the header too, plus 27 bytes of data), totally 62 bytes. While android version of app can easily get all this data, I fail to get them in swift. I called advertisement in corebluetooth, but only receive 27bytes of response data. I can not find the 4 header bytes of response data nor the 31 bytes of advertisement data.</p>
  
  <pre><code>func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
  ......
  let data2: NSDictionary? = advertisementData[CBAdvertisementDataServiceDataKey] as? NSDictionary
      if data2 != nil {
          let str :Data = (data2!.allValues)[0] as! Data
          bytes = [UInt8](str)
          print("advertisement data: ",bytes)
      }
  }
  </code></pre>