From 227a0e12ee262dbabdd8d988fec194273cf90029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 29 May 2019 14:33:16 +0300 Subject: Tweaked function declarations and build files to make it build. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- include/tlv.h | 7 +++++++ src/common/tlv.c | 5 ++--- src/device/meson.build | 8 ++++++-- src/device/screen.cpp | 9 +++++---- src/meson.build | 4 ++-- 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 #include #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 #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') -- cgit v1.2.3