Skip to content

Commit 2e6a327

Browse files
committed
Improve code formatting for sketches of CurieBLE library
Update code formatting for sketches of CurieBLE library with the Auto Format tool of Arduino IDE Signed-off-by: Biagio Montaruli <[email protected]>
1 parent e044d9b commit 2e6a327

File tree

11 files changed

+587
-654
lines changed

11 files changed

+587
-654
lines changed

libraries/CurieBLE/examples/BatteryAdvChange/BatteryAdvChange.ino

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're pr
1919
BLEService batteryService("180F"); // BLE Battery Service
2020

2121
// BLE Battery Level Characteristic with standard 16-bit characteristic UUID.
22-
// This characteristic has Read and Notify properties that allow remote clients
22+
// This characteristic has Read and Notify properties that allow remote clients
2323
// to get notifications when this characteristic changes
2424
BLEUnsignedCharCharacteristic batteryLevelChar("2A19", BLERead | BLENotify);
2525

2626
int count = 0;
2727
bool change_discover = false;
2828

2929
void setup() {
30-
// initialize serial communication
30+
// initialize serial communication
3131
Serial.begin(9600);
3232
// wait for the serial port to connect. Open the Serial Monitor to continue executing the sketch
33-
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
33+
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
3434
// remove or comment out the next line
35-
while(!Serial) ;
36-
// initialize the LED on pin 13. When the BLE device will switch to connectable mode
37-
// the on-board LED will be turned on, otherwise turn the on-board LED off
35+
while (!Serial) ;
36+
// initialize the LED on pin 13. When the BLE device will switch to connectable mode
37+
// the on-board LED will be turned on, otherwise turn the on-board LED off
3838
pinMode(LED_BUILTIN, OUTPUT);
39-
39+
4040
/* Set a local name for the BLE device
4141
This name will appear in advertising packets
4242
and can be used by remote devices to identify this BLE device
@@ -46,7 +46,7 @@ void setup() {
4646
blePeripheral.addAttribute(batteryService); // Add the BLE Battery service
4747
blePeripheral.addAttribute(batteryLevelChar); // add the battery level characteristic
4848

49-
/* Now activate the BLE device. It will start continuously transmitting BLE
49+
/* Now activate the BLE device. It will start continuously transmitting BLE
5050
advertising packets and will be visible to remote BLE central devices
5151
until it receives a new connection */
5252

@@ -65,19 +65,17 @@ void loop() {
6565
Serial.println(count);
6666

6767
}
68-
delay (1000);
68+
delay(1000);
6969
count++;
7070
// Switch from Connectable to Non Connectable and vice versa
71-
if (count > 10 ) {
71+
if (count > 10) {
7272
Serial.println("Stop Advertising and wait for 10 seconds. Device should be invisible");
7373
// Some central devices (phones included) may cache previous scan informations.
7474
// Restart your central device and it should not see this peripheral once stopAdvertising() is called
7575
blePeripheral.stopAdvertising();
7676
delay(10000);
7777

78-
if (change_discover)
79-
{
80-
78+
if (change_discover) {
8179
// Using the method setConnectable() we specify that it is now in NON connectable mode
8280
// The loop is for 10 seconds. Your central device may timeout later than that
8381
// and may eventually connect when we set it back to connectable mode below
@@ -86,9 +84,7 @@ void loop() {
8684
// turn the on-board LED off
8785
digitalWrite(LED_BUILTIN, LOW);
8886
}
89-
else
90-
{
91-
87+
else {
9288
// Switch to connectable mode by calling the setConnectable() method
9389
blePeripheral.setConnectable(true);
9490
Serial.println("In Connectable mode");

libraries/CurieBLE/examples/BatteryMonitor/BatteryMonitor.ino

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3-
* See the bottom of this file for the license terms.
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
44
*/
55

66
#include <CurieBLE.h>
@@ -18,7 +18,7 @@ BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're pr
1818
BLEService batteryService("180F"); // BLE Battery Service with standard 16-bit UUID
1919

2020
// BLE Battery Level Characteristic with standard 16-bit characteristic UUID
21-
// This characteristic has Read and Notify properties that allow remote clients
21+
// This characteristic has Read and Notify properties that allow remote clients
2222
// to get notifications when this characteristic changes
2323
BLEUnsignedCharCharacteristic batteryLevelChar("2A19", BLERead | BLENotify);
2424

@@ -29,9 +29,9 @@ void setup() {
2929
// initialize serial communication
3030
Serial.begin(9600);
3131
// wait for the serial port to connect. Open the Serial Monitor to continue executing the sketch
32-
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
32+
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
3333
// remove or comment out the next line
34-
while(!Serial) ;
34+
while (!Serial) ;
3535
// initialize the LED on pin 13 to indicate when a central is connected
3636
pinMode(LED_BUILTIN, OUTPUT);
3737

@@ -73,12 +73,12 @@ void loop() {
7373
previousMillis = currentMillis;
7474
updateBatteryLevel();
7575

76-
static unsigned short count = 0;
76+
static unsigned short count = 0;
7777
count++;
7878
// update the connection interval
79-
if(count%5 == 0){
79+
if (count % 5 == 0) {
8080
delay(1000);
81-
updateIntervalParams(central);
81+
updateIntervalParams(central);
8282
}
8383
}
8484
}
@@ -90,9 +90,8 @@ void loop() {
9090
}
9191

9292
void updateBatteryLevel() {
93-
/* Read the current voltage level on the A0 analog input pin.
94-
This is used here to simulate the charge level of a battery.
95-
*/
93+
// Read the current voltage level on the A0 analog input pin.
94+
// This is used here to simulate the charge level of a battery.
9695
int battery = analogRead(A0);
9796
int batteryLevel = map(battery, 0, 1023, 0, 100);
9897

@@ -110,24 +109,24 @@ void updateIntervalParams(BLECentralHelper &central) {
110109
ble_conn_param_t m_conn_param;
111110
// Get connection interval that peer central device wanted
112111
central.getConnParams(m_conn_param);
113-
Serial.print("min interval = " );
114-
Serial.println(m_conn_param.interval_min );
115-
Serial.print("max interval = " );
116-
Serial.println(m_conn_param.interval_max );
117-
Serial.print("latency = " );
118-
Serial.println(m_conn_param.latency );
119-
Serial.print("timeout = " );
120-
Serial.println(m_conn_param.timeout );
121-
112+
Serial.print("min interval = ");
113+
Serial.println(m_conn_param.interval_min);
114+
Serial.print("max interval = ");
115+
Serial.println(m_conn_param.interval_max);
116+
Serial.print("latency = ");
117+
Serial.println(m_conn_param.latency);
118+
Serial.print("timeout = ");
119+
Serial.println(m_conn_param.timeout);
120+
122121
//Update connection interval
123122
Serial.println("set Connection Interval");
124-
central.setConnectionInterval(interval,interval);
123+
central.setConnectionInterval(interval, interval);
125124

126125
interval++;
127-
if(interval<0x06)
126+
if (interval < 0x06)
127+
interval = 0x06;
128+
if (interval > 0x100)
128129
interval = 0x06;
129-
if(interval>0x100)
130-
interval = 0x06;
131130
}
132131
/*
133132
Copyright (c) 2016 Intel Corporation. All rights reserved.

libraries/CurieBLE/examples/ButtonLED/ButtonLED.ino

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3-
* See the bottom of this file for the license terms.
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
44
*/
55

66
/*
@@ -11,24 +11,24 @@
1111
After the sketch starts connect to a BLE app on a phone and set notification to the Characteristic and you should see it update
1212
whenever the button is pressed. This sketch is not written to pair with any of the central examples.
1313
*/
14-
14+
1515
#include <CurieBLE.h>
1616

1717
const int ledPin = 13; // set ledPin to on-board LED
1818
const int buttonPin = 4; // set buttonPin to digital pin 4
1919

2020
// create peripheral instance
2121
BLEPeripheral blePeripheral;
22-
22+
2323
// create a new service with a 128-bit UUID (32 characters exclusive of dashes).
2424
// Long UUID denote custom user created UUID
2525
BLEService ledService("19B10010-E8F2-537E-4F6C-D104768A1214");
2626

27-
// create switch characteristic with Read and Write properties that allow remote clients
27+
// create switch characteristic with Read and Write properties that allow remote clients
2828
// to read and write this characteristic value
2929
BLECharCharacteristic ledCharacteristic("19B10011-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
3030

31-
// create button characteristic with Read and Notify properties that allow remote clients
31+
// create button characteristic with Read and Notify properties that allow remote clients
3232
// to get notifications when this characteristic value changes
3333
BLECharCharacteristic buttonCharacteristic("19B10012-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify);
3434
// Note use of Typed Characteristics. These previous 2 characeristics are of the type char
@@ -37,14 +37,14 @@ void setup() {
3737
// initialize serial communication
3838
Serial.begin(9600);
3939
// wait for the serial port to connect. Open the Serial Monitor to continue executing the sketch
40-
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
40+
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
4141
// remove or comment out the next line
42-
while(!Serial) ;
42+
while (!Serial) ;
4343
pinMode(ledPin, OUTPUT); // set the LED pin 13 as output
4444
pinMode(buttonPin, INPUT); // set the button pin 4 as input
4545

46-
// Set a local name for the BLE device.
47-
// This name will appear in advertising packets
46+
// Set a local name for the BLE device.
47+
// This name will appear in advertising packets
4848
// and can be used by remote devices to identify this BLE device
4949
blePeripheral.setLocalName("ButtonLED");
5050
// set the UUID for the service this peripheral advertises:
@@ -83,13 +83,14 @@ void loop() {
8383

8484
if (ledCharacteristic.written() || buttonChanged) {
8585
// update LED, either central has written to characteristic or button state has changed.
86-
// If you are using a phone or a BLE central device that is aware of this characteristic,
86+
// If you are using a phone or a BLE central device that is aware of this characteristic,
8787
// writing a value of 0x40 for example will be interpreted as written and the LED will be turned on
8888
if (ledCharacteristic.value()) {
8989
Serial.println("LED on");
9090
digitalWrite(ledPin, HIGH);
91-
} else {
92-
// If central writes a 0 value (0x00) then it is interpreted as no value and turns the LED off
91+
}
92+
else {
93+
// If central writes a 0 value (0x00) then it is interpreted as no value and turns the LED off
9394
Serial.println("LED off");
9495
digitalWrite(ledPin, LOW);
9596
}

libraries/CurieBLE/examples/CallbackLED/CallbackLED.ino

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3-
* See the bottom of this file for the license terms.
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
44
*/
5-
6-
/*
5+
6+
/*
77
This example can work with LEDCentral.
88
99
You should see the LED blink on and off.
@@ -13,13 +13,13 @@
1313
Connect to BLE device named LEDCB and explore characteristic with UUID 19B10001-E8F2-537E-4F6C-D104768A1214.
1414
Writing a byte value such as 0x40 should turn on the LED.
1515
Writing a byte value of 0x00 should turn off the LED.
16-
*/
16+
*/
1717

1818
#include <CurieBLE.h>
1919

2020
const int ledPin = 13; // set ledPin to use on-board LED
2121
BLEPeripheral blePeripheral; // create peripheral instance
22-
BLECentralHelper *bleCentral1 = NULL; // peer central device
22+
BLECentralHelper *bleCentral1 = NULL; // peer central device
2323

2424
// create service with a 128-bit UUID (32 characters exclusive of dashes).
2525
// Long UUID denote custom user created UUID.
@@ -33,9 +33,9 @@ void setup() {
3333
// initialize serial communication
3434
Serial.begin(9600);
3535
// wait for the serial port to connect. Open the Serial Monitor to continue executing the sketch
36-
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
36+
// If you don't care to see text messages sent to the Serial Monitor during board initialization,
3737
// remove or comment out the next line
38-
while(!Serial) ;
38+
while (!Serial) ;
3939
// set the pin 13 of the on-board LED as output
4040
pinMode(ledPin, OUTPUT);
4141

@@ -94,7 +94,8 @@ void switchCharacteristicWritten(BLEHelper& central, BLECharacteristic& characte
9494
if (switchChar.value()) {
9595
Serial.println("LED on");
9696
digitalWrite(ledPin, HIGH);
97-
} else {
97+
}
98+
else {
9899
Serial.println("LED off");
99100
digitalWrite(ledPin, LOW);
100101
}

0 commit comments

Comments
 (0)