-
-
Save wwj718/2004f9d24dfa77eaae98d59e7227a683 to your computer and use it in GitHub Desktop.
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
#include <Arduino.h> | |
#include <BLEDevice.h> | |
#include <BLEServer.h> | |
#include <BLEAdvertisedDevice.h> | |
BLEAdvertising* pAdvertising = NULL; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("Starting BLE work!"); | |
BLEDevice::init("MicroBlocks OctoStudio"); | |
pAdvertising = BLEDevice::getAdvertising(); | |
} | |
void loop() { | |
pAdvertising->stop(); | |
int randomNumber = random(256); | |
// The first four bytes are random numbers | |
uint8_t service_data[] = {0x2a, 0xa6, 0x84, randomNumber, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00}; | |
BLEAdvertisementData advertisementData = BLEAdvertisementData(); | |
advertisementData.setServiceData(BLEUUID("2540b6b0-0001-4538-bcd7-7ecfb51297c1"), std::string((char*)service_data, 13)); | |
pAdvertising->setAdvertisementData(advertisementData); | |
pAdvertising->start(); | |
delay(3000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment