summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-29 14:33:16 +0300
committerGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-29 14:33:16 +0300
commit227a0e12ee262dbabdd8d988fec194273cf90029 (patch)
tree1e63cd26ac494cc453db5ebc0a120e0b48a562d7
parenta23ca7681b3dad7b63fd7b38e05fdfc2e0d75b33 (diff)
downloadusurpation-227a0e12ee262dbabdd8d988fec194273cf90029.tar.gz
usurpation-227a0e12ee262dbabdd8d988fec194273cf90029.tar.bz2
usurpation-227a0e12ee262dbabdd8d988fec194273cf90029.zip
Tweaked function declarations and build files to make it build.
Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
-rw-r--r--include/tlv.h7
-rw-r--r--src/common/tlv.c5
-rw-r--r--src/device/meson.build8
-rw-r--r--src/device/screen.cpp9
-rw-r--r--src/meson.build4
5 files changed, 22 insertions, 11 deletions
diff --git a/include/tlv.h b/include/tlv.h
index 7bfb275..b52763a 100644
--- a/include/tlv.h
+++ b/include/tlv.h
@@ -69,6 +69,9 @@ A few things to note:
#define TLV_SZ_MAX_RAW (MTU - 64)
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
/**
* Message sequence number since beggining of sesssion.
*
@@ -187,4 +190,8 @@ int tlv_push_data(struct tlv *t, const char *data, size_t size);
*/
int tlv_push_tlv(struct tlv *t, const struct tlv *other);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
#endif /* USURPATION_PROTOCOL_H_INCLUDED */
diff --git a/src/common/tlv.c b/src/common/tlv.c
index 748d3fb..c25f008 100644
--- a/src/common/tlv.c
+++ b/src/common/tlv.c
@@ -28,7 +28,6 @@
#include <string.h>
#include <time.h>
#include "tlv.h"
-#include "tlv_private.h"
#include "net.h"
#include "utils.h"
@@ -41,7 +40,7 @@ int tlv_get(struct tlv_parser *parser, struct tlv *ret)
} else if (parser -> offset == parser->size) {
retval = END_OF_PACKET;
} else {
- ret->type = memcpy(&ret->type, parser->data + parser->offset, sizeof(ret->type));
+ memcpy(&ret->type, parser->data + parser->offset, sizeof(ret->type));
parser->size += sizeof(ret->type);
ret->length = memcpy(&ret->length, parser->data + parser->offset, sizeof(ret->length));
parser->offset += sizeof(ret->length);
@@ -130,4 +129,4 @@ int tlv_push_tlv(struct tlv *t, const struct tlv *other)
}
return ret;
-} \ No newline at end of file
+}
diff --git a/src/device/meson.build b/src/device/meson.build
index d2e3c6e..8e4aa90 100644
--- a/src/device/meson.build
+++ b/src/device/meson.build
@@ -17,10 +17,14 @@ if get_option('fwbuild')
cat = find_program('cat')
cp = find_program('cp')
- fw_filenames = ['main.ino',
+ fw_filenames = [
+ 'main.ino',
'DejaVu_Sans_Mono_13.h',
'device_network.cpp',
- 'device_network.h']
+ 'device_network.h',
+ 'screen.cpp',
+ 'screen.h'
+ ]
fw_true_sources += files(fw_filenames)
fw_filenames += oledlibnames
fw_true_sources += oledlib
diff --git a/src/device/screen.cpp b/src/device/screen.cpp
index c923b99..2857161 100644
--- a/src/device/screen.cpp
+++ b/src/device/screen.cpp
@@ -5,16 +5,17 @@
#include <Wire.h>
#include "screen.h"
-void draw_lines(struct display_status *status);
+void draw_lines(OLEDDisplay *screen, struct display_status *status);
void update_lines(struct display_status *status);
void init_msg(char *msg, size_t size);
/* Effectively const. For type safety reasons. */
static char NOTHING[] = {'\0'};
-void display_status_init(struct display_status *status, char *msg)
+void display_status_init(OLEDDisplay *screen, struct display_status *status, char *msg)
{
status->delta = 2; /* Currently default */
+ status->screen = screen;
init_msg(msg, strlen(msg));
status->message = msg;
status->line_cursor = 0;
@@ -55,7 +56,7 @@ int display_update_scroll(struct display_status *status)
status->last_scroll_time += status->delta;
status->line_cursor++;
update_lines(status);
- draw_lines(status);
+ draw_lines(status->screen, status);
}
if (status->first_line == NOTHING && status->second_line == NOTHING) {
return END_OF_MESSAGE;
@@ -79,4 +80,4 @@ void update_lines(struct display_status *status)
status->second_line = (status->line_cursor * SCREEN_MAX_CHARS < status->message_len)
? status->message + (status->line_cursor + 1) * SCREEN_MAX_CHARS
: NOTHING;
-} \ No newline at end of file
+}
diff --git a/src/meson.build b/src/meson.build
index 12b583a..38a1f57 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,6 +1,6 @@
-#subdir('common')
+subdir('common')
-fw_true_sources = [fw_headers]
+fw_true_sources = [fw_headers, common_sources]
subdir('daemon')
subdir('device')