diff options
Diffstat (limited to 'Mussel')
-rw-r--r-- | Mussel/Mussel.cpp | 290 | ||||
-rw-r--r-- | Mussel/Mussel.h | 78 | ||||
-rw-r--r-- | Mussel/Mussel_begin.puml | 10 | ||||
-rw-r--r-- | Mussel/Mussel_read.puml | 24 | ||||
-rw-r--r-- | Mussel/README.md | 38 | ||||
-rw-r--r-- | Mussel/examples/button/button.ino | 20 | ||||
-rw-r--r-- | Mussel/examples/button_states/button_states.ino | 20 | ||||
-rw-r--r-- | Mussel/examples/command/command.ino | 19 | ||||
-rw-r--r-- | Mussel/examples/minute/minute.ino | 20 | ||||
-rw-r--r-- | Mussel/examples/seconds/seconds.ino | 19 | ||||
-rw-r--r-- | Mussel/examples/seconds/seconds.puml | 15 | ||||
-rw-r--r-- | Mussel/examples/sensor/Mussel_Sensor_Beacon.md | 7 | ||||
-rw-r--r-- | Mussel/examples/sensor/sensor.ino | 54 | ||||
-rw-r--r-- | Mussel/examples/sensor/sensor.puml | 26 | ||||
-rw-r--r-- | Mussel/examples/temperature/temperature.ino | 21 | ||||
-rw-r--r-- | Mussel/examples/vote/Mussel_Beacon_Voting.md | 20 | ||||
-rw-r--r-- | Mussel/examples/vote/vote.ino | 56 | ||||
-rw-r--r-- | Mussel/examples/vote/vote.puml | 27 | ||||
-rw-r--r-- | Mussel/examples/voting/voting.ino | 23 | ||||
-rw-r--r-- | Mussel/examples/voting/voting.puml | 15 | ||||
-rw-r--r-- | Mussel/keywords.txt | 17 | ||||
-rw-r--r-- | Mussel/library.properties | 10 |
22 files changed, 0 insertions, 829 deletions
diff --git a/Mussel/Mussel.cpp b/Mussel/Mussel.cpp deleted file mode 100644 index a05f329..0000000 --- a/Mussel/Mussel.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Amal Mazrah <mazrah@ruc.dk> -// SPDX-FileCopyrightText: 2025 Jonas Smedegaard <dr@jones.dk> -// SPDX-FileCopyrightText: 2025 Mennatullah Hatim Kassim <stud-mennatulla@ruc.dk> -// SPDX-FileCopyrightText: 2025 Noor Ahmad <noora@ruc.dk> -// SPDX-FileCopyrightText: 2025 Tanishka Suwalka <tanishkas@ruc.dk> -// SPDX-License-Identifier: GPL-3.0-or-later - -/// Mussel - a small library for Arduino to emulate a mussel biosensor -/// -/// * v0.0.2 -/// * rewrite attitude #2 to also handle button press -/// * add voting functions and example -/// -/// * v0.0.1 -/// * initial release to radicle -/// -/// @version 0.0.2 -/// @see <https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z2tFBF4gN7ziG9oXtUytVQNYe3VhQ/tree/Mussel/README.md> -/// @see <https://moodle.ruc.dk/course/view.php?id=23504> - -#include "Mussel.h" -#include "Arduino.h" - -/// Main constructor -/// -/// @param attitude behavioral profile as integer -Mussel::Mussel(int attitude) { - _attitude = attitude; -} - -/// Constructor for attitudes using an input pin -/// -/// @param attitude behavioral profile as integer -/// @param pin Used pin as uint8_t -Mussel::Mussel(int attitude, uint8_t pin) { - _attitude = attitude; - _pin = pin; -} - -/// Constructor for attitudes using an input pin and a sensor type -/// -/// @param attitude behavioral profile as integer -/// @param pin Used pin as uint8_t -/// @param type type of sensor as uint8_t -Mussel::Mussel(int attitude, uint8_t pin, uint8_t type) -#ifdef DHT_H - : mussel_dht(pin, type) -#endif -{ - _attitude = attitude; - _pin = pin; -} - -/// Setup function -void Mussel::begin() { - switch(_attitude) { - case 1: - _boolState = HIGH; - - // reset timer - _time = millis(); - - // use INPUT_PULLDOWN to signal when the button is held down - // (not PULLUP which signals when it is released) - pinMode(_pin, INPUT_PULLDOWN); - break; -#ifdef DHT_H - case 3: - mussel_dht.begin(); - break; -#endif - case 4: - // use INPUT_PULLDOWN to signal when the button is held down - // (not PULLUP which signals when it is released) - pinMode(_pin, INPUT_PULLDOWN); - break; - case 5: - _boolState = HIGH; - _count = 0; - _time = 0; - - // Enable internal pull-up resistor for button - pinMode(_pin, INPUT_PULLUP); - break; - case 6: - _boolState = HIGH; - break; - } -} - -/// Description of mussel -/// -/// @return name and attitude of mussel as String -String Mussel::desc() { - String _str; - - switch(_attitude) { - case 1: - _str = "closed 10 seconds every 50 seconds and on button push"; - break; - case 2: - _str = "closed 4 seconds every 8 seconds"; - break; - case 3: - _str = "closed when cold"; - break; - case 4: - _str = "closed when button is pushed"; - break; - case 5: - _str = "changes state when button is pushed"; - break; - case 6: - _str = "changes state on ON/OFF command"; - break; - case 10: - _str = "handles voting"; - break; - default: - _str = "undefined [" + static_cast<String>(_attitude) + "]"; - break; - } - - return _str; -} - -/// Sensor reading -/// -/// * Values 0-99 is a measured relative mussel gape size -/// * Values 100-254 are reserved for future use -/// * Value 255 is an internal error -/// -/// @return relative gape size as value 0-255 encoded as int -int Mussel::read() { - int _read; - - switch(_attitude) { - case 1: - if (digitalRead(_pin) - // TODO: account for rollover - or (millis() - _time) > MUSSEL_NORMAL_PACE * 1000 - ) { - _read = 2; - _boolState = HIGH; - - // reset timer - _time = millis(); - } else if (_boolState == HIGH - and (millis() - _time) > MUSSEL_STRESS_PACE * 1000 - ) { - _read = 42; - _boolState = LOW; - - // reset timer - _time = millis(); - } - break; - case 2: - // 42 if current second modulo 12 is below 9, else 2 - _read = (static_cast<unsigned long>(millis() / 1000) % 12) < 9 - ? 42 - : 2; - break; - case 3: -#ifdef DHT_H - // temperature in Celsius - _read = mussel_dht.readTemperature(); -#else - _read = 255; -#endif - break; - case 4: - // 2 if button is pressed, else 42 - _read = digitalRead(_pin) == HIGH - ? 2 - : 42; - break; - case 5: { - bool _reading = digitalRead(_pin); // Read button state - - // Debounce logic: - // Ensures a single press isn't detected multiple times - if (_reading != _boolState) { - _time = millis(); // Reset debounce timer - } - - if ((millis() - _time) > MUSSEL_DEBOUNCE_DELAY) { - // Check for button press (transition from HIGH to LOW) - if (_reading == LOW && _boolState == HIGH) { - _count++; // Increment click count - if (_count > 3) { - _count = 0; // Reset cycle after 3 clicks - } - switch (_count) { - case 1: _read = 2; break; // State: Angry - case 2: _read = 42; break; // State: Happy - case 3: _read = 15; break; // State: Unsure - case 0: _read = 99; break; // State: Off - } - } - } - - _boolState = _reading; // Update button state - break; - } - case 6: - if (Serial.available() > 0) { - String command = Serial.readStringUntil('\n'); - command.trim(); - - if (command.equalsIgnoreCase("ON")) { - _boolState = HIGH; - } - else if (command.equalsIgnoreCase("OFF")) { - _boolState = LOW; - } - } - _read = _boolState == HIGH - ? 42 - : 2; - break; - default: - _read = 255; - break; - } - - return _read; -} - -/// Function to push data onto the stack -bool Mussel::push(String id, unsigned long timestamp, int measure) { - - // Check if stack is full - if (top >= STACK_SIZE - 1) { - Serial.println("Stack Full"); - - // Return false if stack is full - return false; - } - top++; - idStack[top] = id; - timeStack[top] = timestamp; - measureStack[top] = measure; - - // Return true on successful push - return true; -} - -/// Function to print stack contents -void Mussel::printStack() { - for (int i = top; i >= 0; i--) { - Serial.print("ID: "); Serial.print(idStack[i]); - Serial.print(", Time: "); Serial.print(timeStack[i]); - Serial.print(", measure: "); Serial.println(measureStack[i]); - } -} - -bool qualifyVote(Vote vote, unsigned long currentTime) { - - // If the measure is 42 (YES), check timestamp validity - if (vote.measure == 42) { - // If the vote's timestamp is within 1 minute, count it as YES - if (currentTime - vote.timestamp <= MUSSEL_VOTE_TIME_AHEAD) { - return true; - } - // If the vote's timestamp is older than 2 minutes, count it as NO - else if (currentTime - vote.timestamp > MUSSEL_VOTE_TIME_BEHIND) { - return false; - } - } - - // If the measure is 2, always count the vote as NO - if (vote.measure == 2) { - return false; - } - - // Default case: vote is invalid if no conditions are met - return false; -} - -/// Dump internal variables, formatted for use with Serial Plotter -/// -/// @return internal variables as String -String Mussel::debug() { - return static_cast<String>( - "pin:") + _pin - + "\tboolState:" + _boolState - + "\ttime:" + _time - + "\tcount:" + _count; -} diff --git a/Mussel/Mussel.h b/Mussel/Mussel.h deleted file mode 100644 index ba063c2..0000000 --- a/Mussel/Mussel.h +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Amal Mazrah <mazrah@ruc.dk> -// SPDX-FileCopyrightText: 2025 Jonas Smedegaard <dr@jones.dk> -// SPDX-FileCopyrightText: 2025 Mennatullah Hatim Kassim <stud-mennatulla@ruc.dk> -// SPDX-FileCopyrightText: 2025 Noor Ahmad <noora@ruc.dk> -// SPDX-FileCopyrightText: 2025 Tanishka Suwalka <tanishkas@ruc.dk> -// SPDX-License-Identifier: GPL-3.0-or-later - -/// Mussel - a small library for Arduino to emulate a mussel biosensor -/// -/// @version 0.0.2 -/// @see <https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z2tFBF4gN7ziG9oXtUytVQNYe3VhQ/tree/Mussel/README.md> -/// @see <https://moodle.ruc.dk/course/view.php?id=23504> - -#ifndef Mussel_h -#define Mussel_h -#include "Arduino.h" - -// seconds -#define MUSSEL_NORMAL_PACE 50U -#define MUSSEL_STRESS_PACE 10U -#define MUSSEL_VOTE_TIME_AHEAD 60000U // 1 minute -#define MUSSEL_VOTE_TIME_BEHIND 120000U // 2 minutes - -// milliseconds -#define MUSSEL_DEBOUNCE_DELAY 50U - -// Limited size NOW!! can be transformed into infinite array -#define STACK_SIZE 1000 - -struct Vote { - String id; - unsigned long timestamp; - int measure; -}; - -class Mussel { - public: - - // Default constructor - Mussel(const int attitude); - - // Constructor for attitudes using an input pin - Mussel(const int attitude, const uint8_t pin); - - // Constructor for attitudes using an input pin and a sensor type - Mussel( - const int attitude, - const uint8_t pin, - const uint8_t type); - - void begin(); - String desc(); - int read(); - String debug(); - bool push(String id, unsigned long timestamp, int measure); - void printStack(); - bool qualifyVote(Vote vote, unsigned long currentTime); - - private: - int _attitude; - int _pin; - bool _boolState; - byte _count; - unsigned long _time; -#ifdef DHT_H - DHT mussel_dht; -#endif - - // Array to store ID strings - String idStack[STACK_SIZE]; - unsigned long timeStack[STACK_SIZE]; - int measureStack[STACK_SIZE]; - - // Index of the top element in the stack, -1 means stack is empty - int top = -1; -}; - -#endif diff --git a/Mussel/Mussel_begin.puml b/Mussel/Mussel_begin.puml deleted file mode 100644 index 17fb9fa..0000000 --- a/Mussel/Mussel_begin.puml +++ /dev/null @@ -1,10 +0,0 @@ -@startuml -start -if (type ?) equals (defined) then -:init sensor driver; -endif -if (pin ?) equals (defined) then -:configure input pin; -endif -stop -@enduml diff --git a/Mussel/Mussel_read.puml b/Mussel/Mussel_read.puml deleted file mode 100644 index e9190bb..0000000 --- a/Mussel/Mussel_read.puml +++ /dev/null @@ -1,24 +0,0 @@ -@startuml -start -switch (attitude ?) -case (1) -://TODO//; -case (2) -:set time to current second; -if (time mod 12 ?) equals (< 9) then -:set gape to "42"; -else (>= 9) -:set gape to "2"; -endif -case (3) -:read temperature sensor; -case (4) -:read temperature sensor; -if (button ?) equals (not pressed) then -:set gape to "42"; -else (pressed) -:set gape to "2"; -endif -endswitch -stop -@enduml diff --git a/Mussel/README.md b/Mussel/README.md deleted file mode 100644 index 994f3a7..0000000 --- a/Mussel/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Mussel - -Mussel is a tiny library to emulate a mussel biosensor. - -## Installation - -Download the ZIP archive from the `Raw` link at -<https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z2tFBF4gN7ziG9oXtUytVQNYe3VhQ/tree/Mussel.zip>, -then open the Arduino IDE -and choose Sketch > Include Library > Add .ZIP Library... -and select your downloaded file. - -You should now see in File > Examples > Mussel -an entry for the `basic_usage` example. - -## Motivation - -For exploration of various biosensor behaviours, -hooking into various networking setups with various looping constructs, -maintaining the behaviours as a library seemed convenient. - -## Features - -* Super simple API -* Offers multiple behaviours. - -## Requirements - -* An Arduino — http://arduino.cc/ - -## Copyright and licensing - -SPDX-FileCopyrightText: 2025 Amal Mazrah <mazrah@ruc.dk> -SPDX-FileCopyrightText: 2025 Jonas Smedegaard <dr@jones.dk> -SPDX-FileCopyrightText: 2025 Mennatullah Hatim Kassim <stud-mennatulla@ruc.dk> -SPDX-FileCopyrightText: 2025 Noor Ahmad <noora@ruc.dk> -SPDX-FileCopyrightText: 2025 Tanishka Suwalka <tanishkas@ruc.dk> -SPDX-License-Identifier: GPL-3.0-or-later diff --git a/Mussel/examples/button/button.ino b/Mussel/examples/button/button.ino deleted file mode 100644 index 5efae46..0000000 --- a/Mussel/examples/button/button.ino +++ /dev/null @@ -1,20 +0,0 @@ -#include <Mussel.h> - -// instantiate with attitude #4, -// and pin 4 connected to a button -Mussel mussel(4, 4); - -void setup() { - Serial.begin(115200); - mussel.begin(); - - Serial.printf("\n\nDevice ready: %s\n", - mussel.desc().c_str()); -} - -void loop() { - Serial.printf("gap:%d\n", - mussel.read()); - - delay(1000); -} diff --git a/Mussel/examples/button_states/button_states.ino b/Mussel/examples/button_states/button_states.ino deleted file mode 100644 index 1d91b41..0000000 --- a/Mussel/examples/button_states/button_states.ino +++ /dev/null @@ -1,20 +0,0 @@ -#include <Mussel.h> - -// instantiate with attitude #5, -// and pin 9 connected to a button -Mussel mussel(5, 9); - -void setup() { - Serial.begin(115200); - mussel.begin(); - - Serial.printf("\n\nDevice ready: %s\n", - mussel.desc().c_str()); -} - -void loop() { - Serial.printf("gap:%d\n", - mussel.read()); - - delay(1000); -} diff --git a/Mussel/examples/command/command.ino b/Mussel/examples/command/command.ino deleted file mode 100644 index f359e00..0000000 --- a/Mussel/examples/command/command.ino +++ /dev/null @@ -1,19 +0,0 @@ -#include <Mussel.h> - -// instantiate with attitude #6 -Mussel mussel(6); - -void setup() { - Serial.begin(115200); - mussel.begin(); - - Serial.printf("\n\nDevice ready: %s\n", - mussel.desc().c_str()); -} - -void loop() { - Serial.printf("gap:%d\n", - mussel.read()); - - delay(1000); -} diff --git a/Mussel/examples/minute/minute.ino b/Mussel/examples/minute/minute.ino deleted file mode 100644 index 4bf59ce..0000000 --- a/Mussel/examples/minute/minute.ino +++ /dev/null @@ -1,20 +0,0 @@ -#include <Mussel.h> - -// instantiate with attitude #2, -// and pin 4 connected to a button -Mussel mussel(2, 4); - -void setup() { - Serial.begin(115200); - mussel.begin(); - - Serial.printf("\n\nDevice ready: %s\n", - mussel.desc().c_str()); -} - -void loop() { - Serial.printf("gap:%d\n", - mussel.read()); - - delay(1000); -} diff --git a/Mussel/examples/seconds/seconds.ino b/Mussel/examples/seconds/seconds.ino deleted file mode 100644 index 928537c..0000000 --- a/Mussel/examples/seconds/seconds.ino +++ /dev/null @@ -1,19 +0,0 @@ -#include <Mussel.h> - -// instantiate with attitude #2 -Mussel mussel(2); - -void setup() { - Serial.begin(115200); - mussel.begin(); - - Serial.printf("\n\nDevice ready: %s\n", - mussel.desc().c_str()); -} - -void loop() { - Serial.printf("gap:%d\n", - mussel.read()); - - delay(1000); -} diff --git a/Mussel/examples/seconds/seconds.puml b/Mussel/examples/seconds/seconds.puml deleted file mode 100644 index 55746ff..0000000 --- a/Mussel/examples/seconds/seconds.puml +++ /dev/null @@ -1,15 +0,0 @@ -@startuml -'start -:instantiate object; -group init -:activate object; -:fetch and print object description; -end group -while (each 1s) -group loop { -:fetch and print gape angle; -end group -endwhile --[hidden]-> -kill -@enduml diff --git a/Mussel/examples/sensor/Mussel_Sensor_Beacon.md b/Mussel/examples/sensor/Mussel_Sensor_Beacon.md deleted file mode 100644 index e252104..0000000 --- a/Mussel/examples/sensor/Mussel_Sensor_Beacon.md +++ /dev/null @@ -1,7 +0,0 @@ -## Mussel Sensor Beacon - -1. Reads sensors. - -2. Normalises sensor data as a gape angle in the range of 0°-90°. - -3. Broadcasts normalised sensor data as a beacon on a bluetooth network. diff --git a/Mussel/examples/sensor/sensor.ino b/Mussel/examples/sensor/sensor.ino deleted file mode 100644 index 77b443f..0000000 --- a/Mussel/examples/sensor/sensor.ino +++ /dev/null @@ -1,54 +0,0 @@ -/* - EddystoneTLM beacon by BeeGee based on https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_Eddystone_TLM_deepsleep/ESP32_Eddystone_TLM_deepsleep.ino - EddystoneTLM frame specification https://github.com/google/eddystone/blob/master/eddystone-tlm/tlm-plain.md -*/ - -#include "BLEDevice.h" -#include "BLEBeacon.h" -#include "BLEAdvertising.h" -#include "BLEEddystoneTLM.h" - -#include <Mussel.h> - -#define BEACON_POWER ESP_PWR_LVL_N12 - -// See the following for generating UUIDs: -// https://www.uuidgenerator.net/ -BLEAdvertising *pAdvertising; - -#define BEACON_UUID "8ec76ea3-6668-48da-9866-75be8bc86f4d" // UUID 1 128-Bit (may use linux tool uuidgen or random numbers via https://www.uuidgenerator.net/) - -Mussel mussel(2); - -// Check -// https://github.com/google/eddystone/blob/master/eddystone-tlm/tlm-plain.md -// and http://www.hugi.scene.org/online/coding/hugi%2015%20-%20cmtadfix.htm -// for the temperature value. It is a 8.8 fixed-point notation -void setBeacon() { - BLEEddystoneTLM EddystoneTLM; - EddystoneTLM.setTemp(mussel.read()); // 3000 = 30.00 ˚C - Serial.printf("Temperature is %.2f°C\n", EddystoneTLM.getTemp()); - - BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); - BLEAdvertisementData oScanResponseData = BLEAdvertisementData(); - oScanResponseData.setServiceData(BLEUUID((uint16_t)0xFEAA), String(EddystoneTLM.getData().c_str(), EddystoneTLM.getData().length())); - - oAdvertisementData.setName("ESP32 TLM Beacon"); - pAdvertising->setAdvertisementData(oAdvertisementData); - pAdvertising->setScanResponseData(oScanResponseData); -} - -void setup() { - Serial.begin(115200); - mussel.begin(); - BLEDevice::init("TLMBeacon"); - BLEDevice::setPower(BEACON_POWER); - pAdvertising = BLEDevice::getAdvertising(); - setBeacon(); - pAdvertising->start(); -} - -void loop() { - setBeacon(); - delay(500); -} diff --git a/Mussel/examples/sensor/sensor.puml b/Mussel/examples/sensor/sensor.puml deleted file mode 100644 index 3f033d1..0000000 --- a/Mussel/examples/sensor/sensor.puml +++ /dev/null @@ -1,26 +0,0 @@ -@startuml -'start -:instantiate mussel object; -:instantiate bluetooth object; -group init -:setup mussel sensors; -:setup bluetooth beacon; -end group -split -while (each 500ms) -group loop { -:read sensors; -:normalize sensor data -as a gape angle; -:add gape angle to beacon; -end group -endwhile --[hidden]-> -kill -split again -while (each 100ms) -:broadcast beacon; -endwhile --[hidden]-> -kill -@enduml diff --git a/Mussel/examples/temperature/temperature.ino b/Mussel/examples/temperature/temperature.ino deleted file mode 100644 index 6b4ca08..0000000 --- a/Mussel/examples/temperature/temperature.ino +++ /dev/null @@ -1,21 +0,0 @@ -#include <DHT.h> -#include <Mussel.h> - -// instantiate with attitude #3, -// and PIN 15 connected to an external sensor of type DHT11 -Mussel mussel(3, 15, DHT11); - -void setup() { - Serial.begin(115200); - mussel.begin(); - - Serial.printf("\n\nDevice ready: %s\n", - mussel.desc().c_str()); -} - -void loop() { - Serial.printf("gap:%d\n", - mussel.read()); - - delay(1000); -} diff --git a/Mussel/examples/vote/Mussel_Beacon_Voting.md b/Mussel/examples/vote/Mussel_Beacon_Voting.md deleted file mode 100644 index 33a0893..0000000 --- a/Mussel/examples/vote/Mussel_Beacon_Voting.md +++ /dev/null @@ -1,20 +0,0 @@ -## Mussel Beacon Voting - -1. Scans bluetooth network for beacons. - -2. Collects mussel name and gape angle -as decoded from each detected beacon, -together with the time of detection in milliseconds since boot. - -3. Aligns the collected data -to the format of ballots for a water quality vote. - -4. Qualifies the ballots for criteria of the water quality vote -(e.g. timeliness and sanity of gape angles). - -5. Concludes a vote based on collected, aligned and qualified ballots. - -6. Acts on the voting result, -e.g. turns on a steady light for "code green" -or a blinking light for "code yellow", -or turns on a blinking light and shuts off a valve for "code red". diff --git a/Mussel/examples/vote/vote.ino b/Mussel/examples/vote/vote.ino deleted file mode 100644 index ec9d185..0000000 --- a/Mussel/examples/vote/vote.ino +++ /dev/null @@ -1,56 +0,0 @@ -/* - 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 <Arduino.h> - -#include <BLEDevice.h> -#include <BLEScan.h> -#include <BLEAdvertisedDevice.h> -#include <BLEEddystoneTLM.h> -#include <BLEBeacon.h> - -#include <Mussel.h> - -int scanTime = 1; //In seconds -BLEScan *pBLEScan; - -Mussel mussel(10); - -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); -} diff --git a/Mussel/examples/vote/vote.puml b/Mussel/examples/vote/vote.puml deleted file mode 100644 index a4958f7..0000000 --- a/Mussel/examples/vote/vote.puml +++ /dev/null @@ -1,27 +0,0 @@ -@startuml -:instantiate mussel object; -:instantiate bluetooth object; -group init -:setup mussel voting; -:setup bluetooth scanner; -end group -split -while (each beacon detected) -group "bluetooth callback" { -:collect beacon data; -end group -endwhile --[hidden]-> -kill -split again -while (each 500ms) -group loop { -:allign beacon data as ballots; -:qualify ballots for a vote; -:conclude vote result; -:act on vote result; -end group -endwhile --[hidden]-> -kill -@enduml diff --git a/Mussel/examples/voting/voting.ino b/Mussel/examples/voting/voting.ino deleted file mode 100644 index db4364d..0000000 --- a/Mussel/examples/voting/voting.ino +++ /dev/null @@ -1,23 +0,0 @@ -#include <Mussel.h> - -// instantiate for vote handling -Mussel mussel(10); - -void setup() { - Serial.begin(115200); - mussel.begin(); - - Serial.printf("\n\nDevice ready: %s\n", - mussel.desc().c_str()); -} - -void loop() { - - // Inject sample data - mussel.push("A1", millis(), random(90)); - mussel.push("B2", millis(), random(90)); - mussel.push("C3", millis(), random(90)); - mussel.printStack(); - - delay(1000); -} diff --git a/Mussel/examples/voting/voting.puml b/Mussel/examples/voting/voting.puml deleted file mode 100644 index 8460d90..0000000 --- a/Mussel/examples/voting/voting.puml +++ /dev/null @@ -1,15 +0,0 @@ -@startuml -'start -:instantiate object; -group init -:activate object; -end group -while (each ½s) -group loop { -:register 3 fake votes; -:fetch and print voting tally; -end group -endwhile --[hidden]-> -kill -@enduml diff --git a/Mussel/keywords.txt b/Mussel/keywords.txt deleted file mode 100644 index 4f3eaf1..0000000 --- a/Mussel/keywords.txt +++ /dev/null @@ -1,17 +0,0 @@ -####################################### -# Syntax Coloring Map for Mussel library -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -Mussel KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -read KEYWORD2 -begin KEYWORD2 -desc KEYWORD2 diff --git a/Mussel/library.properties b/Mussel/library.properties deleted file mode 100644 index 604ef3b..0000000 --- a/Mussel/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=Mussel -version=0.0.2 -author= Amal Mazrah <mazrah@ruc.dk>, Jonas Smedegaard <dr@jones.dk>, Mennatullah Hatim Kassim <stud-mennatulla@ruc.dk>, Noor Ahmad <noora@ruc.dk> and Tanishka Suwalka <tanishkas@ruc.dk> -maintainer=Jonas Smedegaard <dr@jones.dk> -sentence=Arduino library to emulate a mussel biosensor. -paragraph=Arduino library to to emulate a mussel biosensor. -category=Sensors -url=https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z2tFBF4gN7ziG9oXtUytVQNYe3VhQ -architectures=* -includes=Mussel.h |