diff options
Diffstat (limited to 'src/device')
-rwxr-xr-x | src/device/protocol_device.ino | 38 | ||||
-rwxr-xr-x | src/device/protocol_device_private.h | 37 |
2 files changed, 75 insertions, 0 deletions
diff --git a/src/device/protocol_device.ino b/src/device/protocol_device.ino new file mode 100755 index 0000000..778196d --- /dev/null +++ b/src/device/protocol_device.ino @@ -0,0 +1,38 @@ +#include "protocol.h" +#include "protocol_private.h" +#include "protocol_device_private.h" +#include <ESP8266WiFi.h> +#include <time.h> +#include <stdlib.h> + +static struct connection_t connection; + +static int push_bytes(cd_t cd, char *data, size_t size) +{ + int ret = 0; + + if (cd >= MAX_CONNECTIONS) { + ret = E_IVALID_DESCRIPTOR; + } else if (connection.outp_crs + size >= sizeof(connection.outp_buf)) { + ret = E_PACKET_OVERFLOW; + } else { + + } + return ret; +} + +static int push_tlv_header(cd_t connection, enum tlv_type type, size_t size) +{ + return 0; +} + +struct tlv * get_tlv() +{ + return NULL; +} + + +void get_last_data(cd_t connection) +{ + +} diff --git a/src/device/protocol_device_private.h b/src/device/protocol_device_private.h new file mode 100755 index 0000000..0fb46c7 --- /dev/null +++ b/src/device/protocol_device_private.h @@ -0,0 +1,37 @@ +#ifndef PROTOCOL_DEVICE_PRIVATE_H +#define PROTOCOL_DEVICE_PRIVATE_H + +#define MAX_PACKET_SIZE_OUT (64) +#define MAX_PACKET_SIZE_IN (512) +#define MAX_CONNECTIONS (1UL) + +/** + * Device's view of connection to daemon. + */ +struct connection_t { + /** + * Initially 0, non-zero when connection is open, 0 when connection + * is closed again. + */ + int is_live; + + /** Daemon IP adress */ + IPAddress address; + + /** Time last packet was reveived */ + time_t last_packet_sec; + + /** Incoming packet buffer */ + char inp_buf[MAX_PACKET_SIZE_IN]; + + /** Incoming packet cursor */ + size_t inp_crs; + + /** Outgoing packet buffer */ + char outp_buf[MAX_PACKET_SIZE_OUT]; + + /** Outgoing packet cursor */ + size_t outp_crs; +}; + +#endif /* PROTOCOL_DEVICE_PRIVATE_H */
\ No newline at end of file |