Skip to content

Commit

Permalink
* Add more sysfs path and values for android gadget.
Browse files Browse the repository at this point in the history
* Update android diag mode by adding AT command support

[usb-moded] AT command support in diag mode. Fixes: JB#7992

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Aug 21, 2013
1 parent 027c0a6 commit cfce0c3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 3 additions & 1 deletion config/dyn-modes/diag_mode.ini
Expand Up @@ -5,10 +5,12 @@ appsync = 1

[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = adb,diag
sysfs_value = diag,serial
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnec_disconnect = 0
android_extra_sysfs_path = /sys/class/android_usb/android0/f_diag/clients
android_extra_sysfs_value = diag,diag_mdm
android_extra_sysfs_path2 = /sys/class/android_usb/android0/f_serial/transports
android_extra_sysfs_value2 = smd,tty
6 changes: 4 additions & 2 deletions src/usb_moded-dyn-config.c
Expand Up @@ -91,9 +91,11 @@ static struct mode_list_elem *read_mode_file(const gchar *filename)
list_item->softconnect_disconnect = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT_DISCONNECT, NULL);
list_item->softconnect_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT_PATH, NULL);
list_item->android_extra_sysfs_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_PATH, NULL);
//log_debug("Android extra mode sysfs path = %s\n", list_item->android_extra_sysfs_path);
list_item->android_extra_sysfs_path2 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_PATH2, NULL);
//log_debug("Android extra mode sysfs path2 = %s\n", list_item->android_extra_sysfs_path2);
list_item->android_extra_sysfs_value = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE, NULL);
//log_debug("Android extra value = %s\n", list_item->android_extra_sysfs_value);
list_item->android_extra_sysfs_value2 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE2, NULL);
//log_debug("Android extra value2 = %s\n", list_item->android_extra_sysfs_value2);
g_key_file_free(settingsfile);
if(list_item->mode_name == NULL || list_item->mode_module == NULL)
{
Expand Down
5 changes: 5 additions & 0 deletions src/usb_moded-dyn-config.h
Expand Up @@ -42,6 +42,9 @@
android engineers prefered to have sysfs entries... go figure... */
#define MODE_ANDROID_EXTRA_SYSFS_PATH "android_extra_sysfs_path"
#define MODE_ANDROID_EXTRA_SYSFS_VALUE "android_extra_sysfs_value"
/* in combined android gadgets we sometime need more than one extra sysfs path or value */
#define MODE_ANDROID_EXTRA_SYSFS_PATH2 "android_extra_sysfs_path2"
#define MODE_ANDROID_EXTRA_SYSFS_VALUE2 "android_extra_sysfs_value2"

/**
* Struct keeping all the data needed for the definition of a dynamic mode
Expand All @@ -62,6 +65,8 @@ typedef struct mode_list_elem
char *softconnect_path; /* path for the softconnect */
char *android_extra_sysfs_path; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value; /* static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path2; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value2; /* static value that never changes that needs to be set by sysfs :( */
/*@} */
}mode_list_elem;

Expand Down
12 changes: 8 additions & 4 deletions src/usb_moded-modesetting.c
Expand Up @@ -364,15 +364,19 @@ int set_dynamic_mode(void)
write_to_file(data->softconnect_path, data->softconnect_disconnect);
}
/* set functionality first, then enable */
if(data->android_extra_sysfs_value && data->android_extra_sysfs_path)
{
write_to_file(data->android_extra_sysfs_path, data->android_extra_sysfs_value);
}
if(data->android_extra_sysfs_value2 && data->android_extra_sysfs_path2)
{
write_to_file(data->android_extra_sysfs_path2, data->android_extra_sysfs_value2);
}
if(data->sysfs_path)
{
write_to_file(data->sysfs_path, data->sysfs_value);
log_debug("writing to file %s, value %s\n", data->sysfs_path, data->sysfs_value);
}
if(data->android_extra_sysfs_value && data->android_extra_sysfs_path)
{
write_to_file(data->android_extra_sysfs_path, data->android_extra_sysfs_value);
}
if(data->softconnect)
{
write_to_file(data->softconnect_path, data->softconnect);
Expand Down

0 comments on commit cfce0c3

Please sign in to comment.