13
13
*********************************************************************/
14
14
#include < bluefruit.h>
15
15
16
- // Beacon uses the Manufacturer Specific Data field in the advertising
17
- // packet, which means you must provide a valid Manufacturer ID. Update
16
+ // Beacon uses the Manufacturer Specific Data field in the advertising packet,
17
+ // which means you must provide a valid Manufacturer ID. Update
18
18
// the field below to an appropriate value. For a list of valid IDs see:
19
19
// https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers
20
- // 0x004C is Apple
21
- // 0x0822 is Adafruit
22
- // 0x0059 is Nordic
20
+ // - 0x004C is Apple
21
+ // - 0x0822 is Adafruit
22
+ // - 0x0059 is Nordic
23
+ // For testing with this sketch, you can use nRF Beacon app
24
+ // - on Android you may need change the MANUFACTURER_ID to Nordic
25
+ // - on iOS you may need to change the MANUFACTURER_ID to Apple.
26
+ // You will also need to "Add Other Beacon, then enter Major, Minor that you set in the sketch
23
27
#define MANUFACTURER_ID 0x0059
24
28
25
29
// "nRF Connect" app can be used to detect beacon
26
- uint8_t beaconUuid[16 ] =
27
- {
30
+ uint8_t beaconUuid[16 ] = {
28
31
0x01 , 0x12 , 0x23 , 0x34 , 0x45 , 0x56 , 0x67 , 0x78 ,
29
32
0x89 , 0x9a , 0xab , 0xbc , 0xcd , 0xde , 0xef , 0xf0
30
33
};
31
34
32
35
// A valid Beacon packet consists of the following information:
33
36
// UUID, Major, Minor, RSSI @ 1M
34
- BLEBeacon beacon (beaconUuid, 0x0102 , 0x0304 , -54 );
37
+ BLEBeacon beacon (beaconUuid, 1 , 2 , -54 );
35
38
36
- void setup ()
37
- {
39
+ void setup () {
38
40
Serial.begin (115200 );
39
41
40
42
// Uncomment to blocking wait for Serial connection
41
- // while ( !Serial ) delay(10);
43
+ // while ( !Serial ) delay(10);
42
44
43
45
Serial.println (" Bluefruit52 Beacon Example" );
44
46
Serial.println (" --------------------------\n " );
@@ -55,7 +57,10 @@ void setup()
55
57
// Setup the advertising packet
56
58
startAdv ();
57
59
58
- Serial.println (" Broadcasting beacon, open your beacon app to test" );
60
+ Serial.printf (" Broadcasting beacon with MANUFACTURER_ID = 0x%04X\n " , MANUFACTURER_ID);
61
+ Serial.println (" open your beacon app to test such as: nRF Beacon" );
62
+ Serial.println (" - on Android you may need to change the MANUFACTURER_ID to 0x0059" );
63
+ Serial.println (" - on iOS you may need to change the MANUFACTURER_ID to 0x004C" );
59
64
60
65
// Suspend Loop() to save power, since we didn't have any code there
61
66
suspendLoop ();
@@ -78,17 +83,16 @@ void startAdv(void)
78
83
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
79
84
*
80
85
* Apple Beacon specs
81
- * - Type: Non connectable, undirected
86
+ * - Type: Non- connectable, scannable , undirected
82
87
* - Fixed interval: 100 ms -> fast = slow = 100 ms
83
88
*/
84
- // Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_ADV_NONCONN_IND );
89
+ Bluefruit.Advertising .setType (BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED );
85
90
Bluefruit.Advertising .restartOnDisconnect (true );
86
91
Bluefruit.Advertising .setInterval (160 , 160 ); // in unit of 0.625 ms
87
92
Bluefruit.Advertising .setFastTimeout (30 ); // number of seconds in fast mode
88
93
Bluefruit.Advertising .start (0 ); // 0 = Don't stop advertising after n seconds
89
94
}
90
95
91
- void loop ()
92
- {
96
+ void loop () {
93
97
// loop is already suspended, CPU will not run loop() at all
94
98
}
0 commit comments