13#define SLIP_ESC_END 0334
14#define SLIP_ESC_ESC 0335
35 _debug->print(
"ELC: got ");
55 if (
crc != resp_crc) {
56 DBG(
"ELC: Invalid CRC");
61 switch (packet->
cmd) {
73 _debug->print(
"RESP_CB: ");
85 _debug->println(
"NEED_SYNC!");
86 if (
resetCb != NULL) (*resetCb)();
125 if (packet != NULL)
return packet;
184 uint8_t *d = (uint8_t*)data;
244 uint8_t *d = (uint8_t*)data;
251 for (uint16_t l=len; l>0; l--) {
258 uint16_t pad = (4-(len&3))&3;
291 PGM_P p =
reinterpret_cast<PGM_P
>(data);
292 for (uint16_t l=len; l>0; l--) {
293 uint8_t c = pgm_read_byte(p++);
299 uint16_t pad = (4-(len&3))&3;
405_debug(debug), _serial(serial) {
445 uint32_t
wait = millis();
446 while (millis() -
wait < timeout) {
448 if (packet != NULL)
return packet;
471 acc = (acc >> 8) | (acc << 8);
472 acc ^= (acc & 0xff00) << 4;
473 acc ^= (acc >> 8) >> 4;
474 acc ^= (acc & 0xff00) >> 5;
495 for (uint16_t i=0; i<len; i++)
533 while ((packet =
WaitReturn(timeout)) != NULL) {
Definitions for ELClient.
uint16_t crc16Add(unsigned char b, uint16_t acc)
Create CRC for a byte add it to an existing CRC checksum and return the result.
ELClientPacket * protoCompletedCb(void)
Process a received SLIP message.
boolean Sync(uint32_t timeout=ESP_TIMEOUT)
Synchronize the communication between the MCU and the ESP.
void Request(void)
Finish the request.
ELClientPacket * Process(void)
Handle serial input.
void write(uint8_t data)
Send a byte.
void DBG(const char *info)
Send debug message over serial debug stream.
ELClientPacket * WaitReturn(uint32_t timeout=ESP_TIMEOUT)
Wait for a response from ESP for a given timeout.
uint16_t crc16Data(const unsigned char *data, uint16_t len, uint16_t acc)
Create/add CRC for a data buffer.
FP< void, void * > wifiCb
void init()
Initialize ELClient protocol.
ELClient(Stream *serial, Stream *debug)
Initialize ELClient and enable debug output.
void GetWifiStatus(void)
Request WiFi status from the ESP.
API abstraction for a Function Pointers.