tag:blogger.com,1999:blog-572782606537465705.post7059974568106884120..comments2023-04-16T06:56:46.044-05:00Comments on Clint's Projects: Pebble Watchface: Parsing JSON WeatherUnknownnoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-572782606537465705.post-37236837222203787502015-01-21T09:48:21.856-06:002015-01-21T09:48:21.856-06:00Great to hear it's working!Great to hear it's working!Clinthttps://www.blogger.com/profile/01247275477919177026noreply@blogger.comtag:blogger.com,1999:blog-572782606537465705.post-5493020114922383122015-01-16T18:20:23.401-06:002015-01-16T18:20:23.401-06:00In your getWeather() function, you're calling:...In your getWeather() function, you're calling:<br />navigator.geolocation.getCurrentPosition(<br />locationSuccess,<br />locationSuccess2,<br />locationError,<br />{timeout: 15000, maximumAge: 60000}<br />);<br /><br />The first argument of .getCurrentPosition() is the function it calls if it successfully gets the location. The second argument is the function it calls if it fails to get the location. The third argument is options.<br /><br />But your first argument is: locationSuccess<br />Second argument (the error) is: locationSuccess2<br />Third argument (the options) is: locationError<br /><br />Basically your locationSuccess2 is in locationError's spot. I suggest changing it to:<br />navigator.geolocation.getCurrentPosition(locationSuccess, locationError, {timeout: 15000, maximumAge: 60000});<br /><br />I don't see your locationSuccess() function, but it would then do all the tasks of locationSuccess and locationSuccess2.<br /><br />Or you could rename your existing locationSuccess to getWeatherData1 and your existing locationSuccess2 to getWeatherData2. Then create a new function called locationSuccess that calls both getWeatherData1 and getWeatherData2.<br />Clinthttps://www.blogger.com/profile/01247275477919177026noreply@blogger.comtag:blogger.com,1999:blog-572782606537465705.post-36081852625653536382015-01-15T21:41:21.139-06:002015-01-15T21:41:21.139-06:00Glad it was of help!
I'm thinking your JavaSc...Glad it was of help!<br /><br />I'm thinking your JavaScript code is fine: You have a function that gets the current conditions and sends them off, and you have a function that gets the forecast conditions and sends them off.<br /><br />I bet your problem is on the receiving side in the C code. Are you assuming both the current and forecast conditions are passed in together? Because they're actually going to come in under 2 separate function calls.<br /><br />Take a look at my first Pebble Watchface posting, function:<br />static void inbox_received_callback(DictionaryIterator *iterator, void *context)<br /><br />The current weather conditions are retrieved in the switch:<br />case KEY_TEMPERATURE:<br /> currentTemperature_c = t->value->int32;<br /> break;<br />case KEY_DESCRIPTION:<br /> // Similar to conditions, but far more descriptive.<br /> strncpy(currentConditions, t->value->cstring, 32);<br /> break;<br /><br />But currentTemperature_c and currentConditions aren't declared in that function; they're global variables. They're only modified if the parameters passed into inbox_received_callback include KEY_TEMPERATURE and KEY_DESCRIPTION. Those will only be passed in with the local conditions call.<br /><br />My forecast conditions are only processed if KEY_DAY1_TIME is passed in.<br />At the top of the function I have a local variable day1Date.<br />Inside the switch:<br />case KEY_DAY1_TIME:<br /> // Usually today's date, but in the morning it's yesterday's!<br /> day1Date = t->value->int32;<br /> break;<br /><br />But I only process my forecast variables if:<br /> if (day1Date > 0)<br /> {<br /><br />If it was the current conditions that were passed in, day1Date would equal 0 and that block of code would get skipped.<br /><br />Is that clear? Please feel free to post your inbox_received_callback function, and I'll take a look. That's probably the culprit.Clinthttps://www.blogger.com/profile/01247275477919177026noreply@blogger.com