         let deviceUUIDString = NSString(string: deviceId.uuidString)
         print("deviceUUIDString = \(deviceUUIDString)")
         let userDefaults = UserDefaults.standard
-        print("userDefaults = \(userDefaults)")
         userDefaults.set(deviceUUIDString, forKey: "MyDevice")
         userDefaults.synchronize()
         peripheral.delegate = self;
-        let serviceUUID = CBUUID(string: "180D")
-        let serviceUUIDs = [serviceUUID]
+        let serviceUUIDs = [heartRateServiceUUID]
         peripheral.discoverServices(serviceUUIDs)
     }
     

        print("thread = \(Thread.current)")
//        print("characteristic = \(characteristic) value = \(characteristic.value) UUID = \(characteristic.UUID) isNotifying = \(characteristic.isNotifying) isBroadcasted = \(characteristic.isBroadcasted)")
        // Updated heart rate measurment
        if characteristic.uuid.isEqual(CBUUID(string: "2A37")) {
            print("Updated heart rate measurement characteristic")
            if let data = characteristic.value {
                updateWithHRMData(data)
            }
        } else
        // read the body sensor location
        if (characteristic.uuid.isEqual(CBUUID(string: "2A38"))) {
            print("Updated body sensor location characterstic")
            if let data = characteristic.value {
                if let location = data.first {

    func centralManager(_ central: CBCentralManager!, didRetrievePeripherals peripherals: [AnyObject]!) {
        for peripheral in peripherals as! [CBPeripheral] {
            print("\(#function): peripheral = \(peripheral)")
            if !(heartRateMonitor != nil) {
                connectToPeripheral(peripheral)
                break;
            }
