Skip to content

Commit aceb455

Browse files
sgbihuSidLeung
authored andcommitted
BLE Peripheral cannot discover Central attributes
1. Add test sketches discoveratperipheral.ino and profileatcentral.ino 2. Modify BLEDeviceManager.cpp to add central to profile buffer in peripheral role.
1 parent 0285190 commit aceb455

File tree

24 files changed

+892
-670
lines changed

24 files changed

+892
-670
lines changed

Diff for: libraries/CurieBLE/examples/central/BatteryMonitor_Central/BatteryMonitor_Central.ino

+44-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1-
#include <CurieBLE.h>
1+
/*
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
4+
*/
25

36
/*
4-
This sketch example works with BatteryMonitor_Notification.ino
7+
* Sketch: BatteryMonitor_Central.ino
8+
*
9+
* Description:
10+
* This sketch will receive the notifications and output the received
11+
* data in the serial monitor. It also illustrates using a non-typed
12+
* characteristic.
13+
*
14+
* Notes:
15+
*
16+
* - Set the baud rate to 115200 on the serial monitor to accomodate
17+
* the speed of constant data updates
18+
* - Expected Peripheral name: BatteryMonitorSketch
19+
* - Expected Peripheral Characteristic: 2A19
20+
* - Expected Peripheral sketch: BatteryMonitor_Notification.ino
21+
*
22+
*/
523

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

1226
#define LED_PIN 13
1327

@@ -123,3 +137,26 @@ void printData(const unsigned char data[], int length) {
123137
Serial.print(b);
124138
}
125139
}
140+
141+
/*
142+
Copyright (c) 2016 Intel Corporation. All rights reserved.
143+
144+
This library is free software; you can redistribute it and/or
145+
modify it under the terms of the GNU Lesser General Public
146+
License as published by the Free Software Foundation; either
147+
version 2.1 of the License, or (at your option) any later version.
148+
149+
This library is distributed in the hope that it will be useful,
150+
but WITHOUT ANY WARRANTY; without even the implied warranty of
151+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
152+
Lesser General Public License for more details.
153+
154+
You should have received a copy of the GNU Lesser General Public
155+
License along with this library; if not, write to the Free Software
156+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
157+
*/
158+
159+
160+
161+
162+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
4+
*/
5+
6+
/*
7+
* Sketch: CentralDouble.ino.
8+
*
9+
* Description:
10+
* This is a simple BLE sketch that initiates the
11+
* Arduino platform as a Central. It reads a double value from
12+
* a connected Peripheral. The sketch exercises: Scanning for
13+
* a specific Peripheral, connecting to it, discover its Attributes,
14+
* and exercise a specific Characteristic to read a double value
15+
* from the Peripheral.
16+
*
17+
* Notes:
18+
* Expected Peripheral name: DataTest
19+
* Expected Peripheral Characteristic: 19b20001e8f2537e4f6cd104768a1214
20+
* Expected Characteristic read value: double.
21+
*/
22+
23+
#include "CurieBLE.h"
24+
25+
26+
// LED pin
27+
#define LED_PIN 13
28+
29+
void setup() {
30+
Serial.begin(9600);
31+
32+
// set LED pin to output mode
33+
pinMode(LED_PIN, OUTPUT);
34+
35+
// begin initialization
36+
BLE.begin();
37+
Serial.println(BLE.address());
38+
39+
BLE.scanForName("DataTest");
40+
}
41+
42+
void loop() {
43+
BLEDevice peripheral = BLE.available();
44+
if (peripheral)
45+
{
46+
Serial.println(peripheral.address());
47+
BLE.stopScan();
48+
// central connected to peripheral
49+
controlLogic(peripheral);
50+
BLE.scanForName("DataTest");
51+
}
52+
}
53+
54+
55+
void controlLogic(BLEDevice &peripheral)
56+
{
57+
// connect to the peripheral
58+
Serial.print("Connecting ... ");
59+
Serial.println(peripheral.address());
60+
61+
if (peripheral.connect())
62+
{
63+
Serial.print("Connected: ");
64+
Serial.println(peripheral.address());
65+
}
66+
else
67+
{
68+
Serial.println("Failed to connect!");
69+
return;
70+
}
71+
72+
if (peripheral.discoverAttributes() == false)
73+
{
74+
Serial.println("Discover failed, Disconnecting...");
75+
peripheral.disconnect();
76+
return;
77+
}
78+
79+
BLECharacteristic doubleCharacteristic = peripheral.characteristic("19b20001e8f2537e4f6cd104768a1214");
80+
81+
if (!doubleCharacteristic)
82+
{
83+
peripheral.disconnect();
84+
Serial.println("Peripheral does not have test double characteristic!");
85+
delay(5000);
86+
return;
87+
}
88+
doubleCharacteristic.subscribe();
89+
90+
while (peripheral.connected())
91+
{
92+
doubleCharacteristic.read();
93+
delay(1000);
94+
if (doubleCharacteristic.valueUpdated())
95+
{
96+
Serial.print("Double characteristic value: ");
97+
Serial.println(doubleCharacteristic.doubleValue());
98+
}
99+
delay(1000);
100+
}
101+
Serial.print("Disconnected");
102+
Serial.println(peripheral.address());
103+
}
104+
105+
106+
107+
/*
108+
Arduino BLE Peripheral Double read/write test example
109+
Copyright (c) 2016 Arduino LLC. All right reserved.
110+
111+
This library is free software; you can redistribute it and/or
112+
modify it under the terms of the GNU Lesser General Public
113+
License as published by the Free Software Foundation; either
114+
version 2.1 of the License, or (at your option) any later version.
115+
116+
This library is distributed in the hope that it will be useful,
117+
but WITHOUT ANY WARRANTY; without even the implied warranty of
118+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
119+
Lesser General Public License for more details.
120+
121+
You should have received a copy of the GNU Lesser General Public
122+
License along with this library; if not, write to the Free Software
123+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
124+
*/
125+
126+

