Example #1
0
        static void Main(string[] args)
        {
            _LastSent = DateTime.Now;

            var utc      = DateTime.UtcNow;
            var fileName = $"{utc.Year}-{utc.Month}-{utc.Day}={utc.Hour}-{utc.Minute}-{utc.Second}.log";

            _streamWriter = File.AppendText(fileName);

            try
            {
                var connectionString = "HostName=iotc-6e7ea251-71bd-4024-a0a8-a8895ea79b7f.azure-devices.net;DeviceId=GeoTracker1;SharedAccessKey=a99ZyFyYPR0tQl7vWK75y4C3YveuQmK118LYEgsYC5c=";

                _deviceClient = DeviceClient.CreateFromConnectionString(connectionString);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception during IoT connection {ex}");
            }

            Console.WriteLine("Read serial port");

            _parser = new NmeaParser();

            _parser.NmeaMessageParsed += NmeaMessageParsed;

            _SerialReader = new SerialReader();

            _SerialReader.NmeaSentenceReceived += NmeaSentenceReceived;

            _SerialReader.Open();

            Console.WriteLine("Initialized...");

            Console.ReadKey();
        }