- for (i = 0; i < cnt; i++) {
- printf("0x%02x ", recv_data[i]);
+ if ((recv_data[0] != 0x02) ||
+ (recv_data[1] != 0x03) ||
+ (recv_data[2] != 0xa0)) {
+ fprintf(stderr, "Unexpected response: ");
+ for (i = 0; i < cnt; i++) {
+ fprintf(stderr, "0x%02x ", recv_data[i]);
+ }
+ fprintf(stderr, "\n");
+
+ return 0;
+ }
+
+ ret = 1;
+
+ switch(recv_data[3]) {
+ case 0x00:
+ printf("Success");
+ break;
+ case 0x01:
+ printf("Firmware V%d.%d", ((recv_data[4] & 0xf0) >> 4) & 0x0f, recv_data[4] & 0x0f);
+ break;
+ case 0x02:
+ printf("Unknown command");
+ ret = 0;
+ break;
+ case 0x03:
+ printf("Wrong length");
+ ret = 0;
+ break;
+ case 0x04:
+ printf("Aborted sending long press");
+ break;
+ case 0x05:
+ printf("Nothing to stop");
+ break;
+ default:
+ printf("Unknown response: 0x%02x 0x%02x", recv_data[3], recv_data[4]);
+ ret = 0;
+ break;