e12
 
Loading...
Searching...
No Matches
arduino_e12_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 ARDUINO_E12_SPEC_H
20#define ARDUINO_E12_SPEC_H
21
22#include <Wire.h>
23#include <e12_protocol.h>
24#include <stdint.h>
25
26#if !defined(__AVR__)
27using namespace arduino;
28#endif
29
33typedef struct e12_event {
34 void* data;
36
40class e12_arduino : public e12 {
41 private:
42 uint8_t _e12_addr;
43 TwoWire* _bus;
44 uint32_t _evt_count;
46
47 public:
53 e12_arduino(uint32_t vid, uint32_t pid);
54
59
66 virtual int begin(void* bus, uint8_t e12_addr = 0);
67
71 void e12_run();
72
77 int close();
78
83 virtual uint32_t get_time_ms();
84
90 virtual int send(e12_packet_t* buf, bool retry = true);
91
96 virtual e12_packet_t* read();
97
102 virtual e12_log_evt_t* get_log_evt();
103
110
115 virtual int on_wakeup();
116
123 virtual int sleep(uint32_t ms, void* data);
124};
125
126#endif
struct e12_event e12_event_t
Structure to hold event data.
Class to handle e12 protocol on Arduino.
Definition arduino_e12_protocol.h:40
virtual int begin(void *bus, uint8_t e12_addr=0)
Initialize the e12 device.
Definition arduino_e12_protocol.cpp:15
virtual uint32_t get_time_ms()
Get the current time in milliseconds.
Definition arduino_e12_protocol.cpp:40
virtual int sleep(uint32_t ms, void *data)
Put the device to sleep.
Definition arduino_e12_protocol.cpp:57
virtual int set_node_auth_credentials(e12_auth_data_t *auth)
Set node authentication credentials.
Definition arduino_e12_protocol.cpp:42
void e12_run()
Run the e12 protocol.
Definition arduino_e12_protocol.cpp:131
int close()
Close the e12 device.
Definition arduino_e12_protocol.cpp:35
virtual e12_log_evt_t * get_log_evt()
Get the log event.
Definition arduino_e12_protocol.cpp:137
~e12_arduino()
Destructor for e12_arduino.
Definition arduino_e12_protocol.cpp:13
virtual int on_wakeup()
Handle wakeup event.
Definition arduino_e12_protocol.cpp:48
virtual e12_packet_t * read()
Read a packet from the e12 device.
Definition arduino_e12_protocol.cpp:108
virtual int send(e12_packet_t *buf, bool retry=true)
Send a packet to the e12 device.
Definition arduino_e12_protocol.cpp:68
This class represents the base class for the e12 protocol.
Definition e12_protocol.h:403
e12_auth_data_t
Definition e12_protocol.h:225
#define E12_MAX_LOG_BUFFERS
Definition e12_protocol.h:143
e12_log_evt_t
Definition e12_protocol.h:174
e12_packet_t
Definition e12_protocol.h:357
Structure to hold event data.
Definition arduino_e12_protocol.h:33
void * data
Definition arduino_e12_protocol.h:34