Skip to content

Commit

Permalink
Merge branch 'release/v1.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jul 18, 2017
2 parents 825210f + 2170f4a commit 838f129
Show file tree
Hide file tree
Showing 54 changed files with 1,939 additions and 1,606 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
atmelavr-and-arduino/engduino-magnetometer/.piolibdeps
.pioenvs
.piolibdeps
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ How to build PlatformIO based project
.. code-block:: bash
# Change directory to example
> cd platformio-examples/mbed/microbit-hello-world
> cd platformio-examples/mbed/mbed-ble-thermometer
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Build specific environment
> platformio run -e nrf52_dk
# Upload firmware for the specific environment
> platformio run -e nrf52_dk --target upload
# Clean build files
> platformio run --target clean
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ Then in `src/main.c` you should use:
PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.

More information about PlatformIO Library Dependency Finder
- http://docs.platformio.org/page/librarymanager/ldf.html
See additional options for PlatformIO Library Dependency Finder `lib_*`:

http://docs.platformio.org/page/projectconf.html#lib-install

32 changes: 32 additions & 0 deletions mbed/mbed-ble-thermometer/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[env:nrf51_dk]
platform = nordicnrf51
framework = mbed
board = nrf51_dk
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

[env:nrf51_dongle]
platform = nordicnrf51
framework = mbed
board = nrf51_dongle
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

[env:nrf52_dk]
platform = nordicnrf52
framework = mbed
board = nrf52_dk
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

[env:delta_dfbm_nq620]
platform = nordicnrf52
framework = mbed
board = delta_dfbm_nq620
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
105 changes: 105 additions & 0 deletions mbed/mbed-ble-thermometer/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* 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.
*/

#include <mbed_events.h>
#include <rtos.h>
#include "mbed.h"
#include "ble/BLE.h"
#include "ble/services/HealthThermometerService.h"

DigitalOut led1(LED1, 1);

const static char DEVICE_NAME[] = "PIOTherm";
static const uint16_t uuid16_list[] = {GattService::UUID_HEALTH_THERMOMETER_SERVICE};

static float currentTemperature = 39.6;
static HealthThermometerService *thermometerServicePtr;

static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);

/* Restart Advertising on disconnection*/
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *)
{
BLE::Instance().gap().startAdvertising();
}

void updateSensorValue(void) {
/* Do blocking calls or whatever is necessary for sensor polling.
In our case, we simply update the Temperature measurement. */
currentTemperature = (currentTemperature + 0.1 > 43.0) ? 39.6 : currentTemperature + 0.1;
thermometerServicePtr->updateTemperature(currentTemperature);
}

void periodicCallback(void)
{
led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */

if (BLE::Instance().gap().getState().connected) {
eventQueue.call(updateSensorValue);
}
}

void onBleInitError(BLE &ble, ble_error_t error)
{
/* Initialization error handling should go here */
}

void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
{
BLE& ble = params->ble;
ble_error_t error = params->error;

if (error != BLE_ERROR_NONE) {
onBleInitError(ble, error);
return;
}

if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {
return;
}

ble.gap().onDisconnection(disconnectionCallback);

/* Setup primary service. */
thermometerServicePtr = new HealthThermometerService(ble, currentTemperature, HealthThermometerService::LOCATION_EAR);

/* setup advertising */
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::THERMOMETER_EAR);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.gap().setAdvertisingInterval(1000); /* 1000ms */
ble.gap().startAdvertising();
}

void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
BLE &ble = BLE::Instance();
eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
}

int main()
{
eventQueue.call_every(500, periodicCallback);

BLE &ble = BLE::Instance();
ble.onEventsToProcess(scheduleBleEventsProcessing);
ble.init(bleInitComplete);

eventQueue.dispatch_forever();

return 0;
}
3 changes: 3 additions & 0 deletions mbed/mbed-events/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pioenvs
.clang_complete
.gcc-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
#
#
# Please choice one of the following templates (proposed below) and uncomment
# Please choose 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).
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ How to build PlatformIO based project
.. code-block:: bash
# Change directory to example
> cd platformio-examples/mbed/mbed-http-client
> cd platformio-examples/mbed/mbed-events
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Build specific environment
> platformio run -e nrf52_dk
# Upload firmware for the specific environment
> platformio run -e nrf52_dk --target upload
# Clean build files
> platformio run --target clean
38 changes: 38 additions & 0 deletions mbed/mbed-events/lib/readme.txt
Original file line number Diff line number Diff line change
@@ -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 organized `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/page/projectconf.html#lib-install

105 changes: 105 additions & 0 deletions mbed/mbed-events/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

# NXP LPC Platform
[env:lpc11u35]
platform = nxplpc
framework = mbed
board = lpc11u35

[env:lpc1768]
platform = nxplpc
framework = mbed
board = lpc1768
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

# Nordic nRF51 Platform
[env:redBearLab]
platform = nordicnrf51
framework = mbed
board = redBearLab

# Nordic nRF52 Platform
[env:nrf52_dk]
platform = nordicnrf52
framework = mbed
board = nrf52_dk

[env:delta_dfbm_nq620]
platform = nordicnrf52
framework = mbed
board = delta_dfbm_nq620
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

# Freescale FRDM Platform
[env:frdm_kl25z]
platform = freescalekinetis
framework = mbed
board = frdm_kl25z

[env:frdm_k64f]
platform = freescalekinetis
framework = mbed
board = frdm_k64f
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

# Maxim32 Platform
[env:max32600mbed]
platform = maxim32
framework = mbed
board = max32600mbed

[env:maxwsnenv]
platform = maxim32
framework = mbed
board = maxwsnenv
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

# ST STM32 Platform
[env:nucleo_f401re]
platform = ststm32
framework = mbed
board = nucleo_f401re

[env:mote_l152rc]
platform = ststm32
framework = mbed
board = mote_l152rc
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

# Teensy Platform
[env:teensy31]
platform = teensy
framework = mbed
board = teensy31
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

# Silicon Labs EFM32 Platform
[env:efm32hg_stk3400]
platform = siliconlabsefm32
framework = mbed
board = efm32hg_stk3400

[env:efm32wg_stk3800]
platform = siliconlabsefm32
framework = mbed
board = efm32wg_stk3800
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

# WIZNet7500 Platform
[env:wizwiki_w7500]
platform = wiznet7500
framework = mbed
board = wizwiki_w7500

[env:wizwiki_w7500eco]
platform = wiznet7500
framework = mbed
board = wizwiki_w7500eco
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
15 changes: 15 additions & 0 deletions mbed/mbed-events/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "mbed_events.h"
#include <stdio.h>

int main() {
// creates a queue with the default size
EventQueue queue;

// events are simple callbacks
queue.call(printf, "called immediately\n");
queue.call_in(2000, printf, "called in 2 seconds\n");
queue.call_every(1000, printf, "called every 1 seconds\n");

// events are executed by the dispatch method
queue.dispatch();
}
3 changes: 3 additions & 0 deletions mbed/mbed-filesystem/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pioenvs
.clang_complete
.gcc-flags.json
Loading

0 comments on commit 838f129

Please sign in to comment.