コード例 #1
0
ファイル: ModBusService.cs プロジェクト: wenfeifei/IoTSharp
        public Task StartAsync(CancellationToken cancellationToken)
        {
            return(Task.Run(async() =>
            {
                await _mqtt.ConnectAsync(_options.BrokerUri, _options.AccessToken);



                do
                {
                    if (!HaveModBusConfig)
                    {
                        await _mqtt.RequestAttributes("me", true, "ModBusConfig");
                    }
                    await _mqtt.UploadAttributeAsync(new { ModBusServiceStatus = "OK" });
                    Thread.Sleep(TimeSpan.FromSeconds(60));
                } while (!cancellationToken.IsCancellationRequested);
            }));
        }