|
Loom
|
Manager to contain Loom modules and provide users with a simpler API. More...
#include <Manager.h>
Public Types | |
| enum | DeviceType { DeviceType::HUB, DeviceType::NODE, DeviceType::REPEATER } |
| Different general types of devices. More... | |
Public Member Functions | |
CONSTRUCTORS / DESTRUCTOR | |
| LoomManager (const FactoryBase *factory_ptr, const char *device_name="Device", const uint8_t instance=1, const DeviceType device_type=DeviceType::NODE, const Verbosity print_verbosity=Verbosity::V_HIGH, const Verbosity package_verbosity=Verbosity::V_LOW, const uint16_t interval=1000) | |
| Loom Manager constructor. More... | |
| virtual | ~LoomManager () |
OPERATION | |
| void | begin_LED () const |
| Begin LED. More... | |
| void | begin_serial (const bool wait_for_monitor=false) const |
| Begin Serial, optionally wait for user. More... | |
| bool | parse_config (const char *json_config) |
| Parse a JSON configuration string specifying enabled modules. More... | |
| bool | parse_config_SD (const char *config_file) |
| Parse a JSON configuration on SD card specifying enabled modules. More... | |
| bool | parse_config_serial () |
| bool | check_serial_for_config () |
| bool | parse_config_json (JsonObject config) |
| Parse a JSON configuration object specifying enabled modules. More... | |
| void | get_config () |
| Get complete configuration of the device. More... | |
| void | measure () |
| Measure data of all managed sensors. More... | |
| void | package (JsonObject json) |
| Package data of all modules into provide JsonObject. More... | |
| void | record () |
| Measure and package data. More... | |
| JsonObject | package () |
| Package data of all modules into JsonObject and return. More... | |
| bool | publish_all (const JsonObject json) |
| Publish. More... | |
| bool | publish_all () |
| Publish. More... | |
| bool | log_all (const JsonObject json) |
| Log. More... | |
| bool | log_all () |
| Log. More... | |
| void | dispatch (JsonObject json) |
| Iterate over list of commands, forwarding to handling module. More... | |
| void | dispatch () |
| Iterate over list of commands, forwarding to handling module. More... | |
| void | pause (const uint16_t ms) const |
| Delay milliseconds. More... | |
| void | pause () const |
| Delay milliseconds based on interval member. More... | |
| void | power_up () |
| Iterate over modules, calling power up method. More... | |
| void | power_down () |
| Iterate over modules, calling power down method. More... | |
| template<typename T > | |
| bool | add_data (const char *module, const char *key, const T val) |
| Append to a Json object of data. More... | |
| template<typename T > | |
| T | get_data_as (const char *module, const char *key) |
| Get a data value from Json object of data. More... | |
| bool | has_module (const LoomModule::Type type) const |
| Save current configuration to SD. More... | |
PRINT INFORMATION | |
| void | print_config (const bool print_modules_config=false) |
| Print the devices current configuration. More... | |
| void | list_modules () const |
| Print the linked modules. More... | |
| void | display_data () const |
| Print out the internal JSON object. More... | |
ADD MODULE TO MANAGER | |
| void | add_module (LoomModule *module) |
| Add a module to be managed. More... | |
GETTERS | |
| DeviceType | get_device_type () const |
| Get device type. More... | |
| JsonObject | internal_json (const bool clear=false) |
| Return reference to internal json object. More... | |
| void | get_device_name (char *buf) const |
| Get the device name, copies into provided buffer. More... | |
| const char * | get_device_name () const |
| Get the device name. More... | |
| uint8_t | get_instance_num () const |
| Get device instance number. More... | |
| Verbosity | get_print_verbosity () const |
| Get print verbosity. More... | |
| Verbosity | get_package_verbosity () const |
| Get package verbosity. More... | |
| uint16_t | get_interval () const |
| Get sampling interval. More... | |
SETTERS | |
| void | set_device_name (const char *device_name) |
| Set the device name. More... | |
| void | set_instance_num (const uint8_t n) |
| Set device instance number. More... | |
| void | set_print_verbosity (const Verbosity v, const bool set_modules=false) |
| Set print verbosity. More... | |
| void | set_package_verbosity (const Verbosity v, const bool set_modules=false) |
| Set package verbosity. More... | |
| void | set_interval (const uint16_t ms) |
| Set default time to use for .pause() \ .delay(). More... | |
Protected Attributes | |
| char | device_name [20] |
| The name of the device. More... | |
| uint8_t | instance |
| The instance / channel ID within the subnet. More... | |
| uint16_t | interval |
| Default value for pause() Used so that manager can control interval, rather than code in .ino. More... | |
| DeviceType | device_type |
| Device type (Hub / Node) More... | |
| Loom_WarmUp_Manager * | warmup_manager = nullptr |
| Loom_Interrupt_Manager * | interrupt_manager = nullptr |
| Loom_Sleep_Manager * | sleep_manager = nullptr |
| LoomRTC * | rtc_module = nullptr |
| std::vector< LoomModule * > | modules |
| Vectors of LoomModule pointers. More... | |
| Verbosity | print_verbosity |
| Print detail verbosity. More... | |
| Verbosity | package_verbosity |
| Package detail verbosity. More... | |
| StaticJsonDocument< 2000 > | doc |
| Json data. More... | |
| uint | packet_number = 1 |
| Packet number, incremented each time package is called. More... | |
MISCELLANEOUS | |
| void | flash_LED (const uint8_t count, const uint8_t time_high, const uint8_t time_low, const bool end_high=false) const |
| Flash the built in LED. More... | |
| void | flash_LED (const uint8_t sequence[3]) const |
| static const char * | enum_device_type_string (const DeviceType t) |
| Get c-string of name associated with device type enum. More... | |
MODULE ACCESS | |
| class | Loom_Interrupt_Manager |
| class | Loom_Sleep_Manager |
| class | LoomRTC |
| class | Loom_SD |
| class | Loom_BatchSD |
| class | LoomNTPSync |
| LoomModule * | find_module (const LoomModule::Type type, const uint8_t idx=0) const |
| Auxiliary function to search a list of modules for a module of specified type. More... | |
| LoomModule * | find_module_by_category (const LoomModule::Category category, const uint8_t idx) const |
| Auxiliary function to search a list of modules for a module of specified category. More... | |
| Loom_WarmUp_Manager & | WarmUpManager (const uint8_t idx=0) |
| Loom_Sleep_Manager & | SleepManager (const uint8_t idx=0) |
| Loom_Interrupt_Manager & | InterruptManager (const uint8_t idx=0) |
| Loom_Multiplexer & | Multiplexer (const uint8_t idx=0) |
| LoomNTPSync & | NTP (const uint8_t idx=0) |
| LoomTempSync & | TempSync (const uint8_t idx=0) |
| Loom_LoRa & | LoRa (const uint8_t idx=0) |
| Loom_nRF & | nRF (const uint8_t idx=0) |
| Loom_Bluetooth & | Bluetooth (const uint8_t idx=0) |
| Loom_OLED & | OLED (const uint8_t idx=0) |
| Loom_SD & | SDCARD (const uint8_t idx=0) |
| Loom_BatchSD & | BATCHSD (const uint8_t idx=0) |
| LoomInternetPlat & | InternetPlat (const uint8_t idx=0) |
| Loom_Ethernet & | Ethernet (const uint8_t idx=0) |
| Loom_WiFi & | WiFi (const uint8_t idx=0) |
| Loom_LTE & | LTE (const uint8_t idx=0) |
| LoomPublishPlat & | PublishPlat (const uint8_t idx=0) |
| Loom_GoogleSheets & | GoogleSheets (const uint8_t idx=0) |
| Loom_SpoolPublish & | Spool (const uint8_t idx=0) |
| Loom_MaxPub & | MaxPub (const uint8_t idx=0) |
| Loom_MaxSub & | MaxSub (const uint8_t idx=0) |
| Loom_DS3231 & | DS3231 (const uint8_t idx=0) |
| Loom_PCF8523 & | PCF8523 (const uint8_t idx=0) |
| Loom_Neopixel & | Neopixel (const uint8_t idx=0) |
| Loom_Relay & | Relay (const uint8_t idx=0) |
| Loom_Servo & | Servo (const uint8_t idx=0) |
| Loom_Stepper & | Stepper (const uint8_t idx=0) |
| Loom_Analog & | Analog (const uint8_t idx=0) |
| Loom_Digital & | Digital (const uint8_t idx=0) |
| Loom_ADS1115 & | ADS1115 (const uint8_t idx=0) |
| Loom_AS7262 & | AS7262 (const uint8_t idx=0) |
| Loom_AS7263 & | AS7263 (const uint8_t idx=0) |
| Loom_AS7265X & | AS7265X (const uint8_t idx=0) |
| Loom_FXAS21002 & | FXAS21002 (const uint8_t idx=0) |
| Loom_FXOS8700 & | FXOS8700 (const uint8_t idx=0) |
| Loom_LIS3DH & | LIS3DH (const uint8_t idx=0) |
| Loom_MB1232 & | MB1232 (const uint8_t idx=0) |
| Loom_MMA8451 & | MMA8451 (const uint8_t idx=0) |
| Loom_MPU6050 & | MPU6050 (const uint8_t idx=0) |
| Loom_MS5803 & | MS5803 (const uint8_t idx=0) |
| Loom_SHT31D & | SHT31D (const uint8_t idx=0) |
| Loom_TMP007 & | TMP007 (const uint8_t idx=0) |
| Loom_TSL2561 & | TSL2561 (const uint8_t idx=0) |
| Loom_TSL2591 & | TSL2591 (const uint8_t idx=0) |
| Loom_ZXGesture & | ZXGesture (const uint8_t idx=0) |
| Loom_STEMMA & | STEMMA (const uint8_t idx=0) |
| Loom_Decagon5TM & | Decagon5TM (const uint8_t idx=0) |
| Loom_DecagonGS3 & | DecagonGS3 (const uint8_t idx=0) |
| Loom_MAX31855 & | MAX31855 (const uint8_t idx=0) |
| Loom_MAX31856 & | MAX31856 (const uint8_t idx=0) |
| Loom_K30 & | K30 (const uint8_t idx=0) |
| void | print_device_label () const |
| Print the device name as '[device_name]'. More... | |
Manager to contain Loom modules and provide users with a simpler API.
|
strong |
| LoomManager::LoomManager | ( | const FactoryBase * | factory_ptr, |
| const char * | device_name = "Device", |
||
| const uint8_t | instance = 1, |
||
| const DeviceType | device_type = DeviceType::NODE, |
||
| const Verbosity | print_verbosity = Verbosity::V_HIGH, |
||
| const Verbosity | package_verbosity = Verbosity::V_LOW, |
||
| const uint16_t | interval = 1000 |
||
| ) |
Loom Manager constructor.
| [in] | device_name | String | <"Default"> | null | Manager name |
| [in] | instance | Int | <1> | [0-99] | Device instance number on its subnet |
| [in] | device_type | Set(DeviceType) | <1> | {0("Hub"), 1("Node"), 2("Repeater")} | Device's topological type |
| [in] | print_verbosity | Set(Verbosity) | <1> | {0("Off"), 1("Low"), 2("High")} | How detailed prints to the Serial Monitor should be |
| [in] | package_verbosity | Set(Verbosity) | <2> | {0("Off"), 1("Low"), 2("High")} | How detailed to package data |
| [in] | interval | Int | <1> | [0-60000] | Default milliseconds to pause |
|
virtual |
|
inline |
Append to a Json object of data.
If object is non-empty and contains non-data, will not add and will return false. Only call this after package, otherwise the data will be overriden
| [in] | module | Which module to add data to (will create if it doesn't exist) |
| [in] | key | Key of data to add |
| [in] | val | Value of data to add |
| void LoomManager::add_module | ( | LoomModule * | module | ) |
Add a module to be managed.
| Loom_ADS1115 & LoomManager::ADS1115 | ( | const uint8_t | idx = 0 | ) |
| Loom_Analog & LoomManager::Analog | ( | const uint8_t | idx = 0 | ) |
| Loom_AS7262 & LoomManager::AS7262 | ( | const uint8_t | idx = 0 | ) |
| Loom_AS7263 & LoomManager::AS7263 | ( | const uint8_t | idx = 0 | ) |
| Loom_AS7265X & LoomManager::AS7265X | ( | const uint8_t | idx = 0 | ) |
| Loom_BatchSD & LoomManager::BATCHSD | ( | const uint8_t | idx = 0 | ) |
|
inline |
Begin LED.
| void LoomManager::begin_serial | ( | const bool | wait_for_monitor = false | ) | const |
Begin Serial, optionally wait for user.
| [in] | wait_for_monitor | True to wait for serial monitor to open |
| Loom_Bluetooth & LoomManager::Bluetooth | ( | const uint8_t | idx = 0 | ) |
| bool LoomManager::check_serial_for_config | ( | ) |
| Loom_Decagon5TM & LoomManager::Decagon5TM | ( | const uint8_t | idx = 0 | ) |
| Loom_DecagonGS3 & LoomManager::DecagonGS3 | ( | const uint8_t | idx = 0 | ) |
| Loom_Digital & LoomManager::Digital | ( | const uint8_t | idx = 0 | ) |
| void LoomManager::dispatch | ( | JsonObject | json | ) |
Iterate over list of commands, forwarding to handling module.
| [in] | json | Object containing commands |
|
inline |
Iterate over list of commands, forwarding to handling module.
Uses internal json
| void LoomManager::display_data | ( | ) | const |
Print out the internal JSON object.
| Loom_DS3231 & LoomManager::DS3231 | ( | const uint8_t | idx = 0 | ) |
|
static |
Get c-string of name associated with device type enum.
| Loom_Ethernet & LoomManager::Ethernet | ( | const uint8_t | idx = 0 | ) |
| LoomModule * LoomManager::find_module | ( | const LoomModule::Type | type, |
| const uint8_t | idx = 0 |
||
| ) | const |
Auxiliary function to search a list of modules for a module of specified type.
| [in] | type | Type to search for |
| LoomModule * LoomManager::find_module_by_category | ( | const LoomModule::Category | category, |
| const uint8_t | idx | ||
| ) | const |
Auxiliary function to search a list of modules for a module of specified category.
| [in] | category | Category to search for |
| void LoomManager::flash_LED | ( | const uint8_t | count, |
| const uint8_t | time_high, | ||
| const uint8_t | time_low, | ||
| const bool | end_high = false |
||
| ) | const |
Flash the built in LED.
| [in] | count | Number of times to flash |
| [in] | time_high | Milliseconds to stay on for |
| [in] | time_low | Milliseconds to stay off for |
|
inline |
| Loom_FXAS21002 & LoomManager::FXAS21002 | ( | const uint8_t | idx = 0 | ) |
| Loom_FXOS8700 & LoomManager::FXOS8700 | ( | const uint8_t | idx = 0 | ) |
| void LoomManager::get_config | ( | ) |
Get complete configuration of the device.
Generally used to save configuration to SD
|
inline |
Get a data value from Json object of data.
| [in] | module | LoomModule key is associated with |
| [in] | key | Key of data value to find |
| void LoomManager::get_device_name | ( | char * | buf | ) | const |
Get the device name, copies into provided buffer.
| [out] | buf | The buffer copy device name into |
| const char * LoomManager::get_device_name | ( | ) | const |
Get the device name.
|
inline |
Get device type.
|
inline |
Get device instance number.
|
inline |
Get sampling interval.
|
inline |
Get package verbosity.
|
inline |
Get print verbosity.
| Loom_GoogleSheets & LoomManager::GoogleSheets | ( | const uint8_t | idx = 0 | ) |
| bool LoomManager::has_module | ( | const LoomModule::Type | type | ) | const |
Save current configuration to SD.
| [in] | config_file | File to save configuration to |
| [in] | type | Module type to check for |
| JsonObject LoomManager::internal_json | ( | const bool | clear = false | ) |
Return reference to internal json object.
| [in] | clear | Whether or not to empty Json before returning it |
| LoomInternetPlat& LoomManager::InternetPlat | ( | const uint8_t | idx = 0 | ) |
| Loom_Interrupt_Manager & LoomManager::InterruptManager | ( | const uint8_t | idx = 0 | ) |
| Loom_K30 & LoomManager::K30 | ( | const uint8_t | idx = 0 | ) |
| Loom_LIS3DH & LoomManager::LIS3DH | ( | const uint8_t | idx = 0 | ) |
| void LoomManager::list_modules | ( | ) | const |
Print the linked modules.
| bool LoomManager::log_all | ( | const JsonObject | json | ) |
Log.
| [in] | json | Data object to log |
|
inline |
| Loom_LoRa & LoomManager::LoRa | ( | const uint8_t | idx = 0 | ) |
| Loom_LTE & LoomManager::LTE | ( | const uint8_t | idx = 0 | ) |
| Loom_MAX31855 & LoomManager::MAX31855 | ( | const uint8_t | idx = 0 | ) |
| Loom_MAX31856 & LoomManager::MAX31856 | ( | const uint8_t | idx = 0 | ) |
| Loom_MaxPub & LoomManager::MaxPub | ( | const uint8_t | idx = 0 | ) |
| Loom_MaxSub & LoomManager::MaxSub | ( | const uint8_t | idx = 0 | ) |
| Loom_MB1232 & LoomManager::MB1232 | ( | const uint8_t | idx = 0 | ) |
| void LoomManager::measure | ( | ) |
Measure data of all managed sensors.
| Loom_MMA8451 & LoomManager::MMA8451 | ( | const uint8_t | idx = 0 | ) |
| Loom_MPU6050 & LoomManager::MPU6050 | ( | const uint8_t | idx = 0 | ) |
| Loom_MS5803 & LoomManager::MS5803 | ( | const uint8_t | idx = 0 | ) |
| Loom_Multiplexer & LoomManager::Multiplexer | ( | const uint8_t | idx = 0 | ) |
| Loom_Neopixel & LoomManager::Neopixel | ( | const uint8_t | idx = 0 | ) |
| Loom_nRF & LoomManager::nRF | ( | const uint8_t | idx = 0 | ) |
| LoomNTPSync & LoomManager::NTP | ( | const uint8_t | idx = 0 | ) |
| Loom_OLED & LoomManager::OLED | ( | const uint8_t | idx = 0 | ) |
| void LoomManager::package | ( | JsonObject | json | ) |
Package data of all modules into provide JsonObject.
How detailed data is can be modified with package_verbosity
| [out] | json | JsonObject of packaged data of enabled modules |
| JsonObject LoomManager::package | ( | ) |
Package data of all modules into JsonObject and return.
| bool LoomManager::parse_config | ( | const char * | json_config | ) |
Parse a JSON configuration string specifying enabled modules.
Enabled modules are instantiated with specified settings and added to manager lists for managing
| [in] | json_config | Configuration |
| bool LoomManager::parse_config_json | ( | JsonObject | config | ) |
Parse a JSON configuration object specifying enabled modules.
Enabled modules are instantiated with specified settings and added to manager lists for managing. Called by parse_config and parse_config_SD
| [in] | json_config | Configuration |
| bool LoomManager::parse_config_SD | ( | const char * | config_file | ) |
Parse a JSON configuration on SD card specifying enabled modules.
Enabled modules are instantiated with specified settings and added to manager lists for managing. Json should be on a single line in a .txt file.
| [in] | json_config | Configuration |
| bool LoomManager::parse_config_serial | ( | ) |
|
inline |
Delay milliseconds.
|
inline |
Delay milliseconds based on interval member.
Uses interval member as value
| Loom_PCF8523 & LoomManager::PCF8523 | ( | const uint8_t | idx = 0 | ) |
| void LoomManager::power_down | ( | ) |
Iterate over modules, calling power down method.
| void LoomManager::power_up | ( | ) |
Iterate over modules, calling power up method.
| void LoomManager::print_config | ( | const bool | print_modules_config = false | ) |
Print the devices current configuration.
Lists modules. Optionally also prints configuration of linked modules.
|
inlineprotected |
Print the device name as '[device_name]'.
| bool LoomManager::publish_all | ( | const JsonObject | json | ) |
Publish.
| [in] | json | Data object to publish |
|
inline |
| LoomPublishPlat& LoomManager::PublishPlat | ( | const uint8_t | idx = 0 | ) |
|
inline |
Measure and package data.
Convenience function, current just calls measure then package
| Loom_Relay & LoomManager::Relay | ( | const uint8_t | idx = 0 | ) |
| Loom_SD & LoomManager::SDCARD | ( | const uint8_t | idx = 0 | ) |
| Loom_Servo & LoomManager::Servo | ( | const uint8_t | idx = 0 | ) |
| void LoomManager::set_device_name | ( | const char * | device_name | ) |
Set the device name.
| [in] | device_name | The new device name |
|
inline |
Set device instance number.
| [in] | n | New instance number |
| void LoomManager::set_interval | ( | const uint16_t | ms | ) |
Set default time to use for .pause() \ .delay().
Pause and delay can still take explicit times, but if not provided, this value will be used
| void LoomManager::set_package_verbosity | ( | const Verbosity | v, |
| const bool | set_modules = false |
||
| ) |
Set package verbosity.
| [in] | v | New package verbosity |
| [in] | set_modules | Whether or not to also apply setting to modules |
| void LoomManager::set_print_verbosity | ( | const Verbosity | v, |
| const bool | set_modules = false |
||
| ) |
Set print verbosity.
| [in] | v | New print verbosity |
| [in] | set_modules | Whether or not to also apply setting to modules |
| Loom_SHT31D & LoomManager::SHT31D | ( | const uint8_t | idx = 0 | ) |
| Loom_Sleep_Manager & LoomManager::SleepManager | ( | const uint8_t | idx = 0 | ) |
| Loom_SpoolPublish & LoomManager::Spool | ( | const uint8_t | idx = 0 | ) |
| Loom_STEMMA & LoomManager::STEMMA | ( | const uint8_t | idx = 0 | ) |
| Loom_Stepper & LoomManager::Stepper | ( | const uint8_t | idx = 0 | ) |
| LoomTempSync & LoomManager::TempSync | ( | const uint8_t | idx = 0 | ) |
| Loom_TMP007 & LoomManager::TMP007 | ( | const uint8_t | idx = 0 | ) |
| Loom_TSL2561 & LoomManager::TSL2561 | ( | const uint8_t | idx = 0 | ) |
| Loom_TSL2591 & LoomManager::TSL2591 | ( | const uint8_t | idx = 0 | ) |
| Loom_WarmUp_Manager & LoomManager::WarmUpManager | ( | const uint8_t | idx = 0 | ) |
| Loom_WiFi & LoomManager::WiFi | ( | const uint8_t | idx = 0 | ) |
| Loom_ZXGesture & LoomManager::ZXGesture | ( | const uint8_t | idx = 0 | ) |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
The name of the device.
|
protected |
Device type (Hub / Node)
|
protected |
Json data.
|
protected |
The instance / channel ID within the subnet.
|
protected |
|
protected |
Default value for pause() Used so that manager can control interval, rather than code in .ino.
|
protected |
Vectors of LoomModule pointers.
|
protected |
Package detail verbosity.
|
protected |
Packet number, incremented each time package is called.
|
protected |
Print detail verbosity.
|
protected |
|
protected |
|
protected |
1.8.11