]> cvs.zerfleddert.de Git - hmcfgusb/blobdiff - hmsniff.c
Release version 0.102
[hmcfgusb] / hmsniff.c
index 70e2412a71d7d534396c01ad8a9e2d1f1fc472ee..9b59e2fbabd47c541acdf0ce44e5bf698265d63e 100644 (file)
--- a/hmsniff.c
+++ b/hmsniff.c
@@ -95,9 +95,18 @@ char *hm_message_types(uint8_t type, uint8_t subtype)
                case 0x5a:
                        return "Thermal control";
                        break;
+               case 0x5e:
+                       return "Power event";
+                       break;
                case 0x70:
                        return "Weather event";
                        break;
+               case 0xca:
+                       return "Firmware";
+                       break;
+               case 0xcb:
+                       return "Rf configuration";
+                       break;
                default:
                        return "?";
                        break;
@@ -151,6 +160,7 @@ static void dissect_hm(uint8_t *buf, int len)
        } else {
                if (!(count++ % 20))
                        printf("                         LL NR FL CM sender recvr  payload\n");
+
                printf("%s.%03ld: %02X %02X %02X %02X %02X%02X%02X %02X%02X%02X ",
                                ts, tv.tv_usec/1000,
                                buf[0], buf[1], buf[2], buf[3],
@@ -189,6 +199,7 @@ static int parse_hmcfgusb(uint8_t *buf, int buf_len, void *data)
                        break;
                case 'R':
                case 'I':
+               case 'G':
                        break;
                default:
                        hexdump(buf, buf_len, "Unknown> ");
@@ -202,6 +213,8 @@ void hmsniff_syntax(char *prog)
 {
        fprintf(stderr, "Syntax: %s options\n\n", prog);
        fprintf(stderr, "Possible options:\n");
+       fprintf(stderr, "\t-f\t\tfast (100k/firmware update) mode\n");
+       fprintf(stderr, "\t-S serial\tuse HM-CFG-USB with given serial\n");
        fprintf(stderr, "\t-v\t\tverbose mode\n");
        fprintf(stderr, "\t-V\t\tshow version (" VERSION ")\n");
 
@@ -211,11 +224,20 @@ int main(int argc, char **argv)
 {
        struct hmcfgusb_dev *dev;
        struct recv_data rdata;
+       char *serial = NULL;
        int quit = 0;
+       int speed = 10;
+       uint8_t speed_buf[2];
        int opt;
 
-       while((opt = getopt(argc, argv, "vV")) != -1) {
+       while((opt = getopt(argc, argv, "fS:vV")) != -1) {
                switch (opt) {
+                       case 'f':
+                               speed = 100;
+                               break;
+                       case 'S':
+                               serial = optarg;
+                               break;
                        case 'v':
                                verbose = 1;
                                break;
@@ -239,7 +261,7 @@ int main(int argc, char **argv)
                memset(&rdata, 0, sizeof(rdata));
                rdata.wrong_hmid = 0;
 
-               dev = hmcfgusb_init(parse_hmcfgusb, &rdata);
+               dev = hmcfgusb_init(parse_hmcfgusb, &rdata, serial);
                if (!dev) {
                        fprintf(stderr, "Can't initialize HM-CFG-USB, retrying in 1s...\n");
                        sleep(1);
@@ -250,6 +272,11 @@ int main(int argc, char **argv)
                hmcfgusb_send_null_frame(dev, 1);
                hmcfgusb_send(dev, (unsigned char*)"K", 1, 1);
 
+               hmcfgusb_send_null_frame(dev, 1);
+               speed_buf[0] = 'G';
+               speed_buf[1] = speed;
+               hmcfgusb_send(dev, speed_buf, 2, 1);
+
                while(!quit) {
                        int fd;
 
Impressum, Datenschutz