add direct more support infrastructure
This commit is contained in:
parent
fc471af8e4
commit
6b25072ac2
4 changed files with 86 additions and 9 deletions
|
@ -746,7 +746,15 @@ void print_direct_status(void)
|
|||
printf("enabled\n");
|
||||
printf("The Direct Mode network will:\n");
|
||||
printf("\twait for %s for a device to connect\n", secsprint(wait_for_secs));
|
||||
printf("\twill stay on %s after the last item is received\n", secsprint(wait_after_secs));
|
||||
printf("\tstay on %s after the last item is received\n", secsprint(wait_after_secs));
|
||||
}
|
||||
|
||||
int direct_mode_enabled(void)
|
||||
{
|
||||
int wait_for_secs = config_int_get(DIRECT_WAIT_FOR_CONNECTION);
|
||||
if (wait_for_secs > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void disable_direct_mode(void)
|
||||
|
@ -770,6 +778,10 @@ void enable_direct_mode(int wait_for_secs, int wait_after_secs)
|
|||
int start_direct(void)
|
||||
{
|
||||
int ret;
|
||||
if (!direct_mode_enabled()) {
|
||||
printf("Direct mode disabled, unable to start access point.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
debug_printf(2, "%s()\n", __func__);
|
||||
ret = issue_noarg_command('S');
|
||||
printf("AP started (%d)\n", ret);
|
||||
|
@ -810,10 +822,9 @@ void testit0(void)
|
|||
int fdin;
|
||||
int fdout;
|
||||
|
||||
start_direct();
|
||||
//start_direct();
|
||||
print_direct_status();
|
||||
//disable_direct_mode();
|
||||
//print_direct_status();
|
||||
enable_direct_mode(60, 120);
|
||||
exit(0);
|
||||
//char new_cmd[] = {'O', 0x06, 0x0d, 0x0a, 0x31, 0x30, 0x2e, 0x36, 0x2e, 0x30, 0x2e, 0x31, 0x33, 0x37};
|
||||
|
||||
|
|
|
@ -372,6 +372,7 @@ int issue_noarg_command(u8 cmd);
|
|||
char *net_test_state_name(u8 state);
|
||||
int network_action(char cmd, char *essid, char *wpa_ascii);
|
||||
char *locate_eyefi_mount(void);
|
||||
void eject_card(void);
|
||||
int get_log_into(u8 *resbuf);
|
||||
void reboot_card(void);
|
||||
void init_card(void);
|
||||
|
|
|
@ -130,3 +130,12 @@ char *locate_eyefi_mount(void)
|
|||
exit(1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void eject_card(void)
|
||||
{
|
||||
char cmd[PATHNAME_MAX];
|
||||
sprintf(cmd, "umount '%s'", locate_eyefi_mount());
|
||||
debug_printf("ejecting card: '%s'\n", cmd);
|
||||
system(cmd);
|
||||
exit(0);
|
||||
}
|
||||
|
|
66
eyefi-unix.c
66
eyefi-unix.c
|
@ -351,6 +351,58 @@ int is_long_opt(int cint, struct option *long_options)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define __stringify_1(x...) #x
|
||||
#define __stringify(x...) __stringify_1(x)
|
||||
|
||||
#define EYEFI_ARG(arg) { \
|
||||
.long_opt = __stringify(arg), \
|
||||
}
|
||||
|
||||
struct eyefi_arg {
|
||||
char *long_opt;
|
||||
int (*func)(char *);
|
||||
char *arg_val;
|
||||
int tmpvar;
|
||||
};
|
||||
|
||||
struct eyefi_arg eyefi_args[] = {
|
||||
EYEFI_ARG(force),
|
||||
};
|
||||
|
||||
int arg_is_set(char *argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(eyefi_args); i++) {
|
||||
struct eyefi_arg *arg = &eyefi_args[i];
|
||||
if (!strcmp(argv, arg->long_opt)) {
|
||||
return arg->tmpvar;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct option *init_args(struct option *extra, int len)
|
||||
{
|
||||
int i;
|
||||
struct option *long_options;
|
||||
int longopt_nr = 0;
|
||||
|
||||
long_options = malloc(sizeof(struct option) * ARRAY_SIZE(eyefi_args) + len);
|
||||
for (i = 0; i < len; i++) {
|
||||
memcpy(&long_options[longopt_nr++], &extra[i],
|
||||
sizeof(struct option));
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(eyefi_args); i++) {
|
||||
struct option *opt = &long_options[longopt_nr++];
|
||||
|
||||
opt->name = eyefi_args[i].long_opt;
|
||||
opt->has_arg = 2;
|
||||
opt->flag = &eyefi_args[i].tmpvar;
|
||||
opt->val = 1;
|
||||
}
|
||||
return long_options;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int option_index;
|
||||
|
@ -363,14 +415,14 @@ int main(int argc, char *argv[])
|
|||
static int transfer_mode = 0;
|
||||
static int wifi_radio_on = 0;
|
||||
static int endless = 0;
|
||||
static int eject = 0;
|
||||
static struct option long_options[] = {
|
||||
//{"wep", 'x', &passed_wep, 1},
|
||||
//{"wpa", 'y', &passed_wpa, 1},
|
||||
{"force", 0, &force, 1},
|
||||
{"help", 0, NULL, 'h'},
|
||||
{"transfer-mode", 2, &transfer_mode, 1},
|
||||
{"wifi-radio", 2, &wifi_radio_on, 1},
|
||||
{"endless", 2, &endless, 1},
|
||||
{"transfer-mode", 2, &transfer_mode, 1},
|
||||
{"wifi-radio", 2, &wifi_radio_on, 1},
|
||||
{"endless", 2, &endless, 1},
|
||||
{"eject", 2, &eject, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -386,6 +438,10 @@ int main(int argc, char *argv[])
|
|||
&long_options[0], &option_index)) != -1) {
|
||||
c = cint;
|
||||
debug_printf(3, "argument: '%c' %d optarg: '%s'\n", c, c, optarg);
|
||||
if (eject) {
|
||||
eject_card();
|
||||
exit(0);
|
||||
}
|
||||
if (transfer_mode) {
|
||||
handle_transfer_mode(optarg);
|
||||
transfer_mode = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue