]> git.kernelconcepts.de Git - metawatch.git/blobdiff - mw_main.c
Implement streaming protocol (mw_feed_...)
[metawatch.git] / mw_main.c
index c08b2d307320a30233d5a2fac050acf06a591466..a5c108327cd3743b97a426305b575b2cea548184 100644 (file)
--- a/mw_main.c
+++ b/mw_main.c
@@ -343,7 +343,7 @@ void process_cmd(char *cmdline, int clinep, mwdata_t *mwdata)
        }
        if (strncmp(cmdline, "srtc", 4) == 0) {
                fprintf(stderr, "Setting RTC from system time...");
-               mw_set_rtc(&mwdata->mwdevice, MW_RTC_CLOCK_24HR, MW_RTC_DATE_DDMM);
+               mw_set_rtc(&mwdata->mwdevice, MW_RTC_CLOCK_12HR, MW_RTC_DATE_MMDD);
                fprintf(stderr, "OK\n");
        }
        if (strncmp(cmdline, "grtc", 4) == 0) {
@@ -399,7 +399,8 @@ void process_cmd(char *cmdline, int clinep, mwdata_t *mwdata)
                bitmap_read(&mwdata->mwdevice);
        }
        if (strncmp(cmdline, "tnote", 5) == 0) {
-               test_notification(&mwdata->mwdevice);
+               // test_notification(&mwdata->mwdevice);
+               mw_do_notification(&mwdata->mwdevice, "TestNotification", "This is a pretty long text that needs to be broken and torn", 1);
        }
        if (strncmp(cmdline, "tapp", 4) == 0) {
                test_application(&mwdata->mwdevice);
@@ -447,7 +448,7 @@ gboolean handle_mw_io(GIOChannel *mw_io, GIOCondition condition, gpointer udata)
        mwdata_t *mdata = (mwdata_t *)udata;
        int rcvd;
 
-       rcvd = read(mdata->mwdevice.mw_fd, mdata->rcvbuf+mdata->rcvbuf_pos, 64);
+       rcvd = read(mdata->mwdevice.mw_fd, mdata->rcvbuf, 64);
 #ifdef DEBUG
        fprintf(stderr, "read %d bytes:\n", rcvd);
 #endif
@@ -455,8 +456,7 @@ gboolean handle_mw_io(GIOChannel *mw_io, GIOCondition condition, gpointer udata)
 #ifdef DEBUG
                dump_frame(mdata->rcvbuf, rcvd);
 #endif
-               decode_frame(&mdata->mwdevice, mdata->rcvbuf, rcvd);
-               mdata->rcvbuf_pos = 0;
+               mw_feed_msg_buffer(&mdata->mwdevice, mdata->rcvbuf, rcvd);
        }
 
        return TRUE;
@@ -598,6 +598,8 @@ int main(int argc, char **argv)
        memset(mdata.cmdline, 0, 128);
        mdata.cmdline_pos = 0;
 
+       mw_init(&mdata.mwdevice, mw_fd);
+
        g_main_loop_run (mdata.mloop);
 
        fsync(mw_fd);