forked from arduino-libraries/ArduinoBLE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRawDataAdvertising.ino
More file actions
42 lines (31 loc) · 1.22 KB
/
RawDataAdvertising.ino
File metadata and controls
42 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <ArduinoBLE.h>
BLEService myService("fff0");
BLEIntCharacteristic myCharacteristic("fff1", BLERead | BLEBroadcast);
// Advertising parameters should have a global scope. Do NOT define them in 'setup' or in 'loop'
const uint8_t completeRawAdvertisingData[] = {0x02,0x01,0x06,0x09,0xff,0x01,0x01,0x00,0x01,0x02,0x03,0x04,0x05};
void setup() {
Serial.begin(9600);
while (!Serial);
if (!BLE.begin()) {
Serial.println("starting Bluetooth® Low Energy module failed!");
while (1);
}
myService.addCharacteristic(myCharacteristic);
BLE.addService(myService);
// Build advertising data packet
BLEAdvertisingData advData;
// If a packet has a raw data parameter, then all the other parameters of the packet will be ignored
advData.setRawData(completeRawAdvertisingData, sizeof(completeRawAdvertisingData));
// Copy set parameters in the actual advertising packet
BLE.setAdvertisingData(advData);
// Build scan response data packet
BLEAdvertisingData scanData;
scanData.setLocalName("Test advertising raw data");
// Copy set parameters in the actual scan response packet
BLE.setScanResponseData(scanData);
BLE.advertise();
Serial.println("advertising ...");
}
void loop() {
BLE.poll();
}