Diff for: libraries/CurieBLE/examples/central/IMUBleCentral/IMUBleCentral.ino

+38-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
/*
2-
Copyright (c) 2016 Arduino LLC. All right reserved.
3-
4-
This library is free software; you can redistribute it and/or
5-
modify it under the terms of the GNU Lesser General Public
6-
License as published by the Free Software Foundation; either
7-
version 2.1 of the License, or (at your option) any later version.
8-
9-
This library is distributed in the hope that it will be useful,
10-
but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
Lesser General Public License for more details.
13-
14-
You should have received a copy of the GNU Lesser General Public
15-
License along with this library; if not, write to the Free Software
16-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17-
*/
18-
#include <CurieBLE.h>
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
4+
*/
195

206
/*
21-
This sketch example works with IMUBleNotification.ino
7+
* Sketch: IMUBleCentral.ino
8+
*
9+
* Description:
10+
* This sketch will receive the notifications and output the
11+
* received data in the serial monitor. It also illustrates
12+
* using a non-typed characteristic.
13+
*
14+
* Notes:
15+
*
16+
* - Expected Peripheral name: Imu
17+
* - Expected Peripheral Characteristic: F7580003-153E-D4F6-F26D-43D8D98EEB13
18+
* - Expected Peripheral sketch: IMUBleNotification.ino
19+
*/
2220

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

2923
#define LED_PIN 13
3024
#define MAX_IMU_RECORD 1
@@ -123,3 +117,24 @@ void controlImu(BLEDevice peripheral)
123117
Serial.print("Disconnected");
124118
Serial.println(peripheral.address());
125119
}
120+
121+
122+
/*
123+
Copyright (c) 2016 Arduino LLC. All right reserved.
124+
125+
This library is free software; you can redistribute it and/or
126+
modify it under the terms of the GNU Lesser General Public
127+
License as published by the Free Software Foundation; either
128+
version 2.1 of the License, or (at your option) any later version.
129+
130+
This library is distributed in the hope that it will be useful,
131+
but WITHOUT ANY WARRANTY; without even the implied warranty of
132+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
133+
Lesser General Public License for more details.
134+
135+
You should have received a copy of the GNU Lesser General Public
136+
License along with this library; if not, write to the Free Software
137+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
138+
*/
139+
140+

Diff for: libraries/CurieBLE/examples/central/led_control/led_control.ino

+41-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
/*
2-
Arduino BLE Central LED Control example
3-
Copyright (c) 2016 Arduino LLC. All right reserved.
4-
5-
This library is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU Lesser General Public
7-
License as published by the Free Software Foundation; either
8-
version 2.1 of the License, or (at your option) any later version.
9-
10-
This library is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
Lesser General Public License for more details.
14-
15-
You should have received a copy of the GNU Lesser General Public
16-
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18-
*/
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
4+
*/
195

6+
/*
7+
* Sketch: led_control.ino
8+
*
9+
* Description:
10+
* This is a Central sketch that looks for a particular Sevice with a
11+
* certain Characteristic from a Peripheral. Upon succesful discovery,
12+
* it reads the state of a button and write that value to the
13+
* Peripheral Characteristic.
14+
*
15+
* Notes:
16+
*
17+
* - Expected Peripheral Service: 19b10000-e8f2-537e-4f6c-d104768a1214
18+
* - Expected Peripheral Characteristic: 19b10001-e8f2-537e-4f6c-d104768a1214
19+
* - Expected Peripheral sketch:
20+
*
21+
*/
2022

2123
#include <CurieBLE.h>
2224

@@ -125,3 +127,25 @@ void controlLed(BLEDevice peripheral) {
125127
}
126128
}
127129
}
130+
131+
/*
132+
Arduino BLE Central LED Control example
133+
Copyright (c) 2016 Arduino LLC. All right reserved.
134+
135+
This library is free software; you can redistribute it and/or
136+
modify it under the terms of the GNU Lesser General Public
137+
License as published by the Free Software Foundation; either
138+
version 2.1 of the License, or (at your option) any later version.
139+
140+
This library is distributed in the hope that it will be useful,
141+
but WITHOUT ANY WARRANTY; without even the implied warranty of
142+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
143+
Lesser General Public License for more details.
144+
145+
You should have received a copy of the GNU Lesser General Public
146+
License along with this library; if not, write to the Free Software
147+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
148+
*/
149+
150+
151+

Diff for: libraries/CurieBLE/examples/central/peripheral_explorer/peripheral_explorer.ino

+37-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
2-
Arduino BLE Central peripheral explorer example
3-
Copyright (c) 2016 Arduino LLC. All right reserved.
4-
5-
This library is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU Lesser General Public
7-
License as published by the Free Software Foundation; either
8-
version 2.1 of the License, or (at your option) any later version.
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
4+
*/
95

10-
This library is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
Lesser General Public License for more details.
14-
15-
You should have received a copy of the GNU Lesser General Public
16-
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18-
*/
6+
/*
7+
* Sketch: peripheral_explorer.ino
8+
*
9+
* Description:
10+
* This is a Central sketch demonstrating the discovery process
11+
* of a Peripheral. The discovered Attributes are being
12+
* display onto the serial output.
13+
*
14+
* Notes:
15+
*
16+
* - Expected Peripheral name: LED
17+
*
18+
*/
1919

2020
#include <CurieBLE.h>
2121

@@ -150,3 +150,24 @@ void printData(const unsigned char data[], int length) {
150150
}
151151
}
152152

153+
154+
/*
155+
Arduino BLE Central peripheral explorer example
156+
Copyright (c) 2016 Arduino LLC. All right reserved.
157+
158+
This library is free software; you can redistribute it and/or
159+
modify it under the terms of the GNU Lesser General Public
160+
License as published by the Free Software Foundation; either
161+
version 2.1 of the License, or (at your option) any later version.
162+
163+
This library is distributed in the hope that it will be useful,
164+
but WITHOUT ANY WARRANTY; without even the implied warranty of
165+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
166+
Lesser General Public License for more details.
167+
168+
You should have received a copy of the GNU Lesser General Public
169+
License along with this library; if not, write to the Free Software
170+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
171+
*/
172+
173+

0 commit comments

Comments
 (0)