Пример #1
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            //used to hold process after this thread has moved past the publisher
            var deferral = taskInstance.GetDeferral();

            //todo: replace with confi setting builders: port type and ID data
            Logger.DebugWrite("Trying to connect...");
            var btp      = new ObdBluetoothPort("Port");
            var provider = new ObdDevice(btp);

            var debug = new DebugSubscriber();
            var iot   = new IotSubscriber("<YOUR IOT HUB>", "<IOT HUB DEVICE NAME>", "<HUB DEVICE KEY>");

            provider.Subscribe(debug);
            provider.Subscribe(iot);
            provider.Startup();
        }
Пример #2
0
        public async void Startup()
        {
            //todo: replace with confi setting builders: port type and ID data
            Logger.DebugWrite("Trying to connect...");
            var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));

            var device = devices[0].Id;
            var btd    = await BluetoothDevice.FromIdAsync(device);

            await btd.RequestAccessAsync();

            var btp      = new ObdBluetoothPort("Port");
            var provider = new ObdDevice(btp);
            await provider.Connect();

            var debug = new DebugSubscriber();
            var iot   = new IotSubscriber("<YOUR IOT HUB NAME>", "<YOUR DEVICE>", "<YOUR DEVICE KEY>");

            provider.Subscribe(debug);
            provider.Subscribe(iot);
            provider.Startup();
        }