Skip to content

Commit

Permalink
add support for fetching upload key
Browse files Browse the repository at this point in the history
Thanks to Makesh for finding this!
  • Loading branch information
hansendc committed Oct 8, 2017
1 parent 6101f07 commit f9857ee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
10 changes: 10 additions & 0 deletions eyefi-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,16 @@ struct card_info_rsp_key *fetch_card_key(void)
return key;
}

struct card_info_rsp_key *fetch_card_upload_key(void)
{
struct card_info_rsp_key *key;

debug_printf(2, "%s()\n", __func__);
card_info_cmd(UPLOAD_KEY);
key = eyefi_buf;
return key;
}

int issue_noarg_command(u8 cmd)
{
struct noarg_request req;
Expand Down
2 changes: 2 additions & 0 deletions eyefi-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ enum card_info_subcommand {
ENDLESS = 27, // 0x1b
DIRECT_WAIT_FOR_CONNECTION = 0x24, // 0 == "direct mode off"
DIRECT_WAIT_AFTER_TRANSFER = 0x25, // set to 60 when direct mode off
UPLOAD_KEY = 0xfd, //
UNKNOWN_ff = 0xff, // The D90 does this, and it looks to
// return a 1-byte response length
// followed by a number of 8-byte responses
Expand Down Expand Up @@ -361,6 +362,7 @@ int card_info_cmd(enum card_info_subcommand cmd);
int card_config_set(enum card_info_subcommand cmd, struct var_byte_response *args);
void *eyefi_response(void);
struct card_info_rsp_key *fetch_card_key(void);
struct card_info_rsp_key *fetch_card_upload_key(void);
int wlan_enabled(void);
void wlan_disable(int do_disable);
enum transfer_mode fetch_transfer_mode(void);
Expand Down
17 changes: 15 additions & 2 deletions eyefi-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ void print_card_key(void)
printf("'\n");
}

void print_upload_key(void)
{
debug_printf(2, "%s()\n", __func__);
struct card_info_rsp_key *foo = fetch_card_upload_key();
printf("card upload key (len: %d): '", foo->key.length);
print_pascal_string(&foo->key);
printf("'\n");
}

void scan_print_nets(void)
{
int i;
Expand Down Expand Up @@ -126,7 +135,7 @@ int try_connection_to(char *essid, char *ascii_password)
issue_noarg_command('s');
rsp = *rsp_ptr;
char *state = net_test_state_name(rsp);
debug_printf(3, "net state: 0x%02x name: '%s'\n", rsp, state);
debug_printf(1, "net state: 0x%02x name: '%s'\n", rsp, state);
if (rsp == last_rsp) {
eyefi_printf(".");
fflush(NULL);;
Expand Down Expand Up @@ -331,6 +340,7 @@ void usage(void)
printf(" -k print card unique key\n");
printf(" -l dump card log\n");
printf(" -m print card mac\n");
printf(" -u print card upload key\n");
printf(" --transfer-mode[=mode] print or change card transfer mode\n");
printf(" or =help to list modes\n");
printf(" --wifi-radio fetch wifi radio state\n");
Expand Down Expand Up @@ -433,7 +443,7 @@ int main(int argc, char *argv[])
if (argc == 1)
usage();

char optarg_shorts[] = "a:bcd:kflmp:r:st:z";
char optarg_shorts[] = "a:bcd:kflmp:r:st:uz";
while ((cint = getopt_long_only(argc, argv, optarg_shorts,
&long_options[0], &option_index)) != -1) {
c = cint;
Expand Down Expand Up @@ -510,6 +520,9 @@ int main(int argc, char *argv[])
case 'p':
passwd = strdup(optarg);
break;
case 'u':
print_upload_key();
break;
case 's':
scan_print_nets();
break;
Expand Down

0 comments on commit f9857ee

Please sign in to comment.