diff options
Diffstat (limited to 'Mussel/examples/voting_from_EddystoneTLM')
3 files changed, 70 insertions, 0 deletions
diff --git a/Mussel/examples/voting_from_EddystoneTLM/Beacon_Scanner.md b/Mussel/examples/voting_from_EddystoneTLM/Beacon_Scanner.md new file mode 100644 index 0000000..34101fe --- /dev/null +++ b/Mussel/examples/voting_from_EddystoneTLM/Beacon_Scanner.md @@ -0,0 +1,9 @@ +## BLE Beacon Scanner + +Initiates a BLE device scan. +Checks if the discovered devices are +- an iBeacon +- an Eddystone TLM beacon +- an Eddystone URL beacon + +and sends the decoded beacon information over Serial log diff --git a/Mussel/examples/voting_from_EddystoneTLM/ci.json b/Mussel/examples/voting_from_EddystoneTLM/ci.json new file mode 100644 index 0000000..abe13a7 --- /dev/null +++ b/Mussel/examples/voting_from_EddystoneTLM/ci.json @@ -0,0 +1,6 @@ +{ + "fqbn_append": "PartitionScheme=huge_app", + "requires": [ + "CONFIG_SOC_BLE_SUPPORTED=y" + ] +} diff --git a/Mussel/examples/voting_from_EddystoneTLM/voting_from_EddystoneTLM.ino b/Mussel/examples/voting_from_EddystoneTLM/voting_from_EddystoneTLM.ino new file mode 100644 index 0000000..25c4720 --- /dev/null +++ b/Mussel/examples/voting_from_EddystoneTLM/voting_from_EddystoneTLM.ino @@ -0,0 +1,55 @@ +/* + Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp + Ported to Arduino ESP32 by Evandro Copercini + Changed to a beacon scanner to report iBeacon, EddystoneURL and EddystoneTLM beacons by beegee-tokyo + Upgraded Eddystone part by Tomas Pilny on Feb 20, 2023 +*/ + +#include <Mussel.h> +#include <Arduino.h> + +#include <BLEDevice.h> +#include <BLEScan.h> +#include <BLEAdvertisedDevice.h> +#include <BLEEddystoneTLM.h> +#include <BLEBeacon.h> + +Mussel mussel(10); + +int scanTime = 1; //In seconds +BLEScan *pBLEScan; + +class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { + void onResult(BLEAdvertisedDevice advertisedDevice) { + if (advertisedDevice.haveName() + && advertisedDevice.getFrameType() == BLE_EDDYSTONE_TLM_FRAME + ) { + BLEEddystoneTLM EddystoneTLM(&advertisedDevice); + mussel.push( + advertisedDevice.getName(), + millis(), + EddystoneTLM.getTemp() + ); + } + } +}; + +void setup() { + Serial.begin(115200); + mussel.begin(); + + BLEDevice::init(""); + pBLEScan = BLEDevice::getScan(); //create new scan + pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); + pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster + pBLEScan->setInterval(100); + pBLEScan->setWindow(99); // less or equal setInterval value +} + +void loop() { + // put your main code here, to run repeatedly: + BLEScanResults *foundDevices = pBLEScan->start(scanTime, false); + pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory + mussel.printStack(); + delay(500); +} |