Skip to content

Improve CurieBLE library #284

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 3 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
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