e12
 
Loading...
Searching...
No Matches
esp32_e12_node_protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 e12.io
3 * All rights reserved.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef H_ESP32_E12_SPEC
20#define H_ESP32_E12_SPEC
21
22#include <Wire.h>
23#include <e12_protocol.h>
24#include <stdint.h>
25
35class e12_esp32_node : public e12 {
36 private:
37 TwoWire* _bus;
38
39 public:
45 e12_esp32_node(uint32_t vid, uint32_t pid);
46
51
52 // Initialization
53
60 virtual int begin(void* bus, uint8_t e12_addr = 0);
61
62 // Time
63
68 virtual uint32_t get_time_ms();
69
70 // Communication
71
78 virtual int send(e12_packet_t* buf, bool retry = true);
79
84 virtual e12_packet_t* read();
85
86 // Event handling
87
92 virtual e12_log_evt_t* get_log_evt();
93
102 virtual int log(uint8_t type, uint8_t status, uint32_t ts, void* data);
103
104 // Configuration
105
112 virtual int on_config(const char* s, int len);
113
121 virtual int on_get_state(char* s, int len, void* ctx);
122
129 virtual int on_restore_state(const char* s, int len);
130
137
138 // Power management
139
144 virtual int on_wakeup();
145
152 virtual int sleep(uint32_t ms, void* data);
153
154 // Utility
155
161 virtual int print_buffer(e12_onwire_t* buf);
162};
163
164#endif
This class represents an ESP32 node for the e12 protocol.
Definition esp32_e12_node_protocol.h:35
virtual int set_node_auth_credentials(e12_auth_data_t *auth)
Sets the authentication credentials for the node.
Definition esp32_e12_node_protocol.cpp:143
virtual uint32_t get_time_ms()
Gets the current time in milliseconds.
Definition esp32_e12_node_protocol.cpp:60
~e12_esp32_node()
Destructor for the e12_esp32_node class.
Definition esp32_e12_node_protocol.cpp:40
virtual e12_packet_t * read()
Reads a packet from the e12 node.
Definition esp32_e12_node_protocol.cpp:208
virtual int on_config(const char *s, int len)
Configures the node with the given settings.
Definition esp32_e12_node_protocol.cpp:181
virtual int send(e12_packet_t *buf, bool retry=true)
Sends a packet to the e12 node.
Definition esp32_e12_node_protocol.cpp:75
virtual int begin(void *bus, uint8_t e12_addr=0)
Initializes the node with the given bus and address.
Definition esp32_e12_node_protocol.cpp:49
virtual int on_get_state(char *s, int len, void *ctx)
Gets the current state of the node.
Definition esp32_e12_node_protocol.cpp:110
virtual int log(uint8_t type, uint8_t status, uint32_t ts, void *data)
Logs an event.
Definition esp32_e12_node_protocol.cpp:169
virtual int sleep(uint32_t ms, void *data)
Puts the node to sleep for the specified duration.
Definition esp32_e12_node_protocol.cpp:155
virtual int on_restore_state(const char *s, int len)
Restores the state of the node from the given string.
Definition esp32_e12_node_protocol.cpp:122
virtual int print_buffer(e12_onwire_t *buf)
Prints the contents of the buffer.
Definition esp32_e12_node_protocol.cpp:193
virtual int on_wakeup()
Wakes up the node.
Definition esp32_e12_node_protocol.cpp:132
virtual e12_log_evt_t * get_log_evt()
Gets the log event.
Definition esp32_e12_node_protocol.cpp:100
This class represents the base class for the e12 protocol.
Definition e12_protocol.h:403
e12_auth_data_t
Definition e12_protocol.h:225
e12_onwire_t
Definition e12_protocol.h:371
e12_log_evt_t
Definition e12_protocol.h:174
e12_packet_t
Definition e12_protocol.h:357