diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-04-30 18:24:13 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-04-30 18:24:13 +0000 |
commit | 2bc66b1d0af2e2a01e545493510347578928ae33 (patch) | |
tree | 11c2cc21b81201fcfbafb6af2fc34fe9c928ec6e | |
parent | 2cd3e62a5415f9a0aa895ea4222606012e23d744 (diff) |
Add support for voice setting
-rw-r--r-- | hcid/hcid.h | 14 | ||||
-rw-r--r-- | hcid/kword.c | 1 | ||||
-rw-r--r-- | hcid/main.c | 34 | ||||
-rw-r--r-- | hcid/parser.y | 13 |
4 files changed, 48 insertions, 14 deletions
diff --git a/hcid/hcid.h b/hcid/hcid.h index 5523d4b7..e275939f 100644 --- a/hcid/hcid.h +++ b/hcid/hcid.h @@ -40,14 +40,26 @@ #define HCID_KEY_FILE CONFIGDIR "/link_key" #define HCID_PIN_HELPER "/usr/bin/bluepin" +enum { + HCID_SET_NAME, + HCID_SET_CLASS, + HCID_SET_VOICE, + HCID_SET_INQMODE, + HCID_SET_PTYPE, + HCID_SET_LM, + HCID_SET_LP, +}; + struct device_opts { + unsigned long flags; char *name; uint32_t class; + uint16_t voice; uint8_t inqmode; uint16_t pkt_type; - uint16_t scan; uint16_t link_mode; uint16_t link_policy; + uint16_t scan; uint16_t auth; uint16_t encrypt; }; diff --git a/hcid/kword.c b/hcid/kword.c index bd2294b2..51c92e1d 100644 --- a/hcid/kword.c +++ b/hcid/kword.c @@ -59,6 +59,7 @@ struct kword cfg_keyword[] = { { "pscan", K_PSCAN }, { "name", K_NAME }, { "class", K_CLASS }, + { "voice", K_VOICE }, { "inqmode", K_INQMODE }, { "auth", K_AUTH }, { "encrypt", K_ENCRYPT }, diff --git a/hcid/main.c b/hcid/main.c index 45b8231d..f4736940 100644 --- a/hcid/main.c +++ b/hcid/main.c @@ -222,8 +222,18 @@ static void configure_device(int hdev) hdev, strerror(errno), errno); } + /* Set device name */ + if ((device_opts->flags & (1 << HCID_SET_NAME)) && device_opts->name) { + change_local_name_cp cp; + memset(cp.name, 0, sizeof(cp.name)); + expand_name(cp.name, sizeof(cp.name), device_opts->name, hdev); + + hci_send_cmd(s, OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME, + CHANGE_LOCAL_NAME_CP_SIZE, (void *) &cp); + } + /* Set device class */ - if (device_opts->class) { + if ((device_opts->flags & (1 << HCID_SET_CLASS))) { uint32_t class = htobl(device_opts->class); write_class_of_dev_cp cp; @@ -232,18 +242,18 @@ static void configure_device(int hdev) WRITE_CLASS_OF_DEV_CP_SIZE, (void *) &cp); } - /* Set device name */ - if (device_opts->name) { - change_local_name_cp cp; - memset(cp.name, 0, sizeof(cp.name)); - expand_name(cp.name, sizeof(cp.name), device_opts->name, hdev); + /* Set voice setting */ + if ((device_opts->flags & (1 << HCID_SET_VOICE))) { + write_voice_setting_cp cp; - hci_send_cmd(s, OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME, - CHANGE_LOCAL_NAME_CP_SIZE, (void *) &cp); + cp.voice_setting = htobl(device_opts->voice); + hci_send_cmd(s, OGF_HOST_CTL, OCF_WRITE_VOICE_SETTING, + WRITE_VOICE_SETTING_CP_SIZE, (void *) &cp); } /* Set inquiry mode */ - if (di.features[3] & LMP_RSSI_INQ) { + if ((device_opts->flags & (1 << HCID_SET_INQMODE)) && + (di.features[3] & LMP_RSSI_INQ)) { write_inquiry_mode_cp cp; cp.mode = device_opts->inqmode; @@ -298,7 +308,7 @@ static void init_device(int hdev) device_opts = get_device_opts(s, hdev); /* Set packet type */ - if (device_opts->pkt_type) { + if ((device_opts->flags & (1 << HCID_SET_PTYPE))) { dr.dev_opt = device_opts->pkt_type; if (ioctl(s, HCISETPTYPE, (unsigned long) &dr) < 0) { syslog(LOG_ERR, "Can't set packet type on hci%d: %s (%d)", @@ -307,7 +317,7 @@ static void init_device(int hdev) } /* Set link mode */ - if (device_opts->link_mode) { + if ((device_opts->flags & (1 << HCID_SET_LM))) { dr.dev_opt = device_opts->link_mode; if (ioctl(s, HCISETLINKMODE, (unsigned long) &dr) < 0) { syslog(LOG_ERR, "Can't set link mode on hci%d: %s (%d)", @@ -316,7 +326,7 @@ static void init_device(int hdev) } /* Set link policy */ - if (device_opts->link_policy) { + if ((device_opts->flags & (1 << HCID_SET_LP))) { dr.dev_opt = device_opts->link_policy; if (ioctl(s, HCISETLINKPOL, (unsigned long) &dr) < 0) { syslog(LOG_ERR, "Can't set link policy on hci%d: %s (%d)", diff --git a/hcid/parser.y b/hcid/parser.y index 3534fb2b..a0eb13de 100644 --- a/hcid/parser.y +++ b/hcid/parser.y @@ -64,7 +64,7 @@ int yyerror(char *s); %token K_OPTIONS K_DEVICE %token K_AUTOINIT K_SECURITY K_PAIRING -%token K_PTYPE K_NAME K_CLASS K_INQMODE K_LM K_LP K_AUTH K_ENCRYPT K_ISCAN K_PSCAN +%token K_PTYPE K_NAME K_CLASS K_VOICE K_INQMODE K_LM K_LP K_AUTH K_ENCRYPT K_ISCAN K_PSCAN %token K_PINHELP K_DBUSPINHELP %token K_YES K_NO @@ -169,28 +169,39 @@ device_options: '{' device_opts '}'; device_opts: | device_opt ';' | error ';' | device_opts device_opt ';'; device_opt: K_PTYPE pkt_type { + parser_device->flags |= (1 << HCID_SET_PTYPE); parser_device->pkt_type = $2; } | K_LM link_mode { + parser_device->flags |= (1 << HCID_SET_LM); parser_device->link_mode = $2; } | K_LP link_policy { + parser_device->flags |= (1 << HCID_SET_LP); parser_device->link_policy = $2; } | K_NAME dev_name { if (parser_device->name) free(parser_device->name); + parser_device->flags |= (1 << HCID_SET_NAME); parser_device->name = strdup($2); } | K_CLASS NUM { + parser_device->flags |= (1 << HCID_SET_CLASS); parser_device->class = $2; } + | K_VOICE NUM { + parser_device->flags |= (1 << HCID_SET_VOICE); + parser_device->voice = $2; + } + | K_INQMODE NUM { + parser_device->flags |= (1 << HCID_SET_INQMODE); parser_device->inqmode = $2; } |