Loom
Protected Attributes | List of all members
Loom_Bluetooth Class Reference

Bluetooth communication platform module. More...

#include <Bluetooth.h>

Inheritance diagram for Loom_Bluetooth:
Inheritance graph
[legend]

Public Member Functions

CONSTRUCTORS / DESTRUCTOR
 Loom_Bluetooth (LoomManager *manager, const uint16_t max_message_len=120, const uint8_t spi_CS=8, const uint8_t spi_IRQ=7, const uint8_t spi_RST=4)
 Constructor. More...
 
 Loom_Bluetooth (LoomManager *manager, JsonArrayConst p)
 Constructor that takes Json Array, extracts args and delegates to regular constructor. More...
 
 ~Loom_Bluetooth ()=default
 Destructor. More...
 
OPERATION
void add_config (JsonObject json) override
 Currently no implementation. More...
 
void connect (const uint16_t connect_timeout)
 Allow a phone to connect. More...
 
int8_t getCommand (const uint16_t max_timeout)
 Receive a command from user. More...
 
TESTING METHODS
bool test_send (const uint8_t val)
 
bool test_send_str (const char *string)
 
PRINT INFORMATION
void print_config () const override
 Display the configuration settings of the module. More...
 
GETTERS
uint8_t get_address () const override
 Bluetooth currently does not use addresses. More...
 
SETTERS
void set_address (const uint8_t addr) override
 Bluetooth currently does not use addresses. More...
 
- Public Member Functions inherited from LoomCommPlat
 LoomCommPlat (LoomManager *manager, const char *module_name, const LoomModule::Type module_type, const uint16_t max_message_len)
 Constructor. More...
 
virtual ~LoomCommPlat ()=default
 Destructor. More...
 
virtual void package (JsonObject json) override
 Package a modules measurements or state. More...
 
bool receive_blocking (JsonObject json, uint max_wait_time)
 Receive, but block until packet received, or timeout reached. More...
 
bool receive (JsonObject json)
 Build json from packet if any exists. More...
 
bool receive_batch ()
 Receive and immediately create a batch file from JSON receieved. More...
 
bool receive_batch_blocking (uint max_wait_time)
 Receive, and block until packet recieved or timeout, and immediately create a batch file from JSON receieved. More...
 
bool receive ()
 Version of receive for use with LoomManager. More...
 
bool receive_blocking (const uint max_wait_time)
 Version of receive_blocking for use with LoomManager. More...
 
JsonObject pre_merge_receive_blocking (JsonObject json)
 Giving the header of the Package from the other board. More...
 
bool merge_json (JsonObject json, const uint8_t loop)
 It will merge all the small packages into one big package. More...
 
bool send (JsonObject json, const uint8_t destination)
 Send json to a specific address. More...
 
bool send (const uint8_t destination)
 Version of send for use with LoomManager. More...
 
uint8_t send_batch (const uint8_t destination, int delay_time)
 Sends all the jsons stored in the batch. More...
 
uint16_t determine_json_size (JsonObject json)
 Return the size of the json to determing wether to send as split or not. More...
 
bool split_send_notification (JsonObject json, const uint8_t destination)
 If the json is over 251, then it let the user the know that it will be sending small mulitple jsons with how many will it be splited into. More...
 
bool split_send (JsonObject json, const uint8_t destination, const uint8_t index)
 The actual processing spliting into small json. More...
 
void broadcast (JsonObject json)
 Broadcast data to all that can receive. More...
 
void broadcast ()
 Version of send for use with LoomManager. More...
 
void broadcast_batch (int delay_time)
 Broadcasts all the jsons stored in the batch. More...
 
virtual void print_state () const override
 Display current state of the module. More...
 
float get_drop_rate () const
 Get the packet drop rate since the start of operation. More...
 
float get_last_ten_drop_rate () const
 Get the packet drop rate of the last ten send() calls. More...
 
- Public Member Functions inherited from LoomModule
 LoomModule (LoomManager *manager, const char *module_name="Unknown", const Type module_type=Type::Unknown)
 Constructor. More...
 
virtual ~LoomModule ()=default
 Destructor. More...
 
virtual void second_stage_ctor ()
 Second stage construction. More...
 
virtual bool dispatch (JsonObject json)
 Route command to driver. More...
 
