Win10 IoT C # development 1.5,
Windows 10 IoT Core is an important product of Microsoft for the IoT market. Unlike the previous Windows version, Windows Core is specially designed for IoT devices. The hardware is not limited to the x86 architecture, it can also run on the ARM architecture.
In the previous chapter, we talked about Raspberry's method of installing Win10 IoT system and setting up Visual Studio 2015 Development Environment (http://www.cnblogs.com/cloudtech/p/5562120.html). This time we will look at how to deploy Win10 IoT program to the Raspberry environment.
Use Remote Machine, Windows IoT Core Web Management, and Power Shell commands.
Preparations:
Raspberry Pi 2
Refresh Raspberry Pi 2 of Win 10 IoT Core System
Deploy a PC in the Visual Studio 2015 Development Environment
Displays supporting HDMI
Objective: To verify the successful deployment by displaying the application interface.
First, create a Universal Windows application. Open VS 2015 and click New Project. in Visual C #-> Windows-> Universal, find the Blank App (Universal Windows) Project template, select a template, enter a project name, and click OK to create a project.
Modify the MainPage. xaml file on the main interface and add the TextBlock tag in the middle to display the start time. (XAML is the abbreviation of eXtensible Application Markup Language. It is used in WPF technology to define the interface style and implement the MVVM structure, the XAML in Windows Universal Project is equivalent to a subset in WPF and provides some functions. The content of the XAML is much more detailed in the following sections)
Here, we use MainPage. cs as the ViewModel to implement the INotifyPropertyChanged interface to complete a simple MVVM framework.
Complete code:
<Page x:Class="CloudTechIot1dot5.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:CloudTechIot1dot5" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Page.Resources> <Style TargetType="TextBlock"> <Setter Property="HorizontalAlignment" Value="Center"></Setter> <Setter Property="VerticalAlignment" Value="Center"></Setter> <Setter Property="FontSize" Value="60"></Setter> <Setter Property="FontWeight" Value="Bold"></Setter> </Style> </Page.Resources> <!--http://www.cnblogs.com/cloudtech cloudtechesx@gmail.com--> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <TextBlock Foreground="LightBlue" Text="cloudtechesx@gmail.com"></TextBlock> <TextBlock Grid.Row="1" Foreground="Red" Text="{Binding CurrentTime,UpdateSourceTrigger=PropertyChanged}"></TextBlock> <TextBlock Grid.Row="2" Foreground="Yellow" Text="Remote Machine"></TextBlock> </Grid></Page>
namespace CloudTechIot1dot5{ //http://www.cnblogs.com/cloudtech //cloudtechesx@gmail.com public sealed partial class MainPage : Page, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private string _currentTime; public string CurrentTime { get { return _currentTime; } set { _currentTime = value; OnProperityChanged("CurrentTime"); } } public MainPage() { this.InitializeComponent(); this.DataContext = this; CurrentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } public void OnProperityChanged(string propertyName) { PropertyChanged?.Invoke(propertyName, new PropertyChangedEventArgs(propertyName)); } }}
Connect the power supply and network cable to the Raspberry and the HDMI monitor.
After the system is started, the IP address of the current IoT device is displayed on the display.
Next we will deploy the IoT Program
Method 1: Remote Machine deployment
On the Visual Studio 2015 toolbar, select Remote Machine for debugging. Enter the IP address of the device. Click "run" to automatically deploy the device.
After the program starts, the display displays the expected interface.
Method 2: Windows IoT Core Web Management deployment
First, package the program. Right-click the project to be packaged in the solution browser of Visual Studio 2015, and select Create App Packages from the Store menu.
Select "No" when asking whether to upload data to Windows Store (we cannot use this function now). Select "Never" for "Generate app bundle.
Click Next to compile the file. The output path is displayed after compilation.
Open your browser and enter the IP address and port number of the IoT device 8080 to go to the Windows IoT Core Web Management logon interface (we will introduce Windows IoT Core Web Management in later articles ), enter the initial username Administrator and password p @ ssw0rd to go to the main interface.
Select the Apps menu item from the left-side menu. The App Manager panel displays information about the installed programs and running programs. The following figure shows how to install the App.
In the App package directory, select the. appx file.
Click the Go button to Start the installation. After the installation is complete, select the application you just Installed in Installed apps, and click the Start button to Start the program. After the program starts, the display displays the expected interface. Click the Set Default button to Set the program as the Default program, which is started by Default after each system startup.
Method 3: deploy the Power Shell command
First, package the program. The method is the same as that of the second method.
By default, Win10 IoT supports FTP. You can use an FTP client to upload the generated program directory to the root directory of Win10 IoT.
Run the following command to connect to Win10 IoT and enter the directory.
Net start WinRM
Set-Item WSMan: \ localhost \ Client \ TrustedHosts-Value 192.168.1.2
Enter-PsSession-ComputerName 192.168.1.2-Credential 192.168.1.2 \ Administrator
Find the uploaded folder, run the cd command to enter the folder, find the. appx file, and run the Add-AppxPackage command to install it. Here we execute Add-AppxPackage CloudTechIot1dot5_1.0.2.0_ARM.appx.
After the program starts, the display displays the expected interface.
Here the process of creating the Win10 IoT UI program and using three methods of deployment is complete, if you have optimization suggestions for the code, please leave a message or mail me (cloudtechesx@gmail.com ). You can also scan the following QR code and add my number to view previous articles.
Project source code GitHub https://github.com/CloudTechx/CloudTechIot under the CloudTechIot1dot5 directory.
Win10 IoT C # Development 2-GPIO Pin control Light Emitting Diode http://www.cnblogs.com/cloudtech/p/5617902.html