forked from cradlepoint/sdk-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NCOS_SDK_Application_Development_Guide.html
818 lines (734 loc) · 31.3 KB
/
NCOS_SDK_Application_Development_Guide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
<!DOCTYPE html>
<html>
<head>
<title>NCOS_SDK_Application_Development_Guide</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) */
/* Author: Nicolas Hery - http://nicolashery.com */
/* Version: b13fe65ca28d2e568c6ed5d7f06581183df8f2ff */
/* Source: https://github.com/nicolahery/markdownpad-github */
/* RESET
=============================================================================*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
}
/* BODY
=============================================================================*/
body {
font-family: Helvetica, arial, freesans, clean, sans-serif;
font-size: 14px;
line-height: 1.6;
color: #333;
background-color: #fff;
padding: 20px;
max-width: 960px;
margin: 0 auto;
}
body>*:first-child {
margin-top: 0 !important;
}
body>*:last-child {
margin-bottom: 0 !important;
}
/* BLOCKS
=============================================================================*/
p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}
/* HEADERS
=============================================================================*/
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}
h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}
h1 {
font-size: 28px;
color: #000;
}
h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
color: #777;
font-size: 14px;
}
body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}
h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}
/* LINKS
=============================================================================*/
a {
color: #4183C4;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* LISTS
=============================================================================*/
ul, ol {
padding-left: 30px;
}
ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}
ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}
dl {
padding: 0;
}
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}
dl dt:first-child {
padding: 0;
}
dl dt>:first-child {
margin-top: 0px;
}
dl dt>:last-child {
margin-bottom: 0px;
}
dl dd {
margin: 0 0 15px;
padding: 0 15px;
}
dl dd>:first-child {
margin-top: 0px;
}
dl dd>:last-child {
margin-bottom: 0px;
}
/* CODE
=============================================================================*/
pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}
code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}
pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}
pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}
pre code, pre tt {
background-color: transparent;
border: none;
}
kbd {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DDDDDD;
background-image: linear-gradient(#F1F1F1, #DDDDDD);
background-repeat: repeat-x;
border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
border-image: none;
border-radius: 2px 2px 2px 2px;
border-style: solid;
border-width: 1px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
line-height: 10px;
padding: 1px 4px;
}
/* QUOTES
=============================================================================*/
blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}
blockquote>:first-child {
margin-top: 0px;
}
blockquote>:last-child {
margin-bottom: 0px;
}
/* HORIZONTAL RULES
=============================================================================*/
hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}
/* TABLES
=============================================================================*/
table th {
font-weight: bold;
}
table th, table td {
border: 1px solid #ccc;
padding: 6px 13px;
}
table tr {
border-top: 1px solid #ccc;
background-color: #fff;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
/* IMAGES
=============================================================================*/
img {
max-width: 100%
}
</style>
</head>
<body>
<h1><strong>NCOS SDK Application Development Guide</strong></h1>
<hr />
<h2>Quick Links</h2>
<h4><a href="#overview">Overview</a></h4>
<h4><a href="#community">Developer Community</a></h4>
<h4><a href="#knowledge">Cradlepoint Knowledge Base</a></h4>
<h4><a href="#environment">NCOS Python Environment</a></h4>
<h4><a href="#setup">Computer Setup Instructions</a></h4>
<h4><a href="#devmode">NCOS Development Mode</a></h4>
<h4><a href="#structure">Application Directory Structure</a></h4>
<h4><a href="#anatomy">Application Package Anatomy</a></h4>
<h4><a href="#sdk">SDK Instructions Overview</a></h4>
<h4><a href="#syslog">NCOS Syslog for Debugging</a></h4>
<h4><a href="#ncm">NCM Application Deployment</a></h4>
<h4><a href="#sample">Sample Application Walk Through</a></h4>
<p><a name="overview"></a></p>
<h2>Overview</h2>
<p>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 <a href="https://cradlepoint.com/ecm">NetCloud Manager</a> (NCM). Cradlepoint’s SDK allows for extending and enhancing the functionality of Cradlepoint devices, FOG computing, and managing IoT devices.</p>
<p>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.</p>
<h3>What is Supported?</h3>
<p>For the scope of this document, NCOS Apps are limited to the non-privileged Python scripts. Supported functionality includes the following:</p>
<ul>
<li>Standard TCP/UDP/SSL socket servers function on ports higher than 1024.</li>
<li>Standard TCP/UDP/SSL socket client to other devices (or the device as 127.0.0.1/localhost).</li>
<li>Access to serial ports via the PySerial module, including native and USB-serial ports.</li>
<li>Ability to PING external devices.</li>
<li>UI Extensibility (i.e. Hot Spot splash page or other UI WEB pages)</li>
<li>Access to the NCOS API (aka: status and control tree data).</li>
<li>USB Memory device file access.</li>
</ul>
<h3>What is not Supported?</h3>
<ul>
<li>Any form of natively compiled or kernel linked code.</li>
<li>Any function requiring privileged (or root) permissions.</li>
<li>Access to shared resources (for example: no ability to issue custom AT commands to cell modems).</li>
<li>Modifications of routing or security behavior.</li>
</ul>
<h3>Supported NCOS Devices</h3>
<p>Please refer to the specifications for the device at <a href="https://www.cradlepoint.com">www.cradlepoint.com</a></p>
<h3>Application Development</h3>
<p>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.</p>
<h3>SDK Toolset</h3>
<p>Cradlepoint has a simplified SDK, written in python, which builds and creates an app package. The SDK, along with sample applications, is located <a href="https://github.com/cradlepoint/sdk-samples/releases">here</a>. </p>
<p>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.</p>
<p>This document is specifically written for SDK version 2.0 and above.</p>
<p><a name="community"></a> </p>
<h2>Developer Community</h2>
<p>Cradlepoint has a <a href="https://dev.cradlepoint.com">Developer Community Portal</a> to leverage knowledge, share, and collaborate with other developers. This forum is also actively monitored by Cradlepoint to answer questions.</p>
<p><a name="knowledge"></a></p>
<h2>Cradlepoint Knowledge Base</h2>
<p>The existing <a href="http://knowledgebase.cradlepoint.com">Cradlepoint Knowledge Base</a> also has many articles related to NCOS applications and the SDK.</p>
<p><a name="environment"></a> </p>
<h2>NCOS Python Environment</h2>
<p>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 “python<em>module</em>list” which is included with the SDK. The “python<em>module</em>list” application writes the names of the installed Python modules on a device to that device’s log.</p>
<p>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. </p>
<p>Example pip command:
pip(3) install --ignore-install --target=<path to application directory> <python module name></p>
<p><strong>Note:</strong> Use pip on Windows and pip3 on Linux or OS X.</p>
<p><a name="setup"></a></p>
<h2>Computer Setup Instructions</h2>
<p>Download the SDK and sample apps from <a href="https://github.com/cradlepoint/sdk-samples">https://github.com/cradlepoint/sdk-samples</a>. Below are the setup instruction for:</p>
<ul>
<li><a href="#Linux">Linux</a></li>
<li><a href="#Mac">OS X</a></li>
<li><a href="#Windows">Windows</a></li>
</ul>
<p><strong>Note:</strong> Command line commands must be performed in the order they appear.</p>
<p><a name="Linux"></a></p>
<h3>Linux</h3>
<ol>
<li>
<p>Install python 3.5.1 from <a href="http://www.python.org">python.org</a>.</p>
</li>
<li>
<p>Add Linux development libraries by using the following commands:</p>
<pre><code>sudo apt-get install libffi-dev
sudo apt-get install libssl-dev
sudo apt-get install sshpass
</code></pre>
</li>
<li>
<p>Install python libraries by using the following commands. </p>
<pre><code>sudo apt-get install python3-pip
pip3 install requests
pip3 install pyopenssl
pip3 install cryptography
</code></pre>
</li>
<li>
<p>Useful tools</p>
<p>PyCharm (community version is free): <a href="https://www.jetbrains.com/pycharm/download/#section=linux">https://www.jetbrains.com/pycharm/download/#section=linux</a>.</p>
</li>
</ol>
<p><a name="Mac"></a></p>
<h3>Mac OS X</h3>
<ol>
<li>
<p>Install python 3.5.1 from <a href="http://www.python.org">python.org</a>.</p>
</li>
<li>
<p>Install HomeBrew for package updates by using the following commands:</p>
<pre><code>/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
</code></pre>
</li>
<li>
<p>Install these required libraries by using the following commands:</p>
<pre><code>brew install openssl
brew install http://git.io/sshpass.rb
</code></pre>
</li>
<li>
<p>Install the python libraries by using the following commands: </p>
<pre><code>pip3 install -U pip
pip3 install requests
pip3 install pyopenssl
pip3 install cryptography
</code></pre>
</li>
<li>
<p>Useful tools</p>
<p>PyCharm (community version is free): <a href="https://www.jetbrains.com/pycharm/download/#section=macOS">https://www.jetbrains.com/pycharm/download/#section=macOS</a>.</p>
</li>
</ol>
<p><a name="Windows"></a></p>
<h3>Windows</h3>
<ol>
<li>Install python 3.5.1 from <a href="https://www.python.org/downloads/release/python-351/">https://www.python.org/downloads/release/python-351/</a>.</li>
<li>
<p>The SDK requires OpenSSL tools to generate digital signatures. Go to <a href="https://slproweb.com/products/Win32OpenSSL.html">https://slproweb.com/products/Win32OpenSSL.html</a> 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.</p>
</li>
<li>
<p>Open a terminal window and use the following commands to install the Python libraries.</p>
<pre><code>python -m pip install -U pip
python -m pip install pyserial
python -m pip install requests
python -m pip install pyopenssl
</code></pre>
</li>
<li>
Useful tools
<ol>
<li>Putty: <a href="http://www.putty.org/">http://www.putty.org/</a></li>
<li>PyCharm (community version is free): <a href="https://www.jetbrains.com/pycharm/download/#section=windows">https://www.jetbrains.com/pycharm/download/#section=windows</a>.</li>
<li>7-zip: <a href="http://www.7-zip.org/">http://www.7-zip.org/</a></li>
<li>MarkdownPad: <a href="http://markdownpad.com/">http://markdownpad.com/</a></li>
</ol>
</li>
</ol>
<p><a name="structure"></a></p>
<h2>SDK/Apps Directory Structure</h2>
<p>Below is the directory structure for for the SDK and sample applications. The <strong>BOLD</strong> items are modified or created by the developer. The other files are used by the SDK or are referenced by the other files.</p>
<ul>
<li>
NCOS_Apps (directory)
<ul>
<li>
app_template (directory for the application)
<ul>
<li><strong>package.ini</strong> - App initialization items.</li>
<li><strong>app_name.py</strong> - The app python code. There can be multiple py files based on the app design.</li>
<li>cs.py - This is included with every sample app and should be in your app. It contains a CSClient class which is a wrapper for the TCP interface to the device config store (i.e. the NCOS JSON API trees).</li>
<li>app_logging.py - If included, this contains a class which can be used to generate NCOS syslogs at different levels (i.e. info, debug, error, etc.). Can be found in the common directory of the SDK. </li>
<li><strong>start.sh</strong> - Script that is executed to starts an app (i.e. cppython app_name.py). Parameters can also be added if needed.</li>
<li><strong>stop.sh</strong> - If included, this script is executed when the app is stopped. It is not required unless one needs a specific action preformed when the application is stopped. In this case, a parameter should be included in the script (i.e. cppython app_name.py stop) and handled by the python code.</li>
</ul>
</li>
<li>
config (directory)
<ul>
<li><strong>settings.mk</strong> - Build system config settings (i.e. NCOS Device MAC, IP, Username, Password, etc.).</li>
</ul>
</li>
<li>
tools (directory)
<ul>
<li>
bin (directory)
<ul>
<li>package_application.py - Used by SDK.</li>
<li>validate_application.py - Used by SDK.</li>
<li>pscp.exe - An executable use on Windows by the SDK.</li>
</ul>
</li>
</ul>
</li>
<li><strong>sdk_setting.ini</strong> - Used by the SDK and contains the settings for building the app and connecting to the local NCOS device.</li>
<li>NCOS_SDK_Application_Development_Guide.html </li>
<li>NCOS_APIs_for_Applications.html </li>
</ul>
</li>
</ul>
<p>Based on the sdk_setting.ini file, the SDK will build all files located in the <em>app_name</em> directory into a <em>tar.gz</em> 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.</p>
<p><a name="anatomy"></a></p>
<h2>Application Package Anatomy</h2>
<p>A NCOS application package, which is a <em>tar.gz</em> 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.</p>
<ul>
<li>
app_name (directory)
<ul>
<li>
METADATA (directory)
<ul>
<li>MANIFEST.json - Contains a file list along with hash signatures and other app the package initialization data.</li>
<li>SIGNATURE.DS - A signature file for the app package.</li>
</ul>
</li>
<li>app_name.py - The application python executable file.</li>
<li>cs.py - Another python file used by the app. There could be multiple python files depending on the application design.</li>
<li>package.ini - The package initialization data.</li>
<li>start.sh - The script run when the app is started.</li>
<li>stop.sh - The script run when the app is stopped. This is not required unless one needs a specific action preformed when the application is stopped. </li>
</ul>
</li>
</ul>
<h3>package.ini</h3>
<p>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.</p>
<p>For example:</p>
<pre><code>[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
</code></pre>
<ul>
<li>
<p><strong>[hello_world]</strong> </p>
<p>This must contain the name of the application. In this example, hello_world is the application name.</p>
</li>
<li>
<p><strong>uuid</strong>
</p>
<p>Every app must contain a universally unique identifier (UUID).</p>
</li>
<li>
<p><strong>vendor</strong></p>
<p>This is the vendor name for the app.</p>
</li>
<li>
<p><strong>notes</strong></p>
<p>Add notes to describe the app or anything else.</p>
</li>
<li>
<p><strong>firmware_major and firmware_minor</strong></p>
<p>This is the required device firmware version for the app. <strong><em>Not implemented at this time.</em></strong></p>
</li>
<li>
<p><strong>restart</strong>
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.</p>
</li>
<li>
<p><strong>reboot</strong>
If set to 'true', the application will be started following a device reboot. Otherwise, it will not be restarted.</p>
</li>
<li>
<p><strong>version_major and version_minor</strong></p>
<p>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.</p>
</li>
<li>
<p><strong>auto_start</strong></p>
<p>If set to 'true', the app will automatically start after installation. </p>
</li>
</ul>
<h3>start.sh</h3>
<p>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. </p>
<p>For example:</p>
<pre><code>#!/bin/bash
cppython hello_world.py start
</code></pre>
<h3>stop.sh</h3>
<p>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.</p>
<p>For example:</p>
<pre><code>#!/bin/bash
cppython hello_world.py stop
</code></pre>
<p><a name="sdk"></a></p>
<h2>SDK Instructions Overview</h2>
<p>The SDK includes a python make.py file which is compatible for Windows, Linux and OS X platforms. </p>
<h3>SDK actions are:</h3>
<p><strong>default (i.e. no action given):</strong>
Print a help file</p>
<p><strong>clean:</strong>
Clean all project artifacts. To clean all the apps, add the option "all" (i.e. clean all).</p>
<p><strong>build or package:</strong>
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.</p>
<p><strong>status:</strong>
Fetch and print current app status from the locally connected device.</p>
<p><strong>install:</strong>
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. <strong>Note:</strong> 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.</p>
<p><strong>start:</strong>
Start the app on the locally connected device.</p>
<p><strong>stop:</strong>
Stop the app on the locally connected device.</p>
<p><strong>uninstall:</strong>
Uninstall the app from the locally connected device.</p>
<p><strong>purge:</strong>
Purge all apps from the locally connected device.</p>
<p><strong>uuid:</strong>
This will create a new UUID for the app and write it to the package.ini file.</p>
<p><strong>unit:</strong>
Run any unit tests associated with selected app.</p>
<p><strong>system:</strong>
Run any system tests associated with selected app.</p>
<p><strong>help:</strong>
Print this help information.</p>
<h3>SDK Usage</h3>
<p>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:</p>
<ul>
<li>
<p>Linux or OS X:</p>
<pre><code>python3
</code></pre>
</li>
<li>
<p>Windows:</p>
<pre><code>python
</code></pre>
</li>
</ul>
<p>The command structure is: </p>
<pre><code>python(3) make.py <action>
</code></pre>
<p>The make.py usage is as follows:</p>
<ol>
<li>
<p>Update the sdk_setting.ini file based on your needs.</p>
<p>Example:</p>
<pre><code>[sdk]
app_name=ping
dev_client_ip=192.168.0.1
dev_client_username=admin
dev_client_password=44224267
</code></pre>
</li>
<li>
<p>Update the UUID in the package.ini file located in the app directory. </p>
<p>Example:</p>
<pre><code>[ping]
uuid=dd91c8ea-cd95-4d9d-b08b-cf62de19684f
</code></pre>
</li>
<li>
<p>Build the application package.</p>
<pre><code>python(3) make.py build
</code></pre>
</li>
<li>
<p>Test connectivity with your device via the status target.</p>
<pre><code>python(3) make.py status
{
"data": {},
"success": true
}
</code></pre>
</li>
<li>
<p>Install the application on your device.</p>
<pre><code>python(3) make.py install
[email protected]'s password:
hspt.tar.gz 100% 1439 1.4KB/s 00:00
Received disconnect from 192.168.0.1: 11: Bye Bye
lost connection
</code></pre>
</li>
<li>
<p>Get the application execution status from your device.</p>
<pre><code>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
}
</code></pre>
</li>
<li>
<p>Uninstall the application from your device.</p>
<pre><code>python(3) make.py uninstall
{
"data": "uninstall 7042c8fd-fe7a-4846-aed1-e3f8d6a1c91c",
"success": true
}
</code></pre>
</li>
</ol>
<p><a name="syslog"></a></p>
<h2>NCOS Syslog for Debugging</h2>
<p>Application debugging is accomplished with the use of debug syslogs. However, the default logging level in the NCOS device is set to <strong>info</strong> so this must be changed to <strong>debug</strong>. 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 <a href="https://cradlepoint.secure.force.com/kb/articles/Support/NCOS-Understanding-Router-Log-Files-and-Features/?q=debug+logs&l=en_US&fs=Search&pn=2">'Understanding Router Log Files'</a>.</p>
<p>Use the following steps to open the device console from the device admin pages:</p>
<pre><code>1. Click System.
2. Click System Control.
3. Click Device Options.
4. Click the Device Console button.
</code></pre>
<p>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. </p>
<pre><code>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)
</code></pre>
<p><a name="devmode"></a></p>
<h2>NCOS Development Mode</h2>
<p>To install an application directly to the device without using NCM, the NCOS device must be placed in <strong>DEV</strong> mode. One would typically debug and test an application using <strong>DEV</strong> mode prior to using NCM for installation. <strong>DEV</strong> mode allows for quicker and easier testing and debugging. Instructions for setting up an NCOS device for <strong>DEV</strong> mode is in Knowledge Base article <a href="https://dev.cradlepoint.com/s/article/ka1380000000EXqAAM/sdk-enable-development-mode">'SDK Enable Developer Mode'</a>. </p>
<p><a name="ncm"></a></p>
<h2>NCM Application Deployment</h2>
<p>NCM is used to securely deploy applications to devices at the group level. If an application <em>tar.gz</em> 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.</p>
<p><a name="sample"></a></p>
<h2>Sample Application Walk Through</h2>
<p>Cradlepoint has provided several sample applications with the SDK which is located <a href="https://github.com/cradlepoint/sdk-samples/releases">here</a>. Any of these apps can be used as a starting point for your application. The application data structure is described <a href="#overview">here</a>. </p>
<p>When using the SDK make.py file, be sure to invoke the proper python command based on your computer OS.</p>
<ul>
<li>
<p>Linux or OS X:</p>
<pre><code>python3
</code></pre>
</li>
<li>
<p>Windows:</p>
<pre><code>python
</code></pre>
</li>
</ul>
<h3>How to Run the Hello World Sample App</h3>
<ol>
<li>Download the SDK and sample apps from <a href="https://github.com/cradlepoint/sdk-samples/releases">here</a>.</li>
<li>Ensure your computer has been setup. See <a href="#setup">Computer Setup Instructions</a>.</li>
<li>Connect the NCOS device to your computer. This can be done by connecting the LAN port of the device to the USB port of your computer via a USB to Ethernet adapter.</li>
<li>Ensure the device is in DEV Mode. See <a href="https://cradlepoint.secure.force.com/kb/articles/Manual/NCOS-sdk-enable-development-mode/?q=dev+mode&l=en_US&fs=Search&pn=1">here</a>.</li>
<li>Enable Debug logs in the device which is very helpful. See <a href="https://cradlepoint.secure.force.com/kb/articles/Support/NCOS-Understanding-Router-Log-Files-and-Features/?q=debug+logs&l=en_US&fs=Search&pn=2">here</a></li>
<li>Open a terminal window.</li>
<li>Change directory to sample_apps. Depending on the version of the SDK that was downloaded, this could be 'sample_apps' or 'sdk_samples-2.1', etc.</li>
<li>
<p>Update the sdk_settings.ini to utilize the hello_world app.</p>
<p>Example:</p>
<pre><code>[sdk]
app_name=hello_world
dev_client_ip=192.168.0.1
dev_client_username=admin
dev_client_password=44224267
</code></pre>
</li>
<li>
<p>Verify device connectivity via:</p>
<pre><code>$ python(3) make.py status
</code></pre>
</li>
<li>
<p>Create the application package</p>
<pre><code>$ python(3) make.py build
</code></pre>
</li>
<li>
<p>Install the application package. <strong>Note:</strong> 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.</p>
<pre><code>$ python(3) make.py install
</code></pre>
</li>
<li>
<p>Check the application status to ensure it has started.</p>
<pre><code>$ python(3) make.py status
</code></pre>
</li>
<li>
<p>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.</p>
</li>
</ol>
<hr />
<p>Published Date: 5/30/2018 1:22:38 PM </p>
<p>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 <a href="mailto:suggestions@cradlepoint.com">suggestions@cradlepoint.com</a>.</p>
</body>
</html>
<!-- This document was created with MarkdownPad, the Markdown editor for Windows (http://markdownpad.com) -->