e12
 
Loading...
Searching...
No Matches
e12 Class Referenceabstract

This class represents the base class for the e12 protocol. More...

#include <e12_protocol.h>

Inheritance diagram for e12:
e12_arduino e12_esp32_node e12_client e12_demo

Public Member Functions

 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 print_buffer (e12_onwire_t *buf)
 Prints the contents of the buffer.
 
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)
 
virtual int begin (void *bus, uint8_t e12_addr=0)=0
 
virtual uint32_t get_time_ms ()=0
 
virtual e12_log_evt_tget_log_evt ()=0
 
virtual int send (e12_packet_t *buf, bool retry=true)=0
 
virtual e12_packet_tread ()=0
 
virtual int sleep (uint32_t ms, void *data)=0
 
virtual int log (uint8_t type, uint8_t status, uint32_t ts, void *data)=0
 
virtual int on_wakeup ()=0
 
virtual int set_node_auth_credentials (e12_auth_data_t *auth)=0
 
virtual int on_config (const char *s, int len)=0
 
virtual int on_get_state (char *s, int len, void *ctx)=0
 
virtual int on_restore_state (const char *s, int len)=0
 

Static Public Member Functions

static uint8_t get_checksum (const char *data, uint8_t len)
 Get the checksum object.
 

Protected Member Functions

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

uint32_t _timeout
 Timeout value in milliseconds.
 
uint8_t _seq
 Sequence number for packets.
 

Detailed Description

This class represents the base class for the e12 protocol.

The e12 class provides methods for encoding and decoding packets, managing device state, handling communication, and performing utility functions. It serves as the base class for specific implementations like e12_esp32_node.

Constructor & Destructor Documentation

◆ e12()

e12::e12 ( uint32_t  vid,
uint32_t  pid 
)

Constructor for the e12 class.

Construct a new e12 object.

Parameters
vidVendor ID
pidProduct ID

◆ ~e12()

e12::~e12 ( )

Destructor for the e12 class.

Destroy the e12 object.

Member Function Documentation

◆ begin()

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

Implemented in e12_esp32_node, and e12_arduino.

◆ decode()

e12_packet_t * e12::decode ( e12_onwire_t pkt,
uint8_t  data 
)

Decodes the given data into a packet.

Decode the given data into a packet.

Parameters
pktPointer to the packet to be decoded
dataData to be decoded
Returns
Pointer to the decoded packet
Parameters
pktPointer to the on-wire packet
dataData byte to decode
Returns
e12_packet_t* Pointer to the decoded packet

◆ e12_get_packet()

e12_packet_t * e12::e12_get_packet ( )

Gets a new packet for the e12 protocol.

Get a new packet for encoding.

Returns
Pointer to the new packet
e12_packet_t* Pointer to the new packet

◆ encode()

e12_onwire_t * e12::encode ( e12_packet_t data)

Encodes the given data into a packet.

Encode the given data into an on-wire packet.

Parameters
dataPointer to the data to be encoded
Returns
Pointer to the encoded packet
Parameters
dataPointer to the data packet to encode
Returns
e12_onwire_t* Pointer to the encoded on-wire packet

◆ flush_buffer()

void e12::flush_buffer ( e12_onwire_t buf)
protected

Flushes the given buffer.

Flush the given buffer.

Parameters
bufPointer to the buffer to be flushed
bufPointer to the buffer to flush

◆ get_checksum()

uint8_t e12::get_checksum ( const char *  data,
uint8_t  len 
)
static

Get the checksum object.

Get the checksum for the given data.

Parameters
dataPointer to the data
lenLength of the data
Returns
uint8_t Returns the checksum
Parameters
dataPointer to the data
lenLength of the data
Returns
uint8_t Checksum value

◆ get_decode_buffer()

e12_onwire_t * e12::get_decode_buffer ( )
inlineprotected

Gets the buffer for decoding packets.

Returns
Pointer to the decoding buffer

◆ get_encode_buffer()

