Connectino Library
ConnectinoArrowConnect.h
1 #ifndef ConnectinoArrowConnect_h
2 #define ConnectinoArrowConnect_h
3 
4 #include "ConnectinoModule.h"
5 #include "MODULE.h"
6 #include "StxHwSerial.h"
7 
8 #define ARROW_CONNECT_SERVER_MAX_LEN 64
9 #define ARROW_CONNECT_VHOST_MAX_LEN 24
10 #define ARROW_CONNECT_HID_LEN 40
11 
20 {
21  public:
26  ConnectinoArrowConnect(StxHwSerial &refSerial);
27 
37  bool moduleCallback(uint8_t subId, uint8_t reqId, uint16_t dataSize, uint8_t *data);
38 
44  uint8_t getModId();
45 
59  bool connect(char *server, uint16_t port, char *vHost, char *gatewayHid, char *apiKey, char *deviceHid, bool waitConnected);
60 
68  bool disconnect(bool waitDisconnected = false);
69 
74  bool isConnected(void);
75 
83  bool available(void);
84 
93  bool read(char *command, uint16_t *commandLen, char *payload, uint16_t *payloadLen);
94 
98  void clear(void);
99 
107  bool publish(char *varName, char *data);
108 
116  bool publish(char *varName, bool data);
117 
125  bool publish(char *varName, long int data);
126 
136  bool publish(char *varName1, long int data1, char *varName2, long int data2);
137  private:
138  StxHwSerial &StxSerial;
139  volatile bool _reqPending;
140  volatile bool _reqResOk;
141  volatile uint8_t _reqSubId;
142  volatile uint8_t _reqReqId;
143  volatile uint8_t _reqState;
145  volatile char *_reqServer;
146  volatile uint16_t *_reqPort;
147  volatile char *_reqVHost;
148  volatile char *_reqGatewayHid;
150  volatile bool _isConnected = false;
151  volatile bool _dataAvailable = false;
153  uint8_t _deviceHid[ARROW_CONNECT_HID_LEN];
160  bool _setState(uint8_t state);
161 
167  bool _getState(uint8_t *state);
168 
178  bool _setConfig(char *server, uint16_t port, char *vHost, char *gatewayHid, char *apiKey);
179 
188  bool _getConfig(char *server, uint16_t *port, char *vHost, char *gatewayHid);
189 
197  bool _sendData(uint8_t datatype, char *varName, void *data);
198 
207  bool _sendDataMulti(uint8_t datatype[], char *varName[], void *data[], uint16_t numData);
208 };
209 
210 #endif
ConnectinoArrowConnect(StxHwSerial &refSerial)
ArrowConnect module constructor.
Definition: ConnectinoArrowConnect.cpp:289
bool isConnected(void)
Check the connection state of the ArrowConnect module.
Definition: ConnectinoArrowConnect.cpp:435
ArrowConnect module.
Definition: ConnectinoArrowConnect.h:19
bool connect(char *server, uint16_t port, char *vHost, char *gatewayHid, char *apiKey, char *deviceHid, bool waitConnected)
Connect to the configured server and gateway.
Definition: ConnectinoArrowConnect.cpp:396
uint8_t getModId()
Get the ID of the ArrowConnect module.
Definition: ConnectinoArrowConnect.cpp:293
bool moduleCallback(uint8_t subId, uint8_t reqId, uint16_t dataSize, uint8_t *data)
Callback function for serial frames of the ArrowConnect module.
Definition: ConnectinoArrowConnect.cpp:298
bool publish(char *varName, char *data)
Publish data.
Definition: ConnectinoArrowConnect.cpp:500
bool available(void)
Check if data is available.
Definition: ConnectinoArrowConnect.cpp:440
bool disconnect(bool waitDisconnected=false)
Disconnect from the configured server.
Definition: ConnectinoArrowConnect.cpp:424
void clear(void)
Clear the receive buffer.
Definition: ConnectinoArrowConnect.cpp:494
bool read(char *command, uint16_t *commandLen, char *payload, uint16_t *payloadLen)
Receive commands sent by the server.
Definition: ConnectinoArrowConnect.cpp:445
Binuart module.
Definition: ConnectinoModule.h:10