e12
 
Loading...
Searching...
No Matches
e12_esp32_node Class Reference

This class represents an ESP32 node for the e12 protocol. More...

#include <esp32_e12_node_protocol.h>

Inheritance diagram for e12_esp32_node:
e12

Public Member Functions

 e12_esp32_node (uint32_t vid, uint32_t pid)
 Constructor for the e12_esp32_node class.
 
 ~e12_esp32_node ()
 Destructor for the e12_esp32_node class.
 
virtual int begin (void *bus, uint8_t e12_addr=0)
 Initializes the node with the given bus and address.
 
virtual uint32_t get_time_ms ()
 Gets the current time in milliseconds.
 
virtual int send (e12_packet_t *buf, bool retry=true)
 Sends a packet to the e12 node.
 
virtual e12_packet_tread ()
 Reads a packet from the e12 node.
 
virtual e12_log_evt_tget_log_evt ()
 Gets the log event.
 
virtual int log (uint8_t type, uint8_t status, uint32_t ts, void *data)
 Logs an event.
 
virtual int on_config (const char *s, int len)
 Configures the node with the given settings.
 
virtual int on_get_state (char *s, int len, void *ctx)
 Gets the current state of the node.
 
virtual int on_restore_state (const char *s, int len)
 Restores the state of the node from the given string.
 
virtual int set_node_auth_credentials (e12_auth_data_t *auth)
 Sets the authentication credentials for the node.
 
virtual int on_wakeup ()
 Wakes up the node.
 
virtual int sleep (uint32_t ms, void *data)
 Puts the node to sleep for the specified duration.
 
virtual int print_buffer (e12_onwire_t *buf)
 Prints the contents of the buffer.
 
- Public Member Functions inherited from e12
 e12 (uint32_t vid, uint32_t pid)
 Constructor for the e12 class.
 
 ~e12 ()
 Destructor for the e12 class.
 
e12_packet_te12_get_packet ()
 Gets a new packet for the e12 protocol.
 
e12_onwire_tencode (e12_packet_t *data)
 Encodes the given data into a packet.
 
e12_packet_tdecode (e12_onwire_t *pkt, uint8_t data)
 Decodes the given data into a packet.
 
void set_e12_device (e12_device_t *p)
 Sets the e12 device.
 
void set_product_info (uint32_t vid, uint32_t pid)
 Sets the product information.
 
void set_fwr_details (uint32_t fwr_version, mcu_arch_t arch, mcu_flashing_protocol_t protocol, bool enabled)
 Set the vmcu firmware details object.
 
uint32_t get_fwr_version ()
 Get the fwr version object.
 
uint32_t get_pin_mask ()
 Get the pin io mask object. top 16bit for analog, lower 16bit for digital.
 
uint32_t get_pin_io_mask ()
 Get the pin io mask object. top 16bit for analog, lower 16bit for digital.
 
int publish_info ()
 Publish info e.g fwr version, arch, protocol etc.
 
int publish_profile ()
 Publish profile info e.g pin configuration.
 
bool set_pin_in (uint8_t pin_number, bool is_analog=false)
 Sets the pin as input and type (analog/digital)
 
bool set_pin_out (uint8_t pin_number, bool is_analog=false)
 Sets the pin as output and type (analog/digital)
 
void set_node_properties (e12_node_properties_t *props)
 Sets the properties of the e12 node.
 
void set_timeout (uint32_t ms)
 Sets the timeout value.
 
bool is_configured ()
 Checks if the e12 endpoint is configured.
 
void set_configured (bool status)
 Set the configured status for e12 endpoint.
 
uint32_t get_version ()
 Gets the version of the e12 protocol.
 
void set_version (uint32_t v)
 Sets the version of the e12 protocol.
 
void set_pin_mask (uint32_t pin_mask, uint32_t io_mask)
 Sets the bit mask for pin and io. Recommended to be used by advanced user or else use set_pin_in and set_pin_out.
 
virtual e12_packet_tget_request (e12_cmd_t cmd, bool response=true, void *data=0)
 Gets a request packet for the given command.
 
virtual e12_packet_tget_response (e12_packet_t *p)
 Gets a response packet for the given packet.
 
bool get_message (e12_packet_t *data)
 Gets a message from the e12 protocol.
 
virtual int on_receive (e12_packet_t *p)
 Handles the received packet.
 
virtual int wakeup_e12_node ()
 Wakes up the e12 node.
 
virtual int on_ctl_read (uint8_t pin)
 allows READ state of any valid pin
 
virtual bool on_ctl_write (uint8_t pin, uint32_t val)
 Validates a WRITE request (PIN <- IN only)
 

Additional Inherited Members

- Static Public Member Functions inherited from e12
static uint8_t get_checksum (const char *data, uint8_t len)
 Get the checksum object.
 
- Protected Member Functions inherited from e12
e12_onwire_tget_encode_buffer ()
 Gets the buffer for encoding packets.
 
e12_onwire_tget_decode_buffer ()
 Gets the buffer for decoding packets.
 
void flush_buffer (e12_onwire_t *buf)
 Flushes the given buffer.
 
e12_node_op_status_t get_node_status ()
 Gets the status of the e12 node.
 
e12_node_op_status_t set_node_status (e12_node_op_status_t status, uint32_t data)
 Sets the status of the e12 node.
 
bool on_ctl (ctl_op_t op, uint8_t pin, uint32_t val)
 function doing basic sanity and scheduling return cmds
 
- Protected Attributes inherited from e12
uint32_t _timeout
 Timeout value in milliseconds.
 
uint8_t _seq
 Sequence number for packets.
 

Detailed Description

This class represents an ESP32 node for the e12 protocol.

The e12_esp32_node class provides methods for initializing the node, handling communication, managing events, configuring the node, and performing utility functions. It extends the base e12 class and integrates with the TwoWire interface for I2C communication.

Constructor & Destructor Documentation

◆ e12_esp32_node()

e12_esp32_node::e12_esp32_node ( uint32_t  vid,
uint32_t  pid 
)

Constructor for the e12_esp32_node class.

Constructor for e12_esp32_node.

Parameters
vidVendor ID
pidProduct ID
vidVendor ID.
pidProduct ID.

◆ ~e12_esp32_node()

e12_esp32_node::~e12_esp32_node ( )

Destructor for the e12_esp32_node class.

Destructor for e12_esp32_node.

Member Function Documentation

◆ begin()

int e12_esp32_node::begin ( void *  bus,
uint8_t  e12_addr = 0 
)
virtual

Initializes the node with the given bus and address.

Parameters
busPointer to the I2C bus
e12_addrAddress of the e12 node
Returns
0 on success, non-zero on failure
Parameters
busPointer to the bus object.
e12_addrAddress of the node.
Returns
int 0 on success, non-zero on failure.

Implements e12.

◆ get_log_evt()

e12_log_evt_t * e12_esp32_node::get_log_evt ( )
virtual

Gets the log event.

Returns
Pointer to the log event
e12_log_evt_t* Pointer to the log event.

Implements e12.

◆ get_time_ms()

uint32_t e12_esp32_node::get_time_ms ( )
virtual

Gets the current time in milliseconds.

Returns
Current time in milliseconds
uint32_t Current time in milliseconds.

Implements e12.

◆ log()

int e12_esp32_node::log ( uint8_t  type,
uint8_t  status,
uint32_t  ts,
void *  data 
)
virtual

Logs an event.

Parameters
typeEvent type
statusEvent status
tsTimestamp
dataPointer to additional data
Returns
0 on success, non-zero on failure
Parameters
typeType of the event.
statusStatus of the event.
tsTimestamp of the event.
dataPointer to additional data.
Returns
int 0 on success, non-zero on failure.

Implements e12.

◆ on_config()

int e12_esp32_node::on_config ( const char *  s,
int  len 
)
virtual

Configures the node with the given settings.

Callback for configuring the node.

Parameters
sPointer to the JSON configuration string
lenLength of the configuration string
Returns
0 on success, non-zero on failure
Parameters
sPointer to the configuration string.
lenLength of the configuration string.
Returns
int 0 on success, non-zero on failure.

Implements e12.

◆ on_get_state()

int e12_esp32_node::on_get_state ( char *  s,
int  len,
void *  ctx 
)
virtual

Gets the current state of the node.

Callback for getting the state.

Parameters
sPointer to the JSON state string buffer
lenLength of the state string buffer
ctxPointer to the context
Returns
0 on success, non-zero on failure
Parameters
sPointer to the state string.
lenLength of the state string.
ctxContext pointer.
Returns
int 0 on success, non-zero on failure.

Implements e12.

◆ on_restore_state()

int e12_esp32_node::on_restore_state ( const char *  s,
int  len 
)
virtual

Restores the state of the node from the given string.

Callback for restoring the state.

Parameters
sPointer to the JSON state string
lenLength of the state string
Returns
0 on success, non-zero on failure
Parameters
sPointer to the state string.
lenLength of the state string.
Returns
int 0 on success, non-zero on failure.

Implements e12.

◆ on_wakeup()

int e12_esp32_node::on_wakeup ( )
virtual

Wakes up the node.

Callback for waking up the node.

Returns
0 on success, non-zero on failure
int 0 on success, non-zero on failure.

Implements e12.

◆ print_buffer()

int e12_esp32_node::print_buffer ( e12_onwire_t buf)
virtual

Prints the contents of the buffer.

Prints the content of the buffer.

Parameters
bufPointer to the buffer
Returns
0 on success, non-zero on failure
Parameters
bufPointer to the buffer.
Returns
int 0 on success, non-zero on failure.

Reimplemented from e12.

◆ read()

e12_packet_t * e12_esp32_node::read ( )
virtual

Reads a packet from the e12 node.

Reads a packet from the bus.

Returns
Pointer to the received packet, or NULL on failure
e12_packet_t* Pointer to the read packet, or NULL on failure.

Implements e12.

◆ send()

int e12_esp32_node::send ( e12_packet_t buf,
bool  retry = true 
)
virtual

Sends a packet to the e12 node.

Sends a packet over the bus.

Parameters
bufPointer to the packet buffer
retryTrue if the packet should be retried, false otherwise
Returns
0 on success, non-zero on failure
Parameters
bufPointer to the packet buffer.
Returns
int 0 on success, non-zero on failure.

Implements e12.

◆ set_node_auth_credentials()

int e12_esp32_node::set_node_auth_credentials ( e12_auth_data_t auth)
virtual

Sets the authentication credentials for the node.

Sets the node authentication credentials.

Parameters
authPointer to the authentication data
Returns
0 on success, non-zero on failure
Parameters
authPointer to the authentication data.
Returns
int 0 on success, non-zero on failure.

Implements e12.

◆ sleep()

int e12_esp32_node::sleep ( uint32_t  ms,
void *  data 
)
virtual

Puts the node to sleep for the specified duration.

Parameters
msSleep duration in milliseconds
dataPointer to additional data
Returns
0 on success, non-zero on failure
Parameters
msDuration in milliseconds.
dataPointer to additional data.
Returns
int 0 on success, non-zero on failure.

Implements e12.


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