diff options
| author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-10-02 12:03:39 +0000 | 
|---|---|---|
| committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-10-02 12:03:39 +0000 | 
| commit | 07021baf7a9e81f75776c99d65b774204b11422e (patch) | |
| tree | d9c5c5136c82bf3a95c57be30fbdd8821bfa357b /hcid/adapter.c | |
| parent | ecb771f7006daf7bdb2c32ac01c435d97cb5bd9d (diff) | |
Implement support for SetMode("on")
Diffstat (limited to 'hcid/adapter.c')
| -rw-r--r-- | hcid/adapter.c | 22 | 
1 files changed, 20 insertions, 2 deletions
| diff --git a/hcid/adapter.c b/hcid/adapter.c index cddffcde..496d13d3 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -248,7 +248,20 @@ const char *mode2str(uint8_t mode)  	}  } -uint8_t str2mode(const char *mode) +static uint8_t on_mode(const char *addr) +{ +	char mode[14]; +	bdaddr_t sba; + +	str2ba(addr, &sba); + +	if (read_on_mode(&sba, mode, sizeof(mode)) < 0) +		return MODE_CONNECTABLE; + +	return str2mode(addr, mode); +} + +uint8_t str2mode(const char *addr, const char *mode)  {  	if (strcasecmp("off", mode) == 0)  		return MODE_OFF; @@ -258,6 +271,8 @@ uint8_t str2mode(const char *mode)  		return MODE_DISCOVERABLE;  	else if (strcasecmp("limited", mode) == 0)  		return MODE_LIMITED; +	else if (strcasecmp("on", mode) == 0) +		return on_mode(addr);  	else  		return MODE_UNKNOWN;  } @@ -531,7 +546,7 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,  	if (!mode)  		return error_invalid_arguments(conn, msg); -	new_mode = str2mode(mode); +	new_mode = str2mode(adapter->address, mode);  	switch(new_mode) {  	case MODE_OFF:  		scan_enable = SCAN_DISABLED; @@ -547,6 +562,9 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,  		return error_invalid_arguments(conn, msg);  	} +	/* Do reverse resolution in case of "on" mode */ +	mode = mode2str(new_mode); +  	dd = hci_open_dev(adapter->dev_id);  	if (dd < 0)  		return error_no_such_adapter(conn, msg); | 
