This class represents the base class for the e12 protocol. More...
#include <e12_protocol.h>
Public Member Functions | |
| e12 (uint32_t vid, uint32_t pid) | |
| Constructor for the e12 class. | |
| ~e12 () | |
| Destructor for the e12 class. | |
| e12_packet_t * | e12_get_packet () |
| Gets a new packet for the e12 protocol. | |
| e12_onwire_t * | encode (e12_packet_t *data) |
| Encodes the given data into a packet. | |
| e12_packet_t * | decode (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_t * | get_request (e12_cmd_t cmd, bool response=true, void *data=0) |
| Gets a request packet for the given command. | |
| virtual e12_packet_t * | get_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_t * | get_log_evt ()=0 |
| virtual int | send (e12_packet_t *buf, bool retry=true)=0 |
| virtual e12_packet_t * | read ()=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_t * | get_encode_buffer () |
| Gets the buffer for encoding packets. | |
| e12_onwire_t * | get_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. | |
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.
| e12::e12 | ( | uint32_t | vid, |
| uint32_t | pid | ||
| ) |
|
pure virtual |
Implemented in e12_esp32_node, and e12_arduino.
| 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.
| pkt | Pointer to the packet to be decoded |
| data | Data to be decoded |
| pkt | Pointer to the on-wire packet |
| data | Data byte to decode |
| e12_packet_t * e12::e12_get_packet | ( | ) |
Gets a new packet for the e12 protocol.
Get a new packet for encoding.
| 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.
| data | Pointer to the data to be encoded |
| data | Pointer to the data packet to encode |
|
protected |
Flushes the given buffer.
Flush the given buffer.
| buf | Pointer to the buffer to be flushed |
| buf | Pointer to the buffer to flush |
|
static |
Get the checksum object.
Get the checksum for the given data.
| data | Pointer to the data |
| len | Length of the data |
| data | Pointer to the data |
| len | Length of the data |
|
inlineprotected |
Gets the buffer for decoding packets.
|
inlineprotected |
Gets the buffer for encoding packets.
|
inline |
Get the fwr version object.
|
pure virtual |
Implemented in e12_esp32_node, and e12_arduino.
| bool e12::get_message | ( | e12_packet_t * | data | ) |
Gets a message from the e12 protocol.
Get the message from the on-wire packet.
| data | Pointer to the data to be retrieved |
| data | Pointer to the data packet to store the message |
|
protected |
| uint32_t e12::get_pin_io_mask | ( | ) |
Get the pin io mask object. top 16bit for analog, lower 16bit for digital.
| uint32_t e12::get_pin_mask | ( | ) |
Get the pin io mask object. top 16bit for analog, lower 16bit for digital.
|
virtual |
Gets a request packet for the given command.
Get a request packet for the given command.
| cmd | Command to be requested |
| response | True if a response is expected, false otherwise |
| data | Pointer to additional data |
| cmd | Command type |
| response | Whether a response is expected |
| data | Pointer to the data associated with the command |
|
virtual |
Gets a response packet for the given packet.
Get a response packet for the given request packet.
| p | Pointer to the packet |
| p | Pointer to the request packet |
|
pure virtual |
Implemented in e12_esp32_node, and e12_arduino.
|
inline |
|
inline |
Checks if the e12 endpoint is configured.
|
pure virtual |
Implemented in e12_esp32_node, and e12_demo.
|
pure virtual |
Implemented in e12_esp32_node, and e12_demo.
|
protected |
function doing basic sanity and scheduling return cmds
| pin | |
| val |
|
virtual |
allows READ state of any valid pin
Validates a READ request (Any configured pin is readable)
| pin |
Reimplemented in e12_demo.
|
virtual |
Validates a WRITE request (PIN <- IN only)
| pin | |
| val |
Reimplemented in e12_demo.
|
pure virtual |
Implemented in e12_esp32_node, and e12_demo.
|
virtual |
Handles the received packet.
Handle the received packet.
| p | Pointer to the received packet |
| p | Pointer to the received packet |
Reimplemented in e12_client.
|
pure virtual |
Implemented in e12_esp32_node, and e12_demo.
|
pure virtual |
Implemented in e12_esp32_node, and e12_arduino.
|
inlinevirtual |
Prints the contents of the buffer.
| buf | Pointer to the buffer |
Reimplemented in e12_esp32_node.
| int e12::publish_info | ( | ) |
Publish info e.g fwr version, arch, protocol etc.
| int e12::publish_profile | ( | ) |
Publish profile info e.g pin configuration.
Publish profile e.g pin configurations.
|
pure virtual |
Implemented in e12_esp32_node, and e12_arduino.
|
pure virtual |
Implemented in e12_esp32_node, e12_client, and e12_arduino.
|
inline |
Set the configured status for e12 endpoint.
| status | true if configured, false otherwise |
|
inline |
|
inline |
Set the vmcu firmware details object.
| arch | |
| protocol | |
| enabled |
|
pure virtual |
Implemented in e12_esp32_node, and e12_arduino.
| void e12::set_node_properties | ( | e12_node_properties_t * | props | ) |
Sets the properties of the e12 node.
Set the node properties.
| props | Pointer to the node properties |
| props | Pointer to the node properties structure |
|
protected |
| bool e12::set_pin_in | ( | uint8_t | pin_number, |
| bool | is_analog = false |
||
| ) |
Sets the pin as input and type (analog/digital)
| pin_number | |
| is_analog | (true = analog, false = digital) |
|
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.
| pin_mask | |
| io_mask |
| bool e12::set_pin_out | ( | uint8_t | pin_number, |
| bool | is_analog = false |
||
| ) |
Sets the pin as output and type (analog/digital)
| pin_number | |
| is_analog | (true = analog, false = digital) |
|
inline |
Sets the product information.
| vid | Vendor ID |
| pid | Product ID |
|
inline |
Sets the timeout value.
| ms | Timeout value in milliseconds |
|
inline |
Sets the version of the e12 protocol.
| v | Version to be set |
|
pure virtual |
Implemented in e12_esp32_node, e12_client, and e12_arduino.
|
inlinevirtual |
|
protected |
Sequence number for packets.
|
protected |
Timeout value in milliseconds.