Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
Log("Found: " & Name & ", " & Id & ", RSSI = " & RSSI & ", " & AdvertisingData)
If Name = "Adafruit Bluefruit LE" Then
Log ("Device Found")
ConnectedName = Name
manager.StopScan
manager.Connect2(Id, False) 'disabling auto connect can make the connection quicker
'Sleep(1000)
manager.SetNotify("6e400001-b5a3-f393-e0a9-e50e24dcca9e", "6e400003-b5a3-f393-e0a9-e50e24dcca9e", True)
manager.SetNotify("6e400001-b5a3-f393-e0a9-e50e24dcca9e", "6e400002-b5a3-f393-e0a9-e50e24dcca9e", True)
End If
End Sub