e12
 
Loading...
Searching...
No Matches
e12_demo.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_E12_DEMO
20#define H_E12_DEMO
21
22#include <DallasTemperature.h>
23#include <Wire.h>
24
25#include "Arduino.h"
26#include "e12_client.h"
27//
28#include <e12_protocol.h>
29//
30
31#include "Arduino.h"
33
34enum {
35 EVT_BLINK = 0x01,
36 EVT_TEMP = 0x02,
37 EVT_DEMO = 0x03,
38 EVT_CTL = 0x04,
40
41class e12_demo : public e12_client {
42 private:
43 uint8_t _on;
44 uint32_t _on_delay;
45 uint32_t _off_delay;
46 uint8_t _pin;
47 uint8_t _count;
48 float _temp;
49
50 public:
51 e12_demo(uint32_t vid, uint32_t pid);
53
54 // virtual function implemented
55 int on_config(const char* s, int len);
56 int on_get_state(char* s, int len, void* ctx);
57 int on_restore_state(const char* s, int len);
58
59 int on_ctl_read(uint8_t pin);
60 bool on_ctl_write(uint8_t pin, uint32_t val);
61
62 int log(uint8_t type, uint8_t status, uint32_t ts, void* data);
63
64 // client device functions
65 uint32_t blink();
66 uint32_t read_temp(DallasTemperature* sensors);
67 uint32_t demo();
68};
69
70#endif
Definition e12_client.h:30
Definition e12_demo.h:41
uint32_t blink()
Definition e12_demo.cpp:51
~e12_demo()
Definition e12_demo.h:52
int log(uint8_t type, uint8_t status, uint32_t ts, void *data)
Definition e12_demo.cpp:126
int on_ctl_read(uint8_t pin)
allows READ state of any valid pin
Definition e12_demo.cpp:70
uint32_t demo()
Definition e12_demo.cpp:157
bool on_ctl_write(uint8_t pin, uint32_t val)
Validates a WRITE request (PIN <- IN only)
Definition e12_demo.cpp:78
int on_config(const char *s, int len)
Definition e12_demo.cpp:90
int on_get_state(char *s, int len, void *ctx)
Definition e12_demo.cpp:101
int on_restore_state(const char *s, int len)
Definition e12_demo.cpp:115
uint32_t read_temp(DallasTemperature *sensors)
Definition e12_demo.cpp:61
@ EVT_CTL
Definition e12_demo.h:38
@ EVT_BLINK
Definition e12_demo.h:35
@ EVT_TEMP
Definition e12_demo.h:36
@ EVT_DEMO
Definition e12_demo.h:37
enum @1 event_t