From 00ba8a61d689fd972638995086fce23404a14694 Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Mon, 9 Aug 2010 13:10:11 -0700 Subject: [PATCH] Add some new code to handle D90 commands I've pulled the card out of my Nikon D90 a few times while it is accessing the card. I can then put it in the PC and see what the D90 was trying to do. I've noticed two new commands: one to disable the WiFi on the card, and the other to check to see if the WiFi is currently disabled or not. I haven't hooked these up to the user interface yet. I also think the 'o' 13 command tells which ESSID the card is currently associated with. 'o' 12 might be something to do with pending uploads. --- eyefi-config.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++- eyefi-config.h | 25 +++++++++++++++++++-- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/eyefi-config.c b/eyefi-config.c index 54c2afc..ea52bb4 100755 --- a/eyefi-config.c +++ b/eyefi-config.c @@ -468,6 +468,26 @@ struct card_firmware_info *fetch_card_firmware_info(void) return NULL; } +void wlan_disable(int do_disable) +{ + /* + * This is complete voodoo to me. I've only ever seen + * a single example of this, so it's hard to figure out + * the structure at all. + */ + char new_cmd[] = {'O', 0x0a, do_disable}; + write_to(REQM, &new_cmd[0], 3); + wait_for_response(); +} + +int wlan_enabled(void) +{ + struct var_byte_response *rsp; + card_info_cmd(WLAN_ENABLED); + rsp = eyefi_buf; + return rsp->responses[0].response; +} + struct testbuf { char cmd; u8 l1; @@ -481,6 +501,7 @@ struct z { char fwbuf[1<<20]; char zbuf[1<<20]; +void scan_print_nets(void); void testit0(void) { char c; @@ -488,7 +509,42 @@ void testit0(void) int i; int fdin; int fdout; - + + printf("WLAN enabled: %d\n", wlan_enabled()); + wlan_disable(1); + printf("WLAN enabled: %d\n", wlan_enabled()); + wlan_disable(0); + printf("WLAN enabled: %d\n", wlan_enabled()); + exit(0); + for (i = 10; i <= 13; i++) { + zero_card_files(); + card_info_cmd(i); + printf("UNKNOWN %d result:\n", i); + dumpbuf(eyefi_buf, 64); + printf("WLAN enabled: %d\n", wlan_enabled()); + scan_print_nets(); + } + i = 0xff; + card_info_cmd(i); + printf("UNKNOWN %d result:\n", i); + dumpbuf(eyefi_buf, 64); + scan_print_nets(); + printf("WLAN enabled: %d\n", wlan_enabled()); + //wlan_disable(); + printf("WLAN enabled: %d\n", wlan_enabled()); + for (i = 10; i <= 13; i++) { + zero_card_files(); + card_info_cmd(i); + printf("UNKNOWN %d result:\n", i); + dumpbuf(eyefi_buf, 64); + printf("WLAN enabled: %d\n", wlan_enabled()); + } + i = 0xff; + card_info_cmd(i); + printf("UNKNOWN %d result:\n", i); + dumpbuf(eyefi_buf, 64); + exit(3); + card_info_cmd(3); printf("o3 result:\n"); dumpbuf(eyefi_buf, 64); @@ -634,7 +690,9 @@ struct configured_net_list *fetch_configured_nets(void) void reboot_card(void) { debug_printf(2, "%s()\n", __func__); + debug_printf(1, "rebooting card..."); issue_noarg_command('b'); + debug_printf(1, "done\n"); } int network_action(char cmd, char *essid, char *ascii_password) diff --git a/eyefi-config.h b/eyefi-config.h index 63781b6..b10d945 100644 --- a/eyefi-config.h +++ b/eyefi-config.h @@ -162,11 +162,27 @@ enum card_info_subcommand { FIRMWARE_INFO = 2, CARD_KEY = 3, API_URL = 4, - UNKNOWN1 = 5, // Chris says these are - UNKNOWN2 = 6, // checksums + UNKNOWN_5 = 5, // Chris says these are + UNKNOWN_6 = 6, // checksums LOG_LEN = 7, + WLAN_ENABLED = 10, + UNKNOWN_13 = 13, // Returns an ASCII SSID. Last connected or + // current WiFi network, maybe? + // + + 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 + // But I've only ever seen a single response + // [000]: 01 04 1d 00 18 56 aa d5 42 00 00 00 00 00 00 00 }; +// new code!!: +///media/NIKON D90/EYEFI/REQM +//00000000 4f 0a 01 00 00 00 00 00 00 00 00 00 00 00 00 00 |O...............| +//00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +// that happens 3 seconds after the card goes into the D90 + struct card_info_req { u8 o; u8 subcommand; @@ -199,6 +215,11 @@ struct byte_response { u8 response; }; +struct var_byte_response { + u8 len; + struct byte_response responses[0]; +}; + enum net_type { NET_UNSECURED, NET_WEP, -- 2.42.0