diff --git a/NCOS_API_for_Applications.html b/NCOS_API_for_Applications.html index e0c70c9d..cb00a94b 100644 --- a/NCOS_API_for_Applications.html +++ b/NCOS_API_for_Applications.html @@ -1,296 +1,296 @@ - - -
-Write operations to control/ping/start will initiate a ping. The following will start a basic ping when written: {"host": "www.google.com", "size": 64}. An IP address can also be used.
-NOTE: Concurrent ping operations are not supported.
+NOTE: Concurrent ping operations are not supported. +
Ping Options for control/ping/start:
By default, the GPS hardware goes into a low power state after a certain interval of inactivity. To prevent the GPS hardware from entering this low power state, set “enablegpskeepalive” to true. When “enablegpskeepalive” is enabled, the GPS service will poll the GPS hardware every 10 seconds and prevent the GPS from entering a low power state. Coming out of a low power state takes extra time to regain the GPS lock so set this flag to keep the hardware from falling asleep. Note this flag has no effect if the GPS service itself is not enabled.
The current GPS data can be found in /status/gps/.
+The current GPS data can be found in /status/gps/. +
This contains two fields: fix and nmea.
Published Date: 5/17/2018 11:02:48 AM
+Published Date: 5/25/2018 2:27:46 PM
This article not have what you need? Not find what you were looking for? Think this article can be improved? Please let us know at suggestions@cradlepoint.com.
- - - - + + + + diff --git a/NCOS_SDK_Application_Development_Guide.html b/NCOS_SDK_Application_Development_Guide.html new file mode 100644 index 00000000..1df4b1fc --- /dev/null +++ b/NCOS_SDK_Application_Development_Guide.html @@ -0,0 +1,817 @@ + + + +Cradlepoint’s NetCloud OS (NCOS) Device Application Framework/SDK provides the ability to customize the functionality of Cradlepoint devices with applications written in Python. Python applications written with the SDK are securely downloaded to the device and enabled using Network Cloud Manager (NCM). Cradlepoint’s SDK allows for extending and enhancing the functionality of Cradlepoint devices, FOG computing, and managing IoT devices.
+At a high level, the Cradlepoint NCOS Device Application Framework/SDK is a mechanism that packages a collection of files – including executable files – in an archive. This archive is transferred securely via NCM and is used to install an SDK application within a Cradlepoint device for execution as an extension to normal firmware.
+For the scope of this document, NCOS Apps are limited to the non-privileged Python scripts. Supported functionality includes the following:
+Please refer to the specifications for the device at www.cradlepoint.com
+For ease of development and debugging, an application can be directly installed into a device which has been placed into Developer Mode. Once the application is fully debugged and ready for deployment, it can be installed via NCM at the group level. Applications may also be installed on individual devices from the command line.
+Cradlepoint has a simplified SDK, written in python, which builds and creates an app package. The SDK, along with sample applications, is located here.
+For app development, the SDK is used to install, start, stop, uninstall, and check the status of an application in a locally connected development device. The application package is the same for local debugging or for uploading to the NCM for production deployment. Application development can be done on Linux, OS X, and Windows operating systems with the same SDK.
+This document is specifically written for SDK version 2.0 and above.
+ +Cradlepoint has a Developer Community Portal to leverage knowledge, share, and collaborate with other developers. This forum is also actively monitored by Cradlepoint to answer questions.
+ +The existing Cradlepoint Knowledge Base also has many articles related to NCOS applications and the SDK.
+ +NCOS application are written in Python. However, for storage space and security purposes, the NCOS Python environment is a subset of a typical Python installation on a computer. A list of installed Python modules in an NCOS device is available by installing and running the sample app named “pythonmodulelist” which is included with the SDK. The “pythonmodulelist” application writes the names of the installed Python modules on a device to that device’s log.
+New python files can be added to your application but their dependencies must also adhere to the NCOS python environment. These new python files/modules can be copied to the main application directory or can be installed using pip. If pip is used, any 'egg' or 'dist' directories can be deleted as they are not required for functionality and will just use up memory unnecessarily when installed into the NCOS device.
+Example pip command: +pip(3) install --ignore-install --target=<path to application directory> <python module name>
+Note: Use pip on Windows and pip3 on Linux or OS X.
+ +Download the SDK and sample apps from https://github.com/cradlepoint/sdk-samples. Below are the setup instruction for:
+ +Note: Command line commands must be performed in the order they appear.
+ +Install python 3.5.1 from python.org.
+Add Linux development libraries by using the following commands:
+sudo apt-get install libffi-dev
+sudo apt-get install libssl-dev
+sudo apt-get install sshpass
+
+
+Install python libraries by using the following commands.
+sudo apt-get install python3-pip
+pip3 install requests
+pip3 install pyopenssl
+pip3 install cryptography
+
+
+Useful tools
+PyCharm (community version is free): https://www.jetbrains.com/pycharm/download/#section=linux.
+Install python 3.5.1 from python.org.
+Install HomeBrew for package updates by using the following commands:
+/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
+
+
+Install these required libraries by using the following commands:
+brew install openssl
+brew install http://git.io/sshpass.rb
+
+
+Install the python libraries by using the following commands:
+pip3 install -U pip
+pip3 install requests
+pip3 install pyopenssl
+pip3 install cryptography
+
+
+Useful tools
+PyCharm (community version is free): https://www.jetbrains.com/pycharm/download/#section=macOS.
+The SDK requires OpenSSL tools to generate digital signatures. Go to https://slproweb.com/products/Win32OpenSSL.html and download the 'Light' version based on your machine (i.e. Win64 or Win32). Then run the executable after it is downloaded to install OpenSSL.
+Open a terminal window and use the following commands to install the Python libraries.
+python -m pip install -U pip
+python -m pip install pyserial
+python -m pip install requests
+python -m pip install pyopenssl
+
+
+Below is the directory structure for for the SDK and sample applications. The BOLD items are modified or created by the developer. The other files are used by the SDK or are referenced by the other files.
+Based on the sdk_setting.ini file, the SDK will build all files located in the app_name directory into a tar.gz package that can then been installed into the device. This installation is performed either directly into the device (if in DEV mode) or via NCM for grouped devices.
+ +A NCOS application package, which is a tar.gz archive, consists of a set of files that includes the python executable, start/stop scripts, initialization files, along with manifest and signature files. This package of files is built by the SDK base on the sdk_settings.ini. Some of these files, like the manifest and signature files, are created by the Make tool. Others are created by the application developer. Below are the example contents for a tar.gz archive created for a NCOS application.
+This initialization file contains information and about the application and items that affect installation and execution. This information will stored in /status/system/sdk within the NCOS config store for installed apps.
+For example:
+[hello_world]
+uuid=7042c8fd-fe7a-4846-aed1-e3f8d6a1c91c
+vendor=Cradlepoint
+notes=Hello World Demo Application
+firmware_major=6
+firmware_minor=1
+restart=false
+reboot=true
+version_major=1
+version_minor=6
+auto_start=true
+
+
+[hello_world]
+This must contain the name of the application. In this example, hello_world is the application name.
+uuid +
+Every app must contain a universally unique identifier (UUID).
+vendor
+This is the vendor name for the app.
+notes
+Add notes to describe the app or anything else.
+firmware_major and firmware_minor
+This is the required device firmware version for the app. Not implemented at this time.
+restart +If set to 'true', the application will be restarted if it dies or is not running. If false, the device will not attempt to restart the application.
+reboot +If set to 'true', the application will be started following a device reboot. Otherwise, it will not be restarted.
+version_major and version_minor
+This contains the app version. This must be incremented for any new production app used installed via NCM. It will not re-install the same version that already exist in the device.
+auto_start
+If set to 'true', the app will automatically start after installation.
+This script is executed to start the application in the device. It contains the command to start the python script and pass any arguments if needed.
+For example:
+#!/bin/bash
+cppython hello_world.py start
+
+
+This script is executed when the application is stopped in the device. It contains the command to stop the python script and pass any arguments. This is not required unless one needs a specific action preformed when the application is stopped.
+For example:
+#!/bin/bash
+cppython hello_world.py stop
+
+
+
+The SDK includes a python make.py file which is compatible for Windows, Linux and OS X platforms.
+default (i.e. no action given): + Print a help file
+clean: + Clean all project artifacts. To clean all the apps, add the option "all" (i.e. clean all).
+build or package: + Create the app archive tar.gz file. To build all the apps, add the option "all" (i.e. build all). Any directory containing a package.ini file is considered an app.
+status: + Fetch and print current app status from the locally connected device.
+install: + Secure copy the app archive to a locally connected device. The device must already be in SDK DEV mode via registration and licensing in NCM. Note: A 'Connection reset by peer' error will be displayed even when the application is successfully copied to the device. This occurs when the device drops the connections after the file copy is complete.
+start: + Start the app on the locally connected device.
+stop: + Stop the app on the locally connected device.
+uninstall: + Uninstall the app from the locally connected device.
+purge: + Purge all apps from the locally connected device.
+uuid: + This will create a new UUID for the app and write it to the package.ini file.
+unit: + Run any unit tests associated with selected app.
+system: + Run any system tests associated with selected app.
+help: + Print this help information.
+All SDK functions are contained in the make.py python file. While this executable is the same regardless of the workstation platform, the python command is not. Use the following python command based on your platform:
+Linux or OS X:
+python3
+
+
+Windows:
+python
+
+
+The command structure is:
+python(3) make.py <action>
+
+
+The make.py usage is as follows:
+Update the sdk_setting.ini file based on your needs.
+Example:
+[sdk]
+app_name=ping
+dev_client_ip=192.168.0.1
+dev_client_username=admin
+dev_client_password=44224267
+
+
+Update the UUID in the package.ini file located in the app directory.
+Example:
+[ping]
+uuid=dd91c8ea-cd95-4d9d-b08b-cf62de19684f
+
+
+Build the application package.
+python(3) make.py build
+
+
+Test connectivity with your device via the status target.
+python(3) make.py status
+{
+ "data": {},
+ "success": true
+}
+
+
+Install the application on your device.
+python(3) make.py install
+admin@192.168.0.1's password:
+hspt.tar.gz 100% 1439 1.4KB/s 00:00
+Received disconnect from 192.168.0.1: 11: Bye Bye
+lost connection
+
+
+Get the application execution status from your device.
+python(3) make.py status
+{
+ "data": {
+ "7042c8fd-fe7a-4846-aed1-e3f8d6a1c91c": {
+ "app": {
+ "date": "2015-12-04T09:30:39.656151",
+ "name": "hspt",
+ "restart": true,
+ "uuid": "7042c8fd-fe7a-4846-aed1-e3f8d6a1c91c",
+ "vendor": "Cradlebox",
+ "version_major": 1,
+ "version_minor": 1
+ },
+ "base_directory": "/var/mnt/sdk/apps/7042c8fd-fe7a-4846-aed1-e3f8d6a1c91c",
+ "directory": hspt",
+ "filename": "dist/tmp_znv2t",
+ "state": "started",
+ "summary": "Package started successfully",
+ "type": "development",
+ "url": "file:///var/tmp/tmpg1385l",
+ "uuid": "7042c8fd-fe7a-4846-aed1-e3f8d6a1c91c"
+ }
+ },
+ "success": true
+}
+
+
+Uninstall the application from your device.
+python(3) make.py uninstall
+{
+ "data": "uninstall 7042c8fd-fe7a-4846-aed1-e3f8d6a1c91c",
+ "success": true
+}
+
+
+Application debugging is accomplished with the use of debug syslogs. However, the default logging level in the NCOS device is set to info so this must be changed to debug. It is also possible to send the device logs to a syslog server running on another device. For more information, see the Knowledge Base article 'Understanding Router Log Files'.
+Use the following steps to open the device console from the device admin pages:
+1. Click System.
+2. Click System Control.
+3. Click Device Options.
+4. Click the Device Console button.
+
+
+You can also view logs via CLI commands when logged into the NCOS device console. This console is available by logging into the device with Secure Shell (i.e. ssh) or by opening a console from the device admin pages.
+log (displays logs in the terminal window)
+log -s <text> (search for logs that contain <text> and displays them)
+log -s -i <text> (search for logs that contain <text> but case insensitive)
+log clear (clears the log buffer)
+help log (display the log command options)
+
+
+
+To install an application directly to the device without using NCM, the NCOS device must be placed in DEV mode. One would typically debug and test an application using DEV mode prior to using NCM for installation. DEV mode allows for quicker and easier testing and debugging. Instructions for setting up an NCOS device for DEV mode is in Knowledge Base article 'SDK Enable Developer Mode'.
+ +NCM is used to securely deploy applications to devices at the group level. If an application tar.gz package is uploaded to NCM and then assigned to an NCOS device group, NCM securely downloads and installs the application to the devices within the group. For security, the application files are not user accessible within NCM or devices. That is, one is not able to download the application from the device or NCM.
+ +Cradlepoint has provided several sample applications with the SDK which is located here. Any of these apps can be used as a starting point for your application. The application data structure is described here.
+When using the SDK make.py file, be sure to invoke the proper python command based on your computer OS.
+Linux or OS X:
+python3
+
+
+Windows:
+python
+
+
+Update the sdk_settings.ini to utilize the hello_world app.
+Example:
+[sdk]
+app_name=hello_world
+dev_client_ip=192.168.0.1
+dev_client_username=admin
+dev_client_password=44224267
+
+
+Verify device connectivity via:
+$ python(3) make.py status
+
+
+Create the application package
+$ python(3) make.py build
+
+
+Install the application package. Note: A 'Connection reset by peer' error will be displayed even when the application is successfully copied to the device. This occurs when the device drops the connections after the file copy is complete.
+$ python(3) make.py install
+
+
+Check the application status to ensure it has started.
+$ python(3) make.py status
+
+
+Check the logs in the device to ensure the application is creating 'Hello World' logs. Use the 'log' command in the device console to check the logs.
+Published Date: 5/25/2018 2:27:46 PM
+This article not have what you need? Not find what you were looking for? Think this article can be improved? Please let us know at suggestions@cradlepoint.com.
+ + + + diff --git a/NCOS_SDK_Application_Development_Guide.md b/NCOS_SDK_Application_Development_Guide.md deleted file mode 100644 index d410acf7..00000000 --- a/NCOS_SDK_Application_Development_Guide.md +++ /dev/null @@ -1,480 +0,0 @@ -# **NCOS SDK Application Development Guide** # - ----------- - -## Quick Links ## - -#### [Overview](#overview) #### -#### [Developer Community](#community) #### -#### [Cradlepoint Knowledge Base](#knowledge) #### -#### [NCOS Python Environment](#environment) #### -#### [Computer Setup Instructions](#setup) #### -#### [NCOS Development Mode](#devmode) #### -#### [Application Directory Structure](#structure) #### -#### [Application Package Anatomy](#anatomy) #### -#### [SDK Instructions Overview](#sdk) #### -#### [NCOS Syslog for Debugging](#syslog) #### -#### [NCM Application Deployment](#ncm) #### -#### [Sample Application Walk Through](#sample) #### - - - -## Overview ## -Cradlepoint’s NCOS device Application Framework provides the ability to add intelligence in the device. Applications written in Python can be securely downloaded to the device via [Network Cloud Manager](https://cradlepoint.com/ecm) (NCM). This allows for extended device features, FOG Computing, and IoT management. - -At a high level, the Cradlepoint NCOS Device Apps/SDK is a mechanism to package a collection of files – including executable files – in an archive, which can be transferred securely via NCM, hidden within a Cradlepoint device, and executed as an extension to normal firmware. - -### What is Supported? ### -For the scope of this document, NCOS Apps are limited to the non-privileged Python scripts. Supported functionality: - -- Standard TCP/UDP/SSL socket servers function on ports higher than 1024. -- Standard TCP/UDP/SSL socket client to other devices (or the device as 127.0.0.1/localhost). -- Access to serial ports via the PySerial module, including native and USB-serial ports. -- Ability to PING external devices. -- UI Extensibility (i.e. Hot Spot splash page or other UI WEB pages) -- Access to the NCOS API (aka: status and control tree data). -- USB Memory device file access. - -### What is not Supported? ### -- Any form of natively compiled or kernel linked code. -- Any function requiring privileged (or root) permissions. -- Access to shared resources (for example: no ability to issue custom AT commands to cell modems). -- Modifications of routing or security behavior. - -### Supported NCOS Devices ### -Please refer to the specifications for the device at [www.cradlepoint.com](https://www.cradlepoint.com) - -### Application Development ### -During development, an application can be directly installed into a 'DEV Mode' device. This makes it easier to debug and work through the development process. Once the application has been fully debugged and is ready for deployment, it can be installed via NCM at the group level. - -### SDK Toolset ### -Cradlepoint has a simplified SDK, written in python, which builds and creates an app package. The SDK, along with sample applications is located [here](https://github.com/cradlepoint/sdk-samples/releases). - -For app development, the SDK is used to install, start, stop, uninstall, and check status of the application in a locally connected development device. The application package is the same for local debugging or for uploading to the NCM for production deployment. Application development can be done on Linux, OS X, and Windows operating systems with the same SDK. - -This document is specifically written for SDK version 2.0 and above. - - - -## Developer Community ## -Cradlepoint has a [Developer Community Portal](https://dev.cradlepoint.com) to leverage knowledge, share, and collaborate with other developers. This forum is also actively monitored by Cradlepoint to answer questions. - - - -## Cradlepoint Knowledge Base ## -The existing [Cradlepoint Knowledge Base](http://knowledgebase.cradlepoint.com) also has many articles related to NCOS applications and the SDK. - - - -## NCOS Python Environment ## -Application are written in python. However, NCOS only contains a subset of a typical python installation on a computer. The list of python modules in the NCOS device can be obtained by installing sample app python\_module\_list which is included with the SDK. This application will list all of the python modules in the logs. - -New python files can be added to your application but their dependencies must also adhere to the NCOS python environment. These new python files/modules can be copied to the main application directory or can be installed using pip. If pip is used, any 'egg' or 'dist' directories can be deleted as they are not required for functionality and will just use up memory unnecessarily when installed into the NCOS device. - -Example pip command: -pip(3) install --ignore-install --target=