Exemplo n.º 1
0
 public ApiController(
     LatestDataProvider latestDataProvider,
     GatewayConfiguration gatewayConfiguration,
     AprsConfig aprsConfig
     )
 {
     _latestDataProvider   = latestDataProvider;
     _gatewayConfiguration = gatewayConfiguration;
     _aprsConfig           = aprsConfig;
 }
Exemplo n.º 2
0
        public Listener() : base(new ClientSettings()
        {
            EndPoint = new DnsEndPoint(
                AprsConfig.GetConfig().Uri,
                AprsConfig.GetConfig().Port),
            Listening             = false,
            Splitter              = "\r\n",
            Timeout               = 1020000, // 17 minutes afaik,
            ReconnectOnDisconnect = true
        })
        {
            // Set the callbacks before starting the client
            ConnectEvent += OnConnect;
            ReceiveEvent += OnReceive;

            Start();
        }
        public void Start()
        {
            if (_Socket != null)
            {
                Stop();
            }

            _Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            var state = new StateObject {
                WorkSocket = _Socket
            };

            _Socket.Connect(AprsConfig.GetConfig().URI, AprsConfig.GetConfig().Port);

            // Begin receiving the data from the remote device.
            _Socket.BeginReceive(state.Buffer, 0, StateObject.BUFFER_SIZE, 0, new AsyncCallback(ReceiveCallback), state);
            _Socket.Send(Encoding.ASCII.GetBytes(string.Format("user {0} pass {1} vers experimenting 0.1 filter {2}\n", AprsConfig.GetConfig().Callsign, AprsConfig.GetConfig().Password, AprsConfig.GetConfig().Filter)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Configures all services & providers that are based on the appsettings.json
        /// </summary>
        /// <param name="services">The systems' IServiceCollection</param>
        private void ConfigureConfigBasedServices(IServiceCollection services)
        {
            var gatewayConfiguration = new GatewayConfiguration();

            Configuration.GetSection("GatewayOptions").Bind(gatewayConfiguration);
            services.AddSingleton(gatewayConfiguration);

            var aprsConfig = new AprsConfig();

            Configuration.GetSection("AprsConfig").Bind(aprsConfig);
            services.AddSingleton(aprsConfig);

            services.AddSingleton(_ =>
            {
                var provider = new AircraftProvider(aprsConfig);
                provider.Initialize().GetAwaiter().GetResult();
                return(provider);
            });
        }
Exemplo n.º 5
0
 public AircraftProvider(AprsConfig aprsConfig)
 {
     _aprsConfig   = aprsConfig;
     _aircraftList = new Dictionary <string, Aircraft>();
 }
Exemplo n.º 6
0
 public StreamProvider(AprsConfig aprsConfig)
 {
     _aprsConfig = aprsConfig;
     Stream      = CreateStream();
 }
Exemplo n.º 7
0
 private void OnConnect()
 {
     Send(
         $"user {AprsConfig.GetConfig().Callsign} pass {AprsConfig.GetConfig().Password} vers experimenting 0.1 filter {AprsConfig.GetConfig().Filter}\n");
 }