Last active
January 26, 2018 06:06
-
-
Save don/536d9f1d605d9bfffcd99b5716a72cb4 to your computer and use it in GitHub Desktop.
Demonstrate BLE broadcast for connectionless data transfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Broadcast Characteristic Value | |
// Simple counter that broadcasts a value | |
#ifdef ARDUINO_ARCH_ARC32 // Arduino 101 | |
#include <CurieBLE.h> | |
#else | |
#include <BLEPeripheral.h> | |
#endif | |
uint8_t value = 0; | |
BLEPeripheral peripheral; | |
BLEService service = BLEService("EEE0"); | |
BLEShortCharacteristic characteristic = BLEShortCharacteristic("EEE1", BLERead | BLENotify | BLEBroadcast); | |
void setup() { | |
Serial.begin(9600); | |
peripheral.setLocalName("BLEBroadcast"); | |
peripheral.setAdvertisedServiceUuid(service.uuid()); | |
peripheral.addAttribute(service); | |
peripheral.addAttribute(characteristic); | |
characteristic.setValue(value); | |
peripheral.begin(); | |
characteristic.broadcast(); | |
Serial.println(F("BLE Broadcast Count")); | |
} | |
void loop() { | |
peripheral.poll(); | |
characteristic.setValue(value); | |
delay(1000); | |
value++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment