Skip to content

Commit 838f129

Browse files
committed
Merge branch 'release/v1.8.2'
2 parents 825210f + 2170f4a commit 838f129

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1939
-1606
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
atmelavr-and-arduino/engduino-magnetometer/.piolibdeps
1+
.pioenvs
2+
.piolibdeps
File renamed without changes.
File renamed without changes.

mbed/microbit-hello-world/README.rst renamed to mbed/mbed-ble-thermometer/README.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ How to build PlatformIO based project
2020
.. code-block:: bash
2121
2222
# Change directory to example
23-
> cd platformio-examples/mbed/microbit-hello-world
23+
> cd platformio-examples/mbed/mbed-ble-thermometer
2424
2525
# Build project
2626
> platformio run
2727
2828
# Upload firmware
2929
> platformio run --target upload
3030
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+
3137
# Clean build files
3238
> platformio run --target clean

mbed/microbit-hello-world/lib/readme.txt renamed to mbed/mbed-ble-thermometer/lib/readme.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ Then in `src/main.c` you should use:
3232
PlatformIO will find your libraries automatically, configure preprocessor's
3333
include paths and build them.
3434

35-
More information about PlatformIO Library Dependency Finder
36-
- http://docs.platformio.org/page/librarymanager/ldf.html
35+
See additional options for PlatformIO Library Dependency Finder `lib_*`:
36+
37+
http://docs.platformio.org/page/projectconf.html#lib-install
38+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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:nrf51_dk]
11+
platform = nordicnrf51
12+
framework = mbed
13+
board = nrf51_dk
14+
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
15+
16+
[env:nrf51_dongle]
17+
platform = nordicnrf51
18+
framework = mbed
19+
board = nrf51_dongle
20+
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
21+
22+
[env:nrf52_dk]
23+
platform = nordicnrf52
24+
framework = mbed
25+
board = nrf52_dk
26+
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
27+
28+
[env:delta_dfbm_nq620]
29+
platform = nordicnrf52
30+
framework = mbed
31+
board = delta_dfbm_nq620
32+
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+
}

mbed/mbed-events/.gitignore

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

mbed/microbit-hello-world/.travis.yml renamed to mbed/mbed-events/.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
1515
#
1616
#
17-
# Please choice one of the following templates (proposed below) and uncomment
17+
# Please choose one of the following templates (proposed below) and uncomment
1818
# it (remove "# " before each line) or use own configuration according to the
1919
# Travis CI documentation (see above).
2020
#

mbed/mbed-http-client/README.rst renamed to mbed/mbed-events/README.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ How to build PlatformIO based project
2020
.. code-block:: bash
2121
2222
# Change directory to example
23-
> cd platformio-examples/mbed/mbed-http-client
23+
> cd platformio-examples/mbed/mbed-events
2424
2525
# Build project
2626
> platformio run
2727
2828
# Upload firmware
2929
> platformio run --target upload
3030
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+
3137
# Clean build files
3238
> platformio run --target clean

0 commit comments

Comments
 (0)