From 8c2e0d6600927c1c69075ced2f22e54570c4d11f Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Wed, 20 Jan 2021 14:51:36 +0000 Subject: [PATCH] Bugfix: fix the ATIS API references --- Nasal/FMGC/mcdu-messages.nas | 2 +- Nasal/Systems/Comm/Notification.nas | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Nasal/FMGC/mcdu-messages.nas b/Nasal/FMGC/mcdu-messages.nas index 3c036d2c..b3274ff5 100644 --- a/Nasal/FMGC/mcdu-messages.nas +++ b/Nasal/FMGC/mcdu-messages.nas @@ -180,7 +180,7 @@ var MessageController = { TypeIMessage.new("USING COST INDEX N", 1),TypeIMessage.new("WAIT FOR SYSTEM RESPONSE"),TypeIMessage.new("RWY/LS MISMATCH"), TypeIMessage.new("VHF3 VOICE MSG NOT GEN"),TypeIMessage.new("NO COMM MSG NOT GEN"),TypeIMessage.new("WX UPLINK"), TypeIMessage.new("SIMBRIEF DOWNLOAD FAILED"),TypeIMessage.new("MISSING USERNAME"),TypeIMessage.new("AOC ACT F-PLN UPLINK"), - TypeIMessage.new("NO ANSWER TO REQUEST"),TypeIMessage.new("NO D-ATIS AVAILABLE"),TypeIMessage.new("BAD SERVER RESPONSE"), + TypeIMessage.new("NO ANSWER TO REQUEST"),TypeIMessage.new("NO D-ATIS AVAILABLE"),TypeIMessage.new("NO METAR AVAILABLE"),TypeIMessage.new("BAD SERVER RESPONSE"), TypeIMessage.new("WIND DATA UPLINK"),TypeIMessage.new("CHECK ALT WIND"),TypeIMessage.new("INVALID WIND UPLINK"),TypeIMessage.new("WIND UPLINK EXISTS"), #p.533 TypeIMessage.new("FM DATALINK UNAVAIL"),TypeIMessage.new("NOT XMITTED TO ACARS"), #p.559 TypeIMessage.new("PRINTER NOT AVAILABLE"), diff --git a/Nasal/Systems/Comm/Notification.nas b/Nasal/Systems/Comm/Notification.nas index 408f2be1..5d01f494 100644 --- a/Nasal/Systems/Comm/Notification.nas +++ b/Nasal/Systems/Comm/Notification.nas @@ -168,12 +168,12 @@ var AOC = { var serverString = ""; if (me.server.getValue() == "vatsim") { - serverString = "https://api.flybywiresim.com/metar?source=vatsim&icao="; + serverString = "https://api.flybywiresim.com/metar/" ~ airport ~ "?source=vatsim"; } else { - serverString = defaultServer; + serverString = defaultServer ~ airport; } - http.load(serverString ~ airport) + http.load(serverString) .fail(func(r) me.downloadFail(i, r)) .done(func(r) { var errs = []; @@ -212,7 +212,23 @@ var AOC = { }, processMETAR: func(r, i) { var raw = r.response; + if (find('"statusCode":404',raw) != -1) { + me.received = 0; + me.sent = 0; + mcdu.mcdu_message(i, "NO METAR AVAILABLE"); + return; + } + if (me.server.getValue() == "vatsim") { + if (find("metar", raw) != -1) { + raw = split('"metar":"', raw)[1]; + raw = split('","source":"Vatsim"}', raw)[0]; + } else { + me.received = 0; + me.sent = 0; + mcdu.mcdu_message(i, "BAD SERVER RESPONSE"); + return; + } me.lastMETAR = raw; } else if (find("", raw) != -1) { raw = split("", raw)[1]; @@ -330,7 +346,7 @@ var ATIS = { }, processATIS: func(r, i) { var raw = r.response; - if (r.response == "FBW_ERROR: D-ATIS not available at this airport" or find("atis not avail",r.response) != -1 or find('"statusCode":404',r.response) != -1) { + if (raw == "FBW_ERROR: D-ATIS not available at this airport" or find("atis not avail",raw) != -1 or find('"statusCode":404',raw) != -1) { me.received = 0; me.sent = 0; mcdu.mcdu_message(i,"NO D-ATIS AVAILABLE");