Skip to content

Improvements for CurieBLE library #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cores/arduino/wiring_pulse.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
* \brief Measures the length (in microseconds) of a pulse on the pin; state is HIGH
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
* to 5 minutes in length, but must be called at least a few dozen microseconds
* before the start of the pulse.
* before the start of the pulse. The pulseIn() function is not designed to detect
* high frequencies. The consequences of using this function to detect frequencies
* such as a 100KHz PWM signal could possibly cause a sketch to hang at the
* pulseIn() function call.
*/
extern uint32_t pulseIn( uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout = 1000000UL ) ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ int oldBatteryLevel = 0; // last battery level reading from analog input
long previousMillis = 0; // last time the battery level was checked, in ms

void setup() {
Serial.begin(9600); // initialize serial communication
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect
pinMode(13, OUTPUT); // initialize the LED on pin 13 to indicate when a central is connected

/* Set a local name for the BLE device
Expand Down
3 changes: 2 additions & 1 deletion libraries/CurieBLE/examples/ButtonLED/ButtonLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ BLECharCharacteristic ledCharacteristic("19B10011-E8F2-537E-4F6C-D104768A1214",
BLECharCharacteristic buttonCharacteristic("19B10012-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify); // allows remote device to get notifications

void setup() {
Serial.begin(9600);
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect
pinMode(ledPin, OUTPUT); // use the LED on pin 13 as an output
pinMode(buttonPin, INPUT); // use button pin 4 as an input

Expand Down
3 changes: 2 additions & 1 deletion libraries/CurieBLE/examples/CallbackLED/CallbackLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // create service
BLECharCharacteristic switchChar("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);

void setup() {
Serial.begin(9600);
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
pinMode(ledPin, OUTPUT); // use the LED on pin 13 as an output

// set the local name peripheral advertises
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieBLE/examples/LED/LED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104
const int ledPin = 13; // pin to use for the LED

void setup() {
Serial.begin(9600);

Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect
// set LED pin to output mode
pinMode(ledPin, OUTPUT);

Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieBLE/examples/MIDIBLE/MIDIBLE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ BLEService midiSvc("03B80E5A-EDE8-4B33-A751-6CE34EC4C700"); // create service
BLECharacteristic midiChar("7772E5DB-3868-4112-A1A9-F2669D106BF3", BLEWrite | BLEWriteWithoutResponse | BLENotify | BLERead, 5);

void setup() {
Serial.begin(9600);

Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
BLESetup();
Serial.println(("Bluetooth device active, waiting for connections..."));
}
Expand Down
12 changes: 7 additions & 5 deletions libraries/CurieBLE/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Datatypes (KEYWORD1)
#######################################

CurieBLE KEYWORD1
BLEAttribute KEYWORD1
BLECentral KEYWORD1
BLECharacteristic KEYWORD1
Expand All @@ -15,6 +16,7 @@ BLEService KEYWORD1
BLETypedCharacteristic KEYWORD1
BLEUuid KEYWORD1

BLETypedCharacteristics KEYWORD1
BLECharCharacteristic KEYWORD1
BLEUnsignedCharCharacteristic KEYWORD1
BLEShortCharacteristic KEYWORD1
Expand Down Expand Up @@ -49,11 +51,13 @@ written KEYWORD2
subscribed KEYWORD2

begin KEYWORD2
end KEYWORD2
getAdvertisingLength KEYWORD2
getAdvertising KEYWORD2
setAdvertisedServiceUuid KEYWORD2
setAdvertisedServiceData KEYWORD2
setLocalName KEYWORD2
setDeviceName KEYWORD2
setAppearance KEYWORD2
setConnectionInterval KEYWORD2
addAttribute KEYWORD2
Expand All @@ -64,11 +68,6 @@ valueLE KEYWORD2
setValueBE KEYWORD2
valueBE KEYWORD2

str KEYWORD2
data KEYWORD2
length KEYWORD2


#######################################
# Constants (LITERAL1)
#######################################
Expand All @@ -90,3 +89,6 @@ BLEDisconnected LITERAL1
BLEWritten LITERAL1
BLESubscribed LITERAL1
BLEUnsubscribed LITERAL1

BLE_MAX_ATTR_DATA_LEN LITERAL1
BLE_DEVICE_NAME_DEFAULT_PREFIX LITERAL1
4 changes: 2 additions & 2 deletions libraries/CurieBLE/src/BLEAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

unsigned char BLEAttribute::_numAttributes = 0;

BLEAttribute::BLEAttribute(const char* uuid, enum BLEAttributeType type) :
BLEAttribute::BLEAttribute(const char* uuid, BLEAttributeType type) :
_uuid(uuid),
_type(type),
_handle(0)
Expand All @@ -36,7 +36,7 @@ BLEAttribute::uuid() const {
return _uuid;
}

enum BLEAttributeType
BLEAttributeType
BLEAttribute::type() const {
return this->_type;
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/CurieBLE/src/BLEAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

#include "BLECommon.h"

enum BLEAttributeType {
typedef enum {
BLETypeService = 0x2800,
BLETypeCharacteristic = 0x2803,
BLETypeDescriptor = 0x2900
};
} BLEAttributeType;

class BLEPeripheral;

Expand All @@ -43,7 +43,7 @@ class BLEAttribute {
protected:
friend BLEPeripheral;

BLEAttribute(const char* uuid, enum BLEAttributeType type);
BLEAttribute(const char* uuid, BLEAttributeType type);

BLEAttributeType type(void) const;
bt_uuid btUuid(void) const;
Expand All @@ -56,7 +56,7 @@ class BLEAttribute {
static unsigned char _numAttributes;

const char* _uuid;
enum BLEAttributeType _type;
BLEAttributeType _type;
uint16_t _handle;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ uint32_t loop_count = 0; // record the higher 16 bits of received data
uint32_t shift_count = 0; // the position of first non-zero
void setup()
{
Serial.begin(115200);
while(!Serial);
Serial.begin(115200); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
Serial.println("CurieI2SDMA Rx Callback");

CurieI2SDMA.iniRX();
Expand Down Expand Up @@ -119,4 +119,4 @@ void loop()
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-
1301 USA
*/
*/
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ uint32_t dataBuff[BUFF_SIZE];
uint32_t loop_count = 0;
void setup()
{
Serial.begin(115200);
while(!Serial);
Serial.begin(115200); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
Serial.println("CurieI2SDMA Tx Callback");

CurieI2SDMA.iniTX();
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieI2S/examples/I2S_RxCallback/I2S_RxCallback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ volatile int count = 0;
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while(!Serial);
Serial.begin(115200); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
Serial.println("CurieI2S Rx Callback Example");
CurieI2S.begin(I2S_44K, I2S_32bit);
CurieI2S.setI2SMode(PHILIPS_MODE);
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieI2S/examples/I2S_TxCallback/I2S_TxCallback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

void setup()
{
Serial.begin(115200);
while(!Serial);
Serial.begin(115200); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
Serial.println("CurieI2S Tx Callback");
CurieI2S.begin(I2S_44K, I2S_32bit);
CurieI2S.setI2SMode(PHILIPS_MODE);
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieIMU/examples/FreeFallDetect/FreeFallDetect.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ unsigned long interruptsTime = 0; // get the time when free fall event is det


void setup() {
Serial.begin(9600);
while(!Serial); // wait for the serial port to open
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.

/* Initialise the IMU */
CurieIMU.begin();
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieIMU/examples/MotionDetect/MotionDetect.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ unsigned long loopTime = 0; // get the time since program started
unsigned long interruptsTime = 0; // get the time when motion event is detected

void setup() {
Serial.begin(9600);
while(!Serial); // wait for the serial port to open
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.

/* Initialise the IMU */
CurieIMU.begin();
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieIMU/examples/ShockDetect/ShockDetect.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
boolean blinkState = false; // state of the LED

void setup() {
Serial.begin(9600);

Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect..
/* Initialise the IMU */
CurieIMU.begin();
CurieIMU.attachInterrupt(eventCallback);
Expand Down
3 changes: 2 additions & 1 deletion libraries/CurieIMU/examples/StepCount/StepCount.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ long lastStepCount = 0; // step count on previous polling check
boolean blinkState = false; // state of the LED

void setup() {
Serial.begin(9600);
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
// pinMode(13, OUTPUT);
// intialize the sensor:
CurieIMU.begin();
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieIMU/examples/TapDetect/TapDetect.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "CurieIMU.h"

void setup() {
Serial.begin(9600);

Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
// Initialise the IMU
CurieIMU.begin();
CurieIMU.attachInterrupt(eventCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "CurieIMU.h"

void setup() {
Serial.begin(9600);

Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
// Initialise the IMU
CurieIMU.begin();
CurieIMU.attachInterrupt(eventCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

boolean ledState = false; // state of the LED
void setup() {
Serial.begin(9600);
while(!Serial); // wait for the serial port to open
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.

/* Initialise the IMU */
CurieIMU.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void setup()
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
; // wait for serial port to connect. Needed for Native USB only
}


Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieTime/examples/ReadTest/ReadTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <CurieTime.h>

void setup() {
while (!Serial);
Serial.begin(9600);
Serial.begin(9600); // initialize Serial communication
while (!Serial); // wait for serial port to connect.

Serial.println("CurieTime Read Test");
Serial.println("-------------------");
Expand Down
4 changes: 2 additions & 2 deletions libraries/CurieTime/examples/SetTime/SetTime.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <CurieTime.h>

void setup() {
while (!Serial);
Serial.begin(9600);
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.

// set the current time to 14:27:00, December 14th, 2015
setTime(14, 27, 00, 14, 12, 2015);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const int blinkPin = 13;
void setup(void)
{
CurieTimerOne.initialize(50000);
Serial.begin(9600);
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
}

void loop(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void timedBlinkIsr() // callback function when interrupt is asserted
void setup() {

#ifdef SERIAL_PORT_LOG_ENABLE
Serial.begin(115200);
while (!Serial); // wait for the serial monitor to open
Serial.begin(115200); // initialize Serial communication
while (!Serial); // wait for the serial monitor to open
#endif

// Initialize pin 13 as an output - onboard LED.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const int dataReadyPin = 6;
const int chipSelectPin = 7;

void setup() {
Serial.begin(9600);
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.

// start the SPI library:
SPI.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
#define CSPIN 21

void setup(){
Serial.begin(9600); //Teensy serial is always at full USB speed and buffered... the baud rate here is required but ignored
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.

pinMode(13, OUTPUT);

Expand Down
5 changes: 3 additions & 2 deletions libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
while(!Serial) ; // wait for serial port to connect.
}

int reading = 0;
Expand Down
4 changes: 2 additions & 2 deletions libraries/Wire/examples/bus_scan/bus_scan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void setup()
// join i2c bus (address optional for master)
Wire.begin();

Serial.begin(115200);
while(!Serial);
Serial.begin(115200); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
}

boolean toggle = false; // state of the LED
Expand Down
3 changes: 2 additions & 1 deletion libraries/Wire/examples/master_reader/master_reader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
Serial.begin(9600); // initialize Serial communication
while(!Serial) ; // wait for serial port to connect.
}

void loop()
Expand Down
Loading