Hi Guys,
Any help would be greatly appreciated!
I'm trying to further this app now. I want to take my 3 separate publishes roll them up into a single event, but I don't understand what I need to do to parse the combined data with 3 variables in it.
Below is my publish routine, and I've been using the three publishes at the top successfully, and my app displays them correctly. I've added a 4th, which is the one I want to use in the future. The data arrives in the IOS device fine, in the Xcode manual it look like this:
Publish routine:
void publishBattSpeedAndTime() {
Particle.publish("SOC", String(charge), PRIVATE);
delay(1000);
Particle.publish("Speed", String(speed), PRIVATE);
delay(1000);
Particle.publish("Time", String(elapsed), PRIVATE);
delay(1000);
Particle.publish("Data", "{ \"A\": \"" + String(charge) + "\"," +
"\"B\": \"" + String(speed) + "\"," +
"\"C\": \"" + String(elapsed) + "\" }", 60, PRIVATE);
}
This is what the data from my new publish statement looks like in the Xcode log:
Got Event Data with data: { "A": "8.089844","B": "12","C": "28" }
Now how do I parse this { "A": "8.089844","B": "12","C": "28" } into three different variables that I can update the labels with?
Here is an Xcode handler from the previous publish statements:
ParticleEventHandler handlerSOC = ^(ParticleEvent *event, NSError *error) {
if (!error)
{
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Got Event %@ with data: %@",event.event,event.data);
self.charge.text = event.data;
});
}
else
{
NSLog(@"Time Error occured: %@",error.localizedDescription);
}
};
Thanks!
J