public async Task CarStop(IDialogContext context, LuisResult result) { await IoTHelper.SendAsync("s0"); await context.PostAsync($"Car halted !!"); context.EndConversation("Conversation Ended"); }
public async Task CarSlower(IDialogContext context, LuisResult result) { await IoTHelper.SendAsync("s-20"); await context.PostAsync($"Pressing the brake"); context.EndConversation("Conversation Ended"); }
public async Task CarFaster(IDialogContext context, LuisResult result) { await IoTHelper.SendAsync("s+20"); await context.PostAsync($"Vroooom, the car goes faster"); context.EndConversation("Conversation Ended"); }
public SerialReader(string port, IoTHelper hub) { this.port = port; this.hub = hub; serialPort = new SerialPort(port, 115200, Parity.None, 8, StopBits.One); serialPort.DtrEnable = true; serialPort.DataReceived += SerialPort_DataReceived; serialPort.Open(); }
public async Task CarStart(IDialogContext context, LuisResult result) { await IoTHelper.SendAsync("s50"); await context.PostAsync("3"); await context.PostAsync("2"); await context.PostAsync("1"); await context.PostAsync("GO !!!!!!"); context.EndConversation("Conversation Ended"); }
protected override void OnStart(string[] args) { poisonFileManager = new PoisonFileManager(5); poisonFileManager.PoisonedFileDetected += PoisonedFileDetectedHandler; logHelper = new LogHelper(LogCategory.lastFile, false); ReadOldCsvFiles(); watcher = new FileSystemWatcher(csvFolder, "*.csv"); watcher.IncludeSubdirectories = true; watcher.Changed += Watcher_Changed; watcher.Created += Watcher_Created; try { watcher.EnableRaisingEvents = true; ioTHelper = new IoTHelper(); try { string comPort = ConfigurationManager.AppSettings["serialPort"]; if (!string.IsNullOrEmpty(comPort)) { reader = new SerialReader(comPort, ioTHelper); } } catch (Exception serialEx) { Trace.TraceError("{0}: SerialReader will not be used. {1}", nameof(OnStart), serialEx.Message); } string interval = ConfigurationManager.AppSettings["interval"]; if (!string.IsNullOrEmpty(interval)) { int value = 0; if (int.TryParse(interval, out value)) { if (value > 1000) { Trace.TraceInformation($"Zip interval set to {value}"); zipInterval = value; } } } startTimer(); } catch (Exception ex) { Trace.TraceError($"OnStart error: {ex.Message}"); } }
private async Task <bool> Provision() { var dpsGlobalEndpoint = _appConfigService.DpsGlobalEndpoint; var dpsIdScope = _appConfigService.DpsIdScope; var deviceId = _deviceInfoService.GetDeviceId(); var dpsSymetricKey = IoTHelper.GenerateSymmetricKey(deviceId, _appConfigService.DpsSymetricKey); using (var security = new SecurityProviderSymmetricKey(deviceId, dpsSymetricKey, dpsSymetricKey)) { using (var transport = new ProvisioningTransportHandlerHttp()) { var provisioningClient = ProvisioningDeviceClient.Create(dpsGlobalEndpoint, dpsIdScope, security, transport); var regResult = await provisioningClient.RegisterAsync(); if (regResult.Status == ProvisioningRegistrationStatusType.Assigned) { _appConfigService.AssignedEndPoint = regResult.AssignedHub; } return(true); } } }
public async Task <bool> ConnectAsync() { var deviceId = _deviceInfoService.GetDeviceId(); if (string.IsNullOrEmpty(_appConfigService.AssignedEndPoint)) { await Provision(); } var symetricKey = IoTHelper.GenerateSymmetricKey(deviceId, _appConfigService.DpsSymetricKey); var sasToken = IoTHelper.GenerateSasToken(_appConfigService.AssignedEndPoint, symetricKey, null); _deviceClient = DeviceClient.Create(_appConfigService.AssignedEndPoint, new DeviceAuthenticationWithToken(deviceId, sasToken), TransportType.Mqtt_WebSocket_Only); _deviceClient.SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler); await _deviceClient.OpenAsync(); return(true); }