public async Task InitAsync() { var listing = await AppServiceCatalog.FindAppServiceProvidersAsync("com.softwarelogistics.gcodemachine"); if (listing != null && listing.Any()) { var packageName = listing[0].PackageFamilyName; Debug.WriteLine("Found Package - Opening: " + packageName); _appServiceConnection = new AppServiceConnection(); _appServiceConnection.PackageFamilyName = packageName; _appServiceConnection.AppServiceName = "com.softwarelogistics.gcodemachine"; var status = await _appServiceConnection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { Debug.WriteLine("Success Opening"); _appServiceConnection.RequestReceived += _appServiceConnection_RequestReceived; } else { Debug.WriteLine("Failed Opening " + status.ToString()); } _appService = new AppService(_appServiceConnection); } else { Debug.Write("Could not connect to background service."); } if (LightningProvider.IsLightningEnabled) { var gpioController = (await GpioController.GetControllersAsync(LightningGpioProvider.GetGpioProvider()))[0]; foreach (var axis in _axes) { axis.Init(gpioController, _appService); } _topLight.Init(gpioController); _bottomLight.Init(gpioController); _vacuum.Init(gpioController); _motorPower.Init(gpioController); _motorPower.Disable(); } else { Debug.WriteLine("Ligtning IS NOT Enabled, please enable through Device Portal"); } StartWorkLoop(); }