Info string inquiry extension

This commit is contained in:
Nils Faerber 2011-08-05 22:15:09 +02:00
parent 6e7a56e3e8
commit ebb651f825
2 changed files with 14 additions and 7 deletions

View file

@ -226,7 +226,7 @@ void mw_get_real_time_clock_response(int mw_fd, unsigned char *rtcrsp, int len)
unsigned char clk1224, date_fmt;
if (len != 10) {
fprintf(stderr, "get real time clock response too short %d != 10\n", len);
fprintf(stderr, "get real time clock response length wrong %d != 10\n", len);
return;
}
@ -298,6 +298,7 @@ int decode_frame(int mw_fd, unsigned char *buf, int len)
unsigned char msgtype;
unsigned char msgopt;
unsigned char *msgdata;
unsigned char msgdatalen;
/* check frame */
crc = *(unsigned short *)(buf+len-2);
@ -322,6 +323,7 @@ int decode_frame(int mw_fd, unsigned char *buf, int len)
msgtype = buf[2];
msgopt = buf[3];
msgdata = (buf+4);
msgdatalen = msglen - 4 - 2;
switch (msgtype) {
case MW_GET_DEVICE_TYPE_RSP:
@ -352,19 +354,19 @@ int decode_frame(int mw_fd, unsigned char *buf, int len)
fprintf(stderr, "Got info string '%s'\n", msgdata);
break;
case MW_GET_REAL_TIME_CLOCK_RSP:
mw_get_real_time_clock_response(mw_fd, msgdata, len-2);
mw_get_real_time_clock_response(mw_fd, msgdata, msgdatalen);
break;
case MW_READ_BATTERY_VOLTAGE_RSP:
mw_get_battery_voltage_response(mw_fd, msgdata, len-2);
mw_get_battery_voltage_response(mw_fd, msgdata, msgdatalen);
break;
case MW_READ_LIGHT_SENSOR_RSP:
mw_read_light_sensor_response(mw_fd, msgdata, len-2);
mw_read_light_sensor_response(mw_fd, msgdata, msgdatalen);
break;
case MW_LOW_BATTERY_WARNING_MSG:
fprintf(stderr, "Watch battery low, please connect charger\n");
break;
case MW_READ_BUTTON_CONFIG_RSP:
mw_read_button_config_response(mw_fd, msgdata, len-2);
mw_read_button_config_response(mw_fd, msgdata, msgdatalen);
break;
case MW_BUTTON_EVENT_MESSAGE:
fprintf(stderr, "Button event message\n");
@ -373,7 +375,7 @@ int decode_frame(int mw_fd, unsigned char *buf, int len)
fprintf(stderr, "Watch battery extremely low - radio will turn off\n");
break;
case MW_STATUS_CHANGE_EVENT:
mw_status_change_event(mw_fd, msgopt, msgdata, len-2);
mw_status_change_event(mw_fd, msgopt, msgdata, msgdatalen);
break;
default:
fprintf(stderr, "Unkown msgtype 0x%02x\n", msgtype);

View file

@ -273,7 +273,12 @@ void process_cmd(char *cmdline, int clinep, int mw_fd)
mw_send_frame(mw_fd, MW_GET_REAL_TIME_CLOCK, 0, NULL, 0);
}
if (strncmp(cmdline, "gistr", 5) == 0) {
mw_send_frame(mw_fd, MW_GET_INFORMATION_STRING, 0, NULL, 0);
intopt = cmdline[6]-0x30;
if (intopt>=0 && intopt <=3)
mdata[0] = intopt;
else
mdata[0] = 0;
mw_send_frame(mw_fd, MW_GET_INFORMATION_STRING, 0, mdata, 1);
}
if (strncmp(cmdline, "gdtype", 6) == 0) {
mw_send_frame(mw_fd, MW_GET_DEVICE_TYPE, 0, NULL, 0);