11 #ifndef _TCMENU_REMOTECONNECTOR_H_
12 #define _TCMENU_REMOTECONNECTOR_H_
14 #include <PlatformDetermination.h>
23 #define TAG_VAL_PROTOCOL 0x01
24 #define BINARY_GZ_PROTOCOL 0x02
25 #define START_OF_MESSAGE 0x01
26 #define TICK_INTERVAL 1
30 #ifndef HEARTBEAT_INTERVAL
31 # define HEARTBEAT_INTERVAL 1500
36 #ifndef PAIRING_TIMEOUT_TICKS
37 #define PAIRING_TIMEOUT_TICKS (15000 / TICK_INTERVAL)
94 char value[MAX_VALUE_LEN];
102 #define COMMSERR_OK 0
103 #define COMMSERR_WRITE_NOT_CONNECTED 1
104 #define COMMSERR_PROTOCOL_ERROR 2
105 #define COMMSERR_CONNECTED 3
106 #define COMMSERR_DISCONNECTED 4
109 uint16_t remoteNo: 4;
110 uint16_t connected: 1;
111 uint16_t errorMode: 8;
145 uint8_t protocolUsed;
150 virtual void startMsg(uint16_t msgType);
151 void startBinMsg(uint16_t msgType, uint16_t byteLen);
152 void writeField(uint16_t field,
const char* value);
153 void writeFieldInt(uint16_t field,
int value);
154 void writeFieldLong(uint16_t field,
long value);
159 virtual void flush() = 0;
160 virtual int writeChar(
char data) = 0;
161 virtual int writeStr(
const char* data) = 0;
162 virtual uint8_t readByte()=0;
163 virtual bool readAvailable()=0;
165 virtual bool available() = 0;
166 virtual bool connected() = 0;
167 virtual void close() = 0;
168 virtual void endMsg();
170 bool findNextMessageStart();
171 bool processMsgKey();
172 bool processValuePart();
175 #define FLAG_CURRENTLY_CONNECTED 0
176 #define FLAG_BOOTSTRAP_MODE 1
177 #define FLAG_BOOTSTRAP_COMPLETE 2
178 #define FLAG_AUTHENTICATED 3
179 #define FLAG_PAIRING_MODE 4
180 #define FLAG_FULLY_JOINED_RX 5
181 #define FLAG_FULLY_JOINED_TX 6
190 uint16_t ticksLastSend;
191 uint16_t ticksLastRead;
192 uint16_t hbTimeoutTicks;
205 uint8_t remoteMajorVer, remoteMinorVer;
239 void provideAuthentication(
const char* auth);
299 void encodeDialogMsg(uint8_t mode, uint8_t btn1, uint8_t btn2,
const char* hdrPgm,
const char* buffer);
465 bool isConnected() {
return bitRead(flags, FLAG_CURRENTLY_CONNECTED); }
491 void setHeartbeatTimeout(uint16_t milli) { hbTimeoutTicks = milli / TICK_INTERVAL; }
493 void encodeBaseMenuFields(
int parentId,
MenuItem* item);
494 bool prepareWriteMsg(uint16_t msgType);
495 void nextBootstrap();
496 void performAnyWrites();
497 void dealWithHeartbeating();
504 void setConnected(
bool conn);
506 bool isBootstrapMode() {
return bitRead(flags, FLAG_BOOTSTRAP_MODE); }
507 void setBootstrapMode(
bool mode) { bitWrite(flags, FLAG_BOOTSTRAP_MODE, mode); }
509 bool isBootstrapComplete() {
return bitRead(flags, FLAG_BOOTSTRAP_COMPLETE); }
510 void setBootstrapComplete(
bool mode) { bitWrite(flags, FLAG_BOOTSTRAP_COMPLETE, mode); }
512 void setAuthenticated(
bool auth) { bitWrite(flags, FLAG_AUTHENTICATED, auth); }
514 bool isPairing() {
return bitRead(flags, FLAG_PAIRING_MODE); }
515 void setPairing(
bool pair) { bitWrite(flags, FLAG_PAIRING_MODE, pair); }
517 bool isConnectionFullyEstablished() {
518 return isConnected() && (bitRead(flags, FLAG_FULLY_JOINED_RX) != 0) && (bitRead(flags, FLAG_FULLY_JOINED_TX) != 0);
521 void setFullyJoinedRx(
bool joinRx) { bitWrite(flags, FLAG_FULLY_JOINED_RX, joinRx); }
523 void setFullyJoinedTx(
bool joinTx) { bitWrite(flags, FLAG_FULLY_JOINED_TX, joinTx); }
525 bool beginEncodeChange(
MenuItem *item);
This file contains the default processors that can deal with incoming messages turning them into even...
void(* CommsCallbackFn)(CommunicationInfo)
Definition: RemoteConnector.h:118
FieldValueType
Definition: RemoteConnector.h:54
@ FVAL_END_MSG
Definition: RemoteConnector.h:58
@ FVAL_PROCESSING_MSGTYPE_HI
Definition: RemoteConnector.h:74
@ FVAL_NEW_MSG
Definition: RemoteConnector.h:56
@ FVAL_PROCESSING_VALUE
Definition: RemoteConnector.h:68
@ FVAL_ERROR_PROTO
Definition: RemoteConnector.h:62
@ FVAL_PROCESSING_PROTOCOL
Definition: RemoteConnector.h:72
@ FVAL_PROCESSING_MSGTYPE_LO
Definition: RemoteConnector.h:76
@ FVAL_FIELD
Definition: RemoteConnector.h:60
@ FVAL_PROCESSING_WAITEQ
Definition: RemoteConnector.h:66
@ FVAL_PROCESSING_AWAITINGMSG
Definition: RemoteConnector.h:70
@ FVAL_PROCESSING
Definition: RemoteConnector.h:64
TagValueTransportType
Definition: RemoteConnector.h:128
@ TVAL_BUFFERED
Definition: RemoteConnector.h:132
@ TVAL_UNBUFFERED
Definition: RemoteConnector.h:130
@ TVAL_BUFFERED_DELEGATE_ENCRYPT
Definition: RemoteConnector.h:134
Definition: RemoteConnector.h:108
Definition: RemoteConnector.h:90
contains the definitions of each message and field.
HeartbeatMode
Definition: RemoteTypes.h:149
ApiPlatform
Definition: RemoteTypes.h:139
Definition: RemoteAuthentication.h:38
Definition: MessageProcessors.h:146
Definition: RemoteConnector.h:187
bool isConnected()
Definition: RemoteConnector.h:465
const char * getRemoteName()
Definition: RemoteConnector.h:444
bool isTransportAvailable()
Definition: RemoteConnector.h:237
void encodeAnalogItem(int parentId, AnalogMenuItem *item)
Definition: RemoteConnector.cpp:433
void setRemoteName(const char *name)
Definition: RemoteConnector.cpp:68
void encodeRuntimeMenuItem(int parentId, RuntimeMenuItem *item)
Definition: RemoteConnector.cpp:537
uint8_t getRemoteMajorVer() const
Definition: RemoteConnector.h:449
void encodeSubMenu(int parentId, SubMenuItem *item)
Definition: RemoteConnector.cpp:587
void encodeMultiEditMenu(int parentId, RuntimeMenuItem *item)
Definition: RemoteConnector.cpp:483
void encodeEnumMenu(int parentId, EnumMenuItem *item)
Definition: RemoteConnector.cpp:552
void encodeBootstrap(bool isComplete)
Definition: RemoteConnector.cpp:380
void tick()
Definition: RemoteConnector.cpp:174
bool isTransportConnected()
Definition: RemoteConnector.h:244
void setRemoteConnected(uint8_t major, uint8_t minor, ApiPlatform platform)
Definition: RemoteConnector.cpp:73
void pairingRequest(const char *name, const char *uuid)
Definition: RemoteConnector.cpp:127
void encodeAcknowledgement(uint32_t correlation, AckResponseStatus status)
Definition: RemoteConnector.cpp:567
void encodeLargeNumberMenuItem(int parentId, EditableLargeNumberMenuItem *item)
Definition: RemoteConnector.cpp:472
void initialise(TagValueTransport *transport, CombinedMessageProcessor *processor, const ConnectorLocalInfo *localInfoPgm, uint8_t remoteNo)
Definition: RemoteConnector.cpp:56
uint8_t getRemoteMinorVer() const
Definition: RemoteConnector.h:454
bool isAuthenticated()
Definition: RemoteConnector.h:488
TagValueRemoteConnector(uint8_t remoteNo=0)
Definition: RemoteConnector.cpp:41
void encodeColorMenuItem(int id, Rgb32MenuItem *pItem)
Definition: RemoteConnector.cpp:462
void encodeCustomBinaryMessage(uint16_t msgType, uint16_t len, void(*msgWriter)(TagValueTransport *, void *, size_t), void *data=nullptr)
Definition: RemoteConnector.cpp:407
void encodeBooleanMenu(int parentId, BooleanMenuItem *item)
Definition: RemoteConnector.cpp:579
void close()
Definition: RemoteConnector.cpp:160
void encodeChangeValue(MenuItem *theItem)
Definition: RemoteConnector.cpp:605
void encodeDialogMsg(uint8_t mode, uint8_t btn1, uint8_t btn2, const char *hdrPgm, const char *buffer)
Definition: RemoteConnector.cpp:340
void setCommsNotificationCallback(CommsCallbackFn callback)
Definition: RemoteConnector.h:232
void encodeActionMenu(int parentId, ActionMenuItem *item)
Definition: RemoteConnector.cpp:593
void encodeCustomTagValMessage(uint16_t msgType, void(*msgWriter)(TagValueTransport *, void *), void *)
Definition: RemoteConnector.cpp:358
void initiateBootstrap()
Definition: RemoteConnector.cpp:270
void commsNotify(uint16_t commsEventType)
Definition: RemoteConnector.cpp:150
void encodeScrollMenuItem(int id, ScrollChoiceMenuItem *pItem)
Definition: RemoteConnector.cpp:447
uint8_t getRemoteNo() const
Definition: RemoteConnector.h:439
void encodeFloatMenu(int parentId, FloatMenuItem *item)
Definition: RemoteConnector.cpp:517
void encodeHeartbeat(HeartbeatMode restartConnection)
Definition: RemoteConnector.cpp:386
void encodeJoin()
Definition: RemoteConnector.cpp:365
ApiPlatform getRemotePlatform()
Definition: RemoteConnector.h:459
Definition: RemoteConnector.h:141
A series of utilities that used throughout tcMenu.