forked from platformio/platformio-core
Add RFDuino iBeacon example
This commit is contained in:
@ -232,3 +232,5 @@ Switch Science
|
|||||||
- 16 MHz
|
- 16 MHz
|
||||||
- 256 Kb
|
- 256 Kb
|
||||||
- 16 Kb
|
- 16 Kb
|
||||||
|
|
||||||
|
.. include:: nordicnrf51_extra.rst
|
||||||
|
18
docs/platforms/nordicnrf51_extra.rst
Normal file
18
docs/platforms/nordicnrf51_extra.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
.. Copyright 2014-2015 Ivan Kravets <me@ikravets.com>
|
||||||
|
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 <https://github.com/platformio/platformio/tree/develop/examples/nordicnrf51>`_.
|
||||||
|
|
||||||
|
* `RFDuino iBeacon <https://github.com/platformio/platformio/tree/develop/examples/nordicnrf51/rfduino-ibeacon>`_
|
1
examples/nordicnrf51/rfduino-ibeacon/.gitignore
vendored
Normal file
1
examples/nordicnrf51/rfduino-ibeacon/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.pioenvs
|
65
examples/nordicnrf51/rfduino-ibeacon/.travis.yml
Normal file
65
examples/nordicnrf51/rfduino-ibeacon/.travis.yml
Normal file
@ -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
|
29
examples/nordicnrf51/rfduino-ibeacon/README.rst
Normal file
29
examples/nordicnrf51/rfduino-ibeacon/README.rst
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
.. Copyright 2014-2015 Ivan Kravets <me@ikravets.com>
|
||||||
|
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 <http://docs.platformio.org/en/latest/installation.html>`_
|
||||||
|
2. Download `source code with examples <https://github.com/platformio/platformio/archive/develop.zip>`_
|
||||||
|
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
|
38
examples/nordicnrf51/rfduino-ibeacon/lib/readme.txt
Normal file
38
examples/nordicnrf51/rfduino-ibeacon/lib/readme.txt
Normal file
@ -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 <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
23
examples/nordicnrf51/rfduino-ibeacon/platformio.ini
Normal file
23
examples/nordicnrf51/rfduino-ibeacon/platformio.ini
Normal file
@ -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
|
61
examples/nordicnrf51/rfduino-ibeacon/src/iBeacon.ino
Normal file
61
examples/nordicnrf51/rfduino-ibeacon/src/iBeacon.ino
Normal file
@ -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 <RFduinoBLE.h>
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
from os import environ
|
from os import environ
|
||||||
from os.path import isfile, join
|
from os.path import join
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables
|
from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables
|
||||||
|
Reference in New Issue
Block a user