e12_onwire_t * e12::get_encode_buffer ( )
inlineprotected

Gets the buffer for encoding packets.

Returns
Pointer to the encoding buffer

◆ get_fwr_version()

uint32_t e12::get_fwr_version ( )
inline

Get the fwr version object.

Returns
uint32_t

◆ get_log_evt()

virtual e12_log_evt_t * e12::get_log_evt ( )
pure virtual

Implemented in e12_esp32_node, and e12_arduino.

◆ get_message()

bool e12::get_message ( e12_packet_t data)

Gets a message from the e12 protocol.

Get the message from the on-wire packet.

Parameters
dataPointer to the data to be retrieved
Returns
True if the message was retrieved, false otherwise
Parameters
dataPointer to the data packet to store the message
Returns
true If the message was successfully retrieved
false If there was an error retrieving the message

◆ get_node_status()

e12_node_op_status_t e12::get_node_status ( )
protected

Gets the status of the e12 node.

Returns
Status of the e12 node

◆ get_pin_io_mask()

uint32_t e12::get_pin_io_mask ( )

Get the pin io mask object. top 16bit for analog, lower 16bit for digital.

Returns
uint32_t

◆ get_pin_mask()

uint32_t e12::get_pin_mask ( )

Get the pin io mask object. top 16bit for analog, lower 16bit for digital.

Returns
uint32_t

◆ get_request()

e12_packet_t * e12::get_request ( e12_cmd_t  cmd,
bool  response = true,
void *  data = 0 
)
virtual

Gets a request packet for the given command.

Get a request packet for the given command.

Parameters
cmdCommand to be requested
responseTrue if a response is expected, false otherwise
dataPointer to additional data
Returns
Pointer to the request packet
Parameters
cmdCommand type
responseWhether a response is expected
dataPointer to the data associated with the command
Returns
e12_packet_t* Pointer to the request packet

◆ get_response()

e12_packet_t * e12::get_response ( e12_packet_t p)
virtual

Gets a response packet for the given packet.

Get a response packet for the given request packet.

Parameters
pPointer to the packet
Returns
Pointer to the response packet
Parameters
pPointer to the request packet
Returns
e12_packet_t* Pointer to the response packet

◆ get_time_ms()

virtual uint32_t e12::get_time_ms ( )
pure virtual

Implemented in e12_esp32_node, and e12_arduino.

◆ get_version()

uint32_t e12::get_version ( )
inline

Gets the version of the e12 protocol.

Returns
Version of the e12 protocol

◆ is_configured()

bool e12::is_configured ( )
inline

Checks if the e12 endpoint is configured.

Returns
True if the endpoint is configured, false otherwise

◆ log()

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

Implemented in e12_esp32_node, and e12_demo.

◆ on_config()

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

Implemented in e12_esp32_node, and e12_demo.

◆ on_ctl()

bool e12::on_ctl ( ctl_op_t  op,
uint8_t  pin,
uint32_t  val 
)
protected

function doing basic sanity and scheduling return cmds

Parameters
pin
val
Returns
true
false

◆ on_ctl_read()

int e12::on_ctl_read ( uint8_t  pin)
virtual

allows READ state of any valid pin

Validates a READ request (Any configured pin is readable)

Parameters
pin
Returns
true // if pin is in range 0-31
false

Reimplemented in e12_demo.

◆ on_ctl_write()

bool e12::on_ctl_write ( uint8_t  pin,
uint32_t  val 
)
virtual

Validates a WRITE request (PIN <- IN only)

Parameters
pin
val
Returns
bool

Reimplemented in e12_demo.

◆ on_get_state()

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

Implemented in e12_esp32_node, and e12_demo.

◆ on_receive()

int e12::on_receive ( e12_packet_t p)
virtual

Handles the received packet.

Handle the received packet.

Parameters
pPointer to the received packet
Returns
0 on success, non-zero on failure
Parameters
pPointer to the received packet
Returns
int Status code

Reimplemented in e12_client.

