1313*********************************************************************/
1414#include < bluefruit.h>
1515
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
1818// the field below to an appropriate value. For a list of valid IDs see:
1919// 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
2327#define MANUFACTURER_ID 0x0059
2428
2529// "nRF Connect" app can be used to detect beacon
26- uint8_t beaconUuid[16 ] =
27- {
30+ uint8_t beaconUuid[16 ] = {
2831 0x01 , 0x12 , 0x23 , 0x34 , 0x45 , 0x56 , 0x67 , 0x78 ,
2932 0x89 , 0x9a , 0xab , 0xbc , 0xcd , 0xde , 0xef , 0xf0
3033};
3134
3235// A valid Beacon packet consists of the following information:
3336// UUID, Major, Minor, RSSI @ 1M
34- BLEBeacon beacon (beaconUuid, 0x0102 , 0x0304 , -54 );
37+ BLEBeacon beacon (beaconUuid, 1 , 2 , -54 );
3538
36- void setup ()
37- {
39+ void setup () {
3840 Serial.begin (115200 );
3941
4042 // Uncomment to blocking wait for Serial connection
41- // while ( !Serial ) delay(10);
43+ // while ( !Serial ) delay(10);
4244
4345 Serial.println (" Bluefruit52 Beacon Example" );
4446 Serial.println (" --------------------------\n " );
@@ -55,7 +57,10 @@ void setup()
5557 // Setup the advertising packet
5658 startAdv ();
5759
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" );
5964
6065 // Suspend Loop() to save power, since we didn't have any code there
6166 suspendLoop ();
@@ -78,17 +83,16 @@ void startAdv(void)
7883 * - Start(timeout) with timeout = 0 will advertise forever (until connected)
7984 *
8085 * Apple Beacon specs
81- * - Type: Non connectable, undirected
86+ * - Type: Non- connectable, scannable , undirected
8287 * - Fixed interval: 100 ms -> fast = slow = 100 ms
8388 */
84- // Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_ADV_NONCONN_IND );
89+ Bluefruit.Advertising .setType (BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED );
8590 Bluefruit.Advertising .restartOnDisconnect (true );
8691 Bluefruit.Advertising .setInterval (160 , 160 ); // in unit of 0.625 ms
8792 Bluefruit.Advertising .setFastTimeout (30 ); // number of seconds in fast mode
8893 Bluefruit.Advertising .start (0 ); // 0 = Don't stop advertising after n seconds
8994}
9095
91- void loop ()
92- {
96+ void loop () {
9397 // loop is already suspended, CPU will not run loop() at all
9498}
0 commit comments