|
15 | 15 | #include <sys/stat.h>
|
16 | 16 |
|
17 | 17 | #define BUFSIZE 65532
|
18 |
| - |
19 | 18 |
|
| 19 | +struct model_s { |
| 20 | + char *pid; |
| 21 | + char *model; |
| 22 | +}; |
| 23 | + |
| 24 | +static const struct model_s model_list[] = { |
| 25 | + { "RA67", "AX5" },//redmi |
| 26 | + { "RA69", "AX6" },//redmi |
| 27 | + { "RA70", "AX9000" },//xiaomi |
| 28 | + { "RA72", "AX6000" },//xiaomi |
| 29 | + { "RA81", "AX3000" },//redmi |
| 30 | + { "RM1800", "AX1800" },//xiaomi |
| 31 | + { "R1800", "AX1800" },//xiaomi |
| 32 | + { "R3600", "AX3600" },//xiaomi |
| 33 | + { NULL, NULL }, |
| 34 | +}; |
20 | 35 |
|
21 | 36 | typedef struct
|
22 | 37 | {
|
@@ -450,15 +465,28 @@ static int lock_mtd(int t)
|
450 | 465 |
|
451 | 466 | }
|
452 | 467 |
|
| 468 | +char *get_model(char *pid) |
| 469 | +{ |
| 470 | + char *model = "unknown"; |
| 471 | + const struct model_s *p; |
| 472 | + |
| 473 | + for (p = &model_list[0]; p->pid; ++p) { |
| 474 | + if (!strcmp(pid, p->pid)) { |
| 475 | + model = p->model; |
| 476 | + break; |
| 477 | + } |
| 478 | + } |
| 479 | + return model; |
| 480 | +} |
| 481 | + |
453 | 482 | static int model_show(void)
|
454 | 483 | {
|
455 |
| - int i,j; |
456 |
| - unsigned char model[]="model"; |
| 484 | + int i; |
| 485 | + |
457 | 486 | if(load_buf()<0)
|
458 | 487 | return -1;
|
459 |
| - memset(buf, 0, sizeof(buf)); |
460 |
| - i = GetSubStrPos(buf,model); |
461 |
| - printf("%s\n",buf); |
| 488 | + i = GetSubStrPos(buf,"model"); |
| 489 | + printf("model=%s\n", get_model(&buf[i+6])); |
462 | 490 | }
|
463 | 491 |
|
464 | 492 | static int password_show(void)
|
@@ -495,12 +523,11 @@ static int calc_img_crc()
|
495 | 523 | unsigned char c[]="ssh_en";
|
496 | 524 | unsigned char c1[]="telnet_en";
|
497 | 525 | unsigned char c2[]="uart_en";
|
498 |
| - unsigned char c3[]="model"; |
499 | 526 |
|
500 | 527 | if(load_buf()<0)
|
501 | 528 | return -1;
|
502 |
| - i = GetSubStrPos(buf,c3); |
503 |
| - printf("%s\n",buf); |
| 529 | + i = GetSubStrPos(buf,"model"); |
| 530 | + printf("model=%s\n", get_model(&buf[i+6])); |
504 | 531 | i = GetSubStrPos(buf,c);
|
505 | 532 | printf("get ssh_en=%c",buf[i+7]);
|
506 | 533 | buf[i+7]='1';//ssh
|
@@ -553,7 +580,7 @@ int main(int argc, char **argv)
|
553 | 580 | else if (!strcmp(argv[1], "password")){
|
554 | 581 | password_show();
|
555 | 582 | printf("ssh default usesrname:root password:%s\n",password);
|
556 |
| - else if (!strcmp(argv[1], "model")){ |
| 583 | + } else if (!strcmp(argv[1], "model")){ |
557 | 584 | model_show();
|
558 | 585 | } else
|
559 | 586 | usage();
|
|
0 commit comments