◆ on_restore_state()

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

Implemented in e12_esp32_node, and e12_demo.

◆ on_wakeup()

virtual int e12::on_wakeup ( )
pure virtual

Implemented in e12_esp32_node, and e12_arduino.

◆ print_buffer()

virtual int e12::print_buffer ( e12_onwire_t buf)
inlinevirtual

Prints the contents of the buffer.

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

Reimplemented in e12_esp32_node.

◆ publish_info()

int e12::publish_info ( )

Publish info e.g fwr version, arch, protocol etc.

Returns
int

◆ publish_profile()

int e12::publish_profile ( )

Publish profile info e.g pin configuration.

Publish profile e.g pin configurations.

Returns
int

◆ read()

virtual e12_packet_t * e12::read ( )
pure virtual

Implemented in e12_esp32_node, and e12_arduino.

◆ send()

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

Implemented in e12_esp32_node, e12_client, and e12_arduino.

◆ set_configured()

void e12::set_configured ( bool  status)
inline

Set the configured status for e12 endpoint.

Parameters
statustrue if configured, false otherwise

◆ set_e12_device()

void e12::set_e12_device ( e12_device_t p)
inline

Sets the e12 device.

Parameters
pPointer to the e12 device

◆ set_fwr_details()

void e12::set_fwr_details ( uint32_t  fwr_version,
mcu_arch_t  arch,
mcu_flashing_protocol_t  protocol,
bool  enabled 
)
inline

Set the vmcu firmware details object.

Parameters
arch
protocol
enabled

◆ set_node_auth_credentials()

virtual int e12::set_node_auth_credentials ( e12_auth_data_t auth)
pure virtual

Implemented in e12_esp32_node, and e12_arduino.

◆ set_node_properties()

void e12::set_node_properties ( e12_node_properties_t props)

Sets the properties of the e12 node.

Set the node properties.

Parameters
propsPointer to the node properties
propsPointer to the node properties structure

◆ set_node_status()

e12_node_op_status_t e12::set_node_status ( e12_node_op_status_t  status,
uint32_t  data 
)
protected

Sets the status of the e12 node.

Parameters
statusStatus to be set
datauint32_t size data to be stored relevant to the status e.g for SLEEP this is ms till the e12_node is in sleep mode
Returns
Status of the e12 node

◆ set_pin_in()

bool e12::set_pin_in ( uint8_t  pin_number,
bool  is_analog = false 
)

Sets the pin as input and type (analog/digital)

Parameters
pin_number
is_analog(true = analog, false = digital)

◆ set_pin_mask()

void e12::set_pin_mask ( uint32_t  pin_mask,
uint32_t  io_mask 
)
inline

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.

Parameters
pin_mask
io_mask

◆ set_pin_out()

bool e12::set_pin_out ( uint8_t  pin_number,
bool  is_analog = false 
)

Sets the pin as output and type (analog/digital)

Parameters
pin_number
is_analog(true = analog, false = digital)

◆ set_product_info()

void e12::set_product_info ( uint32_t  vid,
uint32_t  pid 
)
inline

Sets the product information.

Parameters
vidVendor ID
pidProduct ID

◆ set_timeout()

void e12::set_timeout ( uint32_t  ms)
inline

Sets the timeout value.

Parameters
msTimeout value in milliseconds

◆ set_version()

void e12::set_version ( uint32_t  v)
inline

Sets the version of the e12 protocol.

Parameters
vVersion to be set

◆ sleep()

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

Implemented in e12_esp32_node, e12_client, and e12_arduino.

◆ wakeup_e12_node()

virtual int e12::wakeup_e12_node ( )
inlinevirtual

Wakes up the e12 node.

Returns
0 on success, non-zero on failure

Reimplemented in e12_client.

Member Data Documentation

◆ _seq

uint8_t e12::_seq
protected

Sequence number for packets.

◆ _timeout

uint32_t e12::_timeout
protected

Timeout value in milliseconds.


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