Skip to content

Jira #788: BLE Peripheral cannot discover Central attributes, Git #382. #410

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

Merged
merged 1 commit into from
Feb 16, 2017
Merged
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
@@ -1,13 +1,27 @@
#include <CurieBLE.h>
/*
* Copyright (c) 2016 Intel Corporation. All rights reserved.
* See the bottom of this file for the license terms.
*/

/*
This sketch example works with BatteryMonitor_Notification.ino
* Sketch: BatteryMonitor_Central.ino
*
* Description:
* This sketch will receive the notifications and output the received
* data in the serial monitor. It also illustrates using a non-typed
* characteristic.
*
* Notes:
*
* - Set the baud rate to 115200 on the serial monitor to accomodate
* the speed of constant data updates
* - Expected Peripheral name: BatteryMonitorSketch
* - Expected Peripheral Characteristic: 2A19
* - Expected Peripheral sketch: BatteryMonitor_Notification.ino
*
*/

BatteryMonitor_Notification will send notification to this central sketch.
This sketch will receive the notifications and output the received data in the serial monitor.
It also illustrates using a non-typed characteristic.
Set the baud rate to 115200 on the serial monitor to accomodate the speed of constant data updates
*/
#include <CurieBLE.h>

#define LED_PIN 13

Expand Down Expand Up @@ -123,3 +137,26 @@ void printData(const unsigned char data[], int length) {
Serial.print(b);
}
}

/*
Copyright (c) 2016 Intel Corporation. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/





126 changes: 126 additions & 0 deletions libraries/CurieBLE/examples/central/CentralDouble/CentralDouble.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright (c) 2016 Intel Corporation. All rights reserved.
* See the bottom of this file for the license terms.
*/

/*
* Sketch: CentralDouble.ino.
*
* Description:
* This is a simple BLE sketch that initiates the
* Arduino platform as a Central. It reads a double value from
* a connected Peripheral. The sketch exercises: Scanning for
* a specific Peripheral, connecting to it, discover its Attributes,
* and exercise a specific Characteristic to read a double value
* from the Peripheral.
*
* Notes:
* Expected Peripheral name: DataTest
* Expected Peripheral Characteristic: 19b20001e8f2537e4f6cd104768a1214
* Expected Characteristic read value: double.
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sketch code looks good, it's pretty readable. However I have no idea what this sketch is doing, there are not really any comments to explain it.

Can you please follow the style of our other example sketches (here is a good example: https://github.com/01org/corelibs-arduino101/blob/master/libraries/CurieIMU/examples/Accelerometer/Accelerometer.ino)

Specifically, 1) put the main part of the license at the bottom of the file, with a short 1-line reference at the top. Just copy the style of existing sketches, here. And 2), add a short comment at the top, explaining what the sketch does. Again, just copy the style of existing examples.

#include "CurieBLE.h"


// LED pin
#define LED_PIN 13

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

// set LED pin to output mode
pinMode(LED_PIN, OUTPUT);

// begin initialization
BLE.begin();
Serial.println(BLE.address());

BLE.scanForName("DataTest");
}

void loop() {
BLEDevice peripheral = BLE.available();
if (peripheral)
{
Serial.println(peripheral.address());
BLE.stopScan();
// central connected to peripheral
controlLogic(peripheral);
BLE.scanForName("DataTest");
}
}


void controlLogic(BLEDevice &peripheral)
{
// connect to the peripheral
Serial.print("Connecting ... ");
Serial.println(peripheral.address());

if (peripheral.connect())
{
Serial.print("Connected: ");
Serial.println(peripheral.address());
}
else
{
Serial.println("Failed to connect!");
return;
}

if (peripheral.discoverAttributes() == false)
{
Serial.println("Discover failed, Disconnecting...");
peripheral.disconnect();
return;
}

BLECharacteristic doubleCharacteristic = peripheral.characteristic("19b20001e8f2537e4f6cd104768a1214");

if (!doubleCharacteristic)
{
peripheral.disconnect();
Serial.println("Peripheral does not have test double characteristic!");
delay(5000);
return;
}
doubleCharacteristic.subscribe();

while (peripheral.connected())
{
doubleCharacteristic.read();
delay(1000);
if (doubleCharacteristic.valueUpdated())
{
Serial.print("Double characteristic value: ");
Serial.println(doubleCharacteristic.doubleValue());
}
delay(1000);
}
Serial.print("Disconnected");
Serial.println(peripheral.address());
}



/*
Arduino BLE Peripheral Double read/write test example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong example sketch name here (I think?)

Copyright (c) 2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/


61 changes: 38 additions & 23 deletions libraries/CurieBLE/examples/central/IMUBleCentral/IMUBleCentral.ino
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <CurieBLE.h>
* Copyright (c) 2016 Intel Corporation. All rights reserved.
* See the bottom of this file for the license terms.
*/

/*
This sketch example works with IMUBleNotification.ino
* Sketch: IMUBleCentral.ino
*
* Description:
* This sketch will receive the notifications and output the
* received data in the serial monitor. It also illustrates
* using a non-typed characteristic.
*
* Notes:
*
* - Expected Peripheral name: Imu
* - Expected Peripheral Characteristic: F7580003-153E-D4F6-F26D-43D8D98EEB13
* - Expected Peripheral sketch: IMUBleNotification.ino
*/

IMUBleNotification.ino will send notification to this central sketch.
This sketch will receive the notifications and output the received data in the serial monitor.
It also illustrates using a non-typed characteristic.
Set the baud rate to 115200 on the serial monitor to accomodate the speed of constant data updates from IMU subsystem.
*/
#include <CurieBLE.h>

#define LED_PIN 13
#define MAX_IMU_RECORD 1
Expand Down Expand Up @@ -123,3 +117,24 @@ void controlImu(BLEDevice peripheral)
Serial.print("Disconnected");
Serial.println(peripheral.address());
}


/*
Copyright (c) 2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/


58 changes: 41 additions & 17 deletions libraries/CurieBLE/examples/central/led_control/led_control.ino
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
/*
Arduino BLE Central LED Control example
Copyright (c) 2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
* Copyright (c) 2016 Intel Corporation. All rights reserved.
* See the bottom of this file for the license terms.
*/

/*
* Sketch: led_control.ino
*
* Description:
* This is a Central sketch that looks for a particular Sevice with a
* certain Characteristic from a Peripheral. Upon succesful discovery,
* it reads the state of a button and write that value to the
* Peripheral Characteristic.
*
* Notes:
*
* - Expected Peripheral Service: 19b10000-e8f2-537e-4f6c-d104768a1214
* - Expected Peripheral Characteristic: 19b10001-e8f2-537e-4f6c-d104768a1214
* - Expected Peripheral sketch:
*
*/

#include <CurieBLE.h>

Expand Down Expand Up @@ -125,3 +127,25 @@ void controlLed(BLEDevice peripheral) {
}
}
}

/*
Arduino BLE Central LED Control example
Copyright (c) 2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/



Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*
Arduino BLE Central peripheral explorer example
Copyright (c) 2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
* Copyright (c) 2016 Intel Corporation. All rights reserved.
* See the bottom of this file for the license terms.
*/

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Sketch: peripheral_explorer.ino
*
* Description:
* This is a Central sketch demonstrating the discovery process
* of a Peripheral. The discovered Attributes are being
* display onto the serial output.
*
* Notes:
*
* - Expected Peripheral name: LED
*
*/

#include <CurieBLE.h>

Expand Down Expand Up @@ -150,3 +150,24 @@ void printData(const unsigned char data[], int length) {
}
}


/*
Arduino BLE Central peripheral explorer example
Copyright (c) 2016 Arduino LLC. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/


Loading