Skip to content

Commit cc9f21a

Browse files
committed
Jira 832 Sample Sketch to exercise the BLEbroadcast option.
1. Add example sketch libraries/CurieBLE/examples/peripheral/broadcast 2. Fix the CurieBLE can't send Advertisement when call broadcast.
1 parent 0285190 commit cc9f21a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <CurieBLE.h>
2+
3+
uint8_t value = 0;
4+
5+
BLEService service = BLEService("EEE0");
6+
BLEShortCharacteristic characteristic = BLEShortCharacteristic("EEE1", BLERead | BLENotify | BLEBroadcast);
7+
8+
void setup() {
9+
Serial.begin(9600);
10+
11+
BLE.setLocalName("BLEBroadcast");
12+
BLE.setAdvertisedServiceUuid(service.uuid());
13+
14+
BLE.addService(service);
15+
service.addCharacteristic(characteristic);
16+
17+
characteristic.setValue(value);
18+
19+
BLE.begin();
20+
characteristic.broadcast();
21+
22+
Serial.println(F("BLE Broadcast Count"));
23+
}
24+
25+
void loop() {
26+
BLE.poll();
27+
characteristic.setValue(value);
28+
delay(1000);
29+
value++;
30+
}

libraries/CurieBLE/src/BLECharacteristic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ bool BLECharacteristic::broadcast()
294294
if (BLEDeviceManager::instance()->advertising())
295295
{
296296
BLEDeviceManager::instance()->stopAdvertising();
297-
BLEDeviceManager::instance()->startAdvertising();
298297
}
298+
BLEDeviceManager::instance()->startAdvertising();
299299
return _broadcast;
300300
}
301301

0 commit comments

Comments
 (0)