+void oswald_handle_comm_input(uint16_t mlen, const void *mdat)
+{
+ char *icmd = (char *) mdat;
+
+ if (icmd[0] == '$') {
+ if (strncmp(icmd, "$GRT", 4) == 0) { // get current RTC
+ char rtime[16];
+ snprintf(rtime, 16, "#RTC%02d%02d%02d\n", OswaldClk.hour, OswaldClk.minute, OswaldClk.second);
+ hal_bluetooth_send_data(rtime, strlen(rtime));
+ } else if (strncmp(icmd, "$SRT", 4) == 0) { // set current RTC
+ } else if (strncmp(icmd, "$MSG", 4) == 0) { // message on main screen
+ char *msg = (icmd+4);
+ mlen -= 4;
+ memset(MainMessage, 0, 148);
+ strncpy(MainMessage, msg, (mlen > 147) ? 147 : mlen);
+ } else if (strncmp(icmd, "$MCL", 4) == 0) { // clear message
+ memset(MainMessage, 0, 148);
+ } else if (strncmp(icmd, "$BAT", 4) == 0) { // clear message
+ char rtime[16];
+ snprintf(rtime, 16, "#BAT%d,%d\n", OswaldPowerState.charge_state, OswaldPowerState.percent);
+ hal_bluetooth_send_data(rtime, strlen(rtime));
+ }
+ }
+}
+