virtual void power_down ()
 Turn off any hardware. More...
 
virtual void power_up ()
 Turn on any hardware. More...
 
Type get_module_type () const
 Get module type. More...
 
LoomManagerget_device_manager () const
 Get the device manager class if linked. More...
 
void get_module_name (char *buf) const
 Copy module name into buffer. More...
 
const char * get_module_name () const
 Get module name. More...
 
Verbosity get_print_verbosity () const
 Get print verbosity. More...
 
Verbosity get_package_verbosity () const
 Get package verbosity. More...
 
bool get_active () const
 Get whether or not the module should be treated as active. More...
 
Category category () const
 Get the category of the module. More...
 
virtual void link_device_manager (LoomManager *LM)
 Add pointer back to device manager. More...
 
void set_print_verbosity (const Verbosity v)
 Set print verbosity Controlls level of detail included in debug prints. More...
 
void set_package_verbosity (const Verbosity v)
 Set package verbosity. More...
 
void set_active (const bool enable)
 Set whether or not the module should be treated as active. More...
 

Protected Attributes

Adafruit_BluefruitLE_SPI BLE
 Bluetooth manager instance. More...
 
uint8_t spi_CS
 SPI chip select pin. More...
 
uint8_t spi_IRQ
 SPI IRQ pin. More...
 
uint8_t spi_RST
 SPI reset pin. More...
 
- Protected Attributes inherited from LoomCommPlat
uint16_t max_message_len
 The maximum message length. More...
 
int16_t signal_strength
 RSSI for Lora (need to determine what the other platforms use) More...
 
StaticJsonDocument< 1500 > messageJson
 Document to read incoming data into. More...
 
DynamicJsonDocument mergeJson
 
uint32_t total_packet_count
 
uint32_t total_drop_count
 
bool last_ten_dropped [10]
 
uint8_t last_ten_dropped_idx
 
- Protected Attributes inherited from LoomModule
const Type module_type
 Module type. More...
 
LoomManagerdevice_manager
 Pointer to manager. More...
 
const String module_name_base
 The name of the module (Should have a DEFAULT but can be overriden if provided to constructor) More...
 
const char * module_name
 
bool active
 Whether or not the module should be treated as active. More...
 
Verbosity print_verbosity
 Print verbosity. More...
 
Verbosity package_verbosity
 Package verbosity. More...
 

Additional Inherited Members

- Public Types inherited from LoomModule
enum  Type {
  Type::Unknown = 0, Type::Other =1000, Type::Interrupt_Manager, Type::Sleep_Manager,
  Type::Multiplexer, Type::NTP, Type::TempSync, Type::WarmUp_Manager,
  Type::Sensor =2000, Type::Analog, Type::Digital, Type::I2C =2100,
  Type::ADS1115, Type::AS7262, Type::AS7263, Type::AS7265X,
  Type::FXAS21002, Type::FXOS8700, Type::LIS3DH, Type::MB1232,
  Type::MMA8451, Type::MPU6050, Type::MS5803, Type::SHT31D,
  Type::TMP007, Type::TSL2561, Type::TSL2591, Type::ZXGesture,
  Type::STEMMA, Type::SDI12 =2200, Type::Decagon5TM, Type::DecagonGS3,
  Type::SPI =2300, Type::MAX31855, Type::MAX31856, Type::L_SERIAL =2400,
  Type::K30, Type::L_RTC =3000, Type::DS3231, Type::PCF8523,
  Type::Actuator =4000, Type::Neopixel, Type::Relay, Type::Servo,
  Type::Stepper, Type::LogPlat =5000, Type::OLED, Type::SDCARD,
  Type::BATCHSD, Type::CommPlat =6000, Type::LoRa, Type::nRF,
  Type::Bluetooth, Type::InternetPlat =7000, Type::Ethernet, Type::WiFi,
  Type::LTE, Type::PublishPlat =8000, Type::GoogleSheets, Type::MaxPub,
  Type::SpoolPub, Type::SubscribePlats =9000, Type::MaxSub
}
 Enum to check against to when finding individual component managed by a LoomManager. More...
 
enum  Category {
  Category::Unknown =0, Category::Other =1, Category::Sensor =2, Category::L_RTC =3,
  Category::Actuator =4, Category::LogPlat =5, Category::CommPlat =6, Category::InternetPlat =7,
  Category::PublishPlat =8, Category::SubscribePlat =9
}
 Enum to classify modules. More...
 
- Static Public Member Functions inherited from LoomModule
static const char * enum_verbosity_string (const Verbosity v)
 Get string of name associated with verbosity enum. More...
 
static const char * enum_category_string (const Category c)
 Get string of the category associated with a Category. More...
 
- Protected Member Functions inherited from LoomCommPlat
virtual bool receive_blocking_impl (JsonObject json, uint max_wait_time)
 Receive, but block until packet received, or timeout reached. More...
 
virtual bool send_impl (JsonObject json, const uint8_t destination)
 Send json to a specific address. More...
 
virtual void broadcast_impl (JsonObject json)
 Broadcast data to all that can receive. More...
 
bool json_to_msgpack_buffer (JsonObjectConst json, char *buffer, const uint16_t max_len) const
 Serialize a JsonObject into a MessagePack buffer. More...
 
bool msgpack_buffer_to_json (const char *buffer, JsonObject json)
 Deserialize a MessagePack buffer into a JsonObject. More...
 
void add_packet_result (const bool did_drop)
 Add the result of a packet to the drop_rate tracker. More...
 
- Protected Member Functions inherited from LoomModule
void print_module_label () const
 Print the module name as a label. More...
 

Detailed Description

Bluetooth communication platform module.

Needs more work for complete functionality.

Resources

Constructor & Destructor Documentation

Loom_Bluetooth::Loom_Bluetooth ( LoomManager manager,
const uint16_t  max_message_len = 120,
const uint8_t  spi_CS = 8,
const uint8_t  spi_IRQ = 7,
const uint8_t  spi_RST = 4 
)

Constructor.

Parameters
[in]max_message_lenThe maximum possible message length
[in]spi_CSSPI chip select pin
[in]spi_IRQSPI IRQ pin
[in]spi_RSTSPI reset pin
Loom_Bluetooth::Loom_Bluetooth ( LoomManager manager,
JsonArrayConst  p 
)

Constructor that takes Json Array, extracts args and delegates to regular constructor.

Parameters
[in]pThe array of constuctor args to expand
Loom_Bluetooth::~Loom_Bluetooth ( )
default

Destructor.

Member Function Documentation

void Loom_Bluetooth::add_config ( JsonObject  json)
overridevirtual

Currently no implementation.

Reimplemented from LoomModule.

void Loom_Bluetooth::connect ( const uint16_t  connect_timeout)

Allow a phone to connect.

Parameters
[in]connect_timeoutMax time to allow user to try to connect
uint8_t Loom_Bluetooth::get_address ( ) const
inlineoverridevirtual

Bluetooth currently does not use addresses.

Override with empty body

Implements LoomCommPlat.

int8_t Loom_Bluetooth::getCommand ( const uint16_t  max_timeout)

Receive a command from user.

Returns
Status Gets a command from the ble interface, or times out. This is used in combination with parseCommand if the return value is valid.
Parameters
[in]max_timeoutMaximum number of milliseconds to wait for command
Returns
Status where: -1: user never wrote a command, timed out -2: user entered an invalid command 0 or positive integer: index in COMMAND_TABLE that matches the user-entered command
void Loom_Bluetooth::print_config ( ) const
overridevirtual

Display the configuration settings of the module.

Reimplemented from LoomCommPlat.

void Loom_Bluetooth::set_address ( const uint8_t  addr)
inlineoverridevirtual

Bluetooth currently does not use addresses.

Override with empty body

Implements LoomCommPlat.

bool Loom_Bluetooth::test_send ( const uint8_t  val)
bool Loom_Bluetooth::test_send_str ( const char *  string)

Member Data Documentation

Adafruit_BluefruitLE_SPI Loom_Bluetooth::BLE
protected

Bluetooth manager instance.

uint8_t Loom_Bluetooth::spi_CS
protected

SPI chip select pin.

uint8_t Loom_Bluetooth::spi_IRQ
protected

SPI IRQ pin.

uint8_t Loom_Bluetooth::spi_RST
protected

SPI reset pin.


The documentation for this class was generated from the following files: