Setting Up Your Development Environment
This section describes a development environment for creating programs to run on the SmartServer, and takes you through the installation process. The software described here is the development environment used to develop the Programming Tutorial included in this documentation. Whether you plan to follow the tutorial, or jump right in to programming the SmartServer, you may need to install some, or all, of the software listed below.
This section lists the software used for the development environment, and takes you through the installation process. There are many different software options available to you, and you can use any compatible development environment. However, writing an application for IAP/MQ does not require a development environment. All you need is the ability to interface with MQTT, which is typically, but not necessarily, using a programming language such as Node.js, Python, Java, or C.
The following software is used in the Programming Tutorial:
Node.js v10.16 | Many of the SmartServer services are implemented using Node.js. Installing this version on your development computer is important to ensure that code you test on your development computer will run on the SmartServer. The dynamic nature of Open Source software means versions will change over time. If you open an SSH session on your SmartServer, you can determine the version of node.js running by typing this command: node −v |
Visual Studio Code | Microsoft Visual Studio Code (VS Code) is an open source code editor developed by Microsoft. Distributions for Windows, Mac OS, and Linux are available. VS Code features include intelligent code completion, syntax highlighting, Git integration, and debugging extensions for javascript. Version 1.33.01 was used to create the exercises in this document. You should download the current version. |
SCP Client Software | During these exercises, you will need to transfer files to your SmartServer target. You may already have an SCP client on your development computer, but if not, you should install WinSCP or Core FTP-LE when developing on a Windows PC. Similar SCP products are available for Mac or Linux users. |
SSH Terminal Software | During these exercises, you need to have access to the SmartServer bash shell using either an SSH client or a serial connection. There are many choices for SSH client software, depending on your development computer's operating system. PuTTY is a good free option when developing on a Windows computer. Other products are available for Mac or Linux users. For information on using a serial connection see Connecting to the Console Interface. |
Git | The examples and associated support files are maintained in a public Github repository: SmartServer IoT Example Repo. It is possible to download a snapshot of the repo without Git, but having Git, and leveraging the Git Integration in VS code, will allow you to keep track of changes you make to the source examples. You will find Git at this link: https://git-scm.com/downloads |
Install Node.js
To install Node.js:
- Click this link to find the desired version of Node.js: https://nodejs.org/en/download/releases/
- Scroll down to the Node.js 10.16.0 Dubnium LTS release in the release table, and click the
Downloads
link. - Select the distribution version that matches the operating system of your development computer to download.
For example, if your computer runs Window 10, 64-bit, download: node-v10.16.0-x64.msi. For Mac OS, download: node-v10.16.0.pkg - Launch the downloaded file (such as node-v10.16.0-x64.msi) and select the defaults for installation.
- Add a browser bookmark to the Node.js documentation: https://nodejs.org/download/release/v10.16.0/docs/api/
- Verify that you have installed Node.js by opening a Command Prompt window and typing:
node −−version
.
You will see the version of Node.js that is installed on your computer. The following figure shows the results of this command. If the command fails, you may need to reboot your computer, and run the command again.
Install Visual Studio Code
To install VS Code:
- Click this link to the VS Code website: https://code.visualstudio.com/
- Click the
Download
button located at the top right of the web page. - Download and install the version that matches the operating system of your development computer.
- When you start VS Code, it will attempt to integrate with Git SCM. If not already installed in your computer, VS Code will encourage installing Git. You should follow the links suggested by VS Code to install Git.
Install the npm Intellisense Plugin
VS Code has over 1500 extensions available in the Visual Studio marketplace. The examples in this tutorial use a few of the 650,000 node.js modules available through NPM (Node Package Manager). To improve the coding experience in VS code, we used the npm Intellisense plugin by Christian Kohler.
- Click this link to the npm Intellisense plugin in the Visual Studio marketplace: https://marketplace.visualstudio.com/items?itemName=christian-kohler.npm-intellisense
- Download and install the version that matches the operating system of your development computer.
Change the VS Code Default Terminal (MS Windows Only)
VS Code allows you to configure the terminal window it uses. These examples were developed using Windows cmd.exe as the default terminal window. If you are running Windows 10, VS Code uses PowerShell for the prompt, which creates issues with the instructions in this tutorial. Please follow the steps below to force VS Code to use cmd.exe.
Note: These instructions apply only to computers running Windows.
To change the VS Code default terminal:
- In VS Code, select:
File > Preferences > Settings
VS Code opens the User Settings for editing. - In the Search box, type:
terminal.integrated.shell.windows
as shown here: Click Edit in setttings.json the User Setting in the right pane, and copy this block of JSON to the main edit window as shown below.
Terminal shell configuration{ "workbench.startupEditor": "newUntitledFile", "workbench.colorTheme": "Visual Studio Dark", "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe", "editor.minimap.enabled": false, }
Click
File > Save
to save your setting override.
Recommendations for Using VS Code
If you are not already comfortable using VS Code, consider watching the Introductory videos from the VS Code web site to get familiar with VS code (https://code.visualstudio.com/docs/getstarted/introvideos).
Install an SCP Client
You may already have an SCP client program on you development computer, but if not, you should install WinSCP, Core FTP-LE, or another SCP or SFTP client of your choice.
Install SSH Terminal Software
You may already have an SSH Terminal client program on you development computer, but if not, you should install PuTTY on Windows, or another client of your choice.
For information on using a serial connection see Connecting to the Console Interface.
Install Git
Find the installer for your development computer at this location: https://git-scm.com/downloads. Be sure to select VS code as your default editor, and when prompted about line ending conversions, use Checkout Windows-style, commit Unix-style line ending ( git config --global core.autocrlf true
).
Clone the SmartServer-IoT Example Repository
The source code and supporting files for the examples in this documentation is maintained a public Git repository: https://github.com/izot/smartserver-iot. You can clone this repository in VS Code by entering the git clone command in the VS command prompt. Or, you can open a command window at a selected directory of your choice and run this command: git clone https://github.com/izot/smartserver-iot
. This action clones the contents of this repository on your computer.
When this document refers to SmartServer-IoT example repo, the reference is to the directory created by the git clone command just executed.
Next Step
Once you have completed setting up your environment, you can start going through the Programming Tutorial, or dive in to writing an internal app by going to Creating a Custom LON App.