Hello,
I had this issue before, but now with the new transition of SparkDevice to ParticleDevice, I am facing the same problem again. DigitalWrite doesn’t seem to work even following the documentation.
Documentation >>> iOS SDK | Reference Documentation | Particle
This is my code:
ParticleCloud.sharedInstance().login(withUser: userName, password: password) { (error:Error?) -> Void in
if let _ = error {
print("Wrong credentials or no internet connectivity, please try again")
}
else {
print("Logged in")
var myPhoton : ParticleDevice?
ParticleCloud.sharedInstance().getDevices { (devices:[ParticleDevice]?, error:Error?) -> Void in
if let _ = error {
print("Check your internet connectivity")
}
else {
if let d = devices {
for device in d {
myPhoton = device
print(myPhoton!)
let funcArgs = ["D7,HIGH"] as [Any]
_ = myPhoton?.callFunction("digitalWrite", withArguments: funcArgs) { (resultCode : NSNumber?, error : Error?) -> Void in
if (error == nil) {
print("LED on D7 successfully turned on")
} else {
print("Error! \(String(describing: error))")
}
}
}
}
}
}
}
}
What am I doing wrong?
PS: Is there a github of an example app for swift. The current example file downloaded has only the particle setup code.
Thanks.