summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-21 20:01:08 +0300
committerGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-21 20:01:08 +0300
commitfe71239fc0d1e65e06ba9dcf2fb35239bff21466 (patch)
treee1e708310afc253ca006bb22558cc8cba67bdfb6 /include
parent5ca7e24e58f6bd657787b9235247149ffff420ae (diff)
downloadusurpation-fe71239fc0d1e65e06ba9dcf2fb35239bff21466.tar.gz
usurpation-fe71239fc0d1e65e06ba9dcf2fb35239bff21466.tar.bz2
usurpation-fe71239fc0d1e65e06ba9dcf2fb35239bff21466.zip
Protocol: moved udp code out of main.
An effor was made to increase modularity of device code. It was a partial success. IP adress, communications port, and wifi login details had to be made static and visible in main. Time is scarce and I am not about to push this further. Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/protocol.h4
-rwxr-xr-xinclude/udp.h16
2 files changed, 18 insertions, 2 deletions
diff --git a/include/protocol.h b/include/protocol.h
index c5e657b..8d5c535 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -116,7 +116,7 @@ struct tlv * get_tlv(cd_t cd);
/**
* Any modifications made to the pending outgoing packet are nullified.
* */
-void clear_data(cd_t connection);
+int clear_data(cd_t connection);
/**
* Appends data to the next packet to be sent. Type of data is determined by
@@ -127,7 +127,7 @@ int push_data(cd_t connection, const char *data, enum tlv_type);
/**
* Sends packet towards the other end.
* */
-void flush_data(cd_t connection);
+int flush_data(cd_t connection);
cd_t protocol_init(void);
diff --git a/include/udp.h b/include/udp.h
new file mode 100755
index 0000000..358e585
--- /dev/null
+++ b/include/udp.h
@@ -0,0 +1,16 @@
+#ifndef DEVICE_UDP_H
+#define DEVICE_UDP_H
+
+#include <ESP8266WiFi.h>
+#include <WiFiUdp.h>
+
+static const int com_port = 6996;
+IPAddress ip; /* Daemon IP */
+WiFiUDP Udp;
+
+extern void discover_client(const int port);
+extern void udp_init_packet(IPAddress ip, const int port);
+extern void udp_push(const void * const data, const size_t size);
+extern int udp_flush(void);
+
+#endif /* DEVICE_UDP_H */ \ No newline at end of file