Hi
With SDK 4.x.x I had a workflow for 3 webrequests in one. Also solved by this forum. Now I try the same in 6.4.X. In the simulator, I can see the 3 request were succesfully done. But the println says error.
Any Ideas?:
My Code:
using Toybox.Background as Bg;
using Toybox.Communications as Comm;
using Toybox.System as Sys;
using Toybox.Application.Storage as Ast;
using Toybox.Time as T;
using Toybox.Lang;
(:background)
class MyServiceDelegate extends Sys.ServiceDelegate {
function initialize(){ServiceDelegate.initialize();}
var res1=null,Code1=null,res2=null,Code2=null,res3=null,Code3=null;
var lat=Ast.getValue("V2lastLat");
var lon=Ast.getValue("V2lastLong");
var appid1=Ast.getValue("V2appid1");
var dndOffline=Ast.getValue("V2dndOffline");
var dndSys=Sys.getDeviceSettings().doNotDisturb;
var owmCount=Ast.getValue("V2owmCount");
var tempUnits=Ast.getValue("V2tempUnits");
var langi=Ast.getValue("V2langi");
function onTemporalEvent() {
if(dndOffline==true&&dndSys==true){
}else{
if(Sys.getDeviceSettings().phoneConnected==true){
if(owmCount==0){ //Nur noch zwei Abfragen machen. 1. Current+alerts,dailysum,geolocation
var url1="">api.openweathermap.org/.../onecall";
var param1={"lat"=>lat,"lon"=>lon,"exclude"=>"minutely,daily,hourly,alerts","appid"=>appid1,"units"=>tempUnits,"lang"=>langi};
var opt1={};
var met1=method(:responseCallback1);
Comm.makeWebRequest(url1,param1,opt1,met1);
}else{
//
}
}
}
}
function responseCallback1(responseCode,data) {
if(owmCount==0){
var url2="api.openweathermap.org/data/3.0/onecall/day_summary";
var param2={"lat"=>lat,"lon"=>lon,"date"=>"2023-12-01","appid"=>appid1,"units"=>tempUnits};
var opt2={};
var met2=method(:responseCallback2);
Comm.makeWebRequest(url2,param2,opt2,met2);
res1=data;
data=null;
Code1=responseCode;
Sys.println("Res1 mit owmCount=0: "+res1);
Sys.println("Code1 mit owmCount=0: "+Code1);
}else{
//
}
}
function responseCallback2(responseCode,data){
var url3="api.openweathermap.org/geo/1.0/reverse";
var param3={"lat"=>lat,"lon"=>lon,"limit"=>"1","appid"=>appid1};
var opt3={};
var met3=method(:responseCallback3);
Comm.makeWebRequest(url3,param3,opt3,met3);
res2=data;
data=null;
Code2=responseCode;
Sys.println("Res2 mit owmCount=0: "+res2);
Sys.println("Code2 mit owmCount=0: "+Code2);
}
function responseCallback3(responseCode,data){
res3=data;
data=null;
Code3=responseCode;
Sys.println("Res3 mit owmCount=0: "+res3);
Sys.println("Code3 mit owmCount=0: "+Code3);
Background.exit([res1,Code1,res2,Code2,res3,Code3]);
}
}
From the console:
Background: Res1 mit owmCount=0: {current=>{feels_like=>-0.970000, clouds=>100, uvi=>0, sunrise=>1701436722, wind_gust=>12.350000, dew_point=>3.450000, humidity=>95, sunset=>1701471483, wind_deg=>30, pressure=>1004, dt=>1701418139, rain=>{1h=>0.560000}, temp=>4.180000, visibility=>9656, weather=>[{main=>Rain, description=>light rain, icon=>10n, id=>500}, {main=>Mist, description=>mist, icon=>50n, id=>701}], wind_speed=>8.230000}, timezone=>America/Chicago, lat=>38.855400, timezone_offset=>-21600, lon=>-94.799400}
Background: Code1 mit owmCount=0: 200
Background: Res2 mit owmCount=0: null
Background: Code2 mit owmCount=0: -1001
Background: Res3 mit owmCount=0: null
Background: Code3 mit owmCount=0: -1001
And in the HTTP Traffic Log from the sim: 3x times code 200 and 3 times the correct contents for my ApiGet...
Thanks for any help