diff --git a/libraries/Bluefruit52Lib/examples/beacon/beacon.ino b/libraries/Bluefruit52Lib/examples/beacon/beacon.ino index a75744d0..a28d234a 100644 --- a/libraries/Bluefruit52Lib/examples/beacon/beacon.ino +++ b/libraries/Bluefruit52Lib/examples/beacon/beacon.ino @@ -13,8 +13,11 @@ *********************************************************************/ #include +// Beacon uses the Manufacturer Specific Data field in the advertising +// packet, which means you must provide a valid Manufacturer ID. Update +// the field below to an appropriate value. For a list of valid IDs see: // https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers -// 0x004C is Apple +// 0x004C is Apple (for example) #define MANUFACTURER_ID 0x004C // AirLocate UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 @@ -24,7 +27,8 @@ uint8_t beaconUuid[16] = 0xB0, 0x60, 0xD0, 0xF5, 0xA7, 0x10, 0x96, 0xE0, }; -// uuid, major, minor, rssi @1m +// A valid Beacon packet consists of the following information: +// UUID, Major, Minor, RSSI @ 1M BLEBeacon beacon(beaconUuid, 0x0001, 0x0000, -54); void setup() @@ -36,29 +40,32 @@ void setup() Bluefruit.begin(); Bluefruit.setName("Bluefruit52"); + // Manufacturer ID is required for Manufacturer Specific Data beacon.setManufacturer(MANUFACTURER_ID); - // Set up Advertising Packet + // Setup the advertising packet setupAdv(); - // Start Advertising + // Start advertising Bluefruit.Advertising.start(); } void setupAdv(void) { + // Set the beacon payload using the BLEBeacon class populated + // earlier in this example Bluefruit.Advertising.setBeacon(beacon); - char* adv = Bluefruit.Advertising.getData(); + // char* adv = Bluefruit.Advertising.getData(); - // There is no room for Name in Advertising packet - // Use Scan response for Name + // There is no room left for 'Name' in the advertising packet + // Use the optinal secondary Scan Response packet for 'Name' instead Bluefruit.ScanResponse.addName(); } void loop() { - // Toggle both LEDs every 1 second + // Toggle both LEDs every second digitalToggle(LED_BUILTIN); delay(1000); } diff --git a/libraries/Bluefruit52Lib/examples/controller/controller.ino b/libraries/Bluefruit52Lib/examples/controller/controller.ino index 6136675a..13c4ef8e 100644 --- a/libraries/Bluefruit52Lib/examples/controller/controller.ino +++ b/libraries/Bluefruit52Lib/examples/controller/controller.ino @@ -17,20 +17,13 @@ BLEUart bleuart; // Function prototypes for packetparser.cpp -uint8_t readPacket(BLEUart *ble_uart, uint16_t timeout); -float parsefloat(uint8_t *buffer); -void printHex(const uint8_t * data, const uint32_t numBytes); +uint8_t readPacket (BLEUart *ble_uart, uint16_t timeout); +float parsefloat (uint8_t *buffer); +void printHex (const uint8_t * data, const uint32_t numBytes); -// the packet buffer +// Packet buffer extern uint8_t packetbuffer[]; - -/**************************************************************************/ -/*! - @brief Sets up the HW an the BLE module (this function is called - automatically on startup) -*/ -/**************************************************************************/ void setup(void) { Serial.begin(115200); @@ -40,27 +33,26 @@ void setup(void) Bluefruit.begin(); Bluefruit.setName("Bluefruit52"); - // Configure and Start BLE Uart Service + // Configure and start the BLE Uart service bleuart.start(); // Set up the advertising packet setupAdv(); - // Start Advertising + // Start advertising Bluefruit.Advertising.start(); } void setupAdv(void) -{ - //Bluefruit.Advertising.addTxPower(); +{ Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); Bluefruit.Advertising.addTxPower(); - // Include bleuart 128-bit uuid + // Include the BLE UART (AKA 'NUS') 128-bit UUID Bluefruit.Advertising.addService(bleuart); - // There is no room for Name in Advertising packet - // Use Scan response for Name + // There is no room for 'Name' in the Advertising packet + // Use the optional secondary Scan Response packet for 'Name' instead Bluefruit.ScanResponse.addName(); } @@ -71,11 +63,11 @@ void setupAdv(void) /**************************************************************************/ void loop(void) { - /* Wait for new data to arrive */ + // Wait for new data to arrive uint8_t len = readPacket(&bleuart, 500); if (len == 0) return; - /* Got a packet! */ + // Got a packet! // printHex(packetbuffer, len); // Color diff --git a/platform.txt b/platform.txt index 0e9c65e4..01adce08 100644 --- a/platform.txt +++ b/platform.txt @@ -1,5 +1,6 @@ # Copyright (c) 2014-2015 Arduino LLC. All right reserved. # Copyright (c) 2016 Sandeep Mistry All right reserved. +# Copyright (c) 2017 Adafruit Industries. All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -16,7 +17,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA name=Adafruit Boards -version=0.2.1 +version=0.4.5 # Compile variables # -----------------