diff options
Diffstat (limited to 'arduino/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota')
-rwxr-xr-x | arduino/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/arduino/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino b/arduino/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino new file mode 100755 index 0000000..85cd5f0 --- /dev/null +++ b/arduino/libraries/Bluefruit52Lib/examples/Peripheral/blinky_ota/blinky_ota.ino @@ -0,0 +1,63 @@ +/********************************************************************* + 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> + +void setup() +{ + Serial.begin(115200); + while ( !Serial ) delay(10); // for nrf52840 with native usb + + Serial.println("Bluefruit52 Blinky 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"); + + // Set up and start advertising + startAdv(); +} + +void startAdv(void) +{ + // Advertising packet + Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); + Bluefruit.Advertising.addTxPower(); + Bluefruit.Advertising.addName(); + + /* Start Advertising + * - Enable auto advertising if disconnected + * - Interval: fast mode = 20 ms, slow mode = 152.5 ms + * - Timeout for fast mode is 30 seconds + * - Start(timeout) with timeout = 0 will advertise forever (until connected) + * + * For recommended advertising interval + * https://developer.apple.com/library/content/qa/qa1931/_index.html + */ + Bluefruit.Advertising.restartOnDisconnect(true); + Bluefruit.Advertising.setInterval(32, 244); // 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 1 second + digitalToggle(LED_RED); + + delay(1000); +} + |