http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/170decb3/develop/mkdocs/search_index.json
----------------------------------------------------------------------
diff --git a/develop/mkdocs/search_index.json b/develop/mkdocs/search_index.json
index 8c7d2ba..8beca40 100644
--- a/develop/mkdocs/search_index.json
+++ b/develop/mkdocs/search_index.json
@@ -357,7 +357,7 @@
         }, 
         {
             "location": "/os/get_started/project_create/", 
-            "text": "Create Your First Mynewt Project\n\n\nThis page shows how 
to create a Mynewt Project using the \nnewt\n command-line 
tool.\n\n\n\n\nPre-Requisites\n\n\n\n\nNewt:\n\n\nIf you have taken the Docker 
route, you have already installed Newt.\n\n\nIf you have taken the native 
install route, you have to ensure that you have installed the Newt tool 
following the instructions for \nMac\n or \nLinux\n as appropriate, and that 
the \nnewt\n command is in your system path. \n\n\n\n\n\n\nYou must have 
Internet connectivity to fetch remote Mynewt components.\n\n\nYou must 
\ninstall the compiler tools\n to \nsupport native compiling to build the 
project this tutorial creates.  \n\n\n\n\n\n\nNewt New\n\n\nChoose a project 
name. For this tutorial we will call this project \nmyproj\n.\nEnter the \nnewt 
new myproj\n command. \n\n\n$ newt new myproj\nDownloading project skeleton 
from apache/incubator-mynewt-blinky...\nInstalling skeleton in 
myproj...\nProject myproj successfully crea
 ted.\n\n\n\n\n\n\n\nNewt populates this new project with a base skeleton of a 
new Apache Mynewt \nproject.  It has the following structure. \n\n\nNote\n: If 
you do not have \ntree\n, install it by running \nbrew install tree\n.\n\n\n$ 
cd myproj\n$ tree \n.\n\u251c\u2500\u2500 DISCLAIMER\n\u251c\u2500\u2500 
LICENSE\n\u251c\u2500\u2500 NOTICE\n\u251c\u2500\u2500 
README.md\n\u251c\u2500\u2500 apps\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
blinky\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 pkg.yml\n\u2502\u00a0\u00a0   
  \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 
main.c\n\u251c\u2500\u2500 project.yml\n\u2514\u2500\u2500 targets\n    
\u251c\u2500\u2500 my_blinky_sim\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 
pkg.yml\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 target.yml\n    
\u2514\u2500\u2500 unittest\n        \u251c\u2500\u2500 pkg.yml\n        
\u2514\u2500\u2500 target.yml\n\n6 directories, 11 files\n\n\n\n\n\n\n\nThe 
Newt tool has installed the base files for a
  project comprising the following:\n\n\n\n\nThe file \nproject.yml\n contains 
the repository list that the project uses to fetch\nits packages. Your project 
is a collection of repositories.  In this case, the project just\ncomprises the 
core mynewt repository.  Later you will add more repositories\nto include other 
mynewt components.\n\n\nThe file \napps/blinky/pkg.yml\n contains the 
description of your application\nand its package dependencies.\n\n\nA 
\ntarget\n directory containing \nmy_blinky_sim\n, a target descriptor used 
to\nbuild a version of myproj.  Use \nnewt target show\n to see available build 
\ntargets.\n\n\nA non-buildable target called \nunittest\n.  This is used 
internally by \nnewt\n and is not a formal build target.\n\n\n\n\nNOTE:\n The 
actual code and package files are not installed \n(except the template for 
\nmain.c\n).  See the next step for installing the packages.\n\n\nNOTE:\n By 
default newt uses the code in the master branch. This is the latest stable\ncode
  for newt. If you need to use a different branch, you can set this in the 
project.yml\nfile. \n\n\nrepository.apache-mynewt-core:\n    type: github\n    
vers: 0-latest\n    user: apache\n    repo: 
incubator-mynewt-core\n\n\n\n\n\nChanging to 0-dev will put you on the develop 
branch. \nThe Develop Branch may not be stable and \nyou may encounter bugs or 
other problems.\n\n\n\n\nNewt Install\n\n\nOnce you've switched into your new 
project's directory, the next step is to fetch\nany dependencies this project 
has.  By default, all Newt projects rely on a\nsingle remote repository, 
apache-mynewt-core.  The \nnewt install\n command will\nfetch this 
repository.\n\n\n$ newt install\napache-mynewt-core\n\n\n\n\n\nNOTE:\n 
\napache-mynewt-core\n may take a while to download.  To see progress,\nuse the 
\n-v\n (verbose) option to install. \n\n\n\n\nOnce \nnewt install\n has 
successfully finished, the contents of \napache-mynewt-core\n will have been 
downloaded into your local directory.  You can
  view them by issuing the following commands in the base directory of the new 
project. The actual output will depend on what is in the latest 'master' branch 
you have pulled from.\n\n\n$ tree -L 2 
repos/apache-mynewt-core/\nrepos/apache-mynewt-core/\nrepos/apache-mynewt-core/\n\u251c\u2500\u2500
 CODING_STANDARDS.md\n\u251c\u2500\u2500 DISCLAIMER\n\u251c\u2500\u2500 
LICENSE\n\u251c\u2500\u2500 NOTICE\n\u251c\u2500\u2500 
README.md\n\u251c\u2500\u2500 RELEASE_NOTES.md\n\u251c\u2500\u2500 
apps\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 blecent\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 blehci\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
bleprph\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 bleprph_oic\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 bletest\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
bletiny\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 bleuart\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 boot\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
ffs2native\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
ocf_sample\n\u2502\u00a0\u00a0 \u251c
 \u2500\u2500 slinky\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
slinky_oic\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 spitest\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 splitty\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
test\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 timtest\n\u251c\u2500\u2500 
boot\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 boot_serial\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 bootutil\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
split\n\u251c\u2500\u2500 compiler\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
arm-none-eabi-m0\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
arm-none-eabi-m4\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
gdbmacros\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 sim\n\u251c\u2500\u2500 
crypto\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 mbedtls\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 tinycrypt\n\u251c\u2500\u2500 docs\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 doxygen.xml\n\u251c\u2500\u2500 encoding\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 base64\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
cborattr\n\u2502\u00a0\u00a
 0 \u251c\u2500\u2500 json\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
tinycbor\n\u251c\u2500\u2500 fs\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
fcb\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 fs\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 nffs\n\u251c\u2500\u2500 hw\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 bsp\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
cmsis-core\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 drivers\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 hal\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
mcu\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 scripts\n\u251c\u2500\u2500 
kernel\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 os\n\u251c\u2500\u2500 
libc\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 baselibc\n\u251c\u2500\u2500 
mgmt\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 imgmgr\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 mgmt\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
newtmgr\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 oicmgr\n\u251c\u2500\u2500 
net\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 ip\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 nimble\n\u2502\u00a0
 \u00a0 \u251c\u2500\u2500 oic\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
wifi\n\u251c\u2500\u2500 project.yml\n\u251c\u2500\u2500 
repository.yml\n\u251c\u2500\u2500 sys\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
config\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 console\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 coredump\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
defs\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 flash_map\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 id\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
log\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 mfg\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 reboot\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
shell\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 stats\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 sysinit\n\u251c\u2500\u2500 targets\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 unittest\n\u251c\u2500\u2500 test\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 crash_test\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
flash_test\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 runtest\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 
 testreport\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 testutil\n\u251c\u2500\u2500 
time\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 datetime\n\u2514\u2500\u2500 util\n 
   \u251c\u2500\u2500 cbmem\n    \u251c\u2500\u2500 crc\n    \u2514\u2500\u2500 
mem\n\n87 directories, 9 files\n\n\n\n\n\nAs you can see, the core of the 
Apache Mynewt operating system has been brought \ninto your local directory. 
\n\n\n\n\nTest the project's packages\n\n\nYou have already built your first 
basic project. You can ask Newt to execute the unit tests in a package. For 
example, to test the \nlibs/os\n package in the \napache-mynewt-core\n repo, 
call newt as shown below.\n\n\n$ newt test 
@apache-mynewt-core/sys/config\nTesting package 
@apache-mynewt-core/sys/config/test-fcb\nCompiling bootutil_misc.c\nCompiling 
image_ec.c\nCompiling image_rsa.c\nCompiling 
image_validate.c\n\nsnip\n\n\n\n\n\n\nNOTE:\n If you've installed the latest 
gcc using homebrew on your Mac, you will likely be running gcc-6. Make sure you 
have a
 djusted the compiler.yml configuration to reflect that as noted in \nNative 
Install Option\n. You can choose to downgrade to gcc-5 in order to use the 
default gcc compiler configuration for MyNewt.\n\n\n$ brew uninstall gcc-6\n$ 
brew link gcc-5\n\n\n\n\n\n\n\nTo test all the packages in a project, specify 
\nall\n instead of the package name.\n\n\n$ newt test all\n...lots of compiling 
and testing...\n...about 2 minutes later ...\nCompiling 
mn_sock_test.c\nArchiving mn_socket.a\nLinking test_mn_socket\nExecuting test: 
/Users/dsimmons/myproj/bin/unittest/sys/mn_socket/test_mn_socket\nPassed tests: 
[libs/json libs/util libs/mbedtls net/nimble/host hw/hal libs/bootutil sys/log 
sys/config sys/fcb fs/nffs libs/os libs/boot_serial sys/mn_socket]\nAll tests 
passed\n\n\n\n\n\n\n\nBuild the Project\n\n\nTo build and run your new 
application, simply issue the following command:\n\n\n$ newt build 
my_blinky_sim \nBuilding target targets/my_blinky_sim\nCompiling 
main.c\nArchiving blinky.a\nCompili
 ng hal_bsp.c\nCompiling os_bsp.c\nCompiling sbrk.c\nArchiving 
native.a\nCompiling flash_map.c\n\nsnip\n\nLinking blinky.elf\nApp successfully 
built: 
/Users/dsimmons/myproj/bin/my_blinky_sim/apps/blinky/blinky.elf\n\n\n\n\n\n\n\nRun
 the Project\n\n\nYou can run the simulated version of your project and see the 
simulated LED\nblink.\n\n\n$ 
./bin/my_blinky_sim/apps/blinky/blinky.elf\nhal_gpio set pin  1 to 
0\n\n\n\n\n\n\n\nComplete\n\n\nCongratulations, you have created your first 
project!  The blinky application\nis not terribly exciting when it is run in 
the simulator, as there is no LED to\nblink.  Apache Mynewt has a lot more 
functionality than just running simulated\napplications.  It provides all the 
features you'll need to cross-compile your\napplication, run it on real 
hardware and develop a full featured application.\n\n\nIf you're interested in 
learning more, a good next step is to dig in to one of\nthe \ntutorials\n and 
get a Mynewt project running on real hardware.\n\n\nHap
 py Hacking!", 
+            "text": "Create Your First Mynewt Project\n\n\nThis page shows how 
to create a Mynewt Project using the \nnewt\n command-line 
tool.\n\n\n\n\nPre-Requisites\n\n\n\n\nNewt:\n\n\nIf you have taken the Docker 
route, you have already installed Newt.\n\n\nIf you have taken the native 
install route, you have to ensure that you have installed the Newt tool 
following the instructions for \nMac\n or \nLinux\n as appropriate, and that 
the \nnewt\n command is in your system path. \n\n\n\n\n\n\nYou must have 
Internet connectivity to fetch remote Mynewt components.\n\n\nYou must 
\ninstall the compiler tools\n to \nsupport native compiling to build the 
project this tutorial creates.  \n\n\n\n\n\n\nNewt New\n\n\nChoose a project 
name. For this tutorial we will call this project \nmyproj\n.\nEnter the \nnewt 
new myproj\n command. \n\n\n$ newt new myproj\nDownloading project skeleton 
from apache/incubator-mynewt-blinky...\nInstalling skeleton in 
myproj...\nProject myproj successfully crea
 ted.\n\n\n\n\n\n\n\nNewt populates this new project with a base skeleton of a 
new Apache Mynewt \nproject.  It has the following structure. \n\n\nNote\n: If 
you do not have \ntree\n, install it by running \nbrew install tree\n.\n\n\n$ 
cd myproj\n$ tree \n.\n\u251c\u2500\u2500 DISCLAIMER\n\u251c\u2500\u2500 
LICENSE\n\u251c\u2500\u2500 NOTICE\n\u251c\u2500\u2500 
README.md\n\u251c\u2500\u2500 apps\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
blinky\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 pkg.yml\n\u2502\u00a0\u00a0   
  \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 
main.c\n\u251c\u2500\u2500 project.yml\n\u2514\u2500\u2500 targets\n    
\u251c\u2500\u2500 my_blinky_sim\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 
pkg.yml\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 target.yml\n    
\u2514\u2500\u2500 unittest\n        \u251c\u2500\u2500 pkg.yml\n        
\u2514\u2500\u2500 target.yml\n\n6 directories, 11 files\n\n\n\n\n\n\n\nThe 
Newt tool has installed the base files for a
  project comprising the following:\n\n\n\n\nThe file \nproject.yml\n contains 
the repository list that the project uses to fetch\nits packages. Your project 
is a collection of repositories.  In this case, the project just\ncomprises the 
core mynewt repository.  Later you will add more repositories\nto include other 
mynewt components.\n\n\nThe file \napps/blinky/pkg.yml\n contains the 
description of your application\nand its package dependencies.\n\n\nA 
\ntarget\n directory containing \nmy_blinky_sim\n, a target descriptor used 
to\nbuild a version of myproj.  Use \nnewt target show\n to see available build 
\ntargets.\n\n\nA non-buildable target called \nunittest\n.  This is used 
internally by \nnewt\n and is not a formal build target.\n\n\n\n\nNOTE:\n The 
actual code and package files are not installed \n(except the template for 
\nmain.c\n).  See the next step for installing the packages.\n\n\nNOTE:\n By 
default newt uses the code in the master branch. This is the latest stable\ncode
  for newt. If you need to use a different branch, you can set this in the 
project.yml\nfile. \n\n\nrepository.apache-mynewt-core:\n    type: github\n    
vers: 0-latest\n    user: apache\n    repo: 
incubator-mynewt-core\n\n\n\n\n\nChanging to 0-dev will put you on the develop 
branch. \nThe Develop Branch may not be stable and \nyou may encounter bugs or 
other problems.\n\n\n\n\nNewt Install\n\n\nOnce you've switched into your new 
project's directory, the next step is to fetch\nany dependencies this project 
has.  By default, all Newt projects rely on a\nsingle remote repository, 
apache-mynewt-core.  The \nnewt install\n command will\nfetch this 
repository.\n\n\n$ newt install\napache-mynewt-core\n\n\n\n\n\nNOTE:\n 
\napache-mynewt-core\n may take a while to download.  To see progress,\nuse the 
\n-v\n (verbose) option to install. \n\n\n\n\nOnce \nnewt install\n has 
successfully finished, the contents of \napache-mynewt-core\n will have been 
downloaded into your local directory.  You can
  view them by issuing the following commands in the base directory of the new 
project. The actual output will depend on what is in the latest 'master' branch 
you have pulled from.\n\n\n$ tree -L 2 
repos/apache-mynewt-core/\nrepos/apache-mynewt-core/\nrepos/apache-mynewt-core/\n\u251c\u2500\u2500
 CODING_STANDARDS.md\n\u251c\u2500\u2500 DISCLAIMER\n\u251c\u2500\u2500 
LICENSE\n\u251c\u2500\u2500 NOTICE\n\u251c\u2500\u2500 
README.md\n\u251c\u2500\u2500 RELEASE_NOTES.md\n\u251c\u2500\u2500 
apps\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 blecent\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 blehci\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
bleprph\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 bleprph_oic\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 bletest\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
bletiny\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 bleuart\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 boot\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
ffs2native\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
ocf_sample\n\u2502\u00a0\u00a0 \u251c
 \u2500\u2500 slinky\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
slinky_oic\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 spitest\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 splitty\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
test\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 timtest\n\u251c\u2500\u2500 
boot\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 boot_serial\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 bootutil\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
split\n\u251c\u2500\u2500 compiler\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
arm-none-eabi-m0\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
arm-none-eabi-m4\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
gdbmacros\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 sim\n\u251c\u2500\u2500 
crypto\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 mbedtls\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 tinycrypt\n\u251c\u2500\u2500 docs\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 doxygen.xml\n\u251c\u2500\u2500 encoding\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 base64\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
cborattr\n\u2502\u00a0\u00a
 0 \u251c\u2500\u2500 json\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
tinycbor\n\u251c\u2500\u2500 fs\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
fcb\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 fs\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 nffs\n\u251c\u2500\u2500 hw\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 bsp\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
cmsis-core\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 drivers\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 hal\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
mcu\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 scripts\n\u251c\u2500\u2500 
kernel\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 os\n\u251c\u2500\u2500 
libc\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 baselibc\n\u251c\u2500\u2500 
mgmt\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 imgmgr\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 mgmt\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
newtmgr\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 oicmgr\n\u251c\u2500\u2500 
net\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 ip\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 nimble\n\u2502\u00a0
 \u00a0 \u251c\u2500\u2500 oic\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 
wifi\n\u251c\u2500\u2500 project.yml\n\u251c\u2500\u2500 
repository.yml\n\u251c\u2500\u2500 sys\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
config\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 console\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 coredump\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
defs\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 flash_map\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 id\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
log\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 mfg\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 reboot\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
shell\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 stats\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 sysinit\n\u251c\u2500\u2500 targets\n\u2502\u00a0\u00a0 
\u2514\u2500\u2500 unittest\n\u251c\u2500\u2500 test\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 crash_test\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 
flash_test\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 runtest\n\u2502\u00a0\u00a0 
\u251c\u2500\u2500 
 testreport\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 testutil\n\u251c\u2500\u2500 
time\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 datetime\n\u2514\u2500\u2500 util\n 
   \u251c\u2500\u2500 cbmem\n    \u251c\u2500\u2500 crc\n    \u2514\u2500\u2500 
mem\n\n87 directories, 9 files\n\n\n\n\n\nAs you can see, the core of the 
Apache Mynewt operating system has been brought \ninto your local directory. 
\n\n\n\n\nTest the project's packages\n\n\nYou have already built your first 
basic project. You can ask Newt to execute the unit tests in a package. For 
example, to test the \nlibs/os\n package in the \napache-mynewt-core\n repo, 
call newt as shown below.\n\n\n$ newt test 
@apache-mynewt-core/sys/config\nTesting package 
@apache-mynewt-core/sys/config/test-fcb\nCompiling bootutil_misc.c\nCompiling 
image_ec.c\nCompiling image_rsa.c\nCompiling 
image_validate.c\n\nsnip\n\n\n\n\n\n\nNOTE:\n If you've installed the latest 
gcc using homebrew on your Mac, you will likely be running gcc-6. Make sure you 
have a
 djusted the compiler.yml configuration to reflect that as noted in \nNative 
Install Option\n. You can choose to downgrade to gcc-5 in order to use the 
default gcc compiler configuration for MyNewt.\n\n\nNOTE\n If you are running 
the standard gcc for 64-bit machines, it does not support 32-bit. In that case 
you will see compilation errors. You need to install multiboot gcc (e.g. 
gcc-multilib if you running on a 64-bit Ubuntu).\n\n\n$ brew uninstall gcc-6\n$ 
brew link gcc-5\n\n\n\n\n\n\n\nTo test all the packages in a project, specify 
\nall\n instead of the package name.\n\n\n$ newt test all\n...lots of compiling 
and testing...\n...about 2 minutes later ...\nCompiling 
mn_sock_test.c\nArchiving mn_socket.a\nLinking test_mn_socket\nExecuting test: 
/Users/dsimmons/myproj/bin/unittest/sys/mn_socket/test_mn_socket\nPassed tests: 
[libs/json libs/util libs/mbedtls net/nimble/host hw/hal libs/bootutil sys/log 
sys/config sys/fcb fs/nffs libs/os libs/boot_serial sys/mn_socket]\nAll tests 
passed
 \n\n\n\n\n\n\n\nBuild the Project\n\n\nTo build and run your new application, 
simply issue the following command:\n\n\n$ newt build my_blinky_sim \nBuilding 
target targets/my_blinky_sim\nCompiling main.c\nArchiving blinky.a\nCompiling 
hal_bsp.c\nCompiling os_bsp.c\nCompiling sbrk.c\nArchiving native.a\nCompiling 
flash_map.c\n\nsnip\n\nLinking blinky.elf\nApp successfully built: 
/Users/dsimmons/myproj/bin/my_blinky_sim/apps/blinky/blinky.elf\n\n\n\n\n\n\n\nRun
 the Project\n\n\nYou can run the simulated version of your project and see the 
simulated LED\nblink.\n\n\n$ 
./bin/my_blinky_sim/apps/blinky/blinky.elf\nhal_gpio set pin  1 to 
0\n\n\n\n\n\n\n\nComplete\n\n\nCongratulations, you have created your first 
project!  The blinky application\nis not terribly exciting when it is run in 
the simulator, as there is no LED to\nblink.  Apache Mynewt has a lot more 
functionality than just running simulated\napplications.  It provides all the 
features you'll need to cross-compile your\napplicat
 ion, run it on real hardware and develop a full featured application.\n\n\nIf 
you're interested in learning more, a good next step is to dig in to one 
of\nthe \ntutorials\n and get a Mynewt project running on real 
hardware.\n\n\nHappy Hacking!", 
             "title": "Create Your First Project"
         }, 
         {
@@ -382,7 +382,7 @@
         }, 
         {
             "location": 
"/os/get_started/project_create/#test-the-projects-packages", 
-            "text": "You have already built your first basic project. You can 
ask Newt to execute the unit tests in a package. For example, to test the  
libs/os  package in the  apache-mynewt-core  repo, call newt as shown below.  $ 
newt test @apache-mynewt-core/sys/config\nTesting package 
@apache-mynewt-core/sys/config/test-fcb\nCompiling bootutil_misc.c\nCompiling 
image_ec.c\nCompiling image_rsa.c\nCompiling image_validate.c snip   NOTE:  If 
you've installed the latest gcc using homebrew on your Mac, you will likely be 
running gcc-6. Make sure you have adjusted the compiler.yml configuration to 
reflect that as noted in  Native Install Option . You can choose to downgrade 
to gcc-5 in order to use the default gcc compiler configuration for MyNewt.  $ 
brew uninstall gcc-6\n$ brew link gcc-5   To test all the packages in a 
project, specify  all  instead of the package name.  $ newt test all\n...lots 
of compiling and testing...\n...about 2 minutes later ...\nCompiling 
mn_sock_test.c\nA
 rchiving mn_socket.a\nLinking test_mn_socket\nExecuting test: 
/Users/dsimmons/myproj/bin/unittest/sys/mn_socket/test_mn_socket\nPassed tests: 
[libs/json libs/util libs/mbedtls net/nimble/host hw/hal libs/bootutil sys/log 
sys/config sys/fcb fs/nffs libs/os libs/boot_serial sys/mn_socket]\nAll tests 
passed", 
+            "text": "You have already built your first basic project. You can 
ask Newt to execute the unit tests in a package. For example, to test the  
libs/os  package in the  apache-mynewt-core  repo, call newt as shown below.  $ 
newt test @apache-mynewt-core/sys/config\nTesting package 
@apache-mynewt-core/sys/config/test-fcb\nCompiling bootutil_misc.c\nCompiling 
image_ec.c\nCompiling image_rsa.c\nCompiling image_validate.c snip   NOTE:  If 
you've installed the latest gcc using homebrew on your Mac, you will likely be 
running gcc-6. Make sure you have adjusted the compiler.yml configuration to 
reflect that as noted in  Native Install Option . You can choose to downgrade 
to gcc-5 in order to use the default gcc compiler configuration for MyNewt.  
NOTE  If you are running the standard gcc for 64-bit machines, it does not 
support 32-bit. In that case you will see compilation errors. You need to 
install multiboot gcc (e.g. gcc-multilib if you running on a 64-bit Ubuntu).  $ 
brew unin
 stall gcc-6\n$ brew link gcc-5   To test all the packages in a project, 
specify  all  instead of the package name.  $ newt test all\n...lots of 
compiling and testing...\n...about 2 minutes later ...\nCompiling 
mn_sock_test.c\nArchiving mn_socket.a\nLinking test_mn_socket\nExecuting test: 
/Users/dsimmons/myproj/bin/unittest/sys/mn_socket/test_mn_socket\nPassed tests: 
[libs/json libs/util libs/mbedtls net/nimble/host hw/hal libs/bootutil sys/log 
sys/config sys/fcb fs/nffs libs/os libs/boot_serial sys/mn_socket]\nAll tests 
passed", 
             "title": "Test the project's packages"
         }, 
         {
@@ -1267,8 +1267,8 @@
         }, 
         {
             "location": "/os/tutorials/air_quality_sensor/", 
-            "text": "Air quality sensor project\n\n\nSetting up source tree 
for stuff you need\n\n\nTo start with, you need to create a new project under 
which you will do this development. So you type in:\n\n\n    $ mkdir 
$HOME/src\n    $ cd $HOME/src\n    $ newt new air_quality\n\n\n\n\n\nLet's say 
you are using STM32F3discovery board as the platform. You know you need the 
board support package for that hardware. You can look up its location, add it 
your project, and fetch that along with the core OS components.\n\n\nTo make 
this happen, you'll need to modify the project.yml in your project's root 
directory.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ emacs project.yml \n\n 
   [user@IsMyLaptop:~/src/air_quality]$ cat project.yml\n    project.name: 
\nair_quality\n\n\n    project.repositories:\n        - apache-mynewt-core\n    
    - mynewt_stm32f3\n\n    # Use github\ns distribution mechanism for core ASF 
libraries.\n    # This provides mirroring automatically for us.\n    #\n   
  repository.apache-mynewt-core:\n        type: github\n        vers: 
0-latest\n        user: apache\n        repo: incubator-mynewt-core\n\n    
repository.mynewt_stm32f3:\n        type: github\n        vers: 0-latest\n      
  user: runtimeinc\n        repo: mynewt_stm32f3\n    
[user@IsMyLaptop:~/src/air_quality]$ newt install\n    apache-mynewt-core\n    
mynewt_stm32f3\n    [user@IsMyLaptop:~/src/air_quality]$ ls repos/\n    
apache-mynewt-core  mynewt_stm32f3\n\n\n\n\n\nGood. You want to make sure you 
have all the needed bits for supporting your board; so you decide to build the 
blinky project for the platform first.\n\n\nNow create a target for it and 
build it. Easiest way to proceed is to copy the existing target for blinky, and 
modify it to build for STM32F3Discovery 
board.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target copy my_blinky_sim 
blink_f3\nTarget successfully copied; targets/my_blinky_sim --\n 
targets/blink_f3\n[user@IsMyLaptop:~/src/air_quality]$ newt target set 
 blink_f3 bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget targets/blink_f3 
successfully set target.bsp to 
@mynewt_stm32f3/hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ 
newt build blink_f3\nCompiling hal_bsp.c\n...\nLinking blinky.elf\nApp 
successfully built: 
/Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.elf\n\n\n\n\n\nGood.\n\n\nYou
 know that this platform uses bootloader, which means you have to create a 
target for that too.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
create boot_f3\nTarget targets/boot_f3 successfully 
created\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
show\n@apache-mynewt-core/targets/unittest\n    bsp=hw/bsp/native\n    
build_profile=debug\n    compiler=compiler/sim\ntargets/blink_f3\n    
app=apps/blinky\n    bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\n    
build_profile=debug\ntargets/boot_f3\ntargets/my_blinky_sim\n    
app=apps/blinky\n    bsp=@apache-mynewt-core/hw/bsp/native\n    
build_profile=debug\n[user@IsM
 yLaptop:~/src/air_quality]$ newt target set boot_f3 
bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget targets/boot_f3 
successfully set target.bsp to 
@mynewt_stm32f3/hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ 
newt target set boot_f3 app=@apache-mynewt-core/apps/boot\nTarget 
targets/boot_f3 successfully set target.app to 
@apache-mynewt-core/apps/boot\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
set boot_f3 build_profile=optimized\nTarget targets/boot_f3 successfully set 
target.build_profile to optimized\n\n\n\n\n\nAnd then build it, and load it 
onto the board.\n\n\nnewt build boot_f3\n....\nLinking boot.elf\nApp 
successfully built: 
/Users/user/src/air_quality/bin/boot_f3/apps/boot/boot.elf\n[user@IsMyLaptop:~/src/air_quality]\n$
 newt load boot_f3\n\n\n\n\n\nNext you must download the targets to board, and 
see that the LED actually blinks. You plug in the STM32F3 discovery board to 
your laptop, and say:\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt load blink
 _f3\nDownloading 
/Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img to 
0x08009000\nOpen On-Chip Debugger 0.9.0 (2015-05-28-12:05)\n....\nxPSR: 
0x01000000 pc: 0x0800026c msp: 0x10002000\nauto erase enabled\nError: couldn\nt 
open /Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img\n\nError: 
exit status 1\n\nload - Load app image to target for 
\ntarget-name\n.\n\nUsage:\n  newt load [flags]\n\nExamples:\n  newt load 
\ntarget-name\n\n\n\nGlobal Flags:\n  -l, --loglevel string   Log level, 
defaults to WARN. (default \nWARN\n)\n  -o, --outfile string    Filename to tee 
log output to\n  -q, --quiet             Be quiet; only display error output.\n 
 -s, --silent            Be silent; don\nt output anything.\n  -v, --verbose    
       Enable verbose output when executing commands.\nexit status 
1\n\n\n\n\n\nAh. Forgot to create an image out of the blinky binary. Note that 
every time you want to build and load a new firmware image to target board, you 
need to run 'cre
 ate-image' on it.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt create-image 
blink_f3 0.0.1\nApp image successfully generated: 
/Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img\nBuild 
manifest: 
/Users/user/src/air_quality/bin/blink_f3/apps/blinky/manifest.json\n[user@IsMyLaptop:~/src/air_quality]$
 newt load blink_f3 0.0.1\n\n\n\n\n\nAnd it's blinking.\n\n\nShortcut for doing 
build/create-image/load/debug steps all in one is 'newt run' command. Check out 
the usage from command line help.\n\n\nCreate test project\n\n\nNow that you 
have your system setup, you can start creating your own stuff.\nFirst you want 
to create a project for yourself - you can start by getting project template 
from blinky, as it pretty much has what you want.\n\n\n    
[user@IsMyLaptop:~/src/air_quality]$ mkdir apps/air_quality\n    
[user@IsMyLaptop:~/src/air_quality]$ cp 
repos/apache-mynewt-core/apps/blinky/pkg.yml apps/air_quality/\n    
[user@IsMyLaptop:~/src/air_quality]$ mkdir apps/air_quality
 /src\n    [user@IsMyLaptop:~/src/air_quality]$ cp 
repos/apache-mynewt-core/apps/blinky/src/main.c 
apps/air_quality/src/\n\n\n\n\n\nThen you modify the apps/air_quality/pkg.yml 
for air_quality in order to change the \npkg.name\n to be 
\napps/air_quality\n.\nYou also need to point the package dependencies to point 
to packages in apache-mynewt-core repository.\nSTM32F3discovery board has 
limited amount of memory, so you must also switch your libc to be baselibc, 
instead of the standard one.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
apps/air_quality/pkg.yml\npkg.name: apps/air_quality\npkg.type: 
app\npkg.description: Air quality sensor test\npkg.keywords:\n\npkg.deps:\n    
- \n@apache-mynewt-core/libs/console/full\n\n    - 
\n@apache-mynewt-core/libs/newtmgr\n\n    - \n@apache-mynewt-core/libs/os\n\n   
 - \n@apache-mynewt-core/libs/shell\n\n    - 
\n@apache-mynewt-core/sys/config\n\n    - \n@apache-mynewt-core/sys/log\n\n    
- \n@apache-mynewt-core/sys/stats\n\n    - \n@apache-mynewt-
 core/libs/baselibc\n\n\n\n\n\n\nAnd create a target for 
it:\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target create air_q\nTarget 
targets/air_q successfully created\n[user@IsMyLaptop:~/src/air_quality]$ newt 
target set air_q bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget 
targets/air_q successfully set target.bsp to 
@mynewt_stm32f3/hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ 
newt target set air_q app=apps/air_quality \nTarget targets/air_q successfully 
set target.app to apps/air_quality\n[user@IsMyLaptop:~/src/air_quality]$ newt 
target set air_q build_profile=debug\nTarget targets/air_q successfully set 
target.build_profile to debug\n[user@IsMyLaptop:~/src/air_quality]$ newt build 
air_q\n ....\nLinking air_quality.elf\nApp successfully built: 
/Users/user/src/air_quality/bin/air_q/apps/air_quality/air_quality.elf\n\n\n\n\n\nCreate
 packages for drivers\n\n\nOne of the sensors you want to enable is SenseAir 
K30, which will connect to the board over serial por
 t.\nTo start development of the driver, you first need to create a package 
description for it, and add stubs for sources.\n\n\nSo you add few files. 
pkg.yml to describe the driver, and then header stub followed by source 
stub.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
libs/my_drivers/senseair/pkg.yml\n\n\n\n\n\n#\n\n\n# Licensed to the Apache 
Software Foundation (ASF) under one\n\n\n# or more contributor license 
agreements.  See the NOTICE file\n\n\n# distributed with this work for 
additional information\n\n\n# regarding copyright ownership.  The ASF licenses 
this file\n\n\n# to you under the Apache License, Version 2.0 (the\n\n\n# 
\nLicense\n); you may not use this file except in compliance\n\n\n# with the 
License.  You may obtain a copy of the License at\n\n\n# \n\n\n#  
http:\n//www.apache.org/licenses/LICENSE-2.0\n\n\n#\n\n\n# Unless required by 
applicable law or agreed to in writing,\n\n\n# software distributed under the 
License is distributed on an\n\n\n# \nAS IS\n BASIS, W
 ITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n# KIND, either express or implied. 
 See the License for the\n\n\n# specific language governing permissions and 
limitations\n\n\n# under the License.\n\n\n#\n\n\npkg\n.\nname\n: 
\nlibs/my_drivers/senseair\n\n\npkg\n.\ndeps\n:\n    \n-\n 
\n@apache-mynewt-core/hw/hal\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ 
cat libs/my_drivers/senseair/include/senseair/senseair.h\n\n\n\n\n\n/*\n\n\n * 
Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more 
contributor license agreements.  See the NOTICE file\n\n\n * distributed with 
this work for additional information\n\n\n * regarding copyright ownership.  
The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 
(the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n 
* with the License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  
http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by 
applicable l
 aw or agreed to in writing,\n\n\n * software distributed under the License is 
distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * 
specific language governing permissions and limitations\n\n\n * under the 
License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define 
_SENSEAIR_H_\n\n\n\nvoid\n \nsenseair_init\n(\nvoid\n);\n\n\n#endif \n/* 
_SENSEAIR_H_ */\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
libs/my_drivers/senseair/src/senseair.c\n\n\n\n\n\n/**\n\n\n * Licensed to the 
Apache Software Foundation (ASF) under one\n\n\n * or more contributor license 
agreements.  See the NOTICE file\n\n\n * distributed with this work for 
additional information\n\n\n * regarding copyright ownership.  The ASF licenses 
this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * 
\nLicense\n); you may not use this file except in compliance\n\n\n * with the 
License.  You may obtain 
 a copy of the License at\n\n\n * \n\n\n *  
http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by 
applicable law or agreed to in writing,\n\n\n * software distributed under the 
License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for 
the\n\n\n * specific language governing permissions and limitations\n\n\n * 
under the License.\n\n\n 
*/\n\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n}\n\n\n\n\n\nAnd add 
dependency to this package in my project yml file.\n\n\nHere's from 
apps/air_quality/pkg.yml\n\n\npkg.name: apps/air_quality\npkg.type: 
app\npkg.description: Air quality sensor test\npkg.keywords:\n\npkg.deps:\n    
- \n@apache-mynewt-core/libs/console/full\n\n    - 
\n@apache-mynewt-core/libs/newtmgr\n\n    - \n@apache-mynewt-core/libs/os\n\n   
 - \n@apache-mynewt-core/libs/shell\n\n    - 
\n@apache-mynewt-core/sys/config\n\n    - \n@apache-mynewt-core/sys/log\n\n   
  - \n@apache-mynewt-core/sys/stats\n\n    - 
\n@apache-mynewt-core/libs/baselibc\n\n    - 
libs/my_drivers/senseair\n\n\n\n\n\nAnd add a call to your main() to initialize 
this driver.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ diff 
project/blinky/src/main.c project/air_quality/src/main.c\n    28a29\n    \n 
#include \nsenseair/senseair.h\n\n    190a192\n    \n senseair_init();\n    
[user@IsMyLaptop:~/src/air_quality\n\n\n\n\n\nAnd then build it to make sure 
all goes well.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt build 
air_q\nCompiling senseair.c\nArchiving senseair.a\nLinking air_quality.elf\nApp 
successfully built: 
/Users/user/src/air_quality/bin/air_q/apps/air_quality/air_quality.elf\n\n\n\n\n\nAll
 looks good.\n\n\nAdd CLI commands for testing drivers\n\n\nWhile developing 
the driver, you want to issue operations from console asking it to do stuff. 
The way to do this is to register your command handler with shell. Whenever 
your custom command is issued, you can respond to it
 .\n\n\nThe way you do this is first adding a dependency to shell package for 
your senseair driver. So you change libs/my_drivers/senseair/pkg.yml to have 
the following:\n\n\npkg.name: libs/my_drivers/senseair\npkg.deps:\n    - 
\n@apache-mynewt-core/hw/hal\n\n    - 
\n@apache-mynewt-core/libs/shell\n\n\n\n\n\n\nAnd then register your shell 
command in \nsenseair_init()\n.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
libs/my_drivers/senseair/src/senseair.c\n ....\n\n\n\n\n\n#include 
\nshell/shell.h\n\n\n#include \nconsole/console.h\n\n\n\nstatic\n \nint\n 
\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n 
\nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n 
\nsenseair\n,\n    .\nsc_cmd_func\n \n=\n 
\nsenseair_shell_func\n,\n};\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n    
\nint\n \nrc\n;\n\n    \nrc\n \n=\n \nshell_cmd_register\n(\nsenseair_cmd\n);\n 
   \nassert\n(\nrc\n \n==\n \n0\n);\n}\n\n\nstatic\n 
\nint\n\n\nsenseair_shell_func\n(\ni
 nt\n \nargc\n, \nchar\n \n**argv\n)\n{\n    \nconsole_printf\n(\nYay! Somebody 
called!\\n\n);\n    \nreturn\n \n0\n;\n}\n\n\n\n\n\nThen you build this, 
download to target, and start minicom on your console port.\n\n\nYou'll need to 
wire up your Board to a Serial converter first. On the STM32F3-Discovery Board 
pin PA9 is TX and pin PA10 is RX so wire PA9 to RX on your serial board, and 
PA10 to TX on your serial board.\n\n\n    [user@IsMyLaptop:~]$ minicom -D 
/dev/tty.usbserial-AH02MIE2\n\n\n    Welcome to minicom 2.7\n\n    OPTIONS: \n  
  Compiled on Oct 12 2015, 07:48:30.\n    Port /dev/tty.usbserial-AH02MIE2, 
13:44:40\n\n    Press CTRL-X Z for help on special keys\n\n    ?\n    
141964:Unknown command ?\n    ?\n    143804:config   log     echo    ?       
tasks   mempools \n    143806:stat     senseair \n    senseair\n    150644:Yay! 
Somebody called!\n\n\n\n\n\nNow that's great. You can connect the hardware to 
board and start developing code for the driver itself.\n\n\nUse of HAL for
  drivers\n\n\nThe sensor has a serial port connection, and that's how you are 
going to connect to it. Your original BSP, hw/bsp/stm32f3discovery, has only 
one UART set up (as specified in src/hal_bsp.c, include/hal/bsp.h). Therefore, 
you need to create your own bsp which has configuration for this added 
hardware.\n\n\nSo in the shell you make a copy of the original BSP, and then 
change the package file a little.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ 
mkdir hw\n[user@IsMyLaptop:~/src/air_quality]$ mkdir 
hw/bsp\n\n[user@IsMyLaptop:~/src/air_quality]$ cp -R 
repos/mynewt_stm32f3/hw/bsp/stm32f3discovery 
hw/bsp/stm32f3discovery_with_senseair\n\n\n\n\n\nThen you modify the pkg.yml in 
the copied BSP to assign name for this package. And modify the dependency for 
MCU package to point to mynewt_stm32f3 repository.\n\n\n    
[user@IsMyLaptop:~/src/air_quality]$ grep pkg.name 
hw/bsp/stm32f3discovery_with_senseair/pkg.yml\n    pkg.name: 
\nhw/bsp/stm32f3discovery_with_senseair\n\n    [user@IsMyL
 aptop:~/src/air_quality]$ tail -2 
hw/bsp/stm32f3discovery_with_senseair/pkg.yml\npkg.deps:\n    - 
\n@mynewt_stm32f3/hw/mcu/stm/stm32f3xx\n\n\n\n\n\n\nAnd you want to use this 
BSP with my target. So you change the BSP in the target definition.\n\n\nHere's 
your new target.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target show 
air_q\ntargets/air_q\n    app=apps/air_quality\n    
bsp=hw/bsp/stm32f3discovery_with_senseair\n    
build_profile=debug\n\n\n\n\n\nYou add the 2nd serial port to my new BSP. Go to 
hw/bsp/stm32f3discovery_with_senseair directory to do this.\n\n\nModify the 
include/hal/bsp.h to increase UART_CNT to 2, and add a definition of the 2nd 
logical UART. You will use this in your sensor driver.\n\n\nstatic\n \nconst\n 
\nstruct\n \nstm32f3_uart_cfg\n \nuart_cfg\n[\nUART_CNT\n] \n=\n {\n    [\n0\n] 
\n=\n {\n        .\nsuc_uart\n \n=\n \nUSART1\n,\n        .\nsuc_rcc_cmd\n 
\n=\n \nRCC_APB2PeriphClockCmd\n,\n        .\nsuc_rcc_dev\n \n=\n 
\nRCC_APB2Periph_USART1\n,\n      
   .\nsuc_pin_tx\n \n=\n \n9\n,\n        .\nsuc_pin_rx\n \n=\n \n10\n,\n        
.\nsuc_pin_rts\n \n=\n \n12\n,\n        .\nsuc_pin_cts\n \n=\n \n11\n,\n        
.\nsuc_pin_af\n \n=\n \nGPIO_AF_7\n,\n        .\nsuc_irqn\n \n=\n 
\nUSART1_IRQn\n\n    },\n    [\n1\n] \n=\n {\n        .\nsuc_uart\n \n=\n 
\nUSART2\n,\n        .\nsuc_rcc_cmd\n \n=\n \nRCC_APB1PeriphClockCmd\n,\n       
 .\nsuc_rcc_dev\n \n=\n \nRCC_APB1Periph_USART2\n,\n        .\nsuc_pin_tx\n 
\n=\n \n19\n, \n/* PB3 */\n\n        .\nsuc_pin_rx\n \n=\n \n20\n, \n/* PB4 
*/\n\n        .\nsuc_pin_rts\n \n=\n \n1\n,\n        .\nsuc_pin_cts\n \n=\n 
\n0\n,\n        .\nsuc_pin_af\n \n=\n \nGPIO_AF_7\n,\n        .\nsuc_irqn\n 
\n=\n \nUSART2_IRQn\n\n    }\n};\n\n\n\n\n\nWith this in place, you can refer 
to serial port where your SenseAir sensor is by a logical number. This makes 
the code more platform independent - you could connect this sensor to another 
board, like Olimex. You will also use the HAL UART abstraction to do the UART 
por
 t setup and data transfer. That way you don't need to have any platform 
dependent pieces within your little driver.\n\n\nYou will now see what the 
driver code ends up looking like. Here's the header file, filled in from stub 
you created earlier.\n\n\n/*\n\n\n * Licensed to the Apache Software Foundation 
(ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE 
file\n\n\n * distributed with this work for additional information\n\n\n * 
regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under 
the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this 
file except in compliance\n\n\n * with the License.  You may obtain a copy of 
the License at\n\n\n * \n\n\n *  
http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by 
applicable law or agreed to in writing,\n\n\n * software distributed under the 
License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY\n\n\n * KIND, e
 ither express or implied.  See the License for the\n\n\n * specific language 
governing permissions and limitations\n\n\n * under the 
License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define 
_SENSEAIR_H_\n\n\n\nenum\n \nsenseair_read_type\n {\n        
\nSENSEAIR_CO2\n,\n        \nSENSEAIR_TEMPERATURE\n,\n        
\nSENSEAIR_HUMIDITY\n\n};\n\n\nint\n \nsenseair_init\n(\nint\n 
\nuartno\n);\n\n\nint\n \nsenseair_read\n(\nenum\n 
\nsenseair_read_type\n);\n\n\n#endif \n/* _SENSEAIR_H_ */\n\n\n\n\n\n\nAs you 
can see, logical UART number has been added to the init routine. A 'read' 
function has been added, which is a blocking read. If you were making a 
commercial product, you would probably have a callback for reporting the 
results.\n\n\nAnd here is the source for the driver.\n\n\n/**\n\n\n * Licensed 
to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor 
license agreements.  See the NOTICE file\n\n\n * distributed with this work for 
additional information\n\n\n * regard
 ing copyright ownership.  The ASF licenses this file\n\n\n * to you under the 
Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this 
file except in compliance\n\n\n * with the License.  You may obtain a copy of 
the License at\n\n\n *\n\n\n *  
http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by 
applicable law or agreed to in writing,\n\n\n * software distributed under the 
License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for 
the\n\n\n * specific language governing permissions and limitations\n\n\n * 
under the License.\n\n\n */\n\n\n#include \nstring.h\n\n\n\n#include 
\nshell/shell.h\n\n\n#include \nconsole/console.h\n\n\n#include 
\nos/os.h\n\n\n\n#include \nhal/hal_uart.h\n\n\n\n#include 
\nsenseair/senseair.h\n\n\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_co2\n[] 
\n=\n {\n    \n0xFE\n, \n0\nX44\n, \n0\nX00\n, \n0\nX08\n, \n0\nX02\n, \n
 0\nX9F\n, \n0\nX25\n\n};\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_temp\n[] 
\n=\n {\n    \n0xFE\n, \n0\nX44\n, \n0\nX00\n, \n0\nX12\n, \n0\nX02\n, 
\n0\nX94\n, \n0\nX45\n\n};\n\nstatic\n \nconst\n \nuint8_t\n 
\ncmd_read_humidity\n[] \n=\n {\n    \n0xFE\n, \n0x44\n, \n0x00\n, \n0x14\n, 
\n0x02\n, \n0x97\n, \n0xE5\n\n};\n\n\nstatic\n \nint\n 
\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n 
\nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n 
\nsenseair\n,\n    .\nsc_cmd_func\n \n=\n 
\nsenseair_shell_func\n,\n};\n\n\nstruct\n \nsenseair\n { \n    \nint\n 
\nuart\n;\n    \nstruct\n \nos_sem\n \nsema\n;\n    \nconst\n \nuint8_t\n 
\n*tx_data\n;\n    \nint\n \ntx_off\n;\n    \nint\n \ntx_len\n;\n    
\nuint8_t\n \nrx_data\n[\n32\n]; \n    \nint\n \nrx_off\n;\n    \nint\n 
\nvalue\n;\n} \nsenseair\n;\n\n\nstatic\n 
\nint\n\n\nsenseair_tx_char\n(\nvoid\n \n*arg\n)\n{\n    \nstruct\n 
\nsenseair\n \n*s\n \n=\n \nsenseair\n;\n    \nint\n \nrc\n;\n\n  
   \nif\n (\ns-\ntx_off\n \n=\n \ns-\ntx_len\n) {\n    \n/*\n\n\n         * 
Command tx finished.\n\n\n         */\n\n        \ns-\ntx_data\n \n=\n 
\nNULL\n;\n        \nreturn\n \n-\n1\n;\n    }\n\n    \nrc\n \n=\n 
\ns-\ntx_data\n[\ns-\ntx_off\n];\n    \ns-\ntx_off++\n;\n    \nreturn\n 
\nrc\n;\n}\n\n\n/*\n\n\n * CRC for modbus over serial port.\n\n\n 
*/\n\n\nstatic\n \nconst\n \nuint16_t\n \nmb_crc_tbl\n[] \n=\n {\n    
\n0x0000\n, \n0xcc01\n, \n0xd801\n, \n0x1400\n, \n0xf001\n, \n0x3c00\n, 
\n0x2800\n, \n0xe401\n,\n    \n0xa001\n, \n0x6c00\n, \n0x7800\n, \n0xb401\n, 
\n0x5000\n, \n0x9c01\n, \n0x8801\n, \n0x4400\n\n};\n\n\nstatic\n 
\nuint16_t\n\n\nmb_crc\n(\nconst\n \nuint8_t\n \n*data\n, \nint\n \nlen\n, 
\nuint16_t\n \ncrc\n)\n{\n    \nwhile\n (\nlen--\n \n \n0\n) {\n        \ncrc\n 
\n^=\n \n*data++\n;\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) \n^\n 
\nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) 
\n^\n \nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n    }\n    \nretur
 n\n \ncrc\n;\n}\n\n\nstatic\n \nint\n\n\nmb_crc_check\n(\nconst\n \nvoid\n 
\n*pkt\n, \nint\n \nlen\n)\n{\n    \nuint16_t\n \ncrc\n, \ncmp\n;\n    
\nuint8_t\n \n*bp\n \n=\n (\nuint8_t\n \n*\n)\npkt\n;\n\n    \nif\n (\nlen\n \n 
\nsizeof\n(\ncrc\n) \n+\n \n1\n) {\n        \nreturn\n \n-\n1\n;\n    }\n    
\ncrc\n \n=\n \nmb_crc\n(\npkt\n, \nlen\n \n-\n \n2\n, \n0xffff\n);\n    
\ncmp\n \n=\n \nbp\n[\nlen\n \n-\n \n2\n] \n|\n (\nbp\n[\nlen\n \n-\n \n1\n] \n 
\n8\n);\n    \nif\n (\ncrc\n \n!=\n \ncmp\n) {\n        \nreturn\n \n-\n1\n;\n  
  } \nelse\n {\n        \nreturn\n \n0\n;\n    }\n}\n\n\nstatic\n 
\nint\n\n\nsenseair_rx_char\n(\nvoid\n \n*arg\n, \nuint8_t\n \ndata\n)\n{\n    
\nstruct\n \nsenseair\n \n*s\n \n=\n (\nstruct\n \nsenseair\n \n*\n)\narg\n;\n  
  \nint\n \nrc\n;\n\n    \nif\n (\ns-\nrx_off\n \n=\n 
\nsizeof\n(\ns-\nrx_data\n)) {\n        \ns-\nrx_off\n \n=\n \n0\n;\n    }\n    
\ns-\nrx_data\n[\ns-\nrx_off\n] \n=\n \ndata\n;\n    \ns-\nrx_off++\n;\n\n    
\nif\n (\ns-\nrx_off\n \
 n==\n \n7\n) {\n        \nrc\n \n=\n \nmb_crc_check\n(\ns-\nrx_data\n, 
\ns-\nrx_off\n);\n        \nif\n (\nrc\n \n==\n \n0\n) {\n            
\ns-\nvalue\n \n=\n \ns-\nrx_data\n[\n3\n] \n*\n \n256\n \n+\n 
\ns-\nrx_data\n[\n4\n];\n            \nos_sem_release\n(\ns-\nsema\n);\n        
}\n    }\n    \nreturn\n \n0\n;\n}\n\n\nvoid\n\n\nsenseair_tx\n(\nstruct\n 
\nsenseair\n \n*s\n, \nconst\n \nuint8_t\n \n*tx_data\n, \nint\n 
\ndata_len\n)\n{\n    \ns-\ntx_data\n \n=\n \ntx_data\n;\n    \ns-\ntx_len\n 
\n=\n \ndata_len\n;\n    \ns-\ntx_off\n \n=\n \n0\n;\n    \ns-\nrx_off\n \n=\n 
\n0\n;\n\n    
\nhal_uart_start_tx\n(\ns-\nuart\n);\n}\n\n\nint\n\n\nsenseair_read\n(\nenum\n 
\nsenseair_read_type\n \ntype\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n 
\nsenseair\n;\n    \nconst\n \nuint8_t\n \n*cmd\n;\n    \nint\n \ncmd_len\n;\n  
  \nint\n \nrc\n;\n\n    \nif\n (\ns-\ntx_data\n) {\n        \n/*\n\n\n         
* busy\n\n\n         */\n\n        \nreturn\n \n-\n1\n;\n    }\n    \nswitch\n 
(\ntype
 \n) {\n    \ncase\n \nSENSEAIR_CO2\n:\n        \ncmd\n \n=\n 
\ncmd_read_co2\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_co2\n);\n    
    \nbreak\n;\n    \ncase\n \nSENSEAIR_TEMPERATURE\n:\n        \ncmd\n \n=\n 
\ncmd_read_temp\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_temp\n);\n  
      \nbreak\n;\n    \ncase\n \nSENSEAIR_HUMIDITY\n:\n        \ncmd\n \n=\n 
\ncmd_read_humidity\n;\n        \ncmd_len\n \n=\n 
\nsizeof\n(\ncmd_read_humidity\n);\n        \nbreak\n;\n    \ndefault\n:\n\n    
    \nreturn\n \n-\n1\n;\n    }\n    \nsenseair_tx\n(\ns\n, \ncmd\n, 
\ncmd_len\n);\n    \nrc\n \n=\n \nos_sem_pend\n(\ns-\nsema\n, 
\nOS_TICKS_PER_SEC\n \n/\n \n2\n);\n    \nif\n (\nrc\n \n==\n \nOS_TIMEOUT\n) 
{\n        \n/*\n\n\n         * timeout\n\n\n         */\n\n        \nreturn\n 
\n-\n2\n;\n    }\n    \nreturn\n \ns-\nvalue\n;\n}\n\n\nstatic\n 
\nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    
\nint\n \nvalue\n;\n    \nenum\n \nsenseair_read_type\n \n
 type\n;\n\n    \nif\n (\nargc\n \n \n2\n) {\n\nusage\n:\n        
\nconsole_printf\n(\n%s \nco2|temp|humidity\n\\n\n, \nargv\n[\n0\n]);\n        
\nreturn\n \n0\n;\n    }\n    \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nco2\n)) 
{\n        \ntype\n \n=\n \nSENSEAIR_CO2\n;\n    } \nelse\n \nif\n 
(\n!strcmp\n(\nargv\n[\n1\n], \ntemp\n)) {\n        \ntype\n \n=\n 
\nSENSEAIR_TEMPERATURE\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], 
\nhumidity\n)) {\n        \n/*\n\n\n         * timeout\n\n\n         */\n\n     
   \nreturn\n \n-\n2\n;\n    }\n    \nreturn\n \ns-\nvalue\n;\n}\n\n\nstatic\n 
\nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    
\nint\n \nvalue\n;\n    \nenum\n \nsenseair_read_type\n \ntype\n;\n\n    \nif\n 
(\nargc\n \n \n2\n) {\n\nusage\n:\n        \nconsole_printf\n(\n%s 
\nco2|temp|humidity\n\\n\n, \nargv\n[\n0\n]);\n        \nreturn\n \n0\n;\n    
}\n    \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nco2\n)) {\n        \ntype\n \n=\n 
\nSENSEAIR_CO2\n;\n
     } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \ntemp\n)) {\n        
\ntype\n \n=\n \nSENSEAIR_TEMPERATURE\n;\n    } \nelse\n \nif\n 
(\n!strcmp\n(\nargv\n[\n1\n], \nhumidity\n)) {\n        \ntype\n \n=\n 
\nSENSEAIR_HUMIDITY\n;\n    } \nelse\n {\n        \ngoto\n \nusage\n;\n    }\n  
  \nvalue\n \n=\n \nsenseair_read\n(\ntype\n);\n    \nif\n (\nvalue\n \n=\n 
\n0\n) {\n        \nconsole_printf\n(\nGot %d\\n\n, \nvalue\n);\n    } \nelse\n 
{\n        \nconsole_printf\n(\nError while reading: %d\\n\n, \nvalue\n);\n    
}\n    \nreturn\n \n0\n;\n}\n\n\nint\n\n\nsenseair_init\n(\nint\n 
\nuartno\n)\n{\n    \nint\n \nrc\n;\n    \nstruct\n \nsenseair\n \n*s\n \n=\n 
\nsenseair\n;\n\n    \nrc\n \n=\n \nshell_cmd_register\n(\nsenseair_cmd\n);\n   
 \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n\n    \nrc\n \n=\n 
\nos_sem_init\n(\ns-\nsema\n, \n1\n);\n    \nif\n (\nrc\n) {\n        
\nreturn\n \nrc\n;\n    }\n    \nrc\n \n=\n \nhal_uart_init_cbs\n(\nuartno\n, 
\nsenseair_tx_char\n, \nNUL
 L\n,\n      \nsenseair_rx_char\n, \nsenseair\n);\n    \nif\n (\nrc\n) {\n      
  \nreturn\n \nrc\n;\n    }\n    \nrc\n \n=\n \nhal_uart_config\n(\nuartno\n, 
\n9600\n, \n8\n, \n1\n, \nHAL_UART_PARITY_NONE\n,\n      
\nHAL_UART_FLOW_CTL_NONE\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n 
\nrc\n;\n    }\n    \ns-\nuart\n \n=\n \nuartno\n;\n\n    \nreturn\n 
\n0\n;\n}\n\n\n\n\n\nAnd you modified your main() for senseair driver 
init.\n\n\nint\n\n\nmain\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    
....\n    \nsenseair_init\n(\n1\n);\n    ....\n    }\n\n\n\n\n\nYou can see 
from the code that you are using the HAL interface to open a UART port, and 
using OS semaphore as a way of blocking the task when waiting for read response 
to come back from the sensor.", 
-            "title": "Air-quality Sensor project"
+            "text": "Air quality sensor project\n\n\nSetting up source tree 
for stuff you need\n\n\nTo start with, you need to create a new project under 
which you will do this development. So you type in:\n\n\n    $ mkdir 
$HOME/src\n    $ cd $HOME/src\n    $ newt new air_quality\n\n\n\n\n\nLet's say 
you are using Arduino Primo -- which is based on the Nordic Semi NRF52 chip -- 
as the platform. \nYou know you need the board support package for that 
hardware. You can look up its location, add it your \nproject, and fetch that 
along with the core OS components. Luckily, the Arduino Primo is supported in 
the \nMynewt Core, so there's nothing much to do here. \n\n\nYour project.yml 
file should look like this:\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ emacs 
project.yml \n\n    [user@IsMyLaptop:~/src/air_quality]$ cat project.yml\n    
project.name: \nair_quality\n\n\n    project.repositories:\n        - 
apache-mynewt-core\n\n    # Use github\ns distribution mechanism for core ASF 
libr
 aries.\n    # This provides mirroring automatically for us.\n    #\n    
repository.apache-mynewt-core:\n        type: github\n        vers: 0-latest\n  
      user: apache\n        repo: incubator-mynewt-core\n\n    
[user@IsMyLaptop:~/src/air_quality]$ newt install\n    apache-mynewt-core\n    
[user@IsMyLaptop:~/src/air_quality]$ ls repos/\n    
apache-mynewt-core\n\n\n\n\n\nGood. You want to make sure you have all the 
needed bits for supporting your board; \nso you decide to build the blinky 
project for the platform first.\n\n\nNow create a target for it and build it. 
Easiest way to proceed is to copy the existing target for blinky, and modify it 
to build for Arduino Primo board.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ 
newt target copy my_blinky_sim blink_primo\nTarget successfully copied; 
targets/my_blinky_sim --\n 
targets/blink_primo\n[user@IsMyLaptop:~/src/air_quality]$ newt target set 
blink_primo bsp=@apache-mynewt-core/hw/bsp/arduino_primo_nrf52\nTarget 
targets/blink_nrf succe
 ssfully set target.bsp to 
@apache-mynewt-core/hw/bsp/arduino_primo_nrf52\n[user@IsMyLaptop:~/src/air_quality]$
 newt build blink_primo\nCompiling hal_bsp.c\n...\nLinking blinky.elf\nApp 
successfully built: 
/Users/user/src/air_quality/bin/blink_primo/apps/blinky/blinky.elf\n\n\n\n\n\nGood.\n\n\nYou
 know that this platform uses bootloader, which means you have to create a 
target for that too.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
create boot_primo\nTarget targets/boot_nrf successfully 
created\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
show\n@apache-mynewt-core/targets/unittest\n    bsp=hw/bsp/native\n    
build_profile=debug\n    compiler=compiler/sim\ntargets/blink_primo\n    
app=apps/blinky\n    bsp=@apache-mynewt-core/hw/bsp/arduino_primo_nrf52\n    
build_profile=debug\ntargets/boot_primo\ntargets/my_blinky_sim\n    
app=apps/blinky\n    bsp=@apache-mynewt-core/hw/bsp/native\n    
build_profile=debug\n[user@IsMyLaptop:~/src/air_quality]$ newt target set 
boot_nrf 
 bsp=@apache-mynewt-core/hw/bsp/arduino_primo_nrf52\nTarget targets/boot_nrf 
successfully set target.bsp to 
@apache-mynewt-core/hw/bsp/arduino_primo_nrf52\n[user@IsMyLaptop:~/src/air_quality]$
 newt target set boot_nrf app=@apache-mynewt-core/apps/boot\nTarget 
targets/boot_nrf successfully set target.app to 
@apache-mynewt-core/apps/boot\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
set boot_nrf build_profile=optimized\nTarget targets/boot_nrf successfully set 
target.build_profile to optimized\n\n\n\n\n\nAnd then build it, and load it 
onto the board.\n\n\nnewt build boot_primo\n....\nLinking boot.elf\nApp 
successfully built: 
/Users/user/src/air_quality/bin/boot_primo/apps/boot/boot.elf\n[user@IsMyLaptop:~/src/air_quality]\n$
 newt load boot_primo\n\n\n\n\n\nAt this point, you may (or may not) see a 
bunch of error messages about not being able to connect to\nyour board, not 
being able to load the image, etc. If that's the case, and you haven't already, 
you\nshould most definitely go 
 worth through the \nblinky_primo\n tutorial so that you\ncan properly 
communicate with your board.\n\n\nNext you must download the targets to board, 
and see that the LED actually blinks. You plug in the \nArduino Primo board to 
your laptop, and say:\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt load 
blink_primo\nLoading app image into slot 1\nError: couldn\nt open 
/Users/user/src/air_quality/bin/blink_primo/apps/blinky/blinky.img\n\nError: 
exit status 1\n\nload - Load app image to target for 
\ntarget-name\n.\n\nUsage:\n  newt load [flags]\n\nExamples:\n  newt load 
\ntarget-name\n\n\n\nGlobal Flags:\n  -l, --loglevel string   Log level, 
defaults to WARN. (default \nWARN\n)\n  -o, --outfile string    Filename to tee 
log output to\n  -q, --quiet             Be quiet; only display error output.\n 
 -s, --silent            Be silent; don\nt output anything.\n  -v, --verbose    
       Enable verbose output when executing commands.\nexit status 
1\n\n\n\n\n\nAh. Forgot to create an image ou
 t of the blinky binary. Note that every time you want to build and \nload a 
new firmware image to a target board, you need to run 'create-image' on 
it.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt create-image blink_primo 
0.0.1\nApp image successfully generated: 
/Users/user/src/air_quality/bin/blink_primo/apps/blinky/blinky.img\nBuild 
manifest: 
/Users/user/src/air_quality/bin/blink_nrf/apps/blinky/manifest.json\n[user@IsMyLaptop:~/src/air_quality]$
 newt load blink_primo\n\n\n\n\n\nAnd it's blinking.\n\n\nShortcut for doing 
build/create-image/load/debug steps all in one is 'newt run' command. Check 
\nout the usage from command line help.\n\n\nCreate test project\n\n\nNow that 
you have your system setup, you can start creating your own stuff.\nFirst you 
want to create a project for yourself - you could start by using blinky as a 
project \ntemplate, but since we're going to want to be able to access the data 
via Bluetooth, let's \nuse the \nbleprph\n Bluetooth Peripheral project inst
 ead.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ mkdir apps/air_quality\n    
[user@IsMyLaptop:~/src/air_quality]$ cp 
repos/apache-mynewt-core/apps/bleprph/pkg.yml apps/air_quality/\n    
[user@IsMyLaptop:~/src/air_quality]$ cp -Rp 
repos/apache-mynewt-core/apps/bleprph/src apps/air_quality/\n\n\n\n\n\nThen you 
modify the apps/air_quality/pkg.yml for air_quality in order to change the 
\npkg.name\n to be \napps/air_quality\n.\nYou'll need to add the 
\n@apache-mynewt-core/\n path to all the package dependencies, since the app no 
longer\nresides within the apache-mynewt-core repository.\n\n\nThe Arduino 
Primo board has a limited amount of memory, so you must also switch your libc 
to be baselibc, instead of the standard 
one.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
apps/air_quality/pkg.yml\npkg.name: apps/air_quality\npkg.type: 
app\npkg.description: BLE Air Quality application.\npkg.author: \nApache Mynewt 
\[email protected]\n\npkg.homepage: \nhttp://mynewt.apache.org
 /\n\npkg.keywords:\n\npkg.deps:\n    - \n@apache-mynewt-core/kernel/os\n\n    
- \n@apache-mynewt-core/sys/log\n\n    - \n@apache-mynewt-core/mgmt/newtmgr\n\n 
   - \n@apache-mynewt-core/mgmt/newtmgr/transport/ble\n\n    - 
\n@apache-mynewt-core/net/nimble/controller\n\n    - 
\n@apache-mynewt-core/net/nimble/host\n\n    - 
\n@apache-mynewt-core/net/nimble/host/services/ans\n\n    - 
\n@apache-mynewt-core/net/nimble/host/services/gap\n\n    - 
\n@apache-mynewt-core/net/nimble/host/services/gatt\n\n    - 
\n@apache-mynewt-core/net/nimble/host/store/ram\n\n    - 
\n@apache-mynewt-core/net/nimble/transport/ram\n\n    - 
\n@apache-mynewt-core/sys/console/full\n\n    - 
\n@apache-mynewt-core/libc/baselibc\n\n    - 
\n@apache-mynewt-core/sys/sysinit\n\n    - 
\n@apache-mynewt-core/sys/id\n\n\n\n\n\n\nAnd create a target for 
it:\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target create air_q\nTarget 
targets/air_q successfully created\n[user@IsMyLaptop:~/src/air_quality]$ newt 
target set air_q bsp=@a
 pache-mynewt-core/hw/bsp/arduino_primo_nrf52\nTarget targets/air_q 
successfully set target.bsp to 
@apache-mynewt-core/hw/bsp/arduino_primo_nrf52\n[user@IsMyLaptop:~/src/air_quality]$
 newt target set air_q app=apps/air_quality \nTarget targets/air_q successfully 
set target.app to apps/air_quality\n[user@IsMyLaptop:~/src/air_quality]$ newt 
target set air_q build_profile=debug\nTarget targets/air_q successfully set 
target.build_profile to debug\n[user@IsMyLaptop:~/src/air_quality]$ newt build 
air_q\n ....\nLinking 
/Users/dsimmons/dev/myproj/bin/targets/air_q/app/apps/air_quality/air_quality.elf\nTarget
 successfully built: targets/air_q\n\n\n\n\n\nCreate packages for 
drivers\n\n\nOne of the sensors you want to enable is SenseAir K30, which will 
connect to the board over a serial port.\nTo start development of the driver, 
you first need to create a package description for it, and add stubs for 
sources.\n\n\nThe first thing to do is to create the directory structure for 
your driver:\n\n\n
 [user@IsMyLaptop:~/src/air_quality]$ mkdir -p 
libs/my_drivers/senseair/include/senseair\n[user@IsMyLaptop:~/src/air_quality]$ 
mkdir -p libs/my_drivers/senseair/src\n\n\n\n\n\nNow you can add the files you 
need. You'll need a pkg.yml to describe the driver, and then header stub 
followed by source stub.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
libs/my_drivers/senseair/pkg.yml\n\n\n\n\n\n#\n\n\n# Licensed to the Apache 
Software Foundation (ASF) under one\n\n\n# or more contributor license 
agreements.  See the NOTICE file\n\n\n# distributed with this work for 
additional information\n\n\n# regarding copyright ownership.  The ASF licenses 
this file\n\n\n# to you under the Apache License, Version 2.0 (the\n\n\n# 
\nLicense\n); you may not use this file except in compliance\n\n\n# with the 
License.  You may obtain a copy of the License at\n\n\n# \n\n\n#  
http:\n//www.apache.org/licenses/LICENSE-2.0\n\n\n#\n\n\n# Unless required by 
applicable law or agreed to in writing,\n\n\n# software 
 distributed under the License is distributed on an\n\n\n# \nAS IS\n BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n# KIND, either express or implied. 
 See the License for the\n\n\n# specific language governing permissions and 
limitations\n\n\n# under the License.\n\n\n#\n\n\npkg\n.\nname\n: 
\nlibs/my_drivers/senseair\n\n\npkg\n.\ndeps\n:\n    \n-\n 
\n@apache-mynewt-core/hw/hal\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ 
cat libs/my_drivers/senseair/include/senseair/senseair.h\n\n\n\n\n\n/*\n\n\n * 
Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more 
contributor license agreements.  See the NOTICE file\n\n\n * distributed with 
this work for additional information\n\n\n * regarding copyright ownership.  
The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 
(the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n 
* with the License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  
http://www.apa
 che.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law 
or agreed to in writing,\n\n\n * software distributed under the License is 
distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * 
specific language governing permissions and limitations\n\n\n * under the 
License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define 
_SENSEAIR_H_\n\n\n\nvoid\n \nsenseair_init\n(\nvoid\n);\n\n\n#endif \n/* 
_SENSEAIR_H_ */\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
libs/my_drivers/senseair/src/senseair.c\n\n\n\n\n\n/**\n\n\n * Licensed to the 
Apache Software Foundation (ASF) under one\n\n\n * or more contributor license 
agreements.  See the NOTICE file\n\n\n * distributed with this work for 
additional information\n\n\n * regarding copyright ownership.  The ASF licenses 
this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * 
\nLicense\n); you may not u
 se this file except in compliance\n\n\n * with the License.  You may obtain a 
copy of the License at\n\n\n * \n\n\n *  
http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by 
applicable law or agreed to in writing,\n\n\n * software distributed under the 
License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for 
the\n\n\n * specific language governing permissions and limitations\n\n\n * 
under the License.\n\n\n 
*/\n\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n}\n\n\n\n\n\nAnd add 
dependency to this package in your project yml file.\n\n\nHere's the listing 
from apps/air_quality/pkg.yml\n\n\npkg.name: apps/air_quality\npkg.type: 
app\npkg.description: Air quality sensor test\npkg.keywords:\n\npkg.deps:\n    
- \n@apache-mynewt-core/libs/console/full\n\n    - 
\n@apache-mynewt-core/libs/newtmgr\n\n    - \n@apache-mynewt-core/libs/os\n\n   
 - \n@apache-mynewt-core/libs/she
 ll\n\n    - \n@apache-mynewt-core/sys/config\n\n    - 
\n@apache-mynewt-core/sys/log\n\n    - \n@apache-mynewt-core/sys/stats\n\n    - 
\n@apache-mynewt-core/libs/baselibc\n\n    - 
libs/my_drivers/senseair\n\n\n\n\n\nAnd add a call to your main() to initialize 
this driver.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ diff 
project/blinky/src/main.c project/air_quality/src/main.c\n    28a29\n    \n 
#include \nsenseair/senseair.h\n\n    190a192\n    \n senseair_init();\n    
[user@IsMyLaptop:~/src/air_quality\n\n\n\n\n\nThe ble_prph app runs everything 
in one task handler. For this project, we're going to add a second\ntask 
handler to respond to the shell, and then handle communicating with the 
senseair sensor for us.\n\n\n/** shell task settings. */\n\n\n#define 
SHELL_TASK_PRIO           2\n\n\n#define SHELL_STACK_SIZE          
(OS_STACK_ALIGN(336))\n\n\n\nstruct\n \nos_eventq\n \nshell_evq\n;\n\nstruct\n 
\nos_task\n \nshell_task\n;\n\nbssnz_t\n \nos_stack_t\n 
\nshell_stack\n[\nSHELL_ST
 ACK_SIZE\n];\n\n\n\n\n\nThat defines the task, now we need to initialize it, 
add a task handler, and we're going to \nuse this task as our default task 
handler.\n\n\n/**\n\n\n * Event loop for the main shell task.\n\n\n 
*/\n\n\nstatic\n \nvoid\n\n\nshell_task_handler\n(\nvoid\n \n*unused\n)\n{\n    
\nwhile\n (\n1\n) {\n        \nos_eventq_run\n(\nshell_evq\n);\n    
}\n}\n\n\n\n\n\nAnd in your \nmain()\n add:\n\n\n    \n/* Initialize shell 
eventq */\n\n    \nos_eventq_init\n(\nshell_evq\n);\n\n    \n/* Create the 
shell task.  \n\n\n     * All shell operations are performed in this 
task.\n\n\n     */\n\n    \nos_task_init\n(\nshell_task\n, \nshell\n, 
\nshell_task_handler\n,\n                              \nNULL\n, 
\nSHELL_TASK_PRIO\n, \nOS_WAIT_FOREVER\n,\n                              
\nshell_stack\n, \nSHELL_STACK_SIZE\n);\n\n\n\n\n\nDon't forget to change your 
default task handler!\n\n\n    
\nos_eventq_dflt_set\n(\nshell_evq\n);\n\n\n\n\n\nAnd then build it to make 
sure all goes we
 ll.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt build air_q\nCompiling 
senseair.c\nArchiving senseair.a\nLinking air_quality.elf\nApp successfully 
built: 
/Users/user/src/air_quality/bin/air_q/apps/air_quality/air_quality.elf\n\n\n\n\n\nAll
 looks good.\n\n\nAdd CLI commands for testing drivers\n\n\nWhile developing 
the driver, you want to issue operations from console asking it to do stuff. 
We'll assume that you've already worked through the tutorial \non how to 
\nenable the CLI\n, so all we'll need to do is add the propper values to the 
project's \nsyscfg.yml\n file:\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat 
targets/air_q/syscfg.yml\nsyscfg.vals:\n    # Set as per blinky_primo\n    
OPENOCD_DEBUG: 1\n    # Enable the shell task.\n    SHELL_TASK: 1\n    
STATS_CLI: 1\n    CONSOLE_TICKS: 1\n    CONSOLE_PROMPT: 1\n\n\n\n\n\nThen 
register your senseair command with the shell by adding the following to 
\nlibs/my_drivers/senseair/src/senseair.c\n\n\n#include 
\nshell/shell.h\n\n\n#inc
 lude \nconsole/console.h\n\n\n#include \nassert.h\n\n\n\n\nstatic\n \nint\n 
\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n 
\nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n 
\nsenseair\n,\n    .\nsc_cmd_func\n \n=\n 
\nsenseair_shell_func\n,\n};\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n    
\nint\n \nrc\n;\n\n    \nrc\n \n=\n \nshell_cmd_register\n(\nsenseair_cmd\n);\n 
   \nassert\n(\nrc\n \n==\n \n0\n);\n}\n\n\nstatic\n 
\nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    
\nconsole_printf\n(\nYay! Somebody called!\\n\n);\n    \nreturn\n 
\n0\n;\n\n}\n\n\n\n\n\nNow you can you build this, download to target, and 
start minicom on your console port. If you haven't already, familiarize 
yourself with\nthe tutorial on how to connect a serial port to your board 
\nhere\n.\n\n\nYou'll need to wire up your Board to a Serial converter first. 
On the Arduino Primo Board pin 1 is TX and pin 0 is RX so wire 1 to RX on 
 your serial board, and 0 to TX on your serial board.\n\n\n    
[user@IsMyLaptop:~]$ minicom -D /dev/tty.usbserial-AH02MIE2\n\n\n    Welcome to 
minicom 2.7\n\n    OPTIONS: \n    Compiled on Oct 12 2015, 07:48:30.\n    Port 
/dev/tty.usbserial-AH02MIE2, 13:44:40\n\n    Press CTRL-X Z for help on special 
keys\n\n    ?\n    419: \n ?\n    Commands:\n    641:     stat      echo        
 ?    prompt     ticks     tasks\n    643: mempools      date  senseair\n    
644: \n senseair\n    Yay! Somebody called!\n    1125: \n\n    53611: \n 
tasks\n    Tasks:\n    54047:    task pri tid  runtime      csw    stksz   
stkuse   lcheck   ncheck flg\n    54057:    idle 255   0    54048    66890      
 64       30        0        0   0\n    54068:  ble_ll   0   1        9    
64986       80       58        0        0   0\n    54079: bleprph   1   2       
 0        1      336       32        0        0   0\n    54090:   shell   2   3 
       0     2077      336      262        0        0   0\n    54101: \n\n\n
 \n\n\n\nThat's great. Your shell task is running, and is responding 
appropriately!\nYou can connect the hardware to your board and start developing 
code for the driver itself.\n\n\nUse of HAL for drivers\n\n\nThe sensor has a 
serial port connection, and that's how you are going to connect to it. Your 
original BSP, hw/bsp/arduino_primo_nrf52, has two UARTs set up.\nWe're using 
one for our shell/console. It also has a second UART set up as a 'bit-bang' 
UART but since the SenseAir only needs to\ncommunicate at 9600 baud, this 
bit-banged uart is plenty fast enough.\n\n\nYou'll have to make a small change 
to the \nsyscfg.yml\n file in your project's target directory to chang the pin 
definitions \nfor this second UART. Those changes are as follows:\n\n\n    
UART_0_PIN_TX: 23\n    UART_0_PIN_RX: 24\n\n\n\n\n\nWith this in place, you can 
refer to serial port where your SenseAir sensor by a logical number. This makes 
the code more platform independent - you could connect this sensor to anoth
 er board, like Olimex. You will also use the HAL UART abstraction to do the 
UART port setup and data transfer. That way you don't need to have any platform 
dependent pieces within your little driver.\n\n\nYou will now see what the 
driver code ends up looking like. Here's the header file, filled in from the 
stub you created earlier.\n\n\n/*\n\n\n * Licensed to the Apache Software 
Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See 
the NOTICE file\n\n\n * distributed with this work for additional 
information\n\n\n * regarding copyright ownership.  The ASF licenses this 
file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * 
\nLicense\n); you may not use this file except in compliance\n\n\n * with the 
License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  
http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by 
applicable law or agreed to in writing,\n\n\n * software distributed under the 
License is distribute
 d on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n 
* KIND, either express or implied.  See the License for the\n\n\n * specific 
language governing permissions and limitations\n\n\n * under the 
License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define 
_SENSEAIR_H_\n\n\n\nenum\n \nsenseair_read_type\n {\n        
\nSENSEAIR_CO2\n,\n};\n\n\nint\n \nsenseair_init\n(\nint\n 
\nuartno\n);\n\n\nint\n \nsenseair_read\n(\nenum\n 
\nsenseair_read_type\n);\n\n\n#endif \n/* _SENSEAIR_H_ */\n\n\n\n\n\n\nAs you 
can see, logical UART number has been added to the init routine. A 'read' 
function has been added, \nwhich is a blocking read. If you were making a 
commercial product, you would probably have a callback for reporting the 
results.\n\n\nAnd here is the source for the driver.\n\n\n/**\n\n\n * Licensed 
to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor 
license agreements.  See the NOTICE file\n\n\n * distributed with this work for 
additional in
 formation\n\n\n * regarding copyright ownership.  The ASF licenses this 
file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * 
\nLicense\n); you may not use this file except in compliance\n\n\n * with the 
License.  You may obtain a copy of the License at\n\n\n *\n\n\n *  
http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by 
applicable law or agreed to in writing,\n\n\n * software distributed under the 
License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for 
the\n\n\n * specific language governing permissions and limitations\n\n\n * 
under the License.\n\n\n */\n\n\n#include \nstring.h\n\n\n\n#include 
\nshell/shell.h\n\n\n#include \nconsole/console.h\n\n\n#include 
\nos/os.h\n\n\n\n#include \nhal/hal_uart.h\n\n\n\n#include 
\nsenseair/senseair.h\n\n\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_co2\n[] 
\n=\n {\n    \n0xFE\n, \n0\nX44\n, \n0\nX00\n, \n
 0\nX08\n, \n0\nX02\n, \n0\nX9F\n, \n0\nX25\n\n};\n\n\nstatic\n \nint\n 
\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n 
\nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n 
\nsenseair\n,\n    .\nsc_cmd_func\n \n=\n 
\nsenseair_shell_func\n,\n};\n\n\nstruct\n \nsenseair\n { \n    \nint\n 
\nuart\n;\n    \nstruct\n \nos_sem\n \nsema\n;\n    \nconst\n \nuint8_t\n 
\n*tx_data\n;\n    \nint\n \ntx_off\n;\n    \nint\n \ntx_len\n;\n    
\nuint8_t\n \nrx_data\n[\n32\n]; \n    \nint\n \nrx_off\n;\n    \nint\n 
\nvalue\n;\n} \nsenseair\n;\n\n\nstatic\n 
\nint\n\n\nsenseair_tx_char\n(\nvoid\n \n*arg\n)\n{\n    \nstruct\n 
\nsenseair\n \n*s\n \n=\n \nsenseair\n;\n    \nint\n \nrc\n;\n\n    \nif\n 
(\ns-\ntx_off\n \n=\n \ns-\ntx_len\n) {\n    \n/*\n\n\n         * Command tx 
finished.\n\n\n         */\n\n        \ns-\ntx_data\n \n=\n \nNULL\n;\n        
\nreturn\n \n-\n1\n;\n    }\n\n    \nrc\n \n=\n 
\ns-\ntx_data\n[\ns-\ntx_off\n];\n    \ns-\ntx_off++\n;\n  
   \nreturn\n \nrc\n;\n}\n\n\n/*\n\n\n * CRC for modbus over serial port.\n\n\n 
*/\n\n\nstatic\n \nconst\n \nuint16_t\n \nmb_crc_tbl\n[] \n=\n {\n    
\n0x0000\n, \n0xcc01\n, \n0xd801\n, \n0x1400\n, \n0xf001\n, \n0x3c00\n, 
\n0x2800\n, \n0xe401\n,\n    \n0xa001\n, \n0x6c00\n, \n0x7800\n, \n0xb401\n, 
\n0x5000\n, \n0x9c01\n, \n0x8801\n, \n0x4400\n\n};\n\n\nstatic\n 
\nuint16_t\n\n\nmb_crc\n(\nconst\n \nuint8_t\n \n*data\n, \nint\n \nlen\n, 
\nuint16_t\n \ncrc\n)\n{\n    \nwhile\n (\nlen--\n \n \n0\n) {\n        \ncrc\n 
\n^=\n \n*data++\n;\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) \n^\n 
\nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) 
\n^\n \nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n    }\n    \nreturn\n 
\ncrc\n;\n}\n\n\nstatic\n \nint\n\n\nmb_crc_check\n(\nconst\n \nvoid\n 
\n*pkt\n, \nint\n \nlen\n)\n{\n    \nuint16_t\n \ncrc\n, \ncmp\n;\n    
\nuint8_t\n \n*bp\n \n=\n (\nuint8_t\n \n*\n)\npkt\n;\n\n    \nif\n (\nlen\n \n 
\nsizeof\n(\ncrc\n) \n+\n \n1\n) {\n        \n
 return\n \n-\n1\n;\n    }\n    \ncrc\n \n=\n \nmb_crc\n(\npkt\n, \nlen\n \n-\n 
\n2\n, \n0xffff\n);\n    \ncmp\n \n=\n \nbp\n[\nlen\n \n-\n \n2\n] \n|\n 
(\nbp\n[\nlen\n \n-\n \n1\n] \n \n8\n);\n    \nif\n (\ncrc\n \n!=\n \ncmp\n) 
{\n        \nreturn\n \n-\n1\n;\n    } \nelse\n {\n        \nreturn\n \n0\n;\n  
  }\n}\n\n\nstatic\n \nint\n\n\nsenseair_rx_char\n(\nvoid\n \n*arg\n, 
\nuint8_t\n \ndata\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n (\nstruct\n 
\nsenseair\n \n*\n)\narg\n;\n    \nint\n \nrc\n;\n\n    \nif\n (\ns-\nrx_off\n 
\n=\n \nsizeof\n(\ns-\nrx_data\n)) {\n        \ns-\nrx_off\n \n=\n \n0\n;\n    
}\n    \ns-\nrx_data\n[\ns-\nrx_off\n] \n=\n \ndata\n;\n    
\ns-\nrx_off++\n;\n\n    \nif\n (\ns-\nrx_off\n \n==\n \n7\n) {\n        \nrc\n 
\n=\n \nmb_crc_check\n(\ns-\nrx_data\n, \ns-\nrx_off\n);\n        \nif\n 
(\nrc\n \n==\n \n0\n) {\n            \ns-\nvalue\n \n=\n \ns-\nrx_data\n[\n3\n] 
\n*\n \n256\n \n+\n \ns-\nrx_data\n[\n4\n];\n            
\nos_sem_release\n(\ns-\nsema\n
 );\n        }\n    }\n    \nreturn\n 
\n0\n;\n}\n\n\nvoid\n\n\nsenseair_tx\n(\nstruct\n \nsenseair\n \n*s\n, 
\nconst\n \nuint8_t\n \n*tx_data\n, \nint\n \ndata_len\n)\n{\n    
\ns-\ntx_data\n \n=\n \ntx_data\n;\n    \ns-\ntx_len\n \n=\n \ndata_len\n;\n    
\ns-\ntx_off\n \n=\n \n0\n;\n    \ns-\nrx_off\n \n=\n \n0\n;\n\n    
\nhal_uart_start_tx\n(\ns-\nuart\n);\n}\n\n\nint\n\n\nsenseair_read\n(\nenum\n 
\nsenseair_read_type\n \ntype\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n 
\nsenseair\n;\n    \nconst\n \nuint8_t\n \n*cmd\n;\n    \nint\n \ncmd_len\n;\n  
  \nint\n \nrc\n;\n\n    \nif\n (\ns-\ntx_data\n) {\n        \n/*\n\n\n         
* busy\n\n\n         */\n\n        \nreturn\n \n-\n1\n;\n    }\n    \nswitch\n 
(\ntype\n) {\n    \ncase\n \nSENSEAIR_CO2\n:\n        \ncmd\n \n=\n 
\ncmd_read_co2\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_co2\n);\n    
    \nbreak\n;\n    \ndefault\n:\n\n        \nreturn\n \n-\n1\n;\n    }\n    
\nsenseair_tx\n(\ns\n, \ncmd\n, \ncmd_len\n);\n    \nr
 c\n \n=\n \nos_sem_pend\n(\ns-\nsema\n, \nOS_TICKS_PER_SEC\n \n/\n \n2\n);\n   
 \nif\n (\nrc\n \n==\n \nOS_TIMEOUT\n) {\n        \n/*\n\n\n         * 
timeout\n\n\n         */\n\n        \nreturn\n \n-\n2\n;\n    }\n    \nreturn\n 
\ns-\nvalue\n;\n}\n\n\nstatic\n \nint\n\n\nsenseair_shell_func\n(\nint\n 
\nargc\n, \nchar\n \n**argv\n)\n{\n    \nint\n \nvalue\n;\n    \nenum\n 
\nsenseair_read_type\n \ntype\n;\n\n    \nif\n (\nargc\n \n \n2\n) 
{\n\nusage\n:\n        \nconsole_printf\n(\n%s co2\\n\n, \nargv\n[\n0\n]);\n    
    \nreturn\n \n0\n;\n    }\n    \nif\n (\n!strcmp\n(\nargv\n[\n1\n], 
\nco2\n)) {\n        \ntype\n \n=\n \nSENSEAIR_CO2\n;\n    } \nelse\n {\n       
 \ngoto\n \nusage\n;\n    }\n    \nvalue\n \n=\n \nsenseair_read\n(\ntype\n);\n 
   \nif\n (\nvalue\n \n=\n \n0\n) {\n        \nconsole_printf\n(\nGot %d\\n\n, 
\nvalue\n);\n    } \nelse\n {\n        \nconsole_printf\n(\nError while 
reading: %d\\n\n, \nvalue\n);\n    }\n    \nreturn\n 
\n0\n;\n}\n\n\nint\n\n\nsenseair_init\n(
 \nint\n \nuartno\n)\n{\n    \nint\n \nrc\n;\n    \nstruct\n \nsenseair\n 
\n*s\n \n=\n \nsenseair\n;\n\n    \nrc\n \n=\n 
\nshell_cmd_register\n(\nsenseair_cmd\n);\n    \nif\n (\nrc\n) {\n        
\nreturn\n \nrc\n;\n    }\n\n    \nrc\n \n=\n \nos_sem_init\n(\ns-\nsema\n, 
\n1\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \nrc\n 
\n=\n \nhal_uart_init_cbs\n(\nuartno\n, \nsenseair_tx_char\n, \nNULL\n,\n      
\nsenseair_rx_char\n, \nsenseair\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n 
\nrc\n;\n    }\n    \nrc\n \n=\n \nhal_uart_config\n(\nuartno\n, \n9600\n, 
\n8\n, \n1\n, \nHAL_UART_PARITY_NONE\n,\n      \nHAL_UART_FLOW_CTL_NONE\n);\n   
 \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \ns-\nuart\n \n=\n 
\nuartno\n;\n\n    \nreturn\n \n0\n;\n}\n\n\n\n\n\nAnd your modified your 
main() for senseair driver init.\n\n\nint\n\n\nmain\n(\nint\n \nargc\n, 
\nchar\n \n**argv\n)\n{\n    ....\n    \nsenseair_init\n(\n0\n);\n    ....\n    
}\n\n\n\n\n\nYou can see from t
 he code that you are using the HAL interface to open a UART port, and using OS 
\nsemaphore as a way of blocking the task when waiting for read response to 
come back from the sensor.\n\n\nNow comes the fun part: Hooking up the sensor! 
It's fun because a) hooking up a sensor is always \nfun and b) the SenseAir 
sensor's PCB is entirely unlabeled, so you'll have to trust us on how to hook 
it up. \n\n\nSo here we go. \n\n\nYou'll have to do a little soldering. I 
soldered some header pins to the SenseAir K30 board to\nmake connecting wires 
easier using standard jumper wires, but you can also just solder 
wires\nstraight to the board if you prefer.\n\n\nHere's what your SenseAir 
board should look like once it's wired up:\n\n\n\n\nNow that you have that 
wired up, let's get the Arduino Primo wired up. A couple of things to 
note:\n\n\n\n\nThe Arduino Primo's 'console' UART is actually UART1. The 
secondary (bit-banged) UART is \nUART0, so that's where we'll have to hook up 
the SenseAir.\n\n\n\n
 \nHere's what your Arduino Primo should now look like with everything wired 
in:\n\n\n\n\nEverything is wired and you're ready to go! Build and load your 
new app:\n\n\n$ newt build air_q\nBuilding target targets/air_q\nCompiling 
apps/air_quality/src/main.c\nArchiving apps_air_quality.a\nLinking 
myproj/bin/targets/air_q/app/apps/air_quality/air_quality.elf\nTarget 
successfully built: targets/air_q\n$ newt create-image air_q 1.0.0\nApp image 
succesfully generated: 
myproj/bin/targets/air_q/app/apps/air_quality/air_quality.img\n$ newt load 
air_q\nLoading app image into slot 1\n\n\n\n\n\nNow, you should be able to 
connect to your serial port and read values:\n\n\nuser@IsMyLaptop:~]$ minicom 
-D /dev/tty.usbserial-AH02MIE2\n\n\n    Welcome to minicom 2.7\n\n    OPTIONS: 
\n    Compiled on Oct 12 2015, 07:48:30.\n    Port /dev/tty.usbserial-AH02MIE2, 
13:44:40\n\n    Press CTRL-X Z for help on special keys\n\n    1185: \n ?\n    
Commands:\n    1382:     stat      echo         ?    prompt     t
 icks     tasks\n    1390: mempools      date  senseair\n    1395: \n 
senseair\n    senseair co2\n    2143: \n senseair co2\n    Got 
973\n\n\n\n\n\nAnd you're getting valid readings! Congratulations!\n\n\nNext 
we'll hook this all up via Bluetooth so that you can read those values 
remotely.", 
+            "title": "Basic Air Quality Sensor"
         }, 
         {
             "location": 
"/os/tutorials/air_quality_sensor/#air-quality-sensor-project", 
@@ -1277,30 +1277,45 @@
         }, 
         {
             "location": 
"/os/tutorials/air_quality_sensor/#setting-up-source-tree-for-stuff-you-need", 
-            "text": "To start with, you need to create a new project under 
which you will do this development. So you type in:      $ mkdir $HOME/src\n    
$ cd $HOME/src\n    $ newt new air_quality  Let's say you are using 
STM32F3discovery board as the platform. You know you need the board support 
package for that hardware. You can look up its location, add it your project, 
and fetch that along with the core OS components.  To make this happen, you'll 
need to modify the project.yml in your project's root directory.      
[user@IsMyLaptop:~/src/air_quality]$ emacs project.yml  \n    
[user@IsMyLaptop:~/src/air_quality]$ cat project.yml\n    project.name:  
air_quality \n\n    project.repositories:\n        - apache-mynewt-core\n       
 - mynewt_stm32f3\n\n    # Use github s distribution mechanism for core ASF 
libraries.\n    # This provides mirroring automatically for us.\n    #\n    
repository.apache-mynewt-core:\n        type: github\n        vers: 0-latest\n  
      user: apache\n    
     repo: incubator-mynewt-core\n\n    repository.mynewt_stm32f3:\n        
type: github\n        vers: 0-latest\n        user: runtimeinc\n        repo: 
mynewt_stm32f3\n    [user@IsMyLaptop:~/src/air_quality]$ newt install\n    
apache-mynewt-core\n    mynewt_stm32f3\n    
[user@IsMyLaptop:~/src/air_quality]$ ls repos/\n    apache-mynewt-core  
mynewt_stm32f3  Good. You want to make sure you have all the needed bits for 
supporting your board; so you decide to build the blinky project for the 
platform first.  Now create a target for it and build it. Easiest way to 
proceed is to copy the existing target for blinky, and modify it to build for 
STM32F3Discovery board.  [user@IsMyLaptop:~/src/air_quality]$ newt target copy 
my_blinky_sim blink_f3\nTarget successfully copied; targets/my_blinky_sim --  
targets/blink_f3\n[user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 
bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget targets/blink_f3 
successfully set target.bsp to @mynewt_stm32f3
 /hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ newt build 
blink_f3\nCompiling hal_bsp.c\n...\nLinking blinky.elf\nApp successfully built: 
/Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.elf  Good.  You 
know that this platform uses bootloader, which means you have to create a 
target for that too.  [user@IsMyLaptop:~/src/air_quality]$ newt target create 
boot_f3\nTarget targets/boot_f3 successfully 
created\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
show\n@apache-mynewt-core/targets/unittest\n    bsp=hw/bsp/native\n    
build_profile=debug\n    compiler=compiler/sim\ntargets/blink_f3\n    
app=apps/blinky\n    bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\n    
build_profile=debug\ntargets/boot_f3\ntargets/my_blinky_sim\n    
app=apps/blinky\n    bsp=@apache-mynewt-core/hw/bsp/native\n    
build_profile=debug\n[user@IsMyLaptop:~/src/air_quality]$ newt target set 
boot_f3 bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget targets/boot_f3 
successfully set targe
 t.bsp to 
@mynewt_stm32f3/hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ 
newt target set boot_f3 app=@apache-mynewt-core/apps/boot\nTarget 
targets/boot_f3 successfully set target.app to 
@apache-mynewt-core/apps/boot\n[user@IsMyLaptop:~/src/air_quality]$ newt target 
set boot_f3 build_profile=optimized\nTarget targets/boot_f3 successfully set 
target.build_profile to optimized  And then build it, and load it onto the 
board.  newt build boot_f3\n....\nLinking boot.elf\nApp successfully built: 
/Users/user/src/air_quality/bin/boot_f3/apps/boot/boot.elf\n[user@IsMyLaptop:~/src/air_quality]\n$
 newt load boot_f3  Next you must download the targets to board, and see that 
the LED actually blinks. You plug in the STM32F3 discovery board to your 
laptop, and say:  [user@IsMyLaptop:~/src/air_quality]$ newt load 
blink_f3\nDownloading 
/Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img to 
0x08009000\nOpen On-Chip Debugger 0.9.0 (2015-05-28-12:05)\n....\nxPSR: 
0x01000000 pc:
  0x0800026c msp: 0x10002000\nauto erase enabled\nError: couldn t open 
/Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img\n\nError: exit 
status 1\n\nload - Load app image to target for  target-name .\n\nUsage:\n  
newt load [flags]\n\nExamples:\n  newt load  target-name \n\n\nGlobal Flags:\n  
-l, --loglevel string   Log level, defa

<TRUNCATED>

Reply via email to