diff --git a/docs/platforms/nordicnrf51.rst b/docs/platforms/nordicnrf51.rst index 2e74f90e..1a0fa184 100644 --- a/docs/platforms/nordicnrf51.rst +++ b/docs/platforms/nordicnrf51.rst @@ -232,3 +232,5 @@ Switch Science - 16 MHz - 256 Kb - 16 Kb + +.. include:: nordicnrf51_extra.rst diff --git a/docs/platforms/nordicnrf51_extra.rst b/docs/platforms/nordicnrf51_extra.rst new file mode 100644 index 00000000..f2b68ea5 --- /dev/null +++ b/docs/platforms/nordicnrf51_extra.rst @@ -0,0 +1,18 @@ +.. Copyright 2014-2015 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Examples +-------- + +All project examples are located in PlatformIO repository +`Examples for Nordic nRF51 platform `_. + +* `RFDuino iBeacon `_ diff --git a/examples/nordicnrf51/rfduino-ibeacon/.gitignore b/examples/nordicnrf51/rfduino-ibeacon/.gitignore new file mode 100644 index 00000000..e90612ed --- /dev/null +++ b/examples/nordicnrf51/rfduino-ibeacon/.gitignore @@ -0,0 +1 @@ +.pioenvs \ No newline at end of file diff --git a/examples/nordicnrf51/rfduino-ibeacon/.travis.yml b/examples/nordicnrf51/rfduino-ibeacon/.travis.yml new file mode 100644 index 00000000..b57f6fa8 --- /dev/null +++ b/examples/nordicnrf51/rfduino-ibeacon/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N diff --git a/examples/nordicnrf51/rfduino-ibeacon/README.rst b/examples/nordicnrf51/rfduino-ibeacon/README.rst new file mode 100644 index 00000000..8a399ded --- /dev/null +++ b/examples/nordicnrf51/rfduino-ibeacon/README.rst @@ -0,0 +1,29 @@ +.. Copyright 2014-2015 Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `source code with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platformio-develop/examples/nordicnrf51/rfduino-ibeacon + + # Process example project + > platformio run + + # Upload firmware + > platformio run --target upload diff --git a/examples/nordicnrf51/rfduino-ibeacon/lib/readme.txt b/examples/nordicnrf51/rfduino-ibeacon/lib/readme.txt new file mode 100644 index 00000000..b06c9408 --- /dev/null +++ b/examples/nordicnrf51/rfduino-ibeacon/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organised `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/nordicnrf51/rfduino-ibeacon/platformio.ini b/examples/nordicnrf51/rfduino-ibeacon/platformio.ini new file mode 100644 index 00000000..a614db2c --- /dev/null +++ b/examples/nordicnrf51/rfduino-ibeacon/platformio.ini @@ -0,0 +1,23 @@ +# +# Project Configuration File +# +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html +# + +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + +# Simple and base environment +# [env:mybaseenv] +# platform = %INSTALLED_PLATFORM_NAME_HERE% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload + +[env:rfduino] +platform = nordicnrf51 +framework = arduino +board = rfduino diff --git a/examples/nordicnrf51/rfduino-ibeacon/src/iBeacon.ino b/examples/nordicnrf51/rfduino-ibeacon/src/iBeacon.ino new file mode 100644 index 00000000..d85084df --- /dev/null +++ b/examples/nordicnrf51/rfduino-ibeacon/src/iBeacon.ino @@ -0,0 +1,61 @@ +/* +The sketch demonstrates iBecaon from an RFduino +*/ + +/* + Copyright (c) 2014 OpenSourceRF.com. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include + +// pin 3 on the RGB shield is the green led +int led = 3; + +void setup() { + // led used to indicate that iBeacon has started + pinMode(led, OUTPUT); + + // do iBeacon advertising + RFduinoBLE.iBeacon = true; + + // start the BLE stack + RFduinoBLE.begin(); +} + +void loop() { + // switch to lower power mode + RFduino_ULPDelay(INFINITE); +} + +void RFduinoBLE_onAdvertisement(bool start) +{ + // turn the green led on if we start advertisement, and turn it + // off if we stop advertisement + + if (start) + digitalWrite(led, HIGH); + else + digitalWrite(led, LOW); +} diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 6cf1e05d..e0b7235a 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -14,7 +14,7 @@ import json from os import environ -from os.path import isfile, join +from os.path import join from time import time from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables