Skip to content

Commit ecae218

Browse files
committed
Merge branch 'release/v3.4.0'
2 parents 9c88bae + 67bcb4f commit ecae218

File tree

12 files changed

+395
-27
lines changed

12 files changed

+395
-27
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
- PLATFORMIO_PROJECT_DIR=examples/arduino-blink
1717
- PLATFORMIO_PROJECT_DIR=examples/arduino-ble-led
1818
- PLATFORMIO_PROJECT_DIR=examples/arduino-bluefruit-bleuart
19+
- PLATFORMIO_PROJECT_DIR=examples/arduino-nina-b1-generic-example PLATFORMIO_BUILD_FLAGS="-DNRF52_S132"
1920
- PLATFORMIO_PROJECT_DIR=examples/mbed-ble-thermometer
2021
- PLATFORMIO_PROJECT_DIR=examples/mbed-blink
2122
- PLATFORMIO_PROJECT_DIR=examples/mbed-dsp

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ environment:
1515

1616
install:
1717
- cmd: git submodule update --init --recursive
18-
- cmd: SET PATH=%PATH%;C:\Python27\Scripts
19-
- cmd: pip install -U https://github.com/platformio/platformio/archive/develop.zip
18+
- cmd: SET PATH=%PATH%;C:\Python36\Scripts
19+
- cmd: pip3 install -U https://github.com/platformio/platformio/archive/develop.zip
2020
- cmd: platformio platform install file://.
2121

2222
test_script:

builder/frameworks/arduino

builder/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
SIZECHECKCMD="$SIZETOOL -A -d $SOURCES",
5858
SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES',
5959

60+
ERASEFLAGS=["--eraseall", "-f", "nrf52"],
61+
ERASECMD="nrfjprog $ERASEFLAGS",
62+
6063
PROGSUFFIX=".elf"
6164
)
6265

@@ -321,6 +324,15 @@ def _jlink_cmd_script(env, source):
321324

322325
AlwaysBuild(env.Alias("upload", target_firm, upload_actions))
323326

327+
328+
#
329+
# Target: Erase Flash
330+
#
331+
332+
AlwaysBuild(
333+
env.Alias("erase", None, env.VerboseAction("$ERASECMD",
334+
"Erasing...")))
335+
324336
#
325337
# Default targets
326338
#

examples/arduino-bluefruit-bleuart/src/main.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <bluefruit.h>
1515

1616
// BLE Service
17+
BLEDfu bledfu; // OTA DFU service
1718
BLEDis bledis; // device information
1819
BLEUart bleuart; // uart over ble
1920
BLEBas blebas; // battery
@@ -41,12 +42,14 @@ void setup()
4142
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
4243

4344
Bluefruit.begin();
44-
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
45-
Bluefruit.setTxPower(4);
45+
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
4646
Bluefruit.setName("Bluefruit52");
4747
//Bluefruit.setName(getMcuUniqueID()); // useful testing with multiple central connections
48-
Bluefruit.setConnectCallback(connect_callback);
49-
Bluefruit.setDisconnectCallback(disconnect_callback);
48+
Bluefruit.Periph.setConnectCallback(connect_callback);
49+
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
50+
51+
// To be consistent OTA DFU should be added first if it exists
52+
bledfu.begin();
5053

5154
// Configure and Start Device Information Service
5255
bledis.setManufacturer("Adafruit Industries");
@@ -67,7 +70,7 @@ void setup()
6770
Serial.println("Once connected, enter character(s) that you wish to send");
6871
}
6972

70-
static void startAdv(void)
73+
void startAdv(void)
7174
{
7275
// Advertising packet
7376
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
@@ -115,16 +118,16 @@ void loop()
115118
ch = (uint8_t) bleuart.read();
116119
Serial.write(ch);
117120
}
118-
119-
// Request CPU to enter low-power mode until an event/interrupt occurs
120-
waitForEvent();
121121
}
122122

123123
// callback invoked when central connects
124-
static void connect_callback(uint16_t conn_handle)
124+
void connect_callback(uint16_t conn_handle)
125125
{
126+
// Get the reference to current connection
127+
BLEConnection* connection = Bluefruit.Connection(conn_handle);
128+
126129
char central_name[32] = { 0 };
127-
Bluefruit.Gap.getPeerName(conn_handle, central_name, sizeof(central_name));
130+
connection->getPeerName(central_name, sizeof(central_name));
128131

129132
Serial.print("Connected to ");
130133
Serial.println(central_name);
@@ -134,9 +137,8 @@ static void connect_callback(uint16_t conn_handle)
134137
* Callback invoked when a connection is dropped
135138
* @param conn_handle connection where this event happens
136139
* @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h
137-
* https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include/ble_hci.h
138140
*/
139-
static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
141+
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
140142
{
141143
(void) conn_handle;
142144
(void) reason;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Arduino-u-blox-NINA-B1
2+
3+
u-blox NINA-B1 Arduino example + SHT31 temperature and humidity + Bluetooth BLE
4+
5+
[![GitHub version](https://img.shields.io/github/release/ldab/Arduino-u-blox-NINA-B1.svg)](https://github.com/ldab/Arduino-u-blox-NINA-B1/releases/latest)
6+
[![Build Status](https://travis-ci.org/ldab/Arduino-u-blox-NINA-B1.svg?branch=master)](https://travis-ci.org/ldab/Arduino-u-blox-NINA-B1)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/ldab/Arduino-u-blox-NINA-B1/blob/master/LICENSE)
8+
9+
[![GitHub last commit](https://img.shields.io/github/last-commit/ldab/Arduino-u-blox-NINA-B1.svg?style=social)](https://github.com/ldab/Arduino-u-blox-NINA-B1)
10+
11+
[![EVK-NINA-B1](https://www.u-blox.com/sites/default/files/styles/product_full/public/products/EVK-NINA-B1_2D-medium_RGB-CI.png)](https://www.u-blox.com/en/product/nina-b1-series)
12+
13+
## How to build PlatformIO based project
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+
```
21+
# Change directory to example
22+
> cd platform-nordicnrf52/examples/Arduino-u-blox-NINA-B1
23+
24+
# Build project
25+
> platformio run
26+
27+
# Upload firmware
28+
> platformio run --target upload
29+
30+
# Build specific environment
31+
> platformio run -e nina_b1
32+
33+
# Upload firmware for the specific environment
34+
> platformio run -e nina_b1 --target upload
35+
36+
# Clean build files
37+
> platformio run --target clean
38+
```
39+
40+
## Why?
41+
42+
This example tries to implement some key functions and key PIN atributes in order to get you started with using Arduino and the NRF52832 BLE board u-blox NINA-B1.
43+
44+
Timer functionas are implemented intead of `delay()` and the PINs have been re-mapped on the `#define` section
45+
46+
## Bluetooth iOS and Android app
47+
48+
You can download the sample Bluetooth low energy app - BLE App straight from u-blox wesite: [https://www.u-blox.com/en/product/bluetooth-ios-and-android-app](https://www.u-blox.com/en/product/bluetooth-ios-and-android-app)
49+
50+
![App example](https://raw.githubusercontent.com/ldab/Arduino-u-blox-NINA-B1/master/extras/Screenshot_20190328-130832_u-blox%20BLE.jpg)
51+
52+
## fatal error: ble_gatts.h: No such file or directory
53+
54+
The arduino-nRF5x core **REQUIRES** a SoftDevice in order to successfully use this library. Please see [Flashing a SoftDevice](https://github.com/sandeepmistry/arduino-nRF5#selecting-a-softdevice).
55+
56+
On PlatformIO and when using this example you don't need to do anything special as the `build_flags = -DNRF52_S132` has already been included on `platform.ini` file.
57+
58+
SoftDevices contain the BLE stack and housekeeping, and must be downloaded once before a sketch using BLE can be loaded. The SD consumes ~5k of Ram + some extra based on actual BLE configuration.
59+
60+
* SoftDevice S132 v2.0.1 supports nRF52 in peripheral and central role. It is 112k in size.
61+
62+
## Credits
63+
64+
Github Shields and Badges created with [Shields.io](https://github.com/badges/shields/)
65+
66+
Sandeep Mistry's [Arduino BLE library](https://github.com/sandeepmistry/arduino-BLEPeripheral)
67+
68+
Adafruit [SHT31 Library](https://www.adafruit.com/product/2857)
69+
70+
u-blox NINA-B1 blueprint example [GitHub](https://github.com/u-blox/blueprint-B200-NINA-B1)
71+
72+
u-blox official mBed [library](https://os.mbed.com/platforms/u-blox-EVK-NINA-B1/)
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:nina_b1]
12+
platform = nordicnrf52
13+
board = ublox_evk_nina_b1
14+
framework = arduino
15+
16+
build_flags = -DNRF52_S132
17+
18+
lib_deps =
19+
Adafruit SHT31 Library
20+
Ticker
21+
BLEPeripheral
22+
23+
monitor_speed = 115200
24+
25+
# upload_protocol = blackmagic

0 commit comments

Comments
 (0)