Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "tinyxml2.h";
- String response = "";
- void setup() {
- Serial.begin(9600);
- Particle.subscribe("hook-response/get_weather", gotWeatherData, MY_DEVICES);
- for(int i=0;i<3;i++) {
- Serial.println("waiting " + String(3-i) + " seconds before we publish");
- delay(1000);
- }
- }
- void loop() {
- response = "";
- Serial.println("Requesting Weather!");
- Particle.publish("get_weather");
- delay(60000);
- }
- void gotWeatherData(const char *name, const char *data) {
- Serial.println("Consolidating data");
- String str = String(data);
- response = String(response + data);
- // If you feel you got it all, start parsing
- if( str.indexOf("</current>") != -1 ) {
- Serial.println(response);
- parseResponse();
- }
- }
- String parseResponse() {
- Serial.println("Parsing data");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement