diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2019-02-28 17:04:22 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2019-02-28 17:04:22 -0500 |
commit | d6869d1ec4bd24cd2c3eafa534f0849b25ec5607 (patch) | |
tree | 79e54ed27b39c31864895535d11399708d5a45c0 /arduino/libraries/Bluefruit52Lib/examples/Peripheral/eddystone_url/eddystone_url.ino | |
parent | 614ee97bf3a2270c413527a7f35c54cbecd9e601 (diff) |
added basic code
Diffstat (limited to 'arduino/libraries/Bluefruit52Lib/examples/Peripheral/eddystone_url/eddystone_url.ino')
-rwxr-xr-x | arduino/libraries/Bluefruit52Lib/examples/Peripheral/eddystone_url/eddystone_url.ino | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/arduino/libraries/Bluefruit52Lib/examples/Peripheral/eddystone_url/eddystone_url.ino b/arduino/libraries/Bluefruit52Lib/examples/Peripheral/eddystone_url/eddystone_url.ino new file mode 100755 index 0000000..15b068f --- /dev/null +++ b/arduino/libraries/Bluefruit52Lib/examples/Peripheral/eddystone_url/eddystone_url.ino @@ -0,0 +1,73 @@ +/********************************************************************* + This is an example for our nRF52 based Bluefruit LE modules + + Pick one up today in the adafruit shop! + + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + MIT license, check LICENSE for more information + All text above, and the splash screen below must be included in + any redistribution +*********************************************************************/ +#include <bluefruit.h> + +#define URL "https://www.adafruit.com" + +// Create an EddyStone URL with rssi at 0m = -40 and URL as defined above +EddyStoneUrl eddyUrl(-40, URL); + +void setup() +{ + Serial.begin(115200); + while ( !Serial ) delay(10); // for nrf52840 with native usb + + Serial.println("Bluefruit52 EddyStone URL Example"); + Serial.println("---------------------------------\n"); + + Bluefruit.begin(); + // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4 + Bluefruit.setTxPower(4); + Bluefruit.setName("Bluefruit52"); + + // Setup the advertising packet + startAdv(); + + Serial.println("Broadcasting EddyStone URL, open Google Physical Web app to test"); +} + +void startAdv(void) +{ + // Advertising packet + // Set the beacon payload using the BLEBeacon class populated + // earlier in this example + Bluefruit.Advertising.setBeacon(eddyUrl); + + // Secondary Scan Response packet (optional) + // Since there is no room for 'Name' in Advertising packet + Bluefruit.ScanResponse.addName(); + + /* Start Advertising + * - Enable auto advertising if disconnected + * - Timeout for fast mode is 30 seconds + * - Start(timeout) with timeout = 0 will advertise forever (until connected) + * + * Apple Beacon specs + * - Type: Non connectable, undirected + * - Fixed interval: 100 ms -> fast = slow = 100 ms + */ + //Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_ADV_NONCONN_IND); + Bluefruit.Advertising.restartOnDisconnect(true); + Bluefruit.Advertising.setInterval(160, 160); // in unit of 0.625 ms + Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode + Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds +} + +void loop() +{ + // Toggle both LEDs every second + digitalToggle(LED_RED); + delay(1000); +} + |