Skip to content

Commit a2e0652

Browse files
committed
Merge branch 'release/v1.1.0'
2 parents c0b77af + 763255b commit a2e0652

13 files changed

Lines changed: 293 additions & 36 deletions

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ python:
33
- "2.7"
44

55
env:
6+
- PLATFORMIO_PROJECT_DIR=examples/mbed-ble-thermometer
67
- PLATFORMIO_PROJECT_DIR=examples/mbed-blink
78
- PLATFORMIO_PROJECT_DIR=examples/mbed-dsp
89
- PLATFORMIO_PROJECT_DIR=examples/mbed-events
@@ -21,6 +22,6 @@ notifications:
2122

2223
slack:
2324
rooms:
24-
secure: mnq1v22e4YsxIGBy8SMWsElAPgusglw+rt+E4xX+Y/9C1gv14ZzPVM2KTq07Knuazpq/PLFG8Ag0bbToFNOgT8j5b8RoAYr5RGkSZLnQOp4OHh474szAjfp9eWsqBlhaAanWmIDgWlpOVKaB6VaLkGb8QtmW7fA8LkHIuzWRz/8ujUxcw4QQ1l29cFR8dAATl1gW14UFAzXCO0vqgA/ePqQrV9HyqkBT5zGsdcangivLm3Q9asGGnmjLRyCJDCKmrbMOhaV9GwkP/BPXN4yj+ZwHPn4VyNS4Tb/RDHjSocij2/GnaWtqhH4FN5CrE2A/FNiN4mPiMcKbNsjAsww2IglzBhZ/Z1UqC1ekkw6fLO5pkcvmk9+DEAM+pMR8KTdKxrlY6l4xW9pq2Agiu0PPsN5hWc6ijm+x5GrbRvZ4FpR74Ps8z5ziPpyx/d4lMGnIzgluCqqjIEd+OJfiazCrzH1xQycNHfpYA8IQ9fnTQhQyK337cO/yILLryDMu/xw6CibuLRXeOJWbYlBT0r1Ab1Oso8jph9aSFwxuV0zHfnQPr+9lCMNkcIxNRtbeI0R2ftXIKtuOyEOSt+b366rCHXf8ZDtqsifGNTncA259mVgkRQHsH5QosE+4skAjdWizdHaSmezUzQLn3w/OMzl+QRAq3eENypN4KtJFwA7ALcY=
25+
secure: K16XOvJ+WtAWkif7bB88bPTTeNzM5vAFHHEzSe5UF6vjsyhM7PEITbwB6TCB9upBTsgpBLO8ep98MrOhISnqRRbPXm5G0UDMbxVfsUtrFgR/+YnzF0+GrcMYYYI0vmPE5voM2INjDVca1m8La8udkCQjxojIrIKbxDFnvAgn6irVzGgP4THZEsRL55Nzgun79QALp2F1oiNv+YtZW7sgz7myRk4A1HKYs0cN5JkvbsizS91KYUaGFZwl98kerHykk8UVtUr1UT4xp5ZQnfrvbYRqTL+z4b9Xzri3KmTUHak2v1GyHk1ZJNFDI2T0UvlwTUmVdltFP3La9CMN7lKlOma2HiTKv433mtpU/9+x+iouBZ6ThyVXxxSrQyF2nUtFdp10RTrVzWu8YQJyeMYiOm6Rs6zfFrtNXQg4AI7qdEJmh1TyKreXiia4iSd6A1W8zQfqDsCZhd9EwBfu2cA25+2T52kW/N1ZuVPNr4XXYWXsYjXw6cVNxDHJA0s+uCSxnEif/oMtwS29mwe73Y/26rwli5QWhKn1aWGNCAVvikpm/xVBcQzj7W79Ch4o5NEHGqAIZtDHmDNQkMwPUN3u8sjqescXG/jP9SAuAxmpbu4+FQFr9kj8JHLXdzHexvL3I6D1WiVBbVQBiyzvWFJBzNKou5PX9H069eswr632jhY=
2526
on_failure: always
2627
on_success: change

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build: off
22
environment:
33

44
matrix:
5+
- PLATFORMIO_PROJECT_DIR: "examples/mbed-ble-thermometer"
56
- PLATFORMIO_PROJECT_DIR: "examples/mbed-blink"
67
- PLATFORMIO_PROJECT_DIR: "examples/mbed-dsp"
78
- PLATFORMIO_PROJECT_DIR: "examples/mbed-events"

builder/frameworks/mbed

Submodule mbed updated 1 file
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pioenvs
2+
.clang_complete
3+
.gcc-flags.json
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Continuous Integration (CI) is the practice, in software
2+
# engineering, of merging all developer working copies with a shared mainline
3+
# several times a day < http://docs.platformio.org/page/ci/index.html >
4+
#
5+
# Documentation:
6+
#
7+
# * Travis CI Embedded Builds with PlatformIO
8+
# < https://docs.travis-ci.com/user/integration/platformio/ >
9+
#
10+
# * PlatformIO integration with Travis CI
11+
# < http://docs.platformio.org/page/ci/travis.html >
12+
#
13+
# * User Guide for `platformio ci` command
14+
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
15+
#
16+
#
17+
# Please choose one of the following templates (proposed below) and uncomment
18+
# it (remove "# " before each line) or use own configuration according to the
19+
# Travis CI documentation (see above).
20+
#
21+
22+
23+
#
24+
# Template #1: General project. Test it using existing `platformio.ini`.
25+
#
26+
27+
# language: python
28+
# python:
29+
# - "2.7"
30+
#
31+
# sudo: false
32+
# cache:
33+
# directories:
34+
# - "~/.platformio"
35+
#
36+
# install:
37+
# - pip install -U platformio
38+
#
39+
# script:
40+
# - platformio run
41+
42+
43+
#
44+
# Template #2: The project is intended to by used as a library with examples
45+
#
46+
47+
# language: python
48+
# python:
49+
# - "2.7"
50+
#
51+
# sudo: false
52+
# cache:
53+
# directories:
54+
# - "~/.platformio"
55+
#
56+
# env:
57+
# - PLATFORMIO_CI_SRC=path/to/test/file.c
58+
# - PLATFORMIO_CI_SRC=examples/file.ino
59+
# - PLATFORMIO_CI_SRC=path/to/test/directory
60+
#
61+
# install:
62+
# - pip install -U platformio
63+
#
64+
# script:
65+
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. Copyright 2014-present PlatformIO <contact@platformio.org>
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
http://www.apache.org/licenses/LICENSE-2.0
6+
Unless required by applicable law or agreed to in writing, software
7+
distributed under the License is distributed on an "AS IS" BASIS,
8+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
See the License for the specific language governing permissions and
10+
limitations under the License.
11+
12+
How to build PlatformIO based project
13+
=====================================
14+
15+
1. `Install PlatformIO Core <http://docs.platformio.org/page/core.html>`_
16+
2. Download `development platform with examples <https://github.com/platformio/platform-nordicnrf52/archive/develop.zip>`_
17+
3. Extract ZIP archive
18+
4. Run these commands:
19+
20+
.. code-block:: bash
21+
22+
# Change directory to example
23+
> cd platform-nordicnrf52/examples/mbed-ble-thermometer
24+
25+
# Build project
26+
> platformio run
27+
28+
# Upload firmware
29+
> platformio run --target upload
30+
31+
# Build specific environment
32+
> platformio run -e nrf52_dk
33+
34+
# Upload firmware for the specific environment
35+
> platformio run -e nrf52_dk --target upload
36+
37+
# Clean build files
38+
> platformio run --target clean
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
This directory is intended for the project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link to executable file.
4+
5+
The source code of each library should be placed in separate directory, like
6+
"lib/private_lib/[here are source files]".
7+
8+
For example, see how can be organized `Foo` and `Bar` libraries:
9+
10+
|--lib
11+
| |--Bar
12+
| | |--docs
13+
| | |--examples
14+
| | |--src
15+
| | |- Bar.c
16+
| | |- Bar.h
17+
| |--Foo
18+
| | |- Foo.c
19+
| | |- Foo.h
20+
| |- readme.txt --> THIS FILE
21+
|- platformio.ini
22+
|--src
23+
|- main.c
24+
25+
Then in `src/main.c` you should use:
26+
27+
#include <Foo.h>
28+
#include <Bar.h>
29+
30+
// rest H/C/CPP code
31+
32+
PlatformIO will find your libraries automatically, configure preprocessor's
33+
include paths and build them.
34+
35+
See additional options for PlatformIO Library Dependency Finder `lib_*`:
36+
37+
http://docs.platformio.org/page/projectconf.html#lib-install
38+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter, extra scripting
4+
; Upload options: custom port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
;
7+
; Please visit documentation for the other options and examples
8+
; http://docs.platformio.org/page/projectconf.html
9+
10+
[env:nrf52_dk]
11+
platform = nordicnrf52
12+
framework = mbed
13+
board = nrf52_dk
14+
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
15+
16+
17+
[env:delta_dfbm_nq620]
18+
platform = nordicnrf52
19+
framework = mbed
20+
board = delta_dfbm_nq620
21+
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <mbed_events.h>
18+
#include <rtos.h>
19+
#include "mbed.h"
20+
#include "ble/BLE.h"
21+
#include "ble/services/HealthThermometerService.h"
22+
23+
DigitalOut led1(LED1, 1);
24+
25+
const static char DEVICE_NAME[] = "PIOTherm";
26+
static const uint16_t uuid16_list[] = {GattService::UUID_HEALTH_THERMOMETER_SERVICE};
27+
28+
static float currentTemperature = 39.6;
29+
static HealthThermometerService *thermometerServicePtr;
30+
31+
static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);
32+
33+
/* Restart Advertising on disconnection*/
34+
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *)
35+
{
36+
BLE::Instance().gap().startAdvertising();
37+
}
38+
39+
void updateSensorValue(void) {
40+
/* Do blocking calls or whatever is necessary for sensor polling.
41+
In our case, we simply update the Temperature measurement. */
42+
currentTemperature = (currentTemperature + 0.1 > 43.0) ? 39.6 : currentTemperature + 0.1;
43+
thermometerServicePtr->updateTemperature(currentTemperature);
44+
}
45+
46+
void periodicCallback(void)
47+
{
48+
led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
49+
50+
if (BLE::Instance().gap().getState().connected) {
51+
eventQueue.call(updateSensorValue);
52+
}
53+
}
54+
55+
void onBleInitError(BLE &ble, ble_error_t error)
56+
{
57+
/* Initialization error handling should go here */
58+
}
59+
60+
void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
61+
{
62+
BLE& ble = params->ble;
63+
ble_error_t error = params->error;
64+
65+
if (error != BLE_ERROR_NONE) {
66+
onBleInitError(ble, error);
67+
return;
68+
}
69+
70+
if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {
71+
return;
72+
}
73+
74+
ble.gap().onDisconnection(disconnectionCallback);
75+
76+
/* Setup primary service. */
77+
thermometerServicePtr = new HealthThermometerService(ble, currentTemperature, HealthThermometerService::LOCATION_EAR);
78+
79+
/* setup advertising */
80+
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
81+
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
82+
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::THERMOMETER_EAR);
83+
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
84+
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
85+
ble.gap().setAdvertisingInterval(1000); /* 1000ms */
86+
ble.gap().startAdvertising();
87+
}
88+
89+
void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
90+
BLE &ble = BLE::Instance();
91+
eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
92+
}
93+
94+
int main()
95+
{
96+
eventQueue.call_every(500, periodicCallback);
97+
98+
BLE &ble = BLE::Instance();
99+
ble.onEventsToProcess(scheduleBleEventsProcessing);
100+
ble.init(bleInitComplete);
101+
102+
eventQueue.dispatch_forever();
103+
104+
return 0;
105+
}

examples/mbed-events/platformio.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ board = nrf52_dk
1515
[env:delta_dfbm_nq620]
1616
platform = nordicnrf52
1717
framework = mbed
18-
board = delta_dfbm_nq620
18+
board = delta_dfbm_nq620
19+
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

0 commit comments

Comments
 (0)