Last active
December 10, 2021 19:56
-
-
Save cconstab/5572685871d3192ab9c16c4c90ba7d11 to your computer and use it in GitHub Desktop.
Grab my ic7100 ham radio public information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:http/http.dart' as http; | |
import 'dart:convert'; | |
void main() async { | |
PublicHamRadio hamradio = PublicHamRadio(radioName: 'ic7100'); | |
await lookupRadio('ai6bh','ic7100',hamradio); | |
print(hamradio.vfoaFrequency); | |
} | |
Future<PublicHamRadio> lookupRadio( | |
String atsign, String radio, PublicHamRadio hamRadio) async { | |
print('waiting'); | |
print('Atsign:$atsign'); | |
print('Radio:$radio'); | |
String lookup = 'https://wavi.ng/api?atp=public.$radio.ai6bh@$atsign'; | |
print(lookup); | |
http.Response result = await http.get(Uri.parse(lookup)); | |
var radioMap = jsonDecode(result.body); | |
var radioJson = jsonDecode(radioMap[0]['public.$radio.ai6bh']); | |
print(radioJson); | |
hamRadio = PublicHamRadio.fromJson(radioJson); | |
print(hamRadio.vfoaFrequency); | |
return hamRadio; | |
} | |
class PublicHamRadio { | |
String radioName; | |
String radioUuid; | |
String? vfoaFrequency; | |
String? vfoaModulationMode; | |
String? vfoaOperatingMode; | |
String? vfobFrequency; | |
String? vfobModulationMode; | |
String? vfobOperatingMode; | |
String? vfoaFrequencyLast; | |
String? vfoaModulationModeLast; | |
String? vfoaOperatingModeLast; | |
String? vfobFrequencyLast; | |
String? vfobModulationModeLast; | |
String? vfobOperatingModeLast; | |
PublicHamRadio({ | |
required this.radioName, | |
this.radioUuid = '[]', | |
this.vfoaFrequency = '8888888888', | |
this.vfoaModulationMode = 'QRT', | |
this.vfoaOperatingMode = '---', | |
this.vfobFrequency = '0000000000', | |
this.vfobModulationMode = '---', | |
this.vfobOperatingMode = '---', | |
this.vfoaFrequencyLast = '0000000000', | |
this.vfoaModulationModeLast = '---', | |
this.vfoaOperatingModeLast = '---', | |
this.vfobFrequencyLast = '0000000000', | |
this.vfobModulationModeLast = '---', | |
this.vfobOperatingModeLast = '---', | |
}); | |
PublicHamRadio.fromJson(Map<String, dynamic> json) | |
: radioName = json['radioName'], | |
radioUuid = json['radioUuid'], | |
vfoaFrequency = json['vfoaFrequency'], | |
vfoaModulationMode = json['vfoaModulationMode'], | |
vfoaOperatingMode = json['vfoaOperatingMode'], | |
vfobFrequency = json['vfobFrequency'], | |
vfobModulationMode = json['vfobModulationMode'], | |
vfobOperatingMode = json['vfobOperatingMode']; | |
Map<String, dynamic> toJson() => { | |
'radioName': radioName, | |
'radioUuid': radioUuid, | |
'vfoaFrequency': vfoaFrequency, | |
'vfoaModulationMode': vfoaModulationMode, | |
'vfoaOperatingMode': vfoaOperatingMode, | |
'vfobFrequency': vfobFrequency, | |
'vfobModulationMode': vfobModulationMode, | |
'vfobOperatingMode': vfobOperatingMode, | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment