LightHub
4.6.0
Open-source smart home controller firmware
Toggle main menu visibility
Loading...
Searching...
No Matches
out_uartbridge.h
Go to the documentation of this file.
1
#pragma once
2
#include "
options.h
"
3
#ifdef UARTBRIDGE_ENABLE
4
#include <
abstractout.h
>
5
#include <
item.h
>
6
#include "
itemCmd.h
"
7
#include "
utils.h
"
8
9
#if defined(ESP32)
10
#define serialParamType uint32_t
11
#else
12
#define serialParamType uint16_t
13
#endif
14
15
#define SOURCE_PORT_A 5551
16
#define SOURCE_PORT_B 5552
17
#define MAX_PDU 64
18
19
#ifndef MODULE_UATRBRIDGE_UARTA
20
#define MODULE_UATRBRIDGE_UARTA Serial1
21
#endif
22
23
#ifndef MODULE_UATRBRIDGE_UARTB
24
#define MODULE_UATRBRIDGE_UARTB Serial2
25
#endif
26
27
#ifndef MODULE_UATRBRIDGE_UARTA_RX_PIN
28
#define MODULE_UATRBRIDGE_UARTA_RX_PIN 15
29
#endif
30
31
#ifndef MODULE_UATRBRIDGE_UARTA_TX_PIN
32
#define MODULE_UATRBRIDGE_UARTA_TX_PIN 2
33
#endif
34
35
#ifndef MODULE_UATRBRIDGE_UARTB_RX_PIN
36
#define MODULE_UATRBRIDGE_UARTB_RX_PIN -1
37
#endif
38
39
#ifndef MODULE_UATRBRIDGE_UARTB_TX_PIN
40
#define MODULE_UATRBRIDGE_UARTB_TX_PIN -1
41
#endif
42
49
class
ubPersistent :
public
chPersistent
{
50
51
public
:
52
53
int
baud;
54
serialParamType
serialParam;
55
//uint16_t pollingInterval;
56
//uint32_t timestamp;
57
//aJsonObject * pollingRegisters;
58
//aJsonObject * pollingIrs;
59
//aJsonObject * parameters;
60
};
61
63
#define PDELAY 10
64
89
class
out_UARTbridge :
public
abstractOut
{
90
public
:
91
92
// out_UARTbridge(Item * _item):abstractOut(_item){store = (ubPersistent *) item->getPersistent();};
93
95
out_UARTbridge():store(NULL){};
97
void
link(Item * _item){
abstractOut::link
(_item);
if
(_item) {store = (ubPersistent *) item->getPersistent();}
else
store = NULL;};
98
99
101
int
Setup()
override
;
103
int
Poll(
short
cause)
override
;
105
int
Stop()
override
;
107
int
getChanType()
override
;
109
int
Ctrl(itemCmd cmd,
char
* subItem=NULL,
bool
toExecute=
true
,
bool
authorized =
false
)
override
;
110
//int getDefaultStorageType(){return ST_INT32;};
111
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
112
113
protected
:
114
ubPersistent * store;
116
bool
getConfig();
117
// int findRegister(int registerNum, int posInBuffer, int regType);
118
// void pollModbus(aJsonObject * reg, int regType);
119
};
120
#endif
abstractout.h
abstractOut
Base class of output driver modules (one per channel type).
Definition
abstractout.h:19
abstractOut::link
virtual void link(Item *_item)
Definition
abstractout.h:24
chPersistent
Placeholder for driver-persistent data attached to an item (I_EXT field).
Definition
abstractout.h:8
item.h
Item (virtual channel) system of LightHub.
itemCmd.h
options.h
utils.h
Utility helpers of LightHub.
serialParamType
#define serialParamType
Type for a serial parameter (uint32 on ESP32, uint16 elsewhere).
Definition
utils.h:65
lighthub
modules
out_uartbridge.h
Generated by
1